14 fprintf(stderr,
"Usage: Splitmodes fieldfile \n");
24 string fieldfile(argv[argc-1]);
25 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
26 vector<vector<NekDouble> > fielddata;
31 ASSERTL0(fielddef[0]->m_numModes[2] > 1,
"Expected Fourier field to have at least 2 modes");
33 ASSERTL0(fielddef[0]->m_numHomogeneousDir == 1,
"Expected second fld to have one homogeneous direction");
35 int nmodes = fielddef[0]->m_numModes[2];
38 vector<unsigned int> newNumModes;
39 newNumModes.push_back(fielddef[0]->m_numModes[0]);
40 newNumModes.push_back(fielddef[0]->m_numModes[1]);
41 vector<LibUtilities::BasisType> newBasis;
42 newBasis.push_back(fielddef[0]->m_basis[0]);
43 newBasis.push_back(fielddef[0]->m_basis[1]);
44 for(
int i = 0; i < fielddata.size(); ++i)
46 fielddef[i]->m_numModes = newNumModes;
47 fielddef[i]->m_basis = newBasis;
48 fielddef[i]->m_numHomogeneousDir = 0;
52 for(
int m = 0; m < nmodes; ++m)
54 vector<vector<NekDouble> > writedata;
57 string outfile(argv[argc-1]);
58 string out = outfile.substr(0, outfile.find_last_of(
"."));
60 sprintf(num,
"%d",(m/2));
64 out = out +
"_mode_" + num +
"_real.fld";
68 out = out +
"_mode_" + num +
"_imag.fld";
71 for(
int i = 0; i < fielddata.size(); ++i)
73 vector<NekDouble> newdata;
77 switch(fielddef[i]->m_shapeType)
83 ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
86 ASSERTL0(
false,
"Shape not recognised");
91 vec_iter = fielddata[i].begin();
93 for(
int k = 0; k < fielddef[i]->m_fields.size(); ++k)
95 for(
int n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
98 vec_iter += m*ncoeffs;
99 newdata.insert(newdata.end(),vec_iter,vec_iter+ncoeffs);
100 vec_iter += (nmodes-m)*ncoeffs;
103 writedata.push_back(newdata);
#define ASSERTL0(condition, msg)
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...
int getNumberOfCoefficients(int Na)
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap, const bool backup)
This function allows for data to be written to an FLD file when a session and/or communicator is not ...
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
Base class for a spectral/hp element mesh.