7 using namespace Nektar;
9 int main(
int argc,
char *argv[])
13 fprintf(stderr,
"Usage: Splitmodes fieldfile \n");
23 string fieldfile(argv[argc-1]);
24 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
25 vector<vector<NekDouble> > fielddata;
30 ASSERTL0(fielddef[0]->m_numModes[2] > 1,
"Expected Fourier field to have at least 2 modes");
32 ASSERTL0(fielddef[0]->m_numHomogeneousDir == 1,
"Expected second fld to have one homogeneous direction");
34 int nmodes = fielddef[0]->m_numModes[2];
37 vector<unsigned int> newNumModes;
38 newNumModes.push_back(fielddef[0]->m_numModes[0]);
39 newNumModes.push_back(fielddef[0]->m_numModes[1]);
40 vector<LibUtilities::BasisType> newBasis;
41 newBasis.push_back(fielddef[0]->m_basis[0]);
42 newBasis.push_back(fielddef[0]->m_basis[1]);
43 for(
int i = 0; i < fielddata.size(); ++i)
45 fielddef[i]->m_numModes = newNumModes;
46 fielddef[i]->m_basis = newBasis;
47 fielddef[i]->m_numHomogeneousDir = 0;
51 for(
int m = 0; m < nmodes; ++m)
53 vector<vector<NekDouble> > writedata;
56 string outfile(argv[argc-1]);
57 string out = outfile.substr(0, outfile.find_last_of(
"."));
59 sprintf(num,
"%d",(m/2));
63 out = out +
"_mode_" + num +
"_real.fld";
67 out = out +
"_mode_" + num +
"_imag.fld";
70 for(
int i = 0; i < fielddata.size(); ++i)
72 vector<NekDouble> newdata;
76 switch(fielddef[i]->m_shapeType)
82 ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
85 ASSERTL0(
false,
"Shape not recognised");
90 vec_iter = fielddata[i].begin();
92 for(
int k = 0; k < fielddef[i]->m_fields.size(); ++k)
94 for(
int n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
97 vec_iter += m*ncoeffs;
98 newdata.insert(newdata.end(),vec_iter,vec_iter+ncoeffs);
99 vec_iter += (nmodes-m)*ncoeffs;
102 writedata.push_back(newdata);