Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XmlToTecplot.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: XmlToTecplot.cpp
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Output Tecplot description of mesh.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #include <cstdio>
37 #include <cstdlib>
38 
39 #include <MultiRegions/ExpList.h>
40 #include <MultiRegions/ExpList1D.h>
41 #include <MultiRegions/ExpList2D.h>
42 #include <MultiRegions/ExpList3D.h>
44 
45 using namespace Nektar;
46 
47 int main(int argc, char *argv[])
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 
59  "multi-zone", "m", "Output multi-zone format (one element per zone).");
60 
63 
64  //----------------------------------------------
65  // Read in mesh from input file
66  string meshfile(argv[argc-1]);
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 }
static std::string RegisterCmdLineFlag(const std::string &pName, const std::string &pShortName, const std::string &pDescription)
Registers a command-line flag with the session reader.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
Definition: MeshGraph.cpp:119
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
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:51
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:63
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
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:114
int main(int argc, char *argv[])
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:442
Describes the specification for a Basis.
Definition: Basis.h:50
std::map< int, ExpansionShPtr > ExpansionMap
Definition: MeshGraph.h:174
std::map< int, ExpansionShPtr >::iterator ExpansionMapIter
Definition: MeshGraph.h:175