53 ProcessCombineAvg::create,
"combine two fields containing averages (and possibly Reynolds stresses). Must specify fromfld.");
58 "Fld file form which to add field");
61 "Need to specify fromfld=file.fld ");
73 if(
m_f->m_comm->GetRank() == 0)
75 cout <<
"ProcessCombineAvg: Combining new fld into input avg fld..."
80 ASSERTL0(
m_f->m_exp.size() != 0,
"No input expansion defined");
82 int nfields =
m_f->m_fielddef[0]->m_fields.size();
83 int nq =
m_f->m_exp[0]->GetTotPoints();
84 int expdim =
m_f->m_graph->GetMeshDimension();
85 int spacedim = expdim;
86 if ((
m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
87 (
m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
89 spacedim +=
m_f->m_fielddef[0]->m_numHomogeneousDir;
95 for (
int j = 0; j < nfields; ++j)
101 string fromfld =
m_config[
"fromfld"].as<
string>();
107 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
109 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
112 m_f->m_fld->Import(fromfld,
113 fromField->m_fielddef,
115 fromFieldMetaDataMap,
117 ASSERTL0(fromField->m_fielddef[0]->m_fields.size() == nfields,
118 "Mismatch in number of fields");
120 for (
int j = 0; j < nfields; ++j)
122 ASSERTL0(fromField->m_fielddef[0]->m_fields[j] ==
123 m_f->m_fielddef[0]->m_fields[j],
"Field names do not match.");
126 for (
int i = 0; i < fromField->m_data.size(); ++i)
128 m_f->m_exp[j]->ExtractDataToCoeffs(
129 fromField->m_fielddef[i],
130 fromField->m_data[i],
131 fromField->m_fielddef[i]->m_fields[j],
132 m_f->m_exp[j]->UpdateCoeffs());
134 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(), fromPhys[j]);
138 ASSERTL0(
m_f->m_fieldMetaDataMap.count(
"NumberOfFieldDumps") != 0,
139 "Missing NumberOfFieldDumps metadata.");
140 ASSERTL0(fromFieldMetaDataMap.count(
"NumberOfFieldDumps") != 0,
141 "Missing NumberOfFieldDumps metadata.");
143 s_num =
m_f->m_fieldMetaDataMap[
"NumberOfFieldDumps"];
144 int na = atoi(s_num.c_str());
145 s_num = fromFieldMetaDataMap[
"NumberOfFieldDumps"];
146 int nb = atoi(s_num.c_str());
150 for (
int j = 0; j < nfields; ++j)
152 if (
m_f->m_fielddef[0]->m_fields[j] ==
"uu")
165 for (
int i = 0; i < spacedim; ++i)
167 for (
int j = i; j < spacedim; ++j, ++n)
174 fromPhys[i], 1, correction[n], 1);
176 fromPhys[j], 1, tmp, 1);
177 Vmath::Vmul(nq, correction[n], 1, tmp, 1, correction[n], 1);
178 Vmath::Smul(nq, fac, correction[n], 1, correction[n], 1);
183 for (
int j = 0; j < nfields; ++j)
187 m_f->m_exp[j]->UpdatePhys(), 1);
189 m_f->m_exp[j]->GetPhys(), 1,
190 m_f->m_exp[j]->UpdatePhys(), 1);
193 m_f->m_exp[j]->UpdatePhys(), 1);
195 m_f->m_exp[j]->GetPhys(), 1,
196 m_f->m_exp[j]->UpdatePhys(), 1);
198 m_f->m_exp[j]->FwdTrans_IterPerExp(
m_f->m_exp[j]->GetPhys(),
199 m_f->m_exp[j]->UpdateCoeffs());
203 m_f->m_fieldMetaDataMap[
"NumberOfFieldDumps"] =
204 boost::lexical_cast<std::string>(na+nb);
207 if(
m_f->m_fieldMetaDataMap.count(
"InitialTime"))
209 string s_t =
m_f->m_fieldMetaDataMap[
"InitialTime"];
214 if(fromFieldMetaDataMap.count(
"InitialTime"))
216 string s_t = fromFieldMetaDataMap[
"InitialTime"];
225 t0 = std::min(t0, t);
228 if(
m_f->m_fieldMetaDataMap.count(
"FinalTime"))
230 string s_t =
m_f->m_fieldMetaDataMap[
"FinalTime"];
233 finTime = std::max(t0, t);
235 if(fromFieldMetaDataMap.count(
"FinalTime"))
237 string s_t = fromFieldMetaDataMap[
"FinalTime"];
240 finTime = std::max(t0, t);
244 m_f->m_fieldMetaDataMap[
"InitialTime"] =
245 boost::lexical_cast<std::string>(t0);
249 m_f->m_fieldMetaDataMap[
"FinalTime"] =
250 boost::lexical_cast<std::string>(finTime);
254 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
255 =
m_f->m_exp[0]->GetFieldDefinitions();
256 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
257 for(
int i = 0; i < nfields; ++i)
259 for (
int j = 0; j < FieldDef.size(); ++j)
261 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
262 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
266 m_f->m_fielddef = FieldDef;
267 m_f->m_data = FieldData;
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
map< string, ConfigOption > m_config
List of configuration values.
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
std::map< std::string, std::string > FieldMetaDataMap
FieldSharedPtr m_f
Field object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
boost::shared_ptr< Field > FieldSharedPtr
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.
virtual ~ProcessCombineAvg()
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 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.
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.