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 std;
46 using namespace Nektar;
47 
48 int main(int argc, char *argv[])
49 {
51  Array<OneD,NekDouble> xc0,xc1,xc2;
52 
53  if(argc < 2)
54  {
55  fprintf(stderr,"Usage: XmlToTecplot meshfile\n");
56  exit(1);
57  }
58 
59  LibUtilities::SessionReader::RegisterCmdLineFlag(
60  "multi-zone", "m", "Output multi-zone format (one element per zone).");
61 
63  = LibUtilities::SessionReader::CreateInstance(argc, argv);
64 
65  //----------------------------------------------
66  // Read in mesh from input file
67  string meshfile(argv[argc-1]);
69  = SpatialDomains::MeshGraph::Read(vSession);
70  //----------------------------------------------
71 
72  //----------------------------------------------
73  // Set up Expansion information
74  SpatialDomains::ExpansionMap emap = graphShPt->GetExpansions();
76 
77  for (it = emap.begin(); it != emap.end(); ++it)
78  {
79  for (int i = 0; i < it->second->m_basisKeyVector.size(); ++i)
80  {
81  LibUtilities::BasisKey tmp1 = it->second->m_basisKeyVector[i];
83  it->second->m_basisKeyVector[i] = LibUtilities::BasisKey(
84  tmp1.GetBasisType(), tmp1.GetNumModes(),
87  }
88  }
89  //----------------------------------------------
90 
91  //----------------------------------------------
92  // Define Expansion
93  int expdim = graphShPt->GetMeshDimension();
95 
96  switch(expdim)
97  {
98  case 1:
99  {
102  Exp[0] = Exp1D;
103  break;
104  }
105  case 2:
106  {
107  if(vSession->DefinesSolverInfo("HOMOGENEOUS"))
108  {
109  std::string HomoStr = vSession->GetSolverInfo("HOMOGENEOUS");
111 
112  ASSERTL0(
113  HomoStr == "HOMOGENEOUS1D" || HomoStr == "Homogeneous1D" ||
114  HomoStr == "1D" || HomoStr == "Homo1D",
115  "Only 3DH1D supported for XML output currently.");
116 
117  int nplanes;
118  vSession->LoadParameter("HomModesZ", nplanes);
119 
120  // choose points to be at evenly spaced points at nplanes + 1
121  // points
122  const LibUtilities::PointsKey Pkey(
123  nplanes + 1, LibUtilities::ePolyEvenlySpaced);
124  const LibUtilities::BasisKey Bkey(
125  LibUtilities::eFourier, nplanes, Pkey);
126  NekDouble lz = vSession->GetParameter("LZ");
127 
130  vSession, Bkey, lz, false, false, graphShPt);
131  Exp[0] = Exp3DH1;
132  }
133  else
134  {
137  Exp[0] = Exp2D;
138  }
139  break;
140  }
141  case 3:
142  {
145  Exp[0] = Exp3D;
146  break;
147  }
148  default:
149  ASSERTL0(false,"Expansion dimension not recognised");
150  break;
151  }
152 
153  //-----------------------------------------------
154 
155  //----------------------------------------------
156  // Write solution depending on #define
157  string outfile(strtok(argv[argc-1],"."));
158  outfile += ".dat";
159  ofstream outstrm(outfile.c_str());
160 
161  Exp[0]->WriteTecplotHeader(outstrm);
162 
163  if (vSession->DefinesCmdLineArgument("multi-zone"))
164  {
165  int nExp = Exp[0]->GetExpSize();
166 
167  for (int i = 0; i < nExp; ++i)
168  {
169  Exp[0]->WriteTecplotZone (outstrm, i);
170  Exp[0]->WriteTecplotConnectivity(outstrm, i);
171  }
172  }
173  else
174  {
175  Exp[0]->WriteTecplotZone (outstrm);
176  Exp[0]->WriteTecplotConnectivity(outstrm);
177  }
178 
179  outstrm.close();
180  //----------------------------------------------
181  return 0;
182 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
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
STL namespace.
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
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