Commit f47c8616 authored by Spencer Sherwin's avatar Spencer Sherwin Committed by Chris Cantwell
Browse files

Added a routine to extract mean mode from Fourier field file

parent 723c0310
ADD_UTILITIES_EXECUTABLE(AddModeTo2DFld util AddModeTo2DFld.cpp)
ADD_UTILITIES_EXECUTABLE(CombinePartitions util-extra CombinePartitions.cpp)
ADD_UTILITIES_EXECUTABLE(ExtractMeanModeFromHomo1DFld util ExtractMeanModeFromHomo1DFld.cpp)
ADD_UTILITIES_EXECUTABLE(FldAddFalknerSkanBL util-extra FldAddFalknerSkanBL.cpp)
ADD_UTILITIES_EXECUTABLE(FldAddFld util FldAddFld.cpp)
ADD_UTILITIES_EXECUTABLE(FldAddVort util FldAddVort.cpp)
......@@ -8,7 +9,7 @@ ADD_UTILITIES_EXECUTABLE(FldToGmsh util FldToGmsh.cpp)
ADD_UTILITIES_EXECUTABLE(FldToVtk util FldToVtk.cpp)
ADD_UTILITIES_EXECUTABLE(ProbeFld util-extra ProbeFld.cpp)
ADD_UTILITIES_EXECUTABLE(XmlToTecplot util XmlToTecplot.cpp)
ADD_UTILITIES_EXECUTABLE(XmlToTecplotWireFrame util XmlToTecplotWireFrame.cpp)
ADD_UTILITIES_EXECUTABLE(XmlToTecplotWireFrame util XmlToTecplotWireFrame.cpp)
ADD_UTILITIES_EXECUTABLE(XmlToVtk util XmlToVtk.cpp)
# Generate list of available solvers
......
#include <cstdio>
#include <cstdlib>
#include <SpatialDomains/MeshGraph.h> // for FieldDefinitions, etc
#include <StdRegions/StdTriExp.h>
using namespace Nektar;
int main(int argc, char *argv[])
{
int i,j;
NekDouble scal1,scal2;
if(argc != 3)
{
fprintf(stderr,"Usage: ExtractmeanModeFromHomo1DFld fieldfile outfield\n");
exit(1);
}
//default meshgraph
SpatialDomains::MeshGraph graph;
//----------------------------------------------
// Import fieldfile.
string fieldfile(argv[argc-2]);
vector<SpatialDomains::FieldDefinitionsSharedPtr> fielddef;
vector<vector<NekDouble> > fielddata;
graph.Import(fieldfile,fielddef,fielddata);
//----------------------------------------------
vector<vector<NekDouble> > combineddata;
vector<SpatialDomains::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 j;
int datalen = fielddata[i].size()/fielddef[i]->m_fields.size();
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)
{
case SpatialDomains::eTriangle:
ncoeffs = StdRegions::StdTriData::getNumberOfCoefficients(fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
break;
case SpatialDomains::eQuadrilateral:
ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
break;
default:
ASSERTL0(false,"Shape not recognised");
break;
}
std::vector<NekDouble>::iterator vec_iter;
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.
graph.Write(argv[argc-1], newfielddef, combineddata);
//-----------------------------------------------
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment