Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Linf.cpp
Go to the documentation of this file.
1 #include <cstdio>
2 #include <cstdlib>
3 
4 #include <MultiRegions/ExpList.h>
11 
12 using namespace std;
13 using namespace Nektar;
14 
15 int main(int argc, char *argv[])
16 {
17  int i,j;
18 
19  if(argc != 4)
20  {
21  fprintf(stderr,"Usage: Linf nfield meshfile fld \n");
22  exit(1);
23  }
24 
25  int nfield = boost::lexical_cast<int>(argv[argc-3]);
26 
28  = LibUtilities::SessionReader::CreateInstance(argc-1, argv+1);
29 
30 
31  //----------------------------------------------
32  // Read in mesh from input file
33  string meshfile(argv[argc-2]);
34  SpatialDomains::MeshGraphSharedPtr graphShPt = SpatialDomains::MeshGraph::Read(vSession);//meshfile);
35  //----------------------------------------------
36 
37  //----------------------------------------------
38  // Import field file.
39  string fieldfile(argv[argc-1]);
40  vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
41  vector<vector<NekDouble> > fielddata;
42  LibUtilities::Import(fieldfile,fielddef,fielddata);
43  bool useFFT = false;
44  bool dealiasing = false;
45  //----------------------------------------------
46 
47  //----------------------------------------------
48  // Define Expansion
49  int expdim = graphShPt->GetMeshDimension();
50  int nfields = fielddef[0]->m_fields.size();
52 
53  ASSERTL0((nfield >= 0)&&(nfield < nfields),"Value of nfield must be between zero and less than the number of fields in the file");
54 
55  switch(expdim)
56  {
57  case 1:
58  {
59  ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
60 
61  if(fielddef[0]->m_numHomogeneousDir == 1)
62  {
64 
65  // Define Homogeneous expansion
66  int nplanes = fielddef[0]->m_numModes[1];
67 
68  // choose points to be at evenly spaced points at
70  const LibUtilities::BasisKey Bkey(fielddef[0]->m_basis[1],nplanes,Pkey);
71  NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
72 
73  Exp2DH1 = MemoryManager<MultiRegions::ExpList2DHomogeneous1D>::AllocateSharedPtr(vSession,Bkey,ly,useFFT,dealiasing,graphShPt);
74  Exp[0] = Exp2DH1;
75 
76  for(i = 1; i < nfields; ++i)
77  {
79  }
80  }
81  else if(fielddef[0]->m_numHomogeneousDir == 2)
82  {
84 
85  // Define Homogeneous expansion
86  int nylines = fielddef[0]->m_numModes[1];
87  int nzlines = fielddef[0]->m_numModes[2];
88 
89  // choose points to be at evenly spaced points at
91  const LibUtilities::BasisKey BkeyY(fielddef[0]->m_basis[1],nylines,PkeyY);
92 
94  const LibUtilities::BasisKey BkeyZ(fielddef[0]->m_basis[2],nzlines,PkeyZ);
95 
96  NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
97  NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
98 
99  Exp3DH2 = MemoryManager<MultiRegions::ExpList3DHomogeneous2D>::AllocateSharedPtr(vSession,BkeyY,BkeyZ,ly,lz,useFFT,dealiasing,graphShPt);
100  Exp[0] = Exp3DH2;
101 
102  for(i = 1; i < nfields; ++i)
103  {
105  }
106  }
107  else
108  {
111  ::AllocateSharedPtr(vSession,graphShPt);
112  Exp[0] = Exp1D;
113  for(i = 1; i < nfields; ++i)
114  {
116  ::AllocateSharedPtr(*Exp1D);
117  }
118  }
119  }
120  break;
121  case 2:
122  {
123  ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,"NumHomogeneousDir is only set up for 1");
124 
125  if(fielddef[0]->m_numHomogeneousDir == 1)
126  {
128 
129  // Define Homogeneous expansion
130  int nplanes = fielddef[0]->m_numModes[2];
131 
132  // choose points to be at evenly spaced points at
133  // nplanes + 1 points
135  const LibUtilities::BasisKey Bkey(fielddef[0]->m_basis[2],nplanes,Pkey);
136  NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
137 
138  Exp3DH1 = MemoryManager<MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(vSession,Bkey,lz,useFFT,dealiasing,graphShPt);
139  Exp[0] = Exp3DH1;
140 
141  for(i = 1; i < nfields; ++i)
142  {
144 
145  }
146  }
147  else
148  {
151  ::AllocateSharedPtr(vSession,graphShPt);
152  Exp[0] = Exp2D;
153 
154  for(i = 1; i < nfields; ++i)
155  {
157  ::AllocateSharedPtr(*Exp2D);
158  }
159  }
160  }
161  break;
162  case 3:
163  {
166  ::AllocateSharedPtr(vSession,graphShPt);
167  Exp[0] = Exp3D;
168 
169  for(i = 1; i < nfields; ++i)
170  {
172  ::AllocateSharedPtr(*Exp3D);
173  }
174  }
175  break;
176  default:
177  ASSERTL0(false,"Expansion dimension not recognised");
178  break;
179  }
180  //----------------------------------------------
181 
182  //----------------------------------------------
183  // Copy data from field file
184  for(j = 0; j < nfields; ++j)
185  {
186  for(int i = 0; i < fielddata.size(); ++i)
187  {
188  Exp[j]->ExtractDataToCoeffs(fielddef [i],
189  fielddata[i],
190  fielddef [i]->m_fields[j],
191  Exp[j]->UpdateCoeffs());
192  }
193  Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
194  }
195  //----------------------------------------------
196 
197  cout << "Linf of field "<< nfield << " is : " << Exp[nfield]->Linf(Exp[nfield]->GetPhys()) << endl;
198  return 0;
199 }
200 
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > &ElementIDs)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
Definition: FieldIO.cpp:279
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
STL namespace.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
boost::shared_ptr< ExpList3DHomogeneous2D > ExpList3DHomogeneous2DSharedPtr
Shared pointer to an ExpList3DHomogeneous2D object.
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:65
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< ExpList2DHomogeneous1D > ExpList2DHomogeneous1DSharedPtr
Shared pointer to an ExpList2DHomogeneous1D object.
boost::shared_ptr< ExpList3D > ExpList3DSharedPtr
Shared pointer to an ExpList3D object.
Definition: ExpList3D.h:112
boost::shared_ptr< ExpList3DHomogeneous1D > ExpList3DHomogeneous1DSharedPtr
Shared pointer to an ExpList3DHomogeneous1D object.
int main(int argc, char *argv[])
Definition: Linf.cpp:15
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
Describes the specification for a Basis.
Definition: Basis.h:50