48 "Add mapping coordinates to output file.");
63 int npoints =
m_f->m_exp[0]->GetNpoints();
64 int expdim =
m_f->m_graph->GetMeshDimension();
65 int spacedim = expdim;
66 if ((
m_f->m_numHomogeneousDir) == 1 || (
m_f->m_numHomogeneousDir) == 2)
70 int nfields =
m_f->m_variables.size();
71 int addfields = expdim;
73 string fieldNames[3] = {
"xCoord",
"yCoord",
"zCoord"};
74 for (
int i = 0; i < addfields; ++i)
76 m_f->m_variables.push_back(fieldNames[i]);
80 if (
m_f->m_exp[0]->GetNumElmts() == 0)
85 m_f->m_exp.resize(nfields + addfields);
91 if (
m_f->m_fieldMetaDataMap.count(
"MappingCartesianVel"))
93 if (
m_f->m_fieldMetaDataMap[
"MappingCartesianVel"] ==
"False")
95 m_f->m_fieldMetaDataMap[
"MappingCartesianVel"] =
"True";
99 for (
int i = 0; i < spacedim; ++i)
102 if (
m_f->m_exp[0]->GetWaveSpace())
104 m_f->m_exp[0]->HomogeneousBwdTrans(
105 npoints,
m_f->m_exp[i]->GetPhys(), vel[i]);
114 mapping->ContravarToCartesian(vel, vel);
116 for (
int i = 0; i < spacedim; ++i)
118 if (
m_f->m_exp[0]->GetWaveSpace())
120 m_f->m_exp[0]->HomogeneousFwdTrans(
121 npoints, vel[i],
m_f->m_exp[i]->UpdatePhys());
126 m_f->m_exp[i]->UpdatePhys(), 1);
128 m_f->m_exp[i]->FwdTransLocalElmt(
m_f->m_exp[i]->GetPhys(),
129 m_f->m_exp[i]->UpdateCoeffs());
136 mapping->GetCartesianCoordinates(coords[0], coords[1], coords[2]);
139 for (
int i = 0; i < addfields; ++i)
141 m_f->m_exp[nfields + i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
143 m_f->m_exp[nfields + i]->UpdatePhys(), 1);
144 m_f->m_exp[nfields + i]->FwdTransLocalElmt(
145 coords[i],
m_f->m_exp[nfields + i]->UpdateCoeffs());
153 field[0] = f->m_exp[0];
159 if (f->m_fieldMetaDataMap.count(
"Time"))
161 string s_time = f->m_fieldMetaDataMap[
"Time"];
162 time = atof(s_time.c_str());
170 int npoints = f->m_exp[0]->GetNpoints();
171 int expdim = f->m_graph->GetMeshDimension();
172 int spacedim = expdim + f->m_numHomogeneousDir;
177 for (
int i = 0; i < 3; i++)
183 string fieldNames[3] = {
"x",
"y",
"z"};
184 string velFieldNames[3] = {
"vx",
"vy",
"vz"};
187 if (f->m_fieldMetaDataMap.count(
"MappingType"))
189 if (f->m_fieldMetaDataMap[
"MappingType"] ==
"Expression")
194 if (f->m_fieldMetaDataMap.count(
"MappingExpression"))
196 funcName = f->m_fieldMetaDataMap[
"MappingExpression"];
202 if (f->m_fieldMetaDataMap.count(
"MappingVelExpression"))
204 velFuncName = f->m_fieldMetaDataMap[
"MappingVelExpression"];
213 for (
int i = 0; i < 3; i++)
217 f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
220 std::string s_FieldStr;
221 for (
int i = 0; i < 3; i++)
223 s_FieldStr = fieldNames[i];
224 if (f->m_session->DefinesFunction(funcName, s_FieldStr))
227 f->m_session->GetFunction(funcName, s_FieldStr);
228 ffunc->Evaluate(coords[0], coords[1], coords[2], time,
238 if (f->m_session->DefinesFunction(velFuncName))
240 for (
int i = 0; i < 3; i++)
242 s_FieldStr = velFieldNames[i];
243 if (f->m_session->DefinesFunction(velFuncName, s_FieldStr))
246 f->m_session->GetFunction(velFuncName, s_FieldStr);
247 ffunc->Evaluate(coords[0], coords[1], coords[2], time,
254 mapping->SetFromFunction(
false);
255 mapping->UpdateMapping(time, coords_new, coords_vel);
257 else if (f->m_fieldMetaDataMap[
"MappingType"] ==
"File")
259 ASSERTL0(f->m_fieldMetaDataMap.count(
"FileName"),
260 "FileName parameter for Mapping missing in field file.");
261 string fileName = f->m_fieldMetaDataMap[
"FileName"];
262 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
263 std::vector<std::vector<NekDouble>> FieldData;
265 f->FieldIOForFile(fileName)->Import(fileName, FieldDef, FieldData);
267 for (
int j = 0; j < spacedim; ++j)
269 int ncoeffs = f->m_exp[0]->GetNcoeffs();
271 for (
int i = 0; i < FieldData.size(); ++i)
273 f->m_exp[j]->ExtractDataToCoeffs(
274 FieldDef[i], FieldData[i], fieldNames[j], fieldcoeffs);
276 bool wavespace = f->m_exp[0]->GetWaveSpace();
277 f->m_exp[0]->SetWaveSpace(
false);
279 f->m_exp[0]->BwdTrans(fieldcoeffs, coords_new[j]);
282 if (
std::find(FieldDef[0]->m_fields.begin(),
283 FieldDef[0]->m_fields.end(),
284 velFieldNames[j]) != FieldDef[0]->m_fields.end())
286 for (
int i = 0; i < FieldData.size(); ++i)
288 f->m_exp[j]->ExtractDataToCoeffs(
289 FieldDef[i], FieldData[i], velFieldNames[j],
292 f->m_exp[0]->BwdTrans(fieldcoeffs, coords_vel[j]);
294 f->m_exp[0]->SetWaveSpace(wavespace);
297 mapping->SetFromFunction(
false);
298 mapping->UpdateMapping(time, coords_new, coords_vel);
306 for (
int i = 0; i < 3; i++)
311 f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
312 mapping->SetFromFunction(
false);
313 mapping->UpdateMapping(time, coords, coords_vel);
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
void v_Process(po::variables_map &vm) override
Write mesh to output file.
static ModuleKey className
ProcessMapping(FieldSharedPtr f)
~ProcessMapping() override
static GlobalMapping::MappingSharedPtr GetMapping(FieldSharedPtr f)
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
Abstract base class for processing modules.
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.
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()
GLOBAL_MAPPING_EXPORT typedef std::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
std::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)