38 #include <boost/program_options.hpp>
53 ParamMap::const_iterator it;
56 it = pParams.find(
"OutputFile");
57 if (it == pParams.end())
59 std::stringstream outname;
60 outname <<
m_session->GetSessionName() <<
".fld";
65 ASSERTL0(it->second.length() > 0,
"Missing parameter 'OutputFile'.");
66 if ( it->second.find_last_of(
'.') != string::npos)
72 std::stringstream outname;
73 outname << it->second <<
".fld";
79 it = pParams.find(
"RestartFile");
80 if (it == pParams.end())
86 ASSERTL0(it->second.length() > 0,
"Missing parameter 'RestartFile'.");
87 if ( it->second.find_last_of(
'.') != string::npos)
93 std::stringstream outname;
94 outname << it->second <<
".fld";
100 it = pParams.find(
"SampleFrequency");
101 if (it == pParams.end())
112 it = pParams.find(
"OutputFrequency");
113 if (it == pParams.end())
130 m_f = boost::shared_ptr<Field>(
new Field());
131 vector<string> modcmds;
133 std::stringstream moduleStream;
134 it = pParams.find(
"Modules");
135 if (it != pParams.end())
137 moduleStream.str(it->second);
139 while (!moduleStream.fail())
142 moduleStream >> sMod;
143 if (!moduleStream.fail())
145 modcmds.push_back(sMod);
175 nfield = (n < pFields.num_elements())? n: 0;
180 m_fieldMetaData[
"InitialTime"] = boost::lexical_cast<std::string>(time);
184 m_f->m_graph = pFields[0]->GetGraph();
185 m_f->m_comm =
m_f->m_session->GetComm();
191 std::vector<LibUtilities::FieldDefinitionsSharedPtr> fieldDef;
192 std::vector<std::vector<NekDouble> > fieldData;
196 fld->Import(
m_restartFile, fieldDef, fieldData, fieldMetaData);
204 for(k = 0; k < pFields.num_elements(); ++k)
206 if(pFields[k]->GetSession()->GetVariable(k)
213 if(k == pFields.num_elements())
218 for (
int i = 0; i < fieldData.size(); ++i)
220 pFields[nfield]->ExtractDataToCoeffs(
229 if (fieldMetaData.count(
"NumberOfFieldDumps"))
231 m_numSamples = atoi(fieldMetaData[
"NumberOfFieldDumps"].c_str());
238 if(fieldMetaData.count(
"InitialTime"))
260 int nfield = pFields.num_elements();
262 for (
int n = 0; n < nfield; ++n)
264 m_variables[n] = pFields[n]->GetSession()->GetVariable(n);
302 for(
int n = 0; n < pFields.num_elements(); ++n)
305 pFields[n]->GetCoeffs(),
329 std::stringstream outname;
336 outname << name << suffix << ext;
340 outname << name <<
"_" << dump << suffix << ext;
345 po::options_description desc(
"Available options");
348 "Force the output to be written without any checks");
349 po::variables_map vm;
350 vm.insert(std::make_pair(
"forceoutput", po::variable_value()));
352 for (
int i = 0; i <
m_modules.size(); ++i)
382 for (
int i = 0; i < modcmds.size(); ++i)
389 boost::split(tmp1, modcmds[i], boost::is_any_of(
":"));
391 if (i == modcmds.size() - 1)
402 if (tmp1.size() == 1)
404 int dot = tmp1[0].find_last_of(
'.') + 1;
405 string ext = tmp1[0].substr(dot, tmp1[0].length() - dot);
408 tmp1.push_back(
string(
"outfile=") + tmp1[0]);
412 module.second = tmp1[1];
413 tmp1.push_back(
string(
"outfile=") + tmp1[0]);
420 module.second = tmp1[0];
429 for (
int j = offset; j < tmp1.size(); ++j)
432 boost::split(tmp2, tmp1[j], boost::is_any_of(
"="));
434 if (tmp2.size() == 1)
436 mod->RegisterConfig(tmp2[0],
"1");
438 else if (tmp2.size() == 2)
440 mod->RegisterConfig(tmp2[0], tmp2[1]);
444 cerr <<
"ERROR: Invalid module configuration: format is "
445 <<
"either :arg or :arg=val" << endl;
454 bool RequiresEquiSpaced =
false;
455 for (
int i = 0; i <
m_modules.size(); ++i)
459 RequiresEquiSpaced =
true;
462 if (RequiresEquiSpaced)
464 for (
int i = 0; i <
m_modules.size(); ++i)
466 m_modules[i]->SetRequireEquiSpaced(
true);
477 int NumHomogeneousDir = 0;
480 NumHomogeneousDir = 1;
484 NumHomogeneousDir = 2;
488 m_f->m_exp[0] = pFields[0];
493 nfield = (n < pFields.num_elements())? n: 0;
495 m_f->m_exp[n] =
m_f->AppendExpList(
497 m_f->m_exp[n]->SetWaveSpace(
false);
500 "pFields[nfield] does not have the "
501 "same number of coefficients as m_outFields[n]");
503 m_f->m_exp[n]->ExtractCoeffsToCoeffs(pFields[nfield],
m_outFields[n],
504 m_f->m_exp[n]->UpdateCoeffs());
506 m_f->m_exp[n]->BwdTrans(
m_f->m_exp[n]->GetCoeffs(),
507 m_f->m_exp[n]->UpdatePhys());
509 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
510 pFields[0]->GetFieldDefinitions();
511 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
514 for (
int i = 0; i < FieldDef.size(); ++i)
517 m_f->m_exp[n]->AppendFieldData(FieldDef[i], FieldData[i]);
520 m_f->m_fielddef = FieldDef;
521 m_f->m_data = FieldData;
528 m_f->m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
529 m_f->m_data = std::vector<std::vector<NekDouble> > ();
void OutputField(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, int dump=-1)
LibUtilities::FieldMetaDataMap m_fieldMetaData
virtual SOLVER_UTILS_EXPORT ~FilterFieldConvert()
#define ASSERTL0(condition, msg)
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
static std::string className
Name of the class.
SOLVER_UTILS_EXPORT FilterFieldConvert(const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
vector< ModuleSharedPtr > m_modules
void CreateFields(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields)
pair< ModuleType, string > ModuleKey
std::vector< Array< OneD, NekDouble > > m_outFields
virtual SOLVER_UTILS_EXPORT void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
virtual SOLVER_UTILS_EXPORT void v_PrepareOutput(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
boost::shared_ptr< Module > ModuleSharedPtr
virtual SOLVER_UTILS_EXPORT void v_FillVariablesName(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields)
virtual SOLVER_UTILS_EXPORT std::string v_GetFileSuffix()
unsigned int m_sampleFrequency
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
NekDouble Evaluate() const
static FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::map< std::string, std::string > &pParams)
Creates an instance of this class.
virtual SOLVER_UTILS_EXPORT NekDouble v_GetScale()
void CreateModules(vector< string > &modcmds)
boost::shared_ptr< FieldIO > FieldIOSharedPtr
std::map< std::string, std::string > ParamMap
LibUtilities::SessionReaderSharedPtr m_session
virtual SOLVER_UTILS_EXPORT void v_ProcessSample(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
virtual SOLVER_UTILS_EXPORT void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
static PtsFieldSharedPtr NullPtsField
static boost::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
std::string m_restartFile
unsigned int m_outputFrequency
FilterFactory & GetFilterFactory()
unsigned int m_outputIndex
virtual SOLVER_UTILS_EXPORT void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
virtual SOLVER_UTILS_EXPORT bool v_IsTimeDependent()
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
std::vector< std::string > m_variables
unsigned int m_numSamples
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.