Write mesh to output file.
74 if (
m_f->m_comm->TreatAsRankZero())
76 cout <<
"ProcessCombineAvg: Combining new fld into input avg fld..."
81 ASSERTL0(
m_f->m_exp.size() != 0,
"No input expansion defined");
83 int nfields =
m_f->m_fielddef[0]->m_fields.size();
84 int nq =
m_f->m_exp[0]->GetTotPoints();
85 int expdim =
m_f->m_graph->GetMeshDimension();
86 int spacedim = expdim;
87 if ((
m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
88 (
m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
90 spacedim +=
m_f->m_fielddef[0]->m_numHomogeneousDir;
94 Array<OneD, Array<OneD, NekDouble> > fromPhys(nfields);
95 Array<OneD, Array<OneD, NekDouble> > correction(nfields);
96 for (
int j = 0; j < nfields; ++j)
98 fromPhys[j] = Array<OneD, NekDouble>(nq, 0.0);
99 correction[j] = Array<OneD, NekDouble>(nq, 0.0);
102 string fromfld =
m_config[
"fromfld"].as<
string>();
107 Array<OneD, int> ElementGIDs(
m_f->m_exp[0]->GetExpSize());
108 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
110 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
113 m_f->FieldIOForFile(fromfld)->Import(
114 fromfld, fromField->m_fielddef, fromField->m_data, fromFieldMetaDataMap,
116 ASSERTL0(fromField->m_fielddef[0]->m_fields.size() == nfields,
117 "Mismatch in number of fields");
119 for (
int j = 0; j < nfields; ++j)
121 ASSERTL0(fromField->m_fielddef[0]->m_fields[j] ==
122 m_f->m_fielddef[0]->m_fields[j],
123 "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], fromField->m_data[i],
130 fromField->m_fielddef[i]->m_fields[j],
131 m_f->m_exp[j]->UpdateCoeffs());
133 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(), fromPhys[j]);
137 ASSERTL0(
m_f->m_fieldMetaDataMap.count(
"NumberOfFieldDumps") != 0,
138 "Missing NumberOfFieldDumps metadata.");
139 ASSERTL0(fromFieldMetaDataMap.count(
"NumberOfFieldDumps") != 0,
140 "Missing NumberOfFieldDumps metadata.");
142 s_num =
m_f->m_fieldMetaDataMap[
"NumberOfFieldDumps"];
143 int na = atoi(s_num.c_str());
144 s_num = fromFieldMetaDataMap[
"NumberOfFieldDumps"];
145 int nb = atoi(s_num.c_str());
149 for (
int j = 0; j < nfields; ++j)
151 if (
m_f->m_fielddef[0]->m_fields[j] ==
"uu")
161 Array<OneD, NekDouble> tmp(nq, 0.0);
164 for (
int i = 0; i < spacedim; ++i)
166 for (
int j = i; j < spacedim; ++j, ++n)
176 Vmath::Vmul(nq, correction[n], 1, tmp, 1, correction[n], 1);
177 Vmath::Smul(nq, fac, correction[n], 1, correction[n], 1);
182 for (
int j = 0; j < nfields; ++j)
186 m_f->m_exp[j]->UpdatePhys(), 1);
187 Vmath::Svtvp(nq, 1.0 * nb, fromPhys[j], 1,
m_f->m_exp[j]->GetPhys(), 1,
188 m_f->m_exp[j]->UpdatePhys(), 1);
190 m_f->m_exp[j]->UpdatePhys(), 1);
192 m_f->m_exp[j]->UpdatePhys(), 1);
194 m_f->m_exp[j]->FwdTrans_IterPerExp(
m_f->m_exp[j]->GetPhys(),
195 m_f->m_exp[j]->UpdateCoeffs());
199 m_f->m_fieldMetaDataMap[
"NumberOfFieldDumps"] =
200 boost::lexical_cast<std::string>(na + nb);
203 if (
m_f->m_fieldMetaDataMap.count(
"InitialTime"))
205 string s_t =
m_f->m_fieldMetaDataMap[
"InitialTime"];
210 if (fromFieldMetaDataMap.count(
"InitialTime"))
212 string s_t = fromFieldMetaDataMap[
"InitialTime"];
221 t0 = std::min(t0, t);
224 if (
m_f->m_fieldMetaDataMap.count(
"FinalTime"))
226 string s_t =
m_f->m_fieldMetaDataMap[
"FinalTime"];
229 finTime = std::max(t0, t);
231 if (fromFieldMetaDataMap.count(
"FinalTime"))
233 string s_t = fromFieldMetaDataMap[
"FinalTime"];
236 finTime = std::max(t0, t);
240 m_f->m_fieldMetaDataMap[
"InitialTime"] =
241 boost::lexical_cast<std::string>(t0);
245 m_f->m_fieldMetaDataMap[
"FinalTime"] =
246 boost::lexical_cast<std::string>(finTime);
250 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
251 m_f->m_exp[0]->GetFieldDefinitions();
252 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
253 for (
int i = 0; i < nfields; ++i)
255 for (
int j = 0; j < FieldDef.size(); ++j)
257 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
258 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
262 m_f->m_fielddef = FieldDef;
263 m_f->m_data = FieldData;
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
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
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.
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.
FieldSharedPtr m_f
Field object.