47#include <boost/format.hpp>
58 "IO with Xml geometry");
66 const bool isRoot = comm->TreatAsRankZero();
78 int isPartitioned = 0;
81 if (
m_session->DefinesElement(
"Nektar/Geometry"))
83 if (
m_session->GetElement(
"Nektar/Geometry")
84 ->Attribute(
"PARTITION"))
86 std::cout <<
"Using pre-partitioned mesh." << std::endl;
91 comm->Bcast(isPartitioned, 0);
108 string partitionerName =
"Scotch";
109 if (!haveScotch && haveMetis)
111 partitionerName =
"Metis";
115 if (session->DefinesCmdLineArgument(
"use-metis"))
117 partitionerName =
"Metis";
119 if (session->DefinesCmdLineArgument(
"use-scotch"))
121 partitionerName =
"Scotch";
127 if (session->DefinesCmdLineArgument(
"part-only") ||
128 session->DefinesCmdLineArgument(
"part-only-overlapping"))
133 "The 'part-only' option should be used in serial.");
144 partitionerName, session, session->GetComm(),
147 if (session->DefinesCmdLineArgument(
"part-only"))
149 nParts = session->GetCmdLineArgument<
int>(
"part-only");
150 partitioner->PartitionMesh(nParts,
true);
155 session->GetCmdLineArgument<
int>(
"part-only-overlapping");
156 partitioner->PartitionMesh(nParts,
true,
true);
159 vector<set<unsigned int>> elmtIDs;
160 vector<unsigned int> parts(nParts);
161 for (
int i = 0; i < nParts; ++i)
163 vector<unsigned int> elIDs;
164 set<unsigned int> tmp;
165 partitioner->GetElementIDs(i, elIDs);
166 tmp.insert(elIDs.begin(), elIDs.end());
167 elmtIDs.push_back(tmp);
173 if (isRoot && session->DefinesCmdLineArgument(
"part-info"))
175 partitioner->PrintPartInfo(std::cout);
182 if (commMesh->GetSize() > 1)
185 "Valid partitioner not found! Either Scotch or METIS "
188 int nParts = commMesh->GetSize();
190 if (session->GetSharedFilesystem())
192 vector<unsigned int> keys, vals;
207 partitionerName, session, session->GetComm(),
210 partitioner->PartitionMesh(nParts,
true);
212 vector<set<unsigned int>> elmtIDs;
213 vector<unsigned int> parts(nParts);
214 for (i = 0; i < nParts; ++i)
216 vector<unsigned int> elIDs;
217 set<unsigned int> tmp;
218 partitioner->GetElementIDs(i, elIDs);
219 tmp.insert(elIDs.begin(), elIDs.end());
220 elmtIDs.push_back(tmp);
236 comm->Bcast(keys, 0);
247 vals[i++] = cIt.second.size();
251 comm->Bcast(keys, 0);
252 comm->Bcast(vals, 0);
255 comm->Bcast(cIt.second, 0);
267 vals[i++] = bIt.second.size();
273 comm->Bcast(keys, 0);
277 comm->Bcast(vals, 0);
281 comm->Bcast(bIt.second, 0);
284 if (session->DefinesCmdLineArgument(
"part-info"))
286 partitioner->PrintPartInfo(std::cout);
292 comm->Bcast(keys, 0);
294 int cmpSize = keys[0];
295 int bndSize = keys[1];
297 keys.resize(cmpSize);
298 vals.resize(cmpSize);
299 comm->Bcast(keys, 0);
300 comm->Bcast(vals, 0);
302 for (
int i = 0; i < keys.size(); ++i)
304 vector<unsigned int> tmp(vals[i]);
309 keys.resize(bndSize);
310 vals.resize(bndSize);
313 comm->Bcast(keys, 0);
317 comm->Bcast(vals, 0);
319 for (
int i = 0; i < keys.size(); ++i)
321 vector<unsigned int> tmp(vals[i]);
340 partitionerName, session, session->GetComm(),
343 partitioner->PartitionMesh(nParts,
false);
345 vector<unsigned int> parts(1), tmp;
346 parts[0] = commMesh->GetRank();
347 vector<set<unsigned int>> elIDs(1);
348 partitioner->GetElementIDs(parts[0], tmp);
349 elIDs[0].insert(tmp.begin(), tmp.end());
358 if (
m_session->DefinesCmdLineArgument(
"part-info") && isRoot)
360 partitioner->PrintPartInfo(std::cout);
367 std::string dirname =
m_session->GetSessionName() +
"_xml";
368 fs::path pdirname(dirname);
370 pad % comm->GetRowComm()->GetRank();
371 fs::path pFilename(pad.str());
372 fs::path fullpath = pdirname / pFilename;
374 std::vector<std::string> filenames = {
413 TiXmlAttribute *attr =
m_xmlGeom->FirstAttribute();
424 std::string attrName(attr->Name());
425 if (attrName ==
"DIM")
428 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read mesh dimension.");
430 else if (attrName ==
"SPACE")
433 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read space dimension.");
435 else if (attrName ==
"PARTITION")
438 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read partition.");
443 std::string errstr(
"Unknown attribute: ");
453 "Mesh dimension greater than space dimension");
478 TiXmlElement *element =
m_xmlGeom->FirstChildElement(
"VERTEX");
479 ASSERTL0(element,
"Unable to find mesh VERTEX tag in file.");
486 const char *xscal = element->Attribute(
"XSCALE");
493 std::string xscalstr = xscal;
495 xscale = expEvaluator.
Evaluate(expr_id);
498 const char *yscal = element->Attribute(
"YSCALE");
505 std::string yscalstr = yscal;
507 yscale = expEvaluator.
Evaluate(expr_id);
510 const char *zscal = element->Attribute(
"ZSCALE");
517 std::string zscalstr = zscal;
519 zscale = expEvaluator.
Evaluate(expr_id);
527 const char *xmov = element->Attribute(
"XMOVE");
534 std::string xmovstr = xmov;
536 xmove = expEvaluator.
Evaluate(expr_id);
539 const char *ymov = element->Attribute(
"YMOVE");
546 std::string ymovstr = ymov;
548 ymove = expEvaluator.
Evaluate(expr_id);
551 const char *zmov = element->Attribute(
"ZMOVE");
558 std::string zmovstr = zmov;
560 zmove = expEvaluator.
Evaluate(expr_id);
563 TiXmlElement *vertex = element->FirstChildElement(
"V");
569 TiXmlAttribute *vertexAttr = vertex->FirstAttribute();
570 std::string attrName(vertexAttr->Name());
573 (std::string(
"Unknown attribute name: ") + attrName).c_str());
575 int err = vertexAttr->QueryIntValue(&indx);
576 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
579 std::string vertexBodyStr;
581 TiXmlNode *vertexBody = vertex->FirstChild();
586 if (vertexBody->Type() == TiXmlNode::TINYXML_TEXT)
588 vertexBodyStr += vertexBody->ToText()->Value();
589 vertexBodyStr +=
" ";
592 vertexBody = vertexBody->NextSibling();
596 "Vertex definitions must contain vertex data.");
600 std::istringstream vertexDataStrm(vertexBodyStr.c_str());
604 while (!vertexDataStrm.fail())
606 vertexDataStrm >> xval >> yval >> zval;
608 xval = xval * xscale + xmove;
609 yval = yval * yscale + ymove;
610 zval = zval * zscale + zmove;
615 if (!vertexDataStrm.fail())
626 ASSERTL0(
false,
"Unable to read VERTEX data.");
629 vertex = vertex->NextSiblingElement(
"V");
637 TiXmlElement *element =
m_xmlGeom->FirstChildElement(
"VERTEX");
638 ASSERTL0(element,
"Unable to find mesh VERTEX tag in file.");
643 const char *xscal = element->Attribute(
"XSCALE");
650 std::string xscalstr = xscal;
652 xscale = expEvaluator.
Evaluate(expr_id);
655 const char *yscal = element->Attribute(
"YSCALE");
662 std::string yscalstr = yscal;
664 yscale = expEvaluator.
Evaluate(expr_id);
667 const char *zscal = element->Attribute(
"ZSCALE");
674 std::string zscalstr = zscal;
676 zscale = expEvaluator.
Evaluate(expr_id);
684 const char *xmov = element->Attribute(
"XMOVE");
691 std::string xmovstr = xmov;
693 xmove = expEvaluator.
Evaluate(expr_id);
696 const char *ymov = element->Attribute(
"YMOVE");
703 std::string ymovstr = ymov;
705 ymove = expEvaluator.
Evaluate(expr_id);
708 const char *zmov = element->Attribute(
"ZMOVE");
715 std::string zmovstr = zmov;
717 zmove = expEvaluator.
Evaluate(expr_id);
734 TiXmlElement *edgelement =
field->FirstChildElement(
"E");
736 int edgeindx, edgeid;
740 std::string edge(edgelement->ValueStr());
742 (std::string(
"Unknown 3D curve type:") + edge).c_str());
745 err = edgelement->QueryIntAttribute(
"ID", &edgeindx);
746 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read curve attribute ID.");
749 err = edgelement->QueryIntAttribute(
"EDGEID", &edgeid);
751 "Unable to read curve attribute EDGEID.");
754 std::string elementStr;
755 TiXmlNode *elementChild = edgelement->FirstChild();
760 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
762 elementStr += elementChild->ToText()->ValueStr();
765 elementChild = elementChild->NextSibling();
768 ASSERTL0(!elementStr.empty(),
"Unable to read curve description body.");
776 std::string typeStr = edgelement->Attribute(
"TYPE");
777 ASSERTL0(!typeStr.empty(),
"TYPE must be specified in "
778 "points definition");
782 const std::string *endStr =
784 const std::string *ptsStr =
std::find(begStr, endStr, typeStr);
786 ASSERTL0(ptsStr != endStr,
"Invalid points type.");
790 err = edgelement->QueryIntAttribute(
"NUMPOINTS", &numPts);
792 "Unable to read curve attribute NUMPOINTS.");
798 std::istringstream elementDataStrm(elementStr.c_str());
801 while (!elementDataStrm.fail())
803 elementDataStrm >> xval >> yval >> zval;
805 xval = xval * xscale + xmove;
806 yval = yval * yscale + ymove;
807 zval = zval * zscale + zmove;
812 if (!elementDataStrm.fail())
818 curve->m_points.push_back(vert);
825 (std::string(
"Unable to read curve data for EDGE: ") +
830 ASSERTL0(curve->m_points.size() == numPts,
831 "Number of points specificed by attribute "
832 "NUMPOINTS is different from number of points "
833 "in list (edgeid = " +
834 boost::lexical_cast<string>(edgeid));
838 edgelement = edgelement->NextSiblingElement(
"E");
844 TiXmlElement *facelement =
field->FirstChildElement(
"F");
845 int faceindx, faceid;
849 std::string face(facelement->ValueStr());
851 (std::string(
"Unknown 3D curve type: ") + face).c_str());
854 err = facelement->QueryIntAttribute(
"ID", &faceindx);
855 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read curve attribute ID.");
858 err = facelement->QueryIntAttribute(
"FACEID", &faceid);
860 "Unable to read curve attribute FACEID.");
863 std::string elementStr;
864 TiXmlNode *elementChild = facelement->FirstChild();
869 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
871 elementStr += elementChild->ToText()->ValueStr();
874 elementChild = elementChild->NextSibling();
877 ASSERTL0(!elementStr.empty(),
"Unable to read curve description body.");
883 std::string typeStr = facelement->Attribute(
"TYPE");
884 ASSERTL0(!typeStr.empty(),
"TYPE must be specified in "
885 "points definition");
888 const std::string *endStr =
890 const std::string *ptsStr =
std::find(begStr, endStr, typeStr);
892 ASSERTL0(ptsStr != endStr,
"Invalid points type.");
895 std::string numptsStr = facelement->Attribute(
"NUMPOINTS");
897 "NUMPOINTS must be specified in points definition");
906 ASSERTL0(numPts >= 3,
"NUMPOINTS for face must be greater than 2");
910 ASSERTL0(ptsStr != endStr,
"Invalid points type.");
915 std::istringstream elementDataStrm(elementStr.c_str());
918 while (!elementDataStrm.fail())
920 elementDataStrm >> xval >> yval >> zval;
926 if (!elementDataStrm.fail())
931 curve->m_points.push_back(vert);
938 (std::string(
"Unable to read curve data for FACE: ") +
944 facelement = facelement->NextSiblingElement(
"F");
951 TiXmlElement *domain =
nullptr;
953 domain =
m_xmlGeom->FirstChildElement(
"DOMAIN");
955 ASSERTL0(domain,
"Unable to find DOMAIN tag in file.");
959 TiXmlElement *multidomains = domain->FirstChildElement(
"D");
966 int err = multidomains->QueryIntAttribute(
"ID", &indx);
968 "Unable to read attribute ID in Domain.");
970 TiXmlNode *elementChild = multidomains->FirstChild();
971 while (elementChild &&
972 elementChild->Type() != TiXmlNode::TINYXML_TEXT)
974 elementChild = elementChild->NextSibling();
977 ASSERTL0(elementChild,
"Unable to read DOMAIN body.");
978 std::string elementStr = elementChild->ToText()->ValueStr();
980 elementStr = elementStr.substr(elementStr.find_first_not_of(
" "));
982 std::string::size_type indxBeg = elementStr.find_first_of(
'[') + 1;
983 std::string::size_type indxEnd = elementStr.find_last_of(
']') - 1;
984 std::string indxStr =
985 elementStr.substr(indxBeg, indxEnd - indxBeg + 1);
989 "Unable to read domain's composite index (index missing?).");
993 map<int, CompositeSharedPtr> unrollDomain;
999 "Unable to obtain domain's referenced composite: ") +
1004 multidomains = multidomains->NextSiblingElement(
"D");
1011 TiXmlNode *elementChild = domain->FirstChild();
1012 while (elementChild && elementChild->Type() != TiXmlNode::TINYXML_TEXT)
1014 elementChild = elementChild->NextSibling();
1017 ASSERTL0(elementChild,
"Unable to read DOMAIN body.");
1018 std::string elementStr = elementChild->ToText()->ValueStr();
1020 elementStr = elementStr.substr(elementStr.find_first_not_of(
" "));
1022 std::string::size_type indxBeg = elementStr.find_first_of(
'[') + 1;
1023 std::string::size_type indxEnd = elementStr.find_last_of(
']') - 1;
1024 std::string indxStr = elementStr.substr(indxBeg, indxEnd - indxBeg + 1);
1027 "Unable to read domain's composite index (index missing?).");
1031 map<int, CompositeSharedPtr> fullDomain;
1037 (std::string(
"Unable to obtain domain's referenced composite: ") +
1045 CurveMap::iterator it;
1055 TiXmlElement *edge =
field->FirstChildElement(
"E");
1063 std::string edgeStr;
1068 int err = edge->QueryIntAttribute(
"ID", &indx);
1069 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read edge attribute ID.");
1071 TiXmlNode *child = edge->FirstChild();
1073 if (child->Type() == TiXmlNode::TINYXML_TEXT)
1075 edgeStr += child->ToText()->ValueStr();
1079 int vertex1, vertex2;
1080 std::istringstream edgeDataStrm(edgeStr.c_str());
1084 while (!edgeDataStrm.fail())
1086 edgeDataStrm >> vertex1 >> vertex2;
1093 if (!edgeDataStrm.fail())
1119 (std::string(
"Unable to read edge data: ") + edgeStr).c_str());
1122 edge = edge->NextSiblingElement(
"E");
1137 TiXmlElement *element =
field->FirstChildElement();
1138 CurveMap::iterator it;
1142 std::string elementType(element->ValueStr());
1144 ASSERTL0(elementType ==
"Q" || elementType ==
"T",
1145 (std::string(
"Unknown 3D face type: ") + elementType).c_str());
1149 int err = element->QueryIntAttribute(
"ID", &indx);
1150 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read face attribute ID.");
1156 TiXmlNode *elementChild = element->FirstChild();
1157 std::string elementStr;
1158 while (elementChild)
1160 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
1162 elementStr += elementChild->ToText()->ValueStr();
1164 elementChild = elementChild->NextSibling();
1167 ASSERTL0(!elementStr.empty(),
"Unable to read face description body.");
1171 if (elementType ==
"T")
1174 int edge1, edge2, edge3;
1175 std::istringstream elementDataStrm(elementStr.c_str());
1179 elementDataStrm >> edge1;
1180 elementDataStrm >> edge2;
1181 elementDataStrm >> edge3;
1184 !elementDataStrm.fail(),
1185 (std::string(
"Unable to read face data for TRIANGLE: ") +
1203 indx, edges, it->second);
1206 trigeom->SetGlobalID(indx);
1214 (std::string(
"Unable to read face data for TRIANGLE: ") +
1219 else if (elementType ==
"Q")
1222 int edge1, edge2, edge3, edge4;
1223 std::istringstream elementDataStrm(elementStr.c_str());
1227 elementDataStrm >> edge1;
1228 elementDataStrm >> edge2;
1229 elementDataStrm >> edge3;
1230 elementDataStrm >> edge4;
1233 (std::string(
"Unable to read face data for QUAD: ") +
1252 indx, edges, it->second);
1254 quadgeom->SetGlobalID(indx);
1261 (std::string(
"Unable to read face data for QUAD: ") +
1267 element = element->NextSiblingElement();
1289 TiXmlElement *
field =
nullptr;
1299 TiXmlElement *segment =
field->FirstChildElement(
"S");
1300 CurveMap::iterator it;
1305 int err = segment->QueryIntAttribute(
"ID", &indx);
1306 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
1308 TiXmlNode *elementChild = segment->FirstChild();
1309 while (elementChild && elementChild->Type() != TiXmlNode::TINYXML_TEXT)
1311 elementChild = elementChild->NextSibling();
1314 ASSERTL0(elementChild,
"Unable to read element description body.");
1315 std::string elementStr = elementChild->ToText()->ValueStr();
1320 int vertex1, vertex2;
1321 std::istringstream elementDataStrm(elementStr.c_str());
1325 elementDataStrm >> vertex1;
1326 elementDataStrm >> vertex2;
1329 (std::string(
"Unable to read element data for SEGMENT: ") +
1342 seg->SetGlobalID(indx);
1348 seg->SetGlobalID(indx);
1350 seg->SetGlobalID(indx);
1356 (std::string(
"Unable to read element data for segment: ") +
1361 segment = segment->NextSiblingElement(
"S");
1373 CurveMap::iterator it;
1378 TiXmlElement *element =
field->FirstChildElement();
1382 std::string elementType(element->ValueStr());
1385 elementType ==
"Q" || elementType ==
"T",
1386 (std::string(
"Unknown 2D element type: ") + elementType).c_str());
1390 int err = element->QueryIntAttribute(
"ID", &indx);
1391 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
1396 TiXmlNode *elementChild = element->FirstChild();
1397 std::string elementStr;
1398 while (elementChild)
1400 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
1402 elementStr += elementChild->ToText()->ValueStr();
1404 elementChild = elementChild->NextSibling();
1408 "Unable to read element description body.");
1412 if (elementType ==
"T")
1415 int edge1, edge2, edge3;
1416 std::istringstream elementDataStrm(elementStr.c_str());
1420 elementDataStrm >> edge1;
1421 elementDataStrm >> edge2;
1422 elementDataStrm >> edge3;
1425 !elementDataStrm.fail(),
1426 (std::string(
"Unable to read element data for TRIANGLE: ") +
1443 indx, edges, it->second);
1445 trigeom->SetGlobalID(indx);
1453 (std::string(
"Unable to read element data for TRIANGLE: ") +
1458 else if (elementType ==
"Q")
1461 int edge1, edge2, edge3, edge4;
1462 std::istringstream elementDataStrm(elementStr.c_str());
1466 elementDataStrm >> edge1;
1467 elementDataStrm >> edge2;
1468 elementDataStrm >> edge3;
1469 elementDataStrm >> edge4;
1472 !elementDataStrm.fail(),
1473 (std::string(
"Unable to read element data for QUAD: ") +
1491 indx, edges, it->second);
1493 quadgeom->SetGlobalID(indx);
1501 (std::string(
"Unable to read element data for QUAD: ") +
1507 element = element->NextSiblingElement();
1521 TiXmlElement *element =
field->FirstChildElement();
1525 std::string elementType(element->ValueStr());
1529 elementType ==
"A" || elementType ==
"P" || elementType ==
"R" ||
1531 (std::string(
"Unknown 3D element type: ") + elementType).c_str());
1535 int err = element->QueryIntAttribute(
"ID", &indx);
1536 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
1539 TiXmlNode *elementChild = element->FirstChild();
1540 std::string elementStr;
1541 while (elementChild)
1543 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
1545 elementStr += elementChild->ToText()->ValueStr();
1547 elementChild = elementChild->NextSibling();
1551 "Unable to read element description body.");
1553 std::istringstream elementDataStrm(elementStr.c_str());
1559 if (elementType ==
"A")
1573 std::stringstream errorstring;
1574 errorstring <<
"Element " << indx <<
" must have " << kNtfaces
1575 <<
" triangle face(s), and " << kNqfaces
1576 <<
" quadrilateral face(s).";
1577 for (
int i = 0; i < kNfaces; i++)
1580 elementDataStrm >> faceID;
1586 std::stringstream errorstring;
1587 errorstring <<
"Element " << indx
1588 <<
" has invalid face: " << faceID;
1589 ASSERTL0(
false, errorstring.str().c_str());
1593 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
1594 tfaces[Ntfaces++] = static_pointer_cast<TriGeom>(face);
1596 else if (face->GetShapeType() ==
1599 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
1607 "Unable to read element data for TETRAHEDRON: ") +
1610 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
1611 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
1623 "Unable to read element data for TETRAHEDRON: ") +
1629 else if (elementType ==
"P")
1644 std::stringstream errorstring;
1645 errorstring <<
"Element " << indx <<
" must have " << kNtfaces
1646 <<
" triangle face(s), and " << kNqfaces
1647 <<
" quadrilateral face(s).";
1648 for (
int i = 0; i < kNfaces; i++)
1651 elementDataStrm >> faceID;
1657 std::stringstream errorstring;
1658 errorstring <<
"Element " << indx
1659 <<
" has invalid face: " << faceID;
1660 ASSERTL0(
false, errorstring.str().c_str());
1664 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
1665 faces[Nfaces++] = static_pointer_cast<TriGeom>(face);
1668 else if (face->GetShapeType() ==
1671 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
1672 faces[Nfaces++] = static_pointer_cast<QuadGeom>(face);
1680 !elementDataStrm.fail(),
1681 (std::string(
"Unable to read element data for PYRAMID: ") +
1684 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
1685 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
1697 (std::string(
"Unable to read element data for PYRAMID: ") +
1703 else if (elementType ==
"R")
1718 std::stringstream errorstring;
1719 errorstring <<
"Element " << indx <<
" must have " << kNtfaces
1720 <<
" triangle face(s), and " << kNqfaces
1721 <<
" quadrilateral face(s).";
1723 for (
int i = 0; i < kNfaces; i++)
1726 elementDataStrm >> faceID;
1732 std::stringstream errorstring;
1733 errorstring <<
"Element " << indx
1734 <<
" has invalid face: " << faceID;
1735 ASSERTL0(
false, errorstring.str().c_str());
1739 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
1741 std::static_pointer_cast<TriGeom>(face);
1744 else if (face->GetShapeType() ==
1747 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
1749 std::static_pointer_cast<QuadGeom>(face);
1757 !elementDataStrm.fail(),
1758 (std::string(
"Unable to read element data for PRISM: ") +
1761 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
1762 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
1774 (std::string(
"Unable to read element data for PRISM: ") +
1780 else if (elementType ==
"H")
1795 std::stringstream errorstring;
1796 errorstring <<
"Element " << indx <<
" must have " << kNtfaces
1797 <<
" triangle face(s), and " << kNqfaces
1798 <<
" quadrilateral face(s).";
1799 for (
int i = 0; i < kNfaces; i++)
1802 elementDataStrm >> faceID;
1808 std::stringstream errorstring;
1809 errorstring <<
"Element " << indx
1810 <<
" has invalid face: " << faceID;
1811 ASSERTL0(
false, errorstring.str().c_str());
1815 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
1819 else if (face->GetShapeType() ==
1822 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
1824 std::static_pointer_cast<QuadGeom>(face);
1832 "Unable to read element data for HEXAHEDRAL: ") +
1835 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
1836 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
1848 "Unable to read element data for HEXAHEDRAL: ") +
1854 element = element->NextSiblingElement();
1860 TiXmlElement *
field =
nullptr;
1867 TiXmlElement *node =
field->FirstChildElement(
"C");
1870 int nextCompositeNumber = -1;
1877 nextCompositeNumber++;
1880 int err = node->QueryIntAttribute(
"ID", &indx);
1881 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
1885 TiXmlNode *compositeChild = node->FirstChild();
1890 while (compositeChild &&
1891 compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
1893 compositeChild = compositeChild->NextSibling();
1896 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
1897 std::string compositeStr = compositeChild->ToText()->ValueStr();
1901 std::istringstream compositeDataStrm(compositeStr.c_str());
1906 std::string prevCompositeElementStr;
1908 while (!compositeDataStrm.fail())
1910 std::string compositeElementStr;
1911 compositeDataStrm >> compositeElementStr;
1913 if (!compositeDataStrm.fail())
1924 if (compositeElementStr.length() > 0)
1927 compositeElementStr,
1930 prevCompositeElementStr = compositeElementStr;
1938 (std::string(
"Unable to read COMPOSITE data for composite: ") +
1945 err = node->QueryStringAttribute(
"NAME", &
name);
1946 if (err == TIXML_SUCCESS)
1952 node = node->NextSiblingElement(
"C");
1956 "At least one composite must be specified.");
1960 const std::string &token,
1978 const std::string &token,
1983 std::istringstream tokenStream(token);
1984 std::istringstream prevTokenStream(prevToken);
1989 tokenStream >> type;
1991 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
1992 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
1996 (std::string(
"Error reading index definition:") + token).c_str());
1998 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
2000 typedef vector<unsigned int> SeqVectorType;
2001 SeqVectorType seqVector;
2006 (std::string(
"Ill-formed sequence definition: ") + indxStr)
2010 prevTokenStream >> prevType;
2013 bool validSequence =
2014 (prevToken.empty() ||
2015 (type ==
'V' && prevType ==
'V') ||
2016 (type ==
'S' && prevType ==
'S'));
2019 std::string(
"Invalid combination of composite items: ") +
2020 type +
" and " + prevType +
".");
2025 for (SeqVectorType::iterator iter = seqVector.begin();
2026 iter != seqVector.end(); ++iter)
2031 "Unknown vertex index: " +
2032 std::to_string(*iter));
2036 composite->m_geomVec.push_back(
m_vertSet[*iter]);
2042 for (SeqVectorType::iterator iter = seqVector.begin();
2043 iter != seqVector.end(); ++iter)
2048 "Unknown segment index: " +
2049 std::to_string(*iter));
2053 composite->m_geomVec.push_back(
m_segGeoms[*iter]);
2060 "Unrecognized composite token: " + token);
2066 "Problem processing composite token: " + token);
2073 const std::string &token,
2078 std::istringstream tokenStream(token);
2079 std::istringstream prevTokenStream(prevToken);
2084 tokenStream >> type;
2086 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
2087 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
2091 (std::string(
"Error reading index definition:") + token).c_str());
2093 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
2094 std::vector<unsigned int> seqVector;
2095 std::vector<unsigned int>::iterator seqIter;
2100 (std::string(
"Error reading composite elements: ") + indxStr)
2103 prevTokenStream >> prevType;
2106 bool validSequence =
2107 (prevToken.empty() ||
2108 (type ==
'V' && prevType ==
'V') ||
2109 (type ==
'E' && prevType ==
'E') ||
2110 ((type ==
'T' || type ==
'Q') &&
2111 (prevType ==
'T' || prevType ==
'Q')));
2114 std::string(
"Invalid combination of composite items: ") +
2115 type +
" and " + prevType +
".");
2120 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2126 "Unknown edge index: " +
2127 std::to_string(*seqIter));
2131 composite->m_geomVec.push_back(
m_segGeoms[*seqIter]);
2138 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2144 "Unknown triangle index: " +
2145 std::to_string(*seqIter));
2151 composite->m_geomVec.push_back(
2161 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2168 "Unknown quad index: " + std::to_string(*seqIter) +
2169 " in Composite section");
2175 composite->m_geomVec.push_back(
2184 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2190 "Unknown vertex index: " +
2191 std::to_string(*seqIter));
2195 composite->m_geomVec.push_back(
m_vertSet[*seqIter]);
2202 "Unrecognized composite token: " + token);
2208 "Problem processing composite token: " + token);
2215 const std::string &token,
2220 std::istringstream tokenStream(token);
2221 std::istringstream prevTokenStream(prevToken);
2226 tokenStream >> type;
2228 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
2229 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
2232 "Error reading index definition: " + token);
2234 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
2236 std::vector<unsigned int> seqVector;
2237 std::vector<unsigned int>::iterator seqIter;
2241 ASSERTL0(err,
"Error reading composite elements: " + indxStr);
2243 prevTokenStream >> prevType;
2247 map<char, int> typeMap;
2258 bool validSequence =
2259 (prevToken.empty() || (typeMap[type] == typeMap[prevType]));
2262 std::string(
"Invalid combination of composite items: ") +
2263 type +
" and " + prevType +
".");
2268 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2274 "Unknown vertex index: " +
2275 std::to_string(*seqIter));
2279 composite->m_geomVec.push_back(
m_vertSet[*seqIter]);
2285 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2291 "Unknown edge index: " +
2292 std::to_string(*seqIter));
2296 composite->m_geomVec.push_back(
m_segGeoms[*seqIter]);
2302 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2309 "Unknown face index: " +
2310 std::to_string(*seqIter));
2316 composite->m_geomVec.push_back(face);
2323 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2329 "Unknown triangle index: " +
2330 std::to_string(*seqIter));
2336 composite->m_geomVec.push_back(
2344 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2350 "Unknown quad index: " +
2351 std::to_string(*seqIter));
2357 composite->m_geomVec.push_back(
2366 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2372 "Unknown tet index: " +
2373 std::to_string(*seqIter));
2379 composite->m_geomVec.push_back(
2388 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2394 "Unknown pyramid index: " +
2395 std::to_string(*seqIter));
2401 composite->m_geomVec.push_back(
2410 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2416 "Unknown prism index: " +
2417 std::to_string(*seqIter));
2423 composite->m_geomVec.push_back(
2432 for (seqIter = seqVector.begin(); seqIter != seqVector.end();
2438 "Unknown hex index: " +
2439 std::to_string(*seqIter));
2445 composite->m_geomVec.push_back(
2454 "Unrecognized composite token: " + token);
2460 "Problem processing composite token: " + token);
2468 TiXmlElement *vertTag =
new TiXmlElement(
"VERTEX");
2470 for (
auto &i : verts)
2473 s << scientific << setprecision(8) << (*i.second)(0) <<
" "
2474 << (*i.second)(1) <<
" " << (*i.second)(2);
2475 TiXmlElement *v =
new TiXmlElement(
"V");
2476 v->SetAttribute(
"ID", i.second->GetGlobalID());
2477 v->LinkEndChild(
new TiXmlText(s.str()));
2478 vertTag->LinkEndChild(v);
2481 geomTag->LinkEndChild(vertTag);
2486 TiXmlElement *edgeTag =
2490 for (
auto &i : edges)
2494 s << seg->GetVid(0) <<
" " << seg->GetVid(1);
2495 TiXmlElement *e =
new TiXmlElement(tag);
2496 e->SetAttribute(
"ID", i.first);
2497 e->LinkEndChild(
new TiXmlText(s.str()));
2498 edgeTag->LinkEndChild(e);
2501 geomTag->LinkEndChild(edgeTag);
2508 for (
auto &i : tris)
2512 s << tri->GetEid(0) <<
" " << tri->GetEid(1) <<
" " << tri->GetEid(2);
2513 TiXmlElement *t =
new TiXmlElement(tag);
2514 t->SetAttribute(
"ID", i.first);
2515 t->LinkEndChild(
new TiXmlText(s.str()));
2516 faceTag->LinkEndChild(t);
2524 for (
auto &i : quads)
2528 s << quad->GetEid(0) <<
" " << quad->GetEid(1) <<
" " << quad->GetEid(2)
2529 <<
" " << quad->GetEid(3);
2530 TiXmlElement *
q =
new TiXmlElement(tag);
2531 q->SetAttribute(
"ID", i.first);
2532 q->LinkEndChild(
new TiXmlText(s.str()));
2533 faceTag->LinkEndChild(
q);
2541 for (
auto &i : hexs)
2545 s << hex->GetFid(0) <<
" " << hex->GetFid(1) <<
" " << hex->GetFid(2)
2546 <<
" " << hex->GetFid(3) <<
" " << hex->GetFid(4) <<
" "
2547 << hex->GetFid(5) <<
" ";
2548 TiXmlElement *h =
new TiXmlElement(tag);
2549 h->SetAttribute(
"ID", i.first);
2550 h->LinkEndChild(
new TiXmlText(s.str()));
2551 elmtTag->LinkEndChild(h);
2559 for (
auto &i : pris)
2563 s << prism->GetFid(0) <<
" " << prism->GetFid(1) <<
" "
2564 << prism->GetFid(2) <<
" " << prism->GetFid(3) <<
" "
2565 << prism->GetFid(4) <<
" ";
2566 TiXmlElement *
p =
new TiXmlElement(tag);
2567 p->SetAttribute(
"ID", i.first);
2568 p->LinkEndChild(
new TiXmlText(s.str()));
2569 elmtTag->LinkEndChild(
p);
2577 for (
auto &i : pyrs)
2581 s << pyr->GetFid(0) <<
" " << pyr->GetFid(1) <<
" " << pyr->GetFid(2)
2582 <<
" " << pyr->GetFid(3) <<
" " << pyr->GetFid(4) <<
" ";
2583 TiXmlElement *
p =
new TiXmlElement(tag);
2584 p->SetAttribute(
"ID", i.first);
2585 p->LinkEndChild(
new TiXmlText(s.str()));
2586 elmtTag->LinkEndChild(
p);
2594 for (
auto &i : tets)
2598 s << tet->GetFid(0) <<
" " << tet->GetFid(1) <<
" " << tet->GetFid(2)
2599 <<
" " << tet->GetFid(3) <<
" ";
2600 TiXmlElement *t =
new TiXmlElement(tag);
2601 t->SetAttribute(
"ID", i.first);
2602 t->LinkEndChild(
new TiXmlText(s.str()));
2603 elmtTag->LinkEndChild(t);
2610 TiXmlElement *curveTag =
new TiXmlElement(
"CURVED");
2611 CurveMap::iterator curveIt;
2614 for (curveIt = edges.begin(); curveIt != edges.end(); ++curveIt)
2617 TiXmlElement *c =
new TiXmlElement(
"E");
2621 for (
int j = 0; j < curve->m_points.size(); ++j)
2624 s << scientific << (*p)(0) <<
" " << (*
p)(1) <<
" " << (*
p)(2)
2628 c->SetAttribute(
"ID", curveId++);
2629 c->SetAttribute(
"EDGEID", curve->m_curveID);
2630 c->SetAttribute(
"NUMPOINTS", curve->m_points.size());
2632 c->LinkEndChild(
new TiXmlText(s.str()));
2633 curveTag->LinkEndChild(c);
2636 for (curveIt = faces.begin(); curveIt != faces.end(); ++curveIt)
2639 TiXmlElement *c =
new TiXmlElement(
"F");
2643 for (
int j = 0; j < curve->m_points.size(); ++j)
2646 s << scientific << (*p)(0) <<
" " << (*
p)(1) <<
" " << (*
p)(2)
2650 c->SetAttribute(
"ID", curveId++);
2651 c->SetAttribute(
"FACEID", curve->m_curveID);
2652 c->SetAttribute(
"NUMPOINTS", curve->m_points.size());
2654 c->LinkEndChild(
new TiXmlText(s.str()));
2655 curveTag->LinkEndChild(c);
2658 geomTag->LinkEndChild(curveTag);
2662 std::map<int, std::string> &compLabels)
2664 TiXmlElement *compTag =
new TiXmlElement(
"COMPOSITE");
2666 for (
auto &cIt : comps)
2668 if (cIt.second->m_geomVec.size() == 0)
2673 TiXmlElement *c =
new TiXmlElement(
"C");
2674 c->SetAttribute(
"ID", cIt.first);
2677 c->SetAttribute(
"NAME", compLabels[cIt.first]);
2680 compTag->LinkEndChild(c);
2683 geomTag->LinkEndChild(compTag);
2687 std::map<int, CompositeMap> &domainMap)
2689 TiXmlElement *domTag =
new TiXmlElement(
"DOMAIN");
2691 vector<unsigned int> idxList;
2692 for (
auto &domain : domainMap)
2694 TiXmlElement *c =
new TiXmlElement(
"D");
2701 for (
const auto &elem : domain.second)
2703 idxList.push_back(elem.first);
2707 c->SetAttribute(
"ID", domain.first);
2708 c->LinkEndChild(
new TiXmlText(s.str()));
2709 domTag->LinkEndChild(c);
2712 geomTag->LinkEndChild(domTag);
2717 TiXmlElement *expTag =
new TiXmlElement(
"EXPANSIONS");
2723 TiXmlElement *exp =
new TiXmlElement(
"E");
2724 exp->SetAttribute(
"COMPOSITE",
2725 "C[" + boost::lexical_cast<string>(it->first) +
2727 exp->SetAttribute(
"NUMMODES", 4);
2728 exp->SetAttribute(
"TYPE",
"MODIFIED");
2729 exp->SetAttribute(
"FIELDS",
"u");
2731 expTag->LinkEndChild(exp);
2734 root->LinkEndChild(expTag);
2742 const std::string &outfilename,
bool defaultExp,
2747 TiXmlDeclaration *decl =
new TiXmlDeclaration(
"1.0",
"utf-8",
"");
2748 doc.LinkEndChild(decl);
2750 TiXmlElement *root =
new TiXmlElement(
"NEKTAR");
2751 doc.LinkEndChild(root);
2752 TiXmlElement *geomTag =
new TiXmlElement(
"GEOMETRY");
2753 root->LinkEndChild(geomTag);
2766 geomTag->SetAttribute(
"PARTITION",
m_session->GetComm()->GetRank());
2777 TiXmlElement *faceTag =
2782 geomTag->LinkEndChild(faceTag);
2786 TiXmlElement *elmtTag =
new TiXmlElement(
"ELEMENT");
2793 geomTag->LinkEndChild(elmtTag);
2810 doc.SaveFile(outfilename);
2814 vector<set<unsigned int>> elements,
2815 vector<unsigned int> partitions)
2826 string dirname = outname +
"_xml";
2827 fs::path pdirname(dirname);
2829 if (!fs::is_directory(dirname))
2831 fs::create_directory(dirname);
2834 ASSERTL0(elements.size() == partitions.size(),
2835 "error in partitioned information");
2837 for (
int i = 0; i < partitions.size(); i++)
2840 TiXmlDeclaration *decl =
new TiXmlDeclaration(
"1.0",
"utf-8",
"");
2841 doc.LinkEndChild(decl);
2843 TiXmlElement *root = doc.FirstChildElement(
"NEKTAR");
2844 TiXmlElement *geomTag;
2849 root =
new TiXmlElement(
"NEKTAR");
2850 doc.LinkEndChild(root);
2852 geomTag =
new TiXmlElement(
"GEOMETRY");
2853 root->LinkEndChild(geomTag);
2858 geomTag = root->FirstChildElement(
"GEOMETRY");
2862 geomTag =
new TiXmlElement(
"GEOMETRY");
2863 root->LinkEndChild(geomTag);
2869 geomTag->SetAttribute(
"PARTITION", partitions[i]);
2884 vector<set<unsigned int>> entityIds(4);
2891 for (
auto &j : entityIds[3])
2916 ASSERTL0(
false,
"element in partition not found");
2919 for (
int k = 0; k < g->GetNumFaces(); k++)
2921 entityIds[2].insert(g->GetFid(k));
2923 for (
int k = 0; k < g->GetNumEdges(); k++)
2925 entityIds[1].insert(g->GetEid(k));
2927 for (
int k = 0; k < g->GetNumVerts(); k++)
2929 entityIds[0].insert(g->GetVid(k));
2936 for (
auto &j : entityIds[2])
2951 ASSERTL0(
false,
"element in partition not found");
2954 for (
int k = 0; k < g->GetNumEdges(); k++)
2956 entityIds[1].insert(g->GetEid(k));
2958 for (
int k = 0; k < g->GetNumVerts(); k++)
2960 entityIds[0].insert(g->GetVid(k));
2967 for (
auto &j : entityIds[1])
2977 ASSERTL0(
false,
"element in partition not found");
2980 for (
int k = 0; k < g->GetNumVerts(); k++)
2982 entityIds[0].insert(g->GetVid(k));
2990 for (
auto &j : entityIds[2])
3009 for (
auto &j : entityIds[1])
3022 for (
auto &j : entityIds[0])
3038 TiXmlElement *faceTag =
3043 geomTag->LinkEndChild(faceTag);
3047 TiXmlElement *elmtTag =
new TiXmlElement(
"ELEMENT");
3054 geomTag->LinkEndChild(elmtTag);
3057 for (
auto &j : localTri)
3064 for (
auto &j : localQuad)
3071 for (
auto &j : localEdge)
3082 std::map<int, std::string> localCompLabels;
3087 int dim = j.second->m_geomVec[0]->GetShapeDim();
3089 for (
int k = 0; k < j.second->m_geomVec.size(); k++)
3091 if (entityIds[dim].count(j.second->m_geomVec[k]->GetGlobalID()))
3093 comp->m_geomVec.push_back(j.second->m_geomVec[k]);
3097 if (comp->m_geomVec.size())
3099 localComp[j.first] = comp;
3109 map<int, CompositeMap> domain;
3110 for (
auto &j : localComp)
3114 for (
auto &dIt : dom.second)
3116 if (j.first == dIt.first)
3118 domain[dom.first][j.first] = j.second;
3127 if (
m_session->DefinesElement(
"NEKTAR/CONDITIONS"))
3129 std::set<int> vBndRegionIdList;
3130 TiXmlElement *vConditions =
3131 new TiXmlElement(*
m_session->GetElement(
"Nektar/Conditions"));
3132 TiXmlElement *vBndRegions =
3133 vConditions->FirstChildElement(
"BOUNDARYREGIONS");
3136 TiXmlElement *vBndConditions =
3137 vConditions->FirstChildElement(
"BOUNDARYCONDITIONS");
3141 TiXmlElement *vItem;
3147 vConditions->FirstChildElement(
"BOUNDARYREGIONS")
3148 ->FirstChildElement(
"TIMELEVEL") !=
nullptr;
3150 TiXmlElement *vNewBndRegions =
3151 multiLevel ?
new TiXmlElement(
"TIMELEVEL")
3152 :
new TiXmlElement(
"BOUNDARYREGIONS");
3153 vItem = vBndRegions->FirstChildElement();
3156 std::string vSeqStr =
3157 vItem->FirstChild()->ToText()->Value();
3158 std::string::size_type indxBeg =
3159 vSeqStr.find_first_of(
'[') + 1;
3160 std::string::size_type indxEnd =
3161 vSeqStr.find_last_of(
']') - 1;
3162 vSeqStr = vSeqStr.substr(indxBeg, indxEnd - indxBeg + 1);
3163 std::vector<unsigned int> vSeq;
3166 vector<unsigned int> idxList;
3168 for (
unsigned int i = 0; i < vSeq.size(); ++i)
3170 if (localComp.find(vSeq[i]) != localComp.end())
3172 idxList.push_back(vSeq[i]);
3175 int p = atoi(vItem->Attribute(
"ID"));
3177 std::string vListStr =
3180 if (vListStr.length() == 0)
3182 TiXmlElement *tmp = vItem;
3183 vItem = vItem->NextSiblingElement();
3184 vBndRegions->RemoveChild(tmp);
3188 vListStr =
"C[" + vListStr +
"]";
3189 TiXmlText *vList =
new TiXmlText(vListStr);
3190 TiXmlElement *vNewElement =
new TiXmlElement(
"B");
3191 vNewElement->SetAttribute(
"ID",
p);
3192 vNewElement->LinkEndChild(vList);
3193 vNewBndRegions->LinkEndChild(vNewElement);
3194 vBndRegionIdList.insert(
p);
3195 vItem = vItem->NextSiblingElement();
3204 size_t timeLevel = 0;
3207 vNewBndRegions->SetAttribute(
"VALUE", timeLevel);
3208 vConditions->FirstChildElement(
"BOUNDARYREGIONS")
3209 ->ReplaceChild(vBndRegions, *vNewBndRegions);
3210 vBndRegions = vBndRegions->NextSiblingElement();
3216 vConditions->ReplaceChild(vBndRegions, *vNewBndRegions);
3222 vItem = vBndConditions->FirstChildElement();
3225 std::set<int>::iterator x;
3226 if ((x = vBndRegionIdList.find(atoi(vItem->Attribute(
3227 "REF")))) != vBndRegionIdList.end())
3229 vItem->SetAttribute(
"REF", *x);
3230 vItem = vItem->NextSiblingElement();
3234 TiXmlElement *tmp = vItem;
3235 vItem = vItem->NextSiblingElement();
3236 vBndConditions->RemoveChild(tmp);
3240 root->LinkEndChild(vConditions);
3244 TiXmlElement *vSrc =
3245 m_session->GetElement(
"Nektar")->FirstChildElement();
3248 std::string vName = boost::to_upper_copy(vSrc->ValueStr());
3249 if (vName !=
"GEOMETRY" && vName !=
"CONDITIONS")
3251 root->LinkEndChild(
new TiXmlElement(*vSrc));
3253 vSrc = vSrc->NextSiblingElement();
3259 pad % partitions[i];
3260 fs::path pFilename(pad.str());
3262 fs::path fullpath = pdirname / pFilename;
3273 bool fillComp =
true;
3276 if (c.second ==
d.second)
3283 std::vector<unsigned int> ids;
3284 for (
auto &elmt : c.second->m_geomVec)
3286 ids.push_back(elmt->GetGlobalID());
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
static void AddInfoTag(TagWriterSharedPtr root, const FieldMetaDataMap &fieldmetadatamap)
Add provenance information to the field metadata map.
Interpreter class for the evaluation of mathematical expressions.
int DefineFunction(const std::string &vlist, const std::string &expr)
Defines a function for the purposes of evaluation.
NekDouble Evaluate(const int id)
Evaluate a function which depends only on constants and/or parameters.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
bool ModuleExists(tKey idKey)
Checks if a particular module is available.
static void GetXMLElementTimeLevel(TiXmlElement *&element, const size_t timeLevel, const bool enableCheck=true)
Get XML elment time level (Parallel-in-Time)
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 std::string GenerateSeqString(const std::vector< T > &v)
Generate a compressed comma-separated string representation of a vector of unsigned integers.
static bool GenerateSeqVector(const std::string &str, std::vector< unsigned int > &out)
Takes a comma-separated compressed string and converts it to entries in a vector.
static const int kNqfaces
static const int kNtfaces
bool CheckRange(Geometry2D &geom)
Check if goemetry is in range definition if activated.
PrismGeomMap m_prismGeoms
void ReadGeometry(LibUtilities::DomainRangeShPtr rng, bool fillGraph)
void PopulateFaceToElMap(Geometry3DSharedPtr element, int kNfaces)
Given a 3D geometry object #element, populate the face to element map m_faceToElMap which maps faces ...
Geometry2DSharedPtr GetGeometry2D(int gID)
LibUtilities::SessionReaderSharedPtr m_session
std::map< int, CompositeMap > m_domain
CompositeOrdering m_compOrder
void GetCompositeList(const std::string &compositeStr, CompositeMap &compositeVector) const
CompositeMap m_meshComposites
ExpansionInfoMapShPtrMap m_expansionMapShPtrMap
MovementSharedPtr m_movement
std::string GetCompositeString(CompositeSharedPtr comp)
Returns a string representation of a composite.
std::unordered_map< int, GeometryLinkSharedPtr > m_faceToElMap
std::map< int, MeshEntity > CreateMeshEntities()
Create mesh entities for this graph.
SegGeomSharedPtr GetSegGeom(int id)
CompositeDescriptor CreateCompositeDescriptor()
std::map< int, std::string > m_compositesLabels
PointGeomSharedPtr GetVertex(int id)
LibUtilities::DomainRangeShPtr m_domainRange
BndRegionOrdering m_bndRegOrder
void ResolveGeomRef1D(const std::string &prevToken, const std::string &token, CompositeSharedPtr &composite)
virtual void v_ReadEdges()
void WriteDefaultExpansion(TiXmlElement *root)
void v_WriteGeometry(const std::string &outfilename, bool defaultExp=false, const LibUtilities::FieldMetaDataMap &metadata=LibUtilities::NullFieldMetaDataMap) override
Write out an XML file containing the GEOMETRY block representing this MeshGraph instance inside a NEK...
virtual void v_WriteQuads(TiXmlElement *faceTag, QuadGeomMap &quads)
virtual void v_WritePyrs(TiXmlElement *elmtTag, PyrGeomMap &pyrs)
void WriteXMLGeometry(std::string outname, std::vector< std::set< unsigned int > > elements, std::vector< unsigned int > partitions)
virtual void v_WriteTris(TiXmlElement *faceTag, TriGeomMap &tris)
virtual void v_ReadCurves()
virtual void v_WriteVertices(TiXmlElement *geomTag, PointGeomMap &verts)
static MeshGraphSharedPtr create()
virtual void v_ReadVertices()
virtual void v_ReadElements1D()
void v_ReadGeometry(LibUtilities::DomainRangeShPtr rng, bool fillGraph) override
void ResolveGeomRef(const std::string &prevToken, const std::string &token, CompositeSharedPtr &composite)
void ResolveGeomRef3D(const std::string &prevToken, const std::string &token, CompositeSharedPtr &composite)
static std::string className
CompositeOrdering CreateCompositeOrdering()
virtual void v_WriteHexs(TiXmlElement *elmtTag, HexGeomMap &hexs)
virtual void v_ReadFaces()
virtual void v_WritePrisms(TiXmlElement *elmtTag, PrismGeomMap &pris)
virtual void v_WriteEdges(TiXmlElement *geomTag, SegGeomMap &edges)
void ResolveGeomRef2D(const std::string &prevToken, const std::string &token, CompositeSharedPtr &composite)
virtual void v_WriteTets(TiXmlElement *elmtTag, TetGeomMap &tets)
void WriteDomain(TiXmlElement *geomTag, std::map< int, CompositeMap > &domain)
void v_PartitionMesh(LibUtilities::SessionReaderSharedPtr session) override
void WriteComposites(TiXmlElement *geomTag, CompositeMap &comps, std::map< int, std::string > &compLabels)
virtual void v_ReadElements3D()
virtual void v_ReadElements2D()
virtual void v_WriteCurves(TiXmlElement *geomTag, CurveMap &edges, CurveMap &faces)
static const int kNqfaces
static const int kNtfaces
static const int kNtfaces
static const int kNqfaces
static const int kNqfaces
static const int kNtfaces
static const int kNedges
Get the orientation of face1.
std::map< std::string, std::string > FieldMetaDataMap
const std::string kPointsTypeStr[]
static std::string PortablePath(const fs::path &path)
create portable path on different platforms for std::filesystem path.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< DomainRange > DomainRangeShPtr
std::shared_ptr< XmlTagWriter > XmlTagWriterSharedPtr
static DomainRangeShPtr NullDomainRangeShPtr
@ SIZE_PointsType
Length of enum list.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
std::map< int, TriGeomSharedPtr > TriGeomMap
std::map< int, std::vector< unsigned int > > CompositeOrdering
std::shared_ptr< QuadGeom > QuadGeomSharedPtr
std::map< int, PyrGeomSharedPtr > PyrGeomMap
std::map< int, QuadGeomSharedPtr > QuadGeomMap
std::shared_ptr< PrismGeom > PrismGeomSharedPtr
MeshPartitionFactory & GetMeshPartitionFactory()
std::shared_ptr< Composite > CompositeSharedPtr
std::map< int, SegGeomSharedPtr > SegGeomMap
std::shared_ptr< Curve > CurveSharedPtr
std::unordered_map< int, CurveSharedPtr > CurveMap
std::shared_ptr< HexGeom > HexGeomSharedPtr
std::shared_ptr< SegGeom > SegGeomSharedPtr
std::map< int, TetGeomSharedPtr > TetGeomMap
std::shared_ptr< PyrGeom > PyrGeomSharedPtr
std::shared_ptr< TetGeom > TetGeomSharedPtr
std::map< int, PrismGeomSharedPtr > PrismGeomMap
std::shared_ptr< PointGeom > PointGeomSharedPtr
std::shared_ptr< Geometry2D > Geometry2DSharedPtr
std::shared_ptr< MeshPartition > MeshPartitionSharedPtr
std::shared_ptr< Geometry > GeometrySharedPtr
std::shared_ptr< TriGeom > TriGeomSharedPtr
MeshGraphFactory & GetMeshGraphFactory()
std::map< int, HexGeomSharedPtr > HexGeomMap
std::map< int, PointGeomSharedPtr > PointGeomMap
std::map< int, CompositeSharedPtr > CompositeMap
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
std::vector< double > d(NPUPPER *NPUPPER)
std::vector< double > q(NPUPPER *NPUPPER)