Nektar++
Functions
XmlToTecplot.cpp File Reference
#include <cstdio>
#include <cstdlib>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList3D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
Include dependency graph for XmlToTecplot.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 47 of file XmlToTecplot.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::eFourier, Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::LibUtilities::BasisKey::GetBasisType(), Nektar::LibUtilities::BasisKey::GetNumModes(), Nektar::LibUtilities::BasisKey::GetPointsKey(), Nektar::SpatialDomains::MeshGraph::Read(), and Nektar::LibUtilities::SessionReader::RegisterCmdLineFlag().

48 {
50  Array<OneD,NekDouble> xc0,xc1,xc2;
51 
52  if(argc < 2)
53  {
54  fprintf(stderr,"Usage: XmlToTecplot meshfile\n");
55  exit(1);
56  }
57 
58  LibUtilities::SessionReader::RegisterCmdLineFlag(
59  "multi-zone", "m", "Output multi-zone format (one element per zone).");
60 
62  = LibUtilities::SessionReader::CreateInstance(argc, argv);
63 
64  //----------------------------------------------
65  // Read in mesh from input file
66  string meshfile(argv[argc-1]);
68  = SpatialDomains::MeshGraph::Read(vSession);
69  //----------------------------------------------
70 
71  //----------------------------------------------
72  // Set up Expansion information
73  SpatialDomains::ExpansionMap emap = graphShPt->GetExpansions();
75 
76  for (it = emap.begin(); it != emap.end(); ++it)
77  {
78  for (int i = 0; i < it->second->m_basisKeyVector.size(); ++i)
79  {
80  LibUtilities::BasisKey tmp1 = it->second->m_basisKeyVector[i];
82  it->second->m_basisKeyVector[i] = LibUtilities::BasisKey(
83  tmp1.GetBasisType(), tmp1.GetNumModes(),
86  }
87  }
88  //----------------------------------------------
89 
90  //----------------------------------------------
91  // Define Expansion
92  int expdim = graphShPt->GetMeshDimension();
94 
95  switch(expdim)
96  {
97  case 1:
98  {
101  Exp[0] = Exp1D;
102  break;
103  }
104  case 2:
105  {
106  if(vSession->DefinesSolverInfo("HOMOGENEOUS"))
107  {
108  std::string HomoStr = vSession->GetSolverInfo("HOMOGENEOUS");
110 
111  ASSERTL0(
112  HomoStr == "HOMOGENEOUS1D" || HomoStr == "Homogeneous1D" ||
113  HomoStr == "1D" || HomoStr == "Homo1D",
114  "Only 3DH1D supported for XML output currently.");
115 
116  int nplanes;
117  vSession->LoadParameter("HomModesZ", nplanes);
118 
119  // choose points to be at evenly spaced points at nplanes + 1
120  // points
121  const LibUtilities::PointsKey Pkey(
122  nplanes + 1, LibUtilities::ePolyEvenlySpaced);
123  const LibUtilities::BasisKey Bkey(
124  LibUtilities::eFourier, nplanes, Pkey);
125  NekDouble lz = vSession->GetParameter("LZ");
126 
129  vSession, Bkey, lz, false, false, graphShPt);
130  Exp[0] = Exp3DH1;
131  }
132  else
133  {
136  Exp[0] = Exp2D;
137  }
138  break;
139  }
140  case 3:
141  {
144  Exp[0] = Exp3D;
145  break;
146  }
147  default:
148  ASSERTL0(false,"Expansion dimension not recognised");
149  break;
150  }
151 
152  //-----------------------------------------------
153 
154  //----------------------------------------------
155  // Write solution depending on #define
156  string outfile(strtok(argv[argc-1],"."));
157  outfile += ".dat";
158  ofstream outstrm(outfile.c_str());
159 
160  Exp[0]->WriteTecplotHeader(outstrm);
161 
162  if (vSession->DefinesCmdLineArgument("multi-zone"))
163  {
164  int nExp = Exp[0]->GetExpSize();
165 
166  for (int i = 0; i < nExp; ++i)
167  {
168  Exp[0]->WriteTecplotZone (outstrm, i);
169  Exp[0]->WriteTecplotConnectivity(outstrm, i);
170  }
171  }
172  else
173  {
174  Exp[0]->WriteTecplotZone (outstrm);
175  Exp[0]->WriteTecplotConnectivity(outstrm);
176  }
177 
178  outstrm.close();
179  //----------------------------------------------
180  return 0;
181 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
BasisType GetBasisType() const
Return type of expansion basis.
Definition: Basis.h:139
Fourier Expansion .
Definition: BasisType.h:52
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:50
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:63
boost::shared_ptr< ExpList1D > ExpList1DSharedPtr
Shared pointer to an ExpList1D object.
Definition: ExpList1D.h:50
Defines a specification for a set of points.
Definition: Points.h:58
double NekDouble
boost::shared_ptr< ExpList2D > ExpList2DSharedPtr
Shared pointer to an ExpList2D object.
Definition: ExpList2D.h:49
boost::shared_ptr< ExpList3D > ExpList3DSharedPtr
Shared pointer to an ExpList3D object.
Definition: ExpList3D.h:110
PointsKey GetPointsKey() const
Return distribution of points.
Definition: Basis.h:145
boost::shared_ptr< ExpList3DHomogeneous1D > ExpList3DHomogeneous1DSharedPtr
Shared pointer to an ExpList3DHomogeneous1D object.
int GetNumModes() const
Returns the order of the basis.
Definition: Basis.h:84
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:432
Describes the specification for a Basis.
Definition: Basis.h:50
std::map< int, ExpansionShPtr > ExpansionMap
Definition: MeshGraph.h:171
std::map< int, ExpansionShPtr >::iterator ExpansionMapIter
Definition: MeshGraph.h:172