Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
ExtractMeanModeFromHomo1DFld.cpp File Reference
#include <cstdio>
#include <cstdlib>
#include <SpatialDomains/MeshGraph.h>
#include <StdRegions/StdTriExp.h>
Include dependency graph for ExtractMeanModeFromHomo1DFld.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 8 of file ExtractMeanModeFromHomo1DFld.cpp.

References ASSERTL0, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eTriangle, Nektar::LibUtilities::StdTriData::getNumberOfCoefficients(), Nektar::LibUtilities::Import(), Nektar::iterator, and Nektar::LibUtilities::Write().

{
if(argc != 3)
{
fprintf(stderr,"Usage: ExtractmeanModeFromHomo1DFld fieldfile outfield\n");
exit(1);
}
//default meshgraph
//----------------------------------------------
// Import fieldfile.
string fieldfile(argv[argc-2]);
vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
vector<vector<NekDouble> > fielddata;
LibUtilities::Import(fieldfile,fielddef,fielddata);
//----------------------------------------------
vector<vector<NekDouble> > combineddata;
vector<LibUtilities::FieldDefinitionsSharedPtr> newfielddef;
//----------------------------------------------
// put mean data consecutively
for(int i = 0; i < fielddata.size(); ++i)
{
ASSERTL0(fielddef[i]->m_numHomogeneousDir == 1,"Expected fieldfile to have one homogeneous direction");
if(fielddef[i]->m_homogeneousZIDs[0] != 0)
{
continue;
}
else
{
int nz = fielddef[i]->m_homogeneousZIDs.size();
fielddef[i]->m_numHomogeneousDir = 0;
fielddef[i]->m_basis.resize(2);
newfielddef.push_back(fielddef[i]);
// Determine the number of coefficients per element
int ncoeffs;
switch(fielddef[i]->m_shapeType)
{
ncoeffs = LibUtilities::StdTriData::getNumberOfCoefficients(fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
break;
ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
break;
default:
ASSERTL0(false,"Shape not recognised");
break;
}
vector<NekDouble> newdata;
vec_iter = fielddata[i].begin();
for(int k = 0; k < fielddef[i]->m_fields.size(); ++k)
{
// copy data from each field into consecutive order
for(int n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
{
// put zero mode into newdata
newdata.insert(newdata.end(),vec_iter, vec_iter+ncoeffs);
vec_iter += nz*ncoeffs;
}
}
combineddata.push_back(newdata);
}
}
//----------------------------------------------
//-----------------------------------------------
// Write out datafile.
LibUtilities::Write(argv[argc-1], newfielddef, combineddata);
//-----------------------------------------------
return 0;
}