Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
L2.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/ExpList2DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>
Include dependency graph for L2.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 14 of file L2.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::LibUtilities::Import(), and Nektar::SpatialDomains::MeshGraph::Read().

15 {
16  int i,j;
17 
18  if(argc != 4)
19  {
20  fprintf(stderr,"Usage: L2 nfield meshfile fld \n");
21  exit(1);
22  }
23 
24  int nfield = boost::lexical_cast<int>(argv[argc-3]);
25 
27  = LibUtilities::SessionReader::CreateInstance(argc-1, argv+1);
28 
29 
30  //----------------------------------------------
31  // Read in mesh from input file
32  string meshfile(argv[argc-2]);
33  SpatialDomains::MeshGraphSharedPtr graphShPt = SpatialDomains::MeshGraph::Read(vSession);//meshfile);
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();
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 << "L2 of field "<< nfield << " is : " << Exp[nfield]->L2(Exp[nfield]->GetPhys()) << endl;
197  return 0;
198 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
boost::shared_ptr< ExpList3DHomogeneous2D > ExpList3DHomogeneous2DSharedPtr
Shared pointer to an ExpList3DHomogeneous2D object.
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > ElementiDs)
Imports an FLD file.
Definition: FieldIO.cpp:115
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< ExpList2DHomogeneous1D > ExpList2DHomogeneous1DSharedPtr
Shared pointer to an ExpList2DHomogeneous1D object.
boost::shared_ptr< ExpList3D > ExpList3DSharedPtr
Shared pointer to an ExpList3D object.
Definition: ExpList3D.h:114
boost::shared_ptr< ExpList3DHomogeneous1D > ExpList3DHomogeneous1DSharedPtr
Shared pointer to an ExpList3DHomogeneous1D object.
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
Describes the specification for a Basis.
Definition: Basis.h:50