52 ProcessMapping::create,
"Add mapping coordinates to output file.");
65 int npoints =
m_f->m_exp[0]->GetNpoints();
66 int expdim =
m_f->m_graph->GetMeshDimension();
67 int spacedim = expdim;
68 if ((
m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
69 (
m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
73 int nfields =
m_f->m_fielddef[0]->m_fields.size();
74 int addfields = expdim;
75 m_f->m_exp.resize(nfields+addfields);
81 if (
m_f->m_fieldMetaDataMap.count(
"MappingCartesianVel"))
83 if (
m_f->m_fieldMetaDataMap[
"MappingCartesianVel"] ==
"False")
85 m_f->m_fieldMetaDataMap[
"MappingCartesianVel"] =
"True";
89 for (
int i =0; i<spacedim; ++i )
92 if (
m_f->m_exp[0]->GetWaveSpace())
94 m_f->m_exp[0]->HomogeneousBwdTrans(
m_f->m_exp[i]->GetPhys(),
105 mapping->ContravarToCartesian(vel, vel);
107 for (
int i =0; i<spacedim; ++i )
109 if (
m_f->m_exp[0]->GetWaveSpace())
111 m_f->m_exp[0]->HomogeneousFwdTrans(vel[i],
112 m_f->m_exp[i]->UpdatePhys());
117 m_f->m_exp[i]->UpdatePhys(), 1);
119 m_f->m_exp[i]->FwdTrans_IterPerExp(
m_f->m_exp[i]->GetPhys(),
120 m_f->m_exp[i]->UpdateCoeffs());
127 mapping->GetCartesianCoordinates(coords[0], coords[1], coords[2]);
130 string fieldNames[3] = {
"xCoord",
"yCoord",
"zCoord"};
131 vector<string > outname;
132 for (
int i = 0; i < addfields; ++i)
134 m_f->m_exp[nfields + i] =
m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
135 m_f->m_exp[nfields + i]->UpdatePhys() = coords[i];
136 m_f->m_exp[nfields + i]->FwdTrans_IterPerExp(coords[i],
137 m_f->m_exp[nfields + i]->UpdateCoeffs());
138 outname.push_back(fieldNames[i]);
141 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
142 =
m_f->m_exp[0]->GetFieldDefinitions();
143 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
145 for (
int j = 0; j < nfields + addfields; ++j)
147 for (
int i = 0; i < FieldDef.size(); ++i)
151 FieldDef[i]->m_fields.push_back(outname[j-nfields]);
155 FieldDef[i]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[j]);
157 m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
161 m_f->m_fielddef = FieldDef;
162 m_f->m_data = FieldData;
170 field[0] = f->m_exp[0];
177 if (f->m_fieldMetaDataMap.count(
"Time"))
179 string s_time = f->m_fieldMetaDataMap[
"Time"];
180 time = atof(s_time.c_str());
188 int npoints = f->m_exp[0]->GetNpoints();
189 int expdim = f->m_graph->GetMeshDimension();
190 int spacedim = expdim;
191 if ((f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
192 (f->m_fielddef[0]->m_numHomogeneousDir) == 2)
200 for (
int i = 0; i < 3; i++)
206 string fieldNames[3] = {
"x",
"y",
"z"};
207 string velFieldNames[3] = {
"vx",
"vy",
"vz"};
210 if (f->m_fieldMetaDataMap.count(
"MappingType"))
212 if (f->m_fieldMetaDataMap[
"MappingType"] ==
"Expression")
217 if (f->m_fieldMetaDataMap.count(
"MappingExpression"))
219 funcName = f->m_fieldMetaDataMap[
"MappingExpression"];
225 if (f->m_fieldMetaDataMap.count(
"MappingVelExpression"))
227 velFuncName = f->m_fieldMetaDataMap[
"MappingVelExpression"];
236 for (
int i = 0; i < 3; i++)
240 f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
243 std::string s_FieldStr;
244 for(
int i = 0; i < 3; i++)
246 s_FieldStr = fieldNames[i];
247 if ( f->m_session->DefinesFunction(funcName, s_FieldStr))
250 f->m_session->GetFunction(funcName, s_FieldStr);
251 ffunc->Evaluate(coords[0], coords[1], coords[2],
252 time, coords_new[i]);
261 if (f->m_session->DefinesFunction(velFuncName))
263 for (
int i = 0; i < 3; i++)
265 s_FieldStr = velFieldNames[i];
266 if ( f->m_session->DefinesFunction(velFuncName, s_FieldStr))
269 f->m_session->GetFunction(velFuncName, s_FieldStr);
270 ffunc->Evaluate(coords[0], coords[1], coords[2],
271 time, coords_vel[i]);
277 mapping->SetFromFunction(
false);
278 mapping->UpdateMapping(time, coords_new,coords_vel);
280 else if(f->m_fieldMetaDataMap[
"MappingType"] ==
"File")
282 ASSERTL0(f->m_fieldMetaDataMap.count(
"FileName"),
283 "FileName parameter for Mapping missing in field file.");
284 string fileName = f->m_fieldMetaDataMap[
"FileName"];
285 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
286 std::vector<std::vector<NekDouble> > FieldData;
288 f->m_fld->Import(fileName,
292 for (
int j = 0; j < spacedim; ++j)
294 int ncoeffs = f->m_exp[0]->GetNcoeffs();
296 for (
int i = 0; i < FieldData.size(); ++i)
298 f->m_exp[j]->ExtractDataToCoeffs(FieldDef[i],
303 bool wavespace = f->m_exp[0]->GetWaveSpace();
304 f->m_exp[0]->SetWaveSpace(
false);
306 f->m_exp[0]->BwdTrans(fieldcoeffs,
312 if (
std::find(FieldDef[0]->m_fields.begin(), FieldDef[0]->m_fields.end(),
313 velFieldNames[j])!=FieldDef[0]->m_fields.end())
315 for (
int i = 0; i < FieldData.size(); ++i)
317 f->m_exp[j]->ExtractDataToCoeffs(FieldDef[i],
322 f->m_exp[0]->BwdTrans(fieldcoeffs,
325 f->m_exp[0]->SetWaveSpace(wavespace);
328 mapping->SetFromFunction(
false);
329 mapping->UpdateMapping(time, coords_new,coords_vel);
337 for (
int i = 0; i < 3; i++)
342 f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
343 mapping->SetFromFunction(
false);
344 mapping->UpdateMapping(time, coords,coords_vel);
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
FieldSharedPtr m_f
Field object.
static GlobalMapping::MappingSharedPtr GetMapping(FieldSharedPtr f)
boost::shared_ptr< Field > FieldSharedPtr
GLOBAL_MAPPING_EXPORT typedef boost::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
boost::shared_ptr< Equation > EquationSharedPtr
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
virtual ~ProcessMapping()
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
static GLOBAL_MAPPING_EXPORT MappingSharedPtr Load(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Return a pointer to the mapping, creating it on first call.
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.