178 Array<OneD, MultiRegions::ExpListSharedPtr> field(1);
179 field[0] = f->m_exp[0];
185 if (f->m_fieldMetaDataMap.count(
"Time"))
187 string s_time = f->m_fieldMetaDataMap[
"Time"];
188 time = atof(s_time.c_str());
196 int npoints = f->m_exp[0]->GetNpoints();
197 int expdim = f->m_graph->GetMeshDimension();
198 int spacedim = expdim;
199 if ((f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
200 (f->m_fielddef[0]->m_numHomogeneousDir) == 2)
206 Array<OneD, Array<OneD, NekDouble> > coords_new(3);
207 Array<OneD, Array<OneD, NekDouble> > coords_vel(3);
208 for (
int i = 0; i < 3; i++)
210 coords_new[i] = Array<OneD, NekDouble>(npoints);
211 coords_vel[i] = Array<OneD, NekDouble>(npoints, 0.0);
214 string fieldNames[3] = {
"x",
"y",
"z"};
215 string velFieldNames[3] = {
"vx",
"vy",
"vz"};
218 if (f->m_fieldMetaDataMap.count(
"MappingType"))
220 if (f->m_fieldMetaDataMap[
"MappingType"] ==
"Expression")
225 if (f->m_fieldMetaDataMap.count(
"MappingExpression"))
227 funcName = f->m_fieldMetaDataMap[
"MappingExpression"];
233 if (f->m_fieldMetaDataMap.count(
"MappingVelExpression"))
235 velFuncName = f->m_fieldMetaDataMap[
"MappingVelExpression"];
243 Array<OneD, Array<OneD, NekDouble> > coords(3);
244 for (
int i = 0; i < 3; i++)
246 coords[i] = Array<OneD, NekDouble>(npoints);
248 f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
251 std::string s_FieldStr;
252 for (
int i = 0; i < 3; i++)
254 s_FieldStr = fieldNames[i];
255 if (f->m_session->DefinesFunction(funcName, s_FieldStr))
258 f->m_session->GetFunction(funcName, s_FieldStr);
259 ffunc->Evaluate(coords[0], coords[1], coords[2], time,
269 if (f->m_session->DefinesFunction(velFuncName))
271 for (
int i = 0; i < 3; i++)
273 s_FieldStr = velFieldNames[i];
274 if (f->m_session->DefinesFunction(velFuncName, s_FieldStr))
277 f->m_session->GetFunction(velFuncName, s_FieldStr);
278 ffunc->Evaluate(coords[0], coords[1], coords[2], time,
285 mapping->SetFromFunction(
false);
286 mapping->UpdateMapping(time, coords_new, coords_vel);
288 else if (f->m_fieldMetaDataMap[
"MappingType"] ==
"File")
290 ASSERTL0(f->m_fieldMetaDataMap.count(
"FileName"),
291 "FileName parameter for Mapping missing in field file.");
292 string fileName = f->m_fieldMetaDataMap[
"FileName"];
293 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
294 std::vector<std::vector<NekDouble> > FieldData;
296 f->FieldIOForFile(fileName)->Import(fileName, FieldDef, FieldData);
298 for (
int j = 0; j < spacedim; ++j)
300 int ncoeffs = f->m_exp[0]->GetNcoeffs();
301 Array<OneD, NekDouble> fieldcoeffs(ncoeffs, 0.0);
302 for (
int i = 0; i < FieldData.size(); ++i)
304 f->m_exp[j]->ExtractDataToCoeffs(
305 FieldDef[i], FieldData[i], fieldNames[j], fieldcoeffs);
307 bool wavespace = f->m_exp[0]->GetWaveSpace();
308 f->m_exp[0]->SetWaveSpace(
false);
310 f->m_exp[0]->BwdTrans(fieldcoeffs, coords_new[j]);
313 if (
std::find(FieldDef[0]->m_fields.begin(),
314 FieldDef[0]->m_fields.end(),
315 velFieldNames[j]) != FieldDef[0]->m_fields.end())
317 for (
int i = 0; i < FieldData.size(); ++i)
319 f->m_exp[j]->ExtractDataToCoeffs(
320 FieldDef[i], FieldData[i], velFieldNames[j],
323 f->m_exp[0]->BwdTrans(fieldcoeffs, coords_vel[j]);
325 f->m_exp[0]->SetWaveSpace(wavespace);
328 mapping->SetFromFunction(
false);
329 mapping->UpdateMapping(time, coords_new, coords_vel);
335 Array<OneD, Array<OneD, NekDouble> > coords(3);
336 Array<OneD, Array<OneD, NekDouble> > coords_vel(3);
337 for (
int i = 0; i < 3; i++)
339 coords[i] = Array<OneD, NekDouble>(npoints);
340 coords_vel[i] = Array<OneD, NekDouble>(npoints, 0.0);
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)
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)
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.