Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 Nektar;
13 
14 int main(int argc, char *argv[])
15 {
16  int i,j;
17 
18  if(argc != 4)
19  {
20  fprintf(stderr,"Usage: Linf nfield meshfile fld \n");
21  exit(1);
22  }
23 
24  int nfield = boost::lexical_cast<int>(argv[argc-3]);
25 
28 
29 
30  //----------------------------------------------
31  // Read in mesh from input file
32  string meshfile(argv[argc-2]);
34  //----------------------------------------------
35 
36  //----------------------------------------------
37  // Import field file.
38  string fieldfile(argv[argc-1]);
39  vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
40  vector<vector<NekDouble> > fielddata;
41  LibUtilities::Import(fieldfile,fielddef,fielddata);
42  bool useFFT = false;
43  bool dealiasing = false;
44  //----------------------------------------------
45 
46  //----------------------------------------------
47  // Define Expansion
48  int expdim = graphShPt->GetMeshDimension();
49  int nfields = fielddef[0]->m_fields.size();
50  Array<OneD, MultiRegions::ExpListSharedPtr> Exp(nfields);
51 
52  ASSERTL0((nfield >= 0)&&(nfield < nfields),"Value of nfield must be between zero and less than the number of fields in the file");
53 
54  switch(expdim)
55  {
56  case 1:
57  {
58  ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
59 
60  if(fielddef[0]->m_numHomogeneousDir == 1)
61  {
63 
64  // Define Homogeneous expansion
65  int nplanes = fielddef[0]->m_numModes[1];
66 
67  // choose points to be at evenly spaced points at
69  const LibUtilities::BasisKey Bkey(fielddef[0]->m_basis[1],nplanes,Pkey);
70  NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
71 
72  Exp2DH1 = MemoryManager<MultiRegions::ExpList2DHomogeneous1D>::AllocateSharedPtr(vSession,Bkey,ly,useFFT,dealiasing,graphShPt);
73  Exp[0] = Exp2DH1;
74 
75  for(i = 1; i < nfields; ++i)
76  {
78  }
79  }
80  else if(fielddef[0]->m_numHomogeneousDir == 2)
81  {
83 
84  // Define Homogeneous expansion
85  int nylines = fielddef[0]->m_numModes[1];
86  int nzlines = fielddef[0]->m_numModes[2];
87 
88  // choose points to be at evenly spaced points at
90  const LibUtilities::BasisKey BkeyY(fielddef[0]->m_basis[1],nylines,PkeyY);
91 
93  const LibUtilities::BasisKey BkeyZ(fielddef[0]->m_basis[2],nzlines,PkeyZ);
94 
95  NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
96  NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
97 
98  Exp3DH2 = MemoryManager<MultiRegions::ExpList3DHomogeneous2D>::AllocateSharedPtr(vSession,BkeyY,BkeyZ,ly,lz,useFFT,dealiasing,graphShPt);
99  Exp[0] = Exp3DH2;
100 
101  for(i = 1; i < nfields; ++i)
102  {
104  }
105  }
106  else
107  {
110  ::AllocateSharedPtr(vSession,graphShPt);
111  Exp[0] = Exp1D;
112  for(i = 1; i < nfields; ++i)
113  {
115  ::AllocateSharedPtr(*Exp1D);
116  }
117  }
118  }
119  break;
120  case 2:
121  {
122  ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,"NumHomogeneousDir is only set up for 1");
123 
124  if(fielddef[0]->m_numHomogeneousDir == 1)
125  {
127 
128  // Define Homogeneous expansion
129  int nplanes = fielddef[0]->m_numModes[2];
130 
131  // choose points to be at evenly spaced points at
132  // nplanes + 1 points
134  const LibUtilities::BasisKey Bkey(fielddef[0]->m_basis[2],nplanes,Pkey);
135  NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
136 
137  Exp3DH1 = MemoryManager<MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(vSession,Bkey,lz,useFFT,dealiasing,graphShPt);
138  Exp[0] = Exp3DH1;
139 
140  for(i = 1; i < nfields; ++i)
141  {
143 
144  }
145  }
146  else
147  {
150  ::AllocateSharedPtr(vSession,graphShPt);
151  Exp[0] = Exp2D;
152 
153  for(i = 1; i < nfields; ++i)
154  {
156  ::AllocateSharedPtr(*Exp2D);
157  }
158  }
159  }
160  break;
161  case 3:
162  {
165  ::AllocateSharedPtr(vSession,graphShPt);
166  Exp[0] = Exp3D;
167 
168  for(i = 1; i < nfields; ++i)
169  {
171  ::AllocateSharedPtr(*Exp3D);
172  }
173  }
174  break;
175  default:
176  ASSERTL0(false,"Expansion dimension not recognised");
177  break;
178  }
179  //----------------------------------------------
180 
181  //----------------------------------------------
182  // Copy data from field file
183  for(j = 0; j < nfields; ++j)
184  {
185  for(int i = 0; i < fielddata.size(); ++i)
186  {
187  Exp[j]->ExtractDataToCoeffs(fielddef [i],
188  fielddata[i],
189  fielddef [i]->m_fields[j],
190  Exp[j]->UpdateCoeffs());
191  }
192  Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
193  }
194  //----------------------------------------------
195 
196  cout << "Linf of field "<< nfield << " is : " << Exp[nfield]->Linf(Exp[nfield]->GetPhys()) << endl;
197  return 0;
198 }
199