46#include <boost/format.hpp>
54namespace SpatialDomains
59 "IO with Xml geometry");
67 const bool isRoot = comm->TreatAsRankZero();
79 int isPartitioned = 0;
82 if (
m_session->DefinesElement(
"Nektar/Geometry"))
84 if (
m_session->GetElement(
"Nektar/Geometry")
85 ->Attribute(
"PARTITION"))
87 std::cout <<
"Using pre-partitioned mesh." << std::endl;
92 comm->Bcast(isPartitioned, 0);
107 string partitionerName =
"Metis";
110 partitionerName =
"Scotch";
112 if (session->DefinesCmdLineArgument(
"use-metis"))
114 partitionerName =
"Metis";
116 if (session->DefinesCmdLineArgument(
"use-scotch"))
118 partitionerName =
"Scotch";
124 if (session->DefinesCmdLineArgument(
"part-only") ||
125 session->DefinesCmdLineArgument(
"part-only-overlapping"))
130 "The 'part-only' option should be used in serial.");
141 partitionerName, session, session->GetComm(),
144 if (session->DefinesCmdLineArgument(
"part-only"))
146 nParts = session->GetCmdLineArgument<
int>(
"part-only");
147 partitioner->PartitionMesh(nParts,
true);
152 session->GetCmdLineArgument<
int>(
"part-only-overlapping");
153 partitioner->PartitionMesh(nParts,
true,
true);
156 vector<set<unsigned int>> elmtIDs;
157 vector<unsigned int> parts(nParts);
158 for (
int i = 0; i < nParts; ++i)
160 vector<unsigned int> elIDs;
161 set<unsigned int> tmp;
162 partitioner->GetElementIDs(i, elIDs);
163 tmp.insert(elIDs.begin(), elIDs.end());
164 elmtIDs.push_back(tmp);
170 if (isRoot && session->DefinesCmdLineArgument(
"part-info"))
172 partitioner->PrintPartInfo(std::cout);
179 if (commMesh->GetSize() > 1)
181 int nParts = commMesh->GetSize();
183 if (session->GetSharedFilesystem())
185 vector<unsigned int> keys, vals;
200 partitionerName, session, session->GetComm(),
203 partitioner->PartitionMesh(nParts,
true);
205 vector<set<unsigned int>> elmtIDs;
206 vector<unsigned int> parts(nParts);
207 for (i = 0; i < nParts; ++i)
209 vector<unsigned int> elIDs;
210 set<unsigned int> tmp;
211 partitioner->GetElementIDs(i, elIDs);
212 tmp.insert(elIDs.begin(), elIDs.end());
213 elmtIDs.push_back(tmp);
229 comm->Bcast(keys, 0);
240 vals[i++] = cIt.second.size();
244 comm->Bcast(keys, 0);
245 comm->Bcast(vals, 0);
248 comm->Bcast(cIt.second, 0);
260 vals[i++] = bIt.second.size();
266 comm->Bcast(keys, 0);
270 comm->Bcast(vals, 0);
274 comm->Bcast(bIt.second, 0);
277 if (session->DefinesCmdLineArgument(
"part-info"))
279 partitioner->PrintPartInfo(std::cout);
285 comm->Bcast(keys, 0);
287 int cmpSize = keys[0];
288 int bndSize = keys[1];
290 keys.resize(cmpSize);
291 vals.resize(cmpSize);
292 comm->Bcast(keys, 0);
293 comm->Bcast(vals, 0);
295 for (
int i = 0; i < keys.size(); ++i)
297 vector<unsigned int> tmp(vals[i]);
302 keys.resize(bndSize);
303 vals.resize(bndSize);
306 comm->Bcast(keys, 0);
310 comm->Bcast(vals, 0);
312 for (
int i = 0; i < keys.size(); ++i)
314 vector<unsigned int> tmp(vals[i]);
333 partitionerName, session, session->GetComm(),
336 partitioner->PartitionMesh(nParts,
false);
338 vector<unsigned int> parts(1), tmp;
339 parts[0] = commMesh->GetRank();
340 vector<set<unsigned int>> elIDs(1);
341 partitioner->GetElementIDs(parts[0], tmp);
342 elIDs[0].insert(tmp.begin(), tmp.end());
351 if (
m_session->DefinesCmdLineArgument(
"part-info") && isRoot)
353 partitioner->PrintPartInfo(std::cout);
360 std::string dirname =
m_session->GetSessionName() +
"_xml";
361 fs::path pdirname(dirname);
363 pad % comm->GetRowComm()->GetRank();
364 fs::path pFilename(pad.str());
365 fs::path fullpath = pdirname / pFilename;
367 std::vector<std::string> filenames = {
406 TiXmlAttribute *attr =
m_xmlGeom->FirstAttribute();
417 std::string attrName(attr->Name());
418 if (attrName ==
"DIM")
421 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read mesh dimension.");
423 else if (attrName ==
"SPACE")
426 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read space dimension.");
428 else if (attrName ==
"PARTITION")
431 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read partition.");
436 std::string errstr(
"Unknown attribute: ");
446 "Mesh dimension greater than space dimension");
471 TiXmlElement *element =
m_xmlGeom->FirstChildElement(
"VERTEX");
472 ASSERTL0(element,
"Unable to find mesh VERTEX tag in file.");
479 const char *xscal = element->Attribute(
"XSCALE");
486 std::string xscalstr = xscal;
488 xscale = expEvaluator.
Evaluate(expr_id);
491 const char *yscal = element->Attribute(
"YSCALE");
498 std::string yscalstr = yscal;
500 yscale = expEvaluator.
Evaluate(expr_id);
503 const char *zscal = element->Attribute(
"ZSCALE");
510 std::string zscalstr = zscal;
512 zscale = expEvaluator.
Evaluate(expr_id);
520 const char *xmov = element->Attribute(
"XMOVE");
527 std::string xmovstr = xmov;
529 xmove = expEvaluator.
Evaluate(expr_id);
532 const char *ymov = element->Attribute(
"YMOVE");
539 std::string ymovstr = ymov;
541 ymove = expEvaluator.
Evaluate(expr_id);
544 const char *zmov = element->Attribute(
"ZMOVE");
551 std::string zmovstr = zmov;
553 zmove = expEvaluator.
Evaluate(expr_id);
556 TiXmlElement *vertex = element->FirstChildElement(
"V");
559 int nextVertexNumber = -1;
565 TiXmlAttribute *vertexAttr = vertex->FirstAttribute();
566 std::string attrName(vertexAttr->Name());
569 (std::string(
"Unknown attribute name: ") + attrName).c_str());
571 int err = vertexAttr->QueryIntValue(&indx);
572 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
575 std::string vertexBodyStr;
577 TiXmlNode *vertexBody = vertex->FirstChild();
582 if (vertexBody->Type() == TiXmlNode::TINYXML_TEXT)
584 vertexBodyStr += vertexBody->ToText()->Value();
585 vertexBodyStr +=
" ";
588 vertexBody = vertexBody->NextSibling();
592 "Vertex definitions must contain vertex data.");
596 std::istringstream vertexDataStrm(vertexBodyStr.c_str());
600 while (!vertexDataStrm.fail())
602 vertexDataStrm >> xval >> yval >> zval;
604 xval = xval * xscale + xmove;
605 yval = yval * yscale + ymove;
606 zval = zval * zscale + zmove;
611 if (!vertexDataStrm.fail())
622 ASSERTL0(
false,
"Unable to read VERTEX data.");
625 vertex = vertex->NextSiblingElement(
"V");
633 TiXmlElement *element =
m_xmlGeom->FirstChildElement(
"VERTEX");
634 ASSERTL0(element,
"Unable to find mesh VERTEX tag in file.");
639 const char *xscal = element->Attribute(
"XSCALE");
646 std::string xscalstr = xscal;
648 xscale = expEvaluator.
Evaluate(expr_id);
651 const char *yscal = element->Attribute(
"YSCALE");
658 std::string yscalstr = yscal;
660 yscale = expEvaluator.
Evaluate(expr_id);
663 const char *zscal = element->Attribute(
"ZSCALE");
670 std::string zscalstr = zscal;
672 zscale = expEvaluator.
Evaluate(expr_id);
680 const char *xmov = element->Attribute(
"XMOVE");
687 std::string xmovstr = xmov;
689 xmove = expEvaluator.
Evaluate(expr_id);
692 const char *ymov = element->Attribute(
"YMOVE");
699 std::string ymovstr = ymov;
701 ymove = expEvaluator.
Evaluate(expr_id);
704 const char *zmov = element->Attribute(
"ZMOVE");
711 std::string zmovstr = zmov;
713 zmove = expEvaluator.
Evaluate(expr_id);
719 TiXmlElement *field =
m_xmlGeom->FirstChildElement(
"CURVED");
730 TiXmlElement *edgelement = field->FirstChildElement(
"E");
732 int edgeindx, edgeid;
733 int nextEdgeNumber = -1;
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 = NULL;
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;
1048 TiXmlElement *field =
m_xmlGeom->FirstChildElement(
"EDGE");
1050 ASSERTL0(field,
"Unable to find EDGE tag in file.");
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");
1129 TiXmlElement *field =
m_xmlGeom->FirstChildElement(
"FACE");
1131 ASSERTL0(field,
"Unable to find FACE tag in file.");
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 = NULL;
1292 field =
m_xmlGeom->FirstChildElement(
"ELEMENT");
1294 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
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");
1368 TiXmlElement *field =
m_xmlGeom->FirstChildElement(
"ELEMENT");
1370 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
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();
1514 TiXmlElement *field =
m_xmlGeom->FirstChildElement(
"ELEMENT");
1516 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
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 = NULL;
1863 field =
m_xmlGeom->FirstChildElement(
"COMPOSITE");
1865 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
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 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);
2805 doc.SaveFile(outfilename);
2809 vector<set<unsigned int>> elements,
2810 vector<unsigned int> partitions)
2821 string dirname = outname +
"_xml";
2822 boost::filesystem::path pdirname(dirname);
2824 if (!boost::filesystem::is_directory(dirname))
2826 boost::filesystem::create_directory(dirname);
2829 ASSERTL0(elements.size() == partitions.size(),
2830 "error in partitioned information");
2832 for (
int i = 0; i < partitions.size(); i++)
2835 TiXmlDeclaration *decl =
new TiXmlDeclaration(
"1.0",
"utf-8",
"");
2836 doc.LinkEndChild(decl);
2838 TiXmlElement *root = doc.FirstChildElement(
"NEKTAR");
2839 TiXmlElement *geomTag;
2844 root =
new TiXmlElement(
"NEKTAR");
2845 doc.LinkEndChild(root);
2847 geomTag =
new TiXmlElement(
"GEOMETRY");
2848 root->LinkEndChild(geomTag);
2853 geomTag = root->FirstChildElement(
"GEOMETRY");
2857 geomTag =
new TiXmlElement(
"GEOMETRY");
2858 root->LinkEndChild(geomTag);
2864 geomTag->SetAttribute(
"PARTITION", partitions[i]);
2879 vector<set<unsigned int>> entityIds(4);
2886 for (
auto &j : entityIds[3])
2911 ASSERTL0(
false,
"element in partition not found");
2914 for (
int k = 0; k < g->GetNumFaces(); k++)
2916 entityIds[2].insert(g->GetFid(k));
2918 for (
int k = 0; k < g->GetNumEdges(); k++)
2920 entityIds[1].insert(g->GetEid(k));
2922 for (
int k = 0; k < g->GetNumVerts(); k++)
2924 entityIds[0].insert(g->GetVid(k));
2931 for (
auto &j : entityIds[2])
2946 ASSERTL0(
false,
"element in partition not found");
2949 for (
int k = 0; k < g->GetNumEdges(); k++)
2951 entityIds[1].insert(g->GetEid(k));
2953 for (
int k = 0; k < g->GetNumVerts(); k++)
2955 entityIds[0].insert(g->GetVid(k));
2962 for (
auto &j : entityIds[1])
2972 ASSERTL0(
false,
"element in partition not found");
2975 for (
int k = 0; k < g->GetNumVerts(); k++)
2977 entityIds[0].insert(g->GetVid(k));
2985 for (
auto &j : entityIds[2])
3004 for (
auto &j : entityIds[1])
3017 for (
auto &j : entityIds[0])
3033 TiXmlElement *faceTag =
3038 geomTag->LinkEndChild(faceTag);
3042 TiXmlElement *elmtTag =
new TiXmlElement(
"ELEMENT");
3049 geomTag->LinkEndChild(elmtTag);
3052 for (
auto &j : localTri)
3059 for (
auto &j : localQuad)
3066 for (
auto &j : localEdge)
3077 std::map<int, std::string> localCompLabels;
3082 int dim = j.second->m_geomVec[0]->GetShapeDim();
3084 for (
int k = 0; k < j.second->m_geomVec.size(); k++)
3086 if (entityIds[dim].count(j.second->m_geomVec[k]->GetGlobalID()))
3088 comp->m_geomVec.push_back(j.second->m_geomVec[k]);
3092 if (comp->m_geomVec.size())
3094 localComp[j.first] = comp;
3104 map<int, CompositeMap> domain;
3105 for (
auto &j : localComp)
3109 for (
auto &dIt : dom.second)
3111 if (j.first == dIt.first)
3113 domain[dom.first][j.first] = j.second;
3122 if (
m_session->DefinesElement(
"NEKTAR/CONDITIONS"))
3124 std::set<int> vBndRegionIdList;
3125 TiXmlElement *vConditions =
3126 new TiXmlElement(*
m_session->GetElement(
"Nektar/Conditions"));
3127 TiXmlElement *vBndRegions =
3128 vConditions->FirstChildElement(
"BOUNDARYREGIONS");
3131 TiXmlElement *vBndConditions =
3132 vConditions->FirstChildElement(
"BOUNDARYCONDITIONS");
3136 TiXmlElement *vItem;
3142 vConditions->FirstChildElement(
"BOUNDARYREGIONS")
3143 ->FirstChildElement(
"TIMELEVEL") !=
nullptr;
3145 TiXmlElement *vNewBndRegions =
3146 multiLevel ?
new TiXmlElement(
"TIMELEVEL")
3147 :
new TiXmlElement(
"BOUNDARYREGIONS");
3148 vItem = vBndRegions->FirstChildElement();
3151 std::string vSeqStr =
3152 vItem->FirstChild()->ToText()->Value();
3153 std::string::size_type indxBeg =
3154 vSeqStr.find_first_of(
'[') + 1;
3155 std::string::size_type indxEnd =
3156 vSeqStr.find_last_of(
']') - 1;
3157 vSeqStr = vSeqStr.substr(indxBeg, indxEnd - indxBeg + 1);
3158 std::vector<unsigned int> vSeq;
3161 vector<unsigned int> idxList;
3163 for (
unsigned int i = 0; i < vSeq.size(); ++i)
3165 if (localComp.find(vSeq[i]) != localComp.end())
3167 idxList.push_back(vSeq[i]);
3170 int p = atoi(vItem->Attribute(
"ID"));
3172 std::string vListStr =
3175 if (vListStr.length() == 0)
3177 TiXmlElement *tmp = vItem;
3178 vItem = vItem->NextSiblingElement();
3179 vBndRegions->RemoveChild(tmp);
3183 vListStr =
"C[" + vListStr +
"]";
3184 TiXmlText *vList =
new TiXmlText(vListStr);
3185 TiXmlElement *vNewElement =
new TiXmlElement(
"B");
3186 vNewElement->SetAttribute(
"ID",
p);
3187 vNewElement->LinkEndChild(vList);
3188 vNewBndRegions->LinkEndChild(vNewElement);
3189 vBndRegionIdList.insert(
p);
3190 vItem = vItem->NextSiblingElement();
3199 size_t timeLevel = 0;
3202 vNewBndRegions->SetAttribute(
"VALUE", timeLevel);
3203 vConditions->FirstChildElement(
"BOUNDARYREGIONS")
3204 ->ReplaceChild(vBndRegions, *vNewBndRegions);
3205 vBndRegions = vBndRegions->NextSiblingElement();
3211 vConditions->ReplaceChild(vBndRegions, *vNewBndRegions);
3217 vItem = vBndConditions->FirstChildElement();
3220 std::set<int>::iterator x;
3221 if ((x = vBndRegionIdList.find(atoi(vItem->Attribute(
3222 "REF")))) != vBndRegionIdList.end())
3224 vItem->SetAttribute(
"REF", *x);
3225 vItem = vItem->NextSiblingElement();
3229 TiXmlElement *tmp = vItem;
3230 vItem = vItem->NextSiblingElement();
3231 vBndConditions->RemoveChild(tmp);
3235 root->LinkEndChild(vConditions);
3239 TiXmlElement *vSrc =
3240 m_session->GetElement(
"Nektar")->FirstChildElement();
3243 std::string vName = boost::to_upper_copy(vSrc->ValueStr());
3244 if (vName !=
"GEOMETRY" && vName !=
"CONDITIONS")
3246 root->LinkEndChild(
new TiXmlElement(*vSrc));
3248 vSrc = vSrc->NextSiblingElement();
3254 pad % partitions[i];
3255 boost::filesystem::path pFilename(pad.str());
3257 boost::filesystem::path fullpath = pdirname / pFilename;
3268 bool fillComp =
true;
3271 if (c.second ==
d.second)
3278 std::vector<unsigned int> ids;
3279 for (
auto &elmt : c.second->m_geomVec)
3281 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.
static void GetXMLElementTimeLevel(TiXmlElement *&element, const size_t timeLevel, const bool disableCheck=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
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)
virtual void v_WriteQuads(TiXmlElement *faceTag, QuadGeomMap &quads)
virtual void v_WritePyrs(TiXmlElement *elmtTag, PyrGeomMap &pyrs)
virtual void v_WriteGeometry(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...
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()
virtual 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)
virtual 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[]
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::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)
The above copyright notice and this permission notice shall be included.