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 std;
7 using namespace Nektar;
8 
9 int main(int argc, char *argv[])
10 {
11  if(argc != 3)
12  {
13  fprintf(stderr,"Usage: ExtractmeanModeFromHomo1DFld fieldfile outfield\n");
14  exit(1);
15  }
16 
17  int i = 0;
18  int k = 0;
19  int n = 0;
20  int nz = 0;
21  int ncoeffs = 0;
22  //default meshgraph
24 
25  //----------------------------------------------
26  // Import fieldfile.
27  string fieldfile(argv[argc-2]);
28  vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
29  vector<vector<NekDouble> > fielddata;
30  LibUtilities::Import(fieldfile,fielddef,fielddata);
31  //----------------------------------------------
32 
33  vector<vector<NekDouble> > combineddata;
34  vector<LibUtilities::FieldDefinitionsSharedPtr> newfielddef;
35 
36  //----------------------------------------------
37  // put mean data consecutively
38  for(i = 0; i < fielddata.size(); ++i)
39  {
40  ASSERTL0(fielddef[i]->m_numHomogeneousDir == 1,
41  "Expected fieldfile to have one homogeneous direction");
42 
43  if(fielddef[i]->m_homogeneousZIDs[0] != 0)
44  {
45  continue;
46  }
47  else
48  {
49  nz = fielddef[i]->m_homogeneousZIDs.size();
50 
51  fielddef[i]->m_numHomogeneousDir = 0;
52  fielddef[i]->m_basis.resize(2);
53  newfielddef.push_back(fielddef[i]);
54 
55 
56  // Determine the number of coefficients per element
57  switch(fielddef[i]->m_shapeType)
58  {
61  fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
62  break;
64  ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
65  break;
66  default:
67  ASSERTL0(false,"Shape not recognised");
68  break;
69  }
70 
72 
73  vector<NekDouble> newdata;
74  vec_iter = fielddata[i].begin();
75 
76  for(k = 0; k < fielddef[i]->m_fields.size(); ++k)
77  {
78  // copy data from each field into consecutive order
79  for(n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
80  {
81  // put zero mode into newdata
82  newdata.insert(newdata.end(),vec_iter, vec_iter+ncoeffs);
83  vec_iter += nz*ncoeffs;
84  }
85  }
86  combineddata.push_back(newdata);
87  }
88  }
89  //----------------------------------------------
90 
91  //-----------------------------------------------
92  // Write out datafile.
93  LibUtilities::Write(argv[argc-1], newfielddef, combineddata);
94  //-----------------------------------------------
95 
96  return 0;
97 }
98 
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
STL namespace.
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[])
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