49 "combine two fields containing averages (and possibly Reynolds "
50 "stresses). Must specify fromfld.");
55 ConfigOption(
false,
"NotSet",
"Fld file form which to add field");
67 if (
m_f->m_exp[0]->GetNumElmts() == 0)
73 "Need to specify fromfld=file.fld ");
75 int nfields =
m_f->m_variables.size();
76 int nq =
m_f->m_exp[0]->GetTotPoints();
77 int expdim =
m_f->m_graph->GetMeshDimension();
78 int spacedim = expdim;
79 if ((
m_f->m_numHomogeneousDir) == 1 || (
m_f->m_numHomogeneousDir) == 2)
81 spacedim +=
m_f->m_numHomogeneousDir;
87 for (
int j = 0; j < nfields; ++j)
93 string fromfld =
m_config[
"fromfld"].as<
string>();
99 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
101 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
104 m_f->FieldIOForFile(fromfld)->Import(fromfld, fromField->m_fielddef,
106 fromFieldMetaDataMap, ElementGIDs);
107 ASSERTL0(fromField->m_fielddef[0]->m_fields.size() == nfields,
108 "Mismatch in number of fields");
110 for (
int j = 0; j < nfields; ++j)
112 ASSERTL0(fromField->m_fielddef[0]->m_fields[j] ==
m_f->m_variables[j],
113 "Field names do not match.");
116 for (
int i = 0; i < fromField->m_data.size(); ++i)
118 m_f->m_exp[j]->ExtractDataToCoeffs(
119 fromField->m_fielddef[i], fromField->m_data[i],
120 m_f->m_variables[j],
m_f->m_exp[j]->UpdateCoeffs());
122 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(), fromPhys[j]);
126 ASSERTL0(
m_f->m_fieldMetaDataMap.count(
"NumberOfFieldDumps") != 0,
127 "Missing NumberOfFieldDumps metadata.");
128 ASSERTL0(fromFieldMetaDataMap.count(
"NumberOfFieldDumps") != 0,
129 "Missing NumberOfFieldDumps metadata.");
131 s_num =
m_f->m_fieldMetaDataMap[
"NumberOfFieldDumps"];
132 int na = atoi(s_num.c_str());
133 s_num = fromFieldMetaDataMap[
"NumberOfFieldDumps"];
134 int nb = atoi(s_num.c_str());
138 for (
int j = 0; j < nfields; ++j)
140 if (
m_f->m_variables[j] ==
"uu")
153 for (
int i = 0; i < spacedim; ++i)
155 for (
int j = i; j < spacedim; ++j, ++n)
165 Vmath::Vmul(nq, correction[n], 1, tmp, 1, correction[n], 1);
166 Vmath::Smul(nq, fac, correction[n], 1, correction[n], 1);
171 for (
int j = 0; j < nfields; ++j)
175 m_f->m_exp[j]->UpdatePhys(), 1);
176 Vmath::Svtvp(nq, 1.0 * nb, fromPhys[j], 1,
m_f->m_exp[j]->GetPhys(), 1,
177 m_f->m_exp[j]->UpdatePhys(), 1);
179 m_f->m_exp[j]->UpdatePhys(), 1);
181 m_f->m_exp[j]->UpdatePhys(), 1);
182 m_f->m_exp[j]->FwdTransLocalElmt(
m_f->m_exp[j]->GetPhys(),
183 m_f->m_exp[j]->UpdateCoeffs());
187 m_f->m_fieldMetaDataMap[
"NumberOfFieldDumps"] = std::to_string(na + nb);
190 if (
m_f->m_fieldMetaDataMap.count(
"InitialTime"))
192 string s_t =
m_f->m_fieldMetaDataMap[
"InitialTime"];
197 if (fromFieldMetaDataMap.count(
"InitialTime"))
199 string s_t = fromFieldMetaDataMap[
"InitialTime"];
208 t0 = std::min(t0, t);
211 if (
m_f->m_fieldMetaDataMap.count(
"FinalTime"))
213 string s_t =
m_f->m_fieldMetaDataMap[
"FinalTime"];
216 finTime = std::max(t0, t);
218 if (fromFieldMetaDataMap.count(
"FinalTime"))
220 string s_t = fromFieldMetaDataMap[
"FinalTime"];
223 finTime = std::max(t0, t);
227 m_f->m_fieldMetaDataMap[
"InitialTime"] =
228 boost::lexical_cast<std::string>(t0);
232 m_f->m_fieldMetaDataMap[
"FinalTime"] =
233 boost::lexical_cast<std::string>(finTime);
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
ProcessCombineAvg(FieldSharedPtr f)
~ProcessCombineAvg() override
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
void v_Process(po::variables_map &vm) override
Write mesh to output file.
static ModuleKey className
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
std::map< std::string, std::string > FieldMetaDataMap
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
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.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Represents a command-line configuration option.