40#include <boost/format.hpp>
50 "averaging of several field files. Must specify inputfld and range of "
56 ConfigOption(
false,
"NotSet",
"Fld file form which to average");
68 "Need to specify inputfld=file_%.fld ");
70 "Need to specify range=ns,dn,ne[include]");
72 std::string infilename =
m_config[
"inputfld"].as<
string>();
73 std::vector<int> range;
75 "Failed to interpret range string");
78 "range string should contain 3 values nstart, deltan, nend[include].");
80 vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
81 vector<vector<double>> FieldData;
83 for (
int i = range[0]; i <= range[2]; i += range[1])
87 string inputfldname = filenameformat.str();
88 vector<LibUtilities::FieldDefinitionsSharedPtr> tempFieldDef;
89 vector<vector<double>> tempFieldData;
94 m_f->m_graph->GetExpansionInfo();
100 if (!expansions.size())
108 for (
auto &expIt : expansions)
110 ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
112 m_f->FieldIOForFile(inputfldname)
113 ->Import(inputfldname, tempFieldDef, tempFieldData,
118 m_f->FieldIOForFile(inputfldname)
119 ->Import(inputfldname, tempFieldDef, tempFieldData,
123 if (FieldDef.size() == 0)
125 FieldDef = tempFieldDef;
128 if (FieldData.size() < tempFieldData.size())
130 FieldData.resize(tempFieldData.size());
133 for (
size_t i = 0; i < tempFieldData.size(); ++i)
135 if (FieldData[i].size() < tempFieldData[i].size())
137 FieldData[i].resize(tempFieldData[i].size(), 0.);
139 Vmath::Vadd(FieldData[i].size(), tempFieldData[i].data(), 1,
140 FieldData[i].data(), 1, FieldData[i].data(), 1);
142 if (
m_f->m_comm->GetSpaceComm()->GetRank() == 0 && vm.count(
"verbose"))
144 std::cout <<
"File " << inputfldname <<
" processed." << std::endl;
155 int numHomoDir =
m_f->m_numHomogeneousDir;
156 int nfields = FieldDef[0]->m_fields.size();
157 m_f->m_exp.resize(nfields);
158 for (
int i = 1; i < nfields; ++i)
160 m_f->m_exp[i] =
m_f->AppendExpList(numHomoDir);
162 m_f->m_variables = FieldDef[0]->m_fields;
164 for (
int j = 0; j < nfields; ++j)
167 for (
int i = 0; i < FieldDef.size(); ++i)
169 m_f->m_exp[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
171 m_f->m_exp[j]->UpdateCoeffs());
174 m_f->m_exp[j]->UpdateCoeffs(), 1,
175 m_f->m_exp[j]->UpdateCoeffs(), 1);
176 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(),
177 m_f->m_exp[j]->UpdatePhys());
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
~ProcessAverageFld() override
ProcessAverageFld(FieldSharedPtr f)
void v_Process(po::variables_map &vm) override
Write mesh to output file.
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
static ModuleKey className
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
static FieldMetaDataMap NullFieldMetaDataMap
std::map< int, ExpansionInfoShPtr > ExpansionInfoMap
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Represents a command-line configuration option.