44 namespace SpatialDomains
47 std::string
static inline ReadTag(std::string &tagStr)
49 std::string::size_type indxBeg = tagStr.find_first_of(
'[') + 1;
50 std::string::size_type indxEnd = tagStr.find_last_of(
']') - 1;
54 (std::string(
"Error reading interface region definition:") + tagStr)
57 std::string indxStr = tagStr.substr(indxBeg, indxEnd - indxBeg + 1);
65 TiXmlNode *nektar = pSession->GetElement(
"NEKTAR");
66 if (nektar ==
nullptr)
71 TiXmlNode *movement = nektar->FirstChild(
"MOVEMENT");
72 if (movement !=
nullptr)
74 bool zones = movement->FirstChild(
"ZONES") !=
nullptr;
77 ReadZones(pSession->GetElement(
"NEKTAR/MOVEMENT/ZONES"), meshGraph,
81 bool interfaces = movement->FirstChild(
"INTERFACES") !=
nullptr;
89 "Only one of ZONES or INTERFACES present in the MOVEMENT "
93 if (pSession->DefinesSolverInfo(
"DiffusionType"))
95 ASSERTL0(pSession->GetSolverInfo(
"DiffusionType") ==
"LDGNS",
96 "Only LDGNS is supported as the DiffusionType in "
97 "SOLVERINFO when a MOVEMENT block is defined.")
102 if (movement !=
nullptr && pSession->DefinesCmdLineArgument(
"verbose"))
104 auto comm = pSession->GetComm();
105 if (comm->TreatAsRankZero())
107 std::cout <<
"Movement Info:\n";
108 std::cout <<
"\tNum zones: " <<
m_zones.size() <<
"\n";
113 auto numEl = zone.second->GetElements().size();
118 !zone.second->GetElements().empty()
119 ? zone.second->GetElements().front()->GetShapeType()
123 if (comm->TreatAsRankZero())
125 std::cout <<
"\t- " << zone.first <<
" "
127 zone.second->GetMovementType())]
128 <<
": " << numEl <<
" "
133 if (comm->TreatAsRankZero())
135 std::cout <<
"\tNum interfaces: " <<
m_interfaces.size() <<
"\n";
141 interface.second->GetLeftInterface()->GetEdge().size();
143 interface.second->GetRightInterface()->GetEdge().size();
149 !interface.second->GetLeftInterface()->GetEdge().empty()
150 ? interface.second->GetLeftInterface()
153 ->second->GetShapeType()
157 !interface.second->GetRightInterface()->GetEdge().empty()
158 ? interface.second->GetRightInterface()
161 ->second->GetShapeType()
165 if (comm->TreatAsRankZero())
167 std::cout <<
"\t- \"" << interface.first.second <<
"\": "
168 << interface.second->GetLeftInterface()->GetId()
169 <<
" (" << numLeft <<
" "
172 << interface.second->GetRightInterface()->GetId()
173 <<
" (" << numRight <<
" "
180 if (comm->TreatAsRankZero())
182 std::cout << std::endl;
192 ASSERTL0(zonesTag,
"Unable to find ZONES tag in file.");
193 TiXmlElement *zonesElement = zonesTag->FirstChildElement();
196 std::string zoneType = zonesElement->Value();
201 err = zonesElement->QueryIntAttribute(
"ID", &indx);
202 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read zone ID.");
204 std::string interfaceDomainStr;
205 err = zonesElement->QueryStringAttribute(
"DOMAIN", &interfaceDomainStr);
206 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read zone domain.");
209 auto domFind = stoi(
ReadTag(interfaceDomainStr));
210 std::map<int, CompositeSharedPtr> domain;
211 if (domains.find(domFind) != domains.end())
213 domain = domains.at(domFind);
217 if (zoneType ==
"F" || zoneType ==
"FIXED")
220 indx, domain, coordDim));
222 else if (zoneType ==
"R" || zoneType ==
"ROTATE" ||
223 zoneType ==
"ROTATING")
225 std::string originStr;
226 err = zonesElement->QueryStringAttribute(
"ORIGIN", &originStr);
227 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read origin.");
228 std::vector<NekDouble> originVec;
234 err = zonesElement->QueryStringAttribute(
"AXIS", &axisStr);
235 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read axis.");
239 std::string angularVelStr;
240 err = zonesElement->QueryStringAttribute(
"ANGVEL", &angularVelStr);
241 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read angular velocity.");
243 pSession->SubstituteExpressions(angularVelStr);
246 pSession->GetInterpreter(), angularVelStr);
249 indx, domain, coordDim, origin, axis, angularVelEqn));
253 else if (zoneType ==
"T" || zoneType ==
"TRANSLATE" ||
254 zoneType ==
"TRANSLATING")
256 std::string velocityStr;
257 err = zonesElement->QueryStringAttribute(
"VELOCITY", &velocityStr);
258 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read direction.");
259 std::vector<NekDouble> velocity;
264 indx, domain, coordDim, velocity));
268 else if (zoneType ==
"P" || zoneType ==
"PRESCRIBED")
270 std::string xDeformStr;
271 err = zonesElement->QueryStringAttribute(
"XDEFORM", &xDeformStr);
272 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read x deform equation.");
274 std::make_shared<LibUtilities::Equation>(
275 pSession->GetInterpreter(), xDeformStr);
277 std::string yDeformStr;
278 err = zonesElement->QueryStringAttribute(
"YDEFORM", &yDeformStr);
279 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read y deform equation.");
281 std::make_shared<LibUtilities::Equation>(
282 pSession->GetInterpreter(), yDeformStr);
284 std::string zDeformStr;
285 err = zonesElement->QueryStringAttribute(
"ZDEFORM", &zDeformStr);
286 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read z deform equation.");
288 std::make_shared<LibUtilities::Equation>(
289 pSession->GetInterpreter(), zDeformStr);
293 indx, domain, coordDim, xDeformEqn, yDeformEqn,
300 WARNINGL0(
false,
"Zone type '" + zoneType +
301 "' is unsupported. Valid types are: 'Fixed', "
302 "'Rotate', 'Translate', or 'Prescribe'.")
306 zonesElement = zonesElement->NextSiblingElement();
312 ASSERTL0(interfacesTag,
"Unable to find INTERFACES tag in file.");
313 TiXmlElement *interfaceElement = interfacesTag->FirstChildElement();
315 while (interfaceElement)
318 "INTERFACE" == (std::string)interfaceElement->Value(),
319 "Only INTERFACE tags may be present inside the INTERFACES block.")
324 err = interfaceElement->QueryStringAttribute(
"NAME", &
name);
325 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read interface name.");
326 TiXmlElement *sideElement = interfaceElement->FirstChildElement();
332 std::vector<int> cnt;
337 "In INTERFACE NAME " +
name +
338 ", only two sides may be present in each INTERFACE block.")
341 err = sideElement->QueryIntAttribute(
"ID", &indx);
342 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read interface ID.");
344 std::string boundaryStr;
346 sideElement->QueryStringAttribute(
"BOUNDARY", &boundaryStr);
349 if (boundaryErr == TIXML_SUCCESS)
351 std::string indxStr =
ReadTag(boundaryStr);
356 auto sideElVal = sideElement->ValueStr();
357 if (sideElVal ==
"LEFT" || sideElVal ==
"L")
361 else if (sideElVal ==
"RIGHT" || sideElVal ==
"R")
368 sideElement->ValueStr() +
369 " is not a valid interface side for interface "
371 name +
". Please only use LEFT or RIGHT.")
374 interfaces[cnt[cnt.size() - 1]] =
376 indx, boundaryEdge));
378 sideElement = sideElement->NextSiblingElement();
381 ASSERTL0(std::accumulate(cnt.begin(), cnt.end(), 0) == 1,
382 "You must have only one LEFT and one RIGHT side"
383 " present in interface NAME " +
388 interfaces[0], interfaces[1]));
389 interfaceElement = interfaceElement->NextSiblingElement();
397 std::set<int> movedZoneIds;
400 if (zone.second->Move(timeStep))
402 movedZoneIds.insert(zone.first);
409 int leftId = interPair.second->GetLeftInterface()->GetId();
410 int rightId = interPair.second->GetRightInterface()->GetId();
412 if (movedZoneIds.find(leftId) != movedZoneIds.end() ||
413 movedZoneIds.find(rightId) != movedZoneIds.end())
415 m_zones[leftId]->GetMoved() =
true;
416 m_zones[rightId]->GetMoved() =
true;
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define WARNINGL0(condition, msg)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
Base class for a spectral/hp element mesh.
void GetCompositeList(const std::string &compositeStr, CompositeMap &compositeVector) const
std::map< int, std::map< int, CompositeSharedPtr > > & GetDomain()
int GetSpaceDimension()
Dimension of the space (can be a 1D curve in 3D space).
void PerformMovement(NekDouble timeStep)
Movement(const LibUtilities::SessionReaderSharedPtr &pSession, MeshGraph *meshGraph)
Constructor.
void ReadZones(TiXmlElement *zonesTag, MeshGraph *meshGraph, const LibUtilities::SessionReaderSharedPtr &pSession)
Read zones given TiXmlDocument.
void ReadInterfaces(TiXmlElement *interfacesTag, MeshGraph *meshGraph)
Read interfaces given TiXmlDocument.
InterfaceCollection m_interfaces
std::map< int, ZoneBaseShPtr > m_zones
const char *const ShapeTypeMap[SIZE_ShapeType]
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
std::shared_ptr< ZoneBase > ZoneBaseShPtr
std::shared_ptr< ZonePrescribe > ZonePrescribeShPtr
std::shared_ptr< ZoneTranslate > ZoneTranslateShPtr
std::shared_ptr< InterfacePair > InterfacePairShPtr
std::shared_ptr< ZoneRotate > ZoneRotateShPtr
std::shared_ptr< Interface > InterfaceShPtr
std::shared_ptr< ZoneFixed > ZoneFixedShPtr
static std::string ReadTag(std::string &tagStr)
const std::string MovementTypeStr[]
Map of zone movement type to movement type string.
std::map< int, CompositeSharedPtr > CompositeMap
The above copyright notice and this permission notice shall be included.