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);
164 int ncoeff = pFields[0]->GetNcoeffs();
173 m_fieldMetaData[
"InitialTime"] = boost::lexical_cast<std::string>(time);
177 m_f->m_graph = pFields[0]->GetGraph();
178 m_f->m_comm =
m_f->m_session->GetComm();
184 std::vector<LibUtilities::FieldDefinitionsSharedPtr> fieldDef;
185 std::vector<std::vector<NekDouble> > fieldData;
189 fld->Import(
m_restartFile, fieldDef, fieldData, fieldMetaData);
194 for (
int i = 0; i < fieldData.size(); ++i)
196 pFields[0]->ExtractDataToCoeffs(
205 if (fieldMetaData.count(
"NumberOfFieldDumps"))
207 m_numSamples = atoi(fieldMetaData[
"NumberOfFieldDumps"].c_str());
231 int nfield = pFields.num_elements();
233 for (
int n = 0; n < nfield; ++n)
235 m_variables[n] = pFields[n]->GetSession()->GetVariable(n);
273 for(
int n = 0; n < pFields.num_elements(); ++n)
276 pFields[n]->GetCoeffs(),
300 std::stringstream outname;
307 outname << name << suffix << ext;
311 outname << name <<
"_" << dump << suffix << ext;
316 po::options_description desc(
"Available options");
319 "Force the output to be written without any checks");
320 po::variables_map vm;
321 vm.insert(std::make_pair(
"forceoutput", po::variable_value()));
323 for (
int i = 0; i <
m_modules.size(); ++i)
353 for (
int i = 0; i < modcmds.size(); ++i)
360 boost::split(tmp1, modcmds[i], boost::is_any_of(
":"));
362 if (i == modcmds.size() - 1)
373 if (tmp1.size() == 1)
375 int dot = tmp1[0].find_last_of(
'.') + 1;
376 string ext = tmp1[0].substr(dot, tmp1[0].length() - dot);
379 tmp1.push_back(
string(
"outfile=") + tmp1[0]);
383 module.second = tmp1[1];
384 tmp1.push_back(
string(
"outfile=") + tmp1[0]);
391 module.second = tmp1[0];
400 for (
int j = offset; j < tmp1.size(); ++j)
403 boost::split(tmp2, tmp1[j], boost::is_any_of(
"="));
405 if (tmp2.size() == 1)
407 mod->RegisterConfig(tmp2[0],
"1");
409 else if (tmp2.size() == 2)
411 mod->RegisterConfig(tmp2[0], tmp2[1]);
415 cerr <<
"ERROR: Invalid module configuration: format is "
416 <<
"either :arg or :arg=val" << endl;
425 bool RequiresEquiSpaced =
false;
426 for (
int i = 0; i <
m_modules.size(); ++i)
430 RequiresEquiSpaced =
true;
433 if (RequiresEquiSpaced)
435 for (
int i = 0; i <
m_modules.size(); ++i)
437 m_modules[i]->SetRequireEquiSpaced(
true);
448 int NumHomogeneousDir = 0;
451 NumHomogeneousDir = 1;
455 NumHomogeneousDir = 2;
459 m_f->m_exp[0] = pFields[0];
462 m_f->m_exp[n] =
m_f->AppendExpList(
464 m_f->m_exp[n]->SetWaveSpace(
false);
467 m_f->m_exp[n]->UpdateCoeffs(), 1);
468 m_f->m_exp[n]->BwdTrans(
m_f->m_exp[n]->GetCoeffs(),
469 m_f->m_exp[n]->UpdatePhys());
471 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
472 pFields[0]->GetFieldDefinitions();
473 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
476 for (
int i = 0; i < FieldDef.size(); ++i)
479 m_f->m_exp[n]->AppendFieldData(FieldDef[i], FieldData[i]);
482 m_f->m_fielddef = FieldDef;
483 m_f->m_data = FieldData;
490 m_f->m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
491 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()
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.