Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExtractMeanModeFromHomo1DFld.cpp
Go to the documentation of this file.
1 #include <cstdio>
2 #include <cstdlib>
3 #include <SpatialDomains/MeshGraph.h> // for FieldDefinitions, etc
4 #include <StdRegions/StdTriExp.h>
5 
6 using namespace Nektar;
7 
8 int main(int argc, char *argv[])
9 {
10  if(argc != 3)
11  {
12  fprintf(stderr,"Usage: ExtractmeanModeFromHomo1DFld fieldfile outfield\n");
13  exit(1);
14  }
15 
16  int i = 0;
17  int k = 0;
18  int n = 0;
19  int nz = 0;
20  int ncoeffs = 0;
21  //default meshgraph
23 
24  //----------------------------------------------
25  // Import fieldfile.
26  string fieldfile(argv[argc-2]);
27  vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
28  vector<vector<NekDouble> > fielddata;
29  LibUtilities::Import(fieldfile,fielddef,fielddata);
30  //----------------------------------------------
31 
32  vector<vector<NekDouble> > combineddata;
33  vector<LibUtilities::FieldDefinitionsSharedPtr> newfielddef;
34 
35  //----------------------------------------------
36  // put mean data consecutively
37  for(i = 0; i < fielddata.size(); ++i)
38  {
39  ASSERTL0(fielddef[i]->m_numHomogeneousDir == 1,
40  "Expected fieldfile to have one homogeneous direction");
41 
42  if(fielddef[i]->m_homogeneousZIDs[0] != 0)
43  {
44  continue;
45  }
46  else
47  {
48  nz = fielddef[i]->m_homogeneousZIDs.size();
49 
50  fielddef[i]->m_numHomogeneousDir = 0;
51  fielddef[i]->m_basis.resize(2);
52  newfielddef.push_back(fielddef[i]);
53 
54 
55  // Determine the number of coefficients per element
56  switch(fielddef[i]->m_shapeType)
57  {
60  fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
61  break;
63  ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
64  break;
65  default:
66  ASSERTL0(false,"Shape not recognised");
67  break;
68  }
69 
71 
72  vector<NekDouble> newdata;
73  vec_iter = fielddata[i].begin();
74 
75  for(k = 0; k < fielddef[i]->m_fields.size(); ++k)
76  {
77  // copy data from each field into consecutive order
78  for(n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
79  {
80  // put zero mode into newdata
81  newdata.insert(newdata.end(),vec_iter, vec_iter+ncoeffs);
82  vec_iter += nz*ncoeffs;
83  }
84  }
85  combineddata.push_back(newdata);
86  }
87  }
88  //----------------------------------------------
89 
90  //-----------------------------------------------
91  // Write out datafile.
92  LibUtilities::Write(argv[argc-1], newfielddef, combineddata);
93  //-----------------------------------------------
94 
95  return 0;
96 }
97 
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
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
int main(int argc, char *argv[])
int getNumberOfCoefficients(int Na, int Nb)
Definition: ShapeType.hpp:111
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
Base class for a spectral/hp element mesh.
Definition: MeshGraph.h:186
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap)
Write a field file in serial only.
Definition: FieldIO.cpp:81