44 namespace SpatialDomains
64 TiXmlDocument doc(infilename);
65 bool loadOkay = doc.LoadFile();
67 std::stringstream errstr;
68 errstr <<
"Unable to load file: " << infilename <<
"\n";
69 errstr << doc.ErrorDesc() <<
" (Line " << doc.ErrorRow()
70 <<
", Column " << doc.ErrorCol() <<
")";
81 TiXmlHandle docHandle(&doc);
83 TiXmlElement* mesh = NULL;
86 mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
88 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
101 TiXmlHandle docHandle(&doc);
102 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
103 TiXmlElement* field = NULL;
106 field = mesh->FirstChildElement(
"EDGE");
108 ASSERTL0(field,
"Unable to find EDGE tag in file.");
113 TiXmlElement *edge = field->FirstChildElement(
"E");
122 int nextEdgeNumber = -1;
125 map<int, int> edge_curved;
135 int err = edge->QueryIntAttribute(
"ID",&indx);
136 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read edge attribute ID.");
138 TiXmlNode *child = edge->FirstChild();
140 if (child->Type() == TiXmlNode::TEXT)
142 edgeStr += child->ToText()->ValueStr();
146 int vertex1, vertex2;
147 std::istringstream edgeDataStrm(edgeStr.c_str());
151 while (!edgeDataStrm.fail())
153 edgeDataStrm >> vertex1 >> vertex2;
158 if (!edgeDataStrm.fail())
163 if (edge_curved.count(indx) == 0)
181 edge = edge->NextSiblingElement(
"E");
188 TiXmlHandle docHandle(&doc);
189 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
190 TiXmlElement* field = NULL;
193 field = mesh->FirstChildElement(
"FACE");
195 ASSERTL0(field,
"Unable to find FACE tag in file.");
198 map<int, int> face_curved;
207 TiXmlElement *element = field->FirstChildElement();
211 std::string elementType(element->ValueStr());
213 ASSERTL0(elementType ==
"Q" || elementType ==
"T",
214 (std::string(
"Unknown 3D face type: ") + elementType).c_str());
218 int err = element->QueryIntAttribute(
"ID", &indx);
219 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read face attribute ID.");
222 TiXmlNode* elementChild = element->FirstChild();
223 std::string elementStr;
226 if (elementChild->Type() == TiXmlNode::TEXT)
228 elementStr += elementChild->ToText()->ValueStr();
230 elementChild = elementChild->NextSibling();
233 ASSERTL0(!elementStr.empty(),
"Unable to read face description body.");
236 if (elementType ==
"T")
239 int edge1, edge2, edge3;
240 std::istringstream elementDataStrm(elementStr.c_str());
244 elementDataStrm >> edge1;
245 elementDataStrm >> edge2;
246 elementDataStrm >> edge3;
248 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read face data for TRIANGLE: ") + elementStr).c_str());
267 if (face_curved.count(indx) == 0)
276 trigeom->SetGlobalID(indx);
283 (std::string(
"Unable to read face data for TRIANGLE: ") + elementStr).c_str());
286 else if (elementType ==
"Q")
289 int edge1, edge2, edge3, edge4;
290 std::istringstream elementDataStrm(elementStr.c_str());
294 elementDataStrm >> edge1;
295 elementDataStrm >> edge2;
296 elementDataStrm >> edge3;
297 elementDataStrm >> edge4;
299 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read face data for QUAD: ") + elementStr).c_str());
316 if (face_curved.count(indx) == 0)
322 quadgeom->SetGlobalID(indx);
334 element = element->NextSiblingElement();
341 TiXmlHandle docHandle(&doc);
342 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
343 TiXmlElement* field = NULL;
346 field = mesh->FirstChildElement(
"ELEMENT");
348 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
350 int nextElementNumber = -1;
355 TiXmlElement *element = field->FirstChildElement();
359 std::string elementType(element->ValueStr());
362 ASSERTL0(elementType ==
"A" || elementType ==
"P" || elementType ==
"R" || elementType ==
"H",
363 (std::string(
"Unknown 3D element type: ") + elementType).c_str());
370 int err = element->QueryIntAttribute(
"ID", &indx);
371 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
375 TiXmlNode* elementChild = element->FirstChild();
376 std::string elementStr;
379 if (elementChild->Type() == TiXmlNode::TEXT)
381 elementStr += elementChild->ToText()->ValueStr();
383 elementChild = elementChild->NextSibling();
386 ASSERTL0(!elementStr.empty(),
"Unable to read element description body.");
388 std::istringstream elementDataStrm(elementStr.c_str());
393 if (elementType ==
"A")
407 std::stringstream errorstring;
408 errorstring <<
"Element " << indx <<
" must have " << kNtfaces <<
" triangle face(s), and " << kNqfaces <<
" quadrilateral face(s).";
409 for (
int i = 0; i < kNfaces; i++)
412 elementDataStrm >> faceID;
417 std::stringstream errorstring;
418 errorstring <<
"Element " << indx <<
" has invalid face: " << faceID;
419 ASSERTL0(
false, errorstring.str().c_str());
423 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
424 tfaces[Ntfaces++] = boost::static_pointer_cast<
TriGeom>(face);
428 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
433 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for TETRAHEDRON: ") + elementStr).c_str());
434 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
435 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
438 tetgeom->SetGlobalID(indx);
446 (std::string(
"Unable to read element data for TETRAHEDRON: ") + elementStr).c_str());
450 else if (elementType ==
"P")
464 std::stringstream errorstring;
465 errorstring <<
"Element " << indx <<
" must have " << kNtfaces <<
" triangle face(s), and " << kNqfaces <<
" quadrilateral face(s).";
466 for (
int i = 0; i < kNfaces; i++)
469 elementDataStrm >> faceID;
474 std::stringstream errorstring;
475 errorstring <<
"Element " << indx <<
" has invalid face: " << faceID;
476 ASSERTL0(
false, errorstring.str().c_str());
480 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
481 faces[Nfaces++] = boost::static_pointer_cast<
TriGeom>(face);
486 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
487 faces[Nfaces++] = boost::static_pointer_cast<
QuadGeom>(face);
493 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for PYRAMID: ") + elementStr).c_str());
494 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
495 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
498 pyrgeom->SetGlobalID(indx);
506 (std::string(
"Unable to read element data for PYRAMID: ") + elementStr).c_str());
510 else if (elementType ==
"R")
524 std::stringstream errorstring;
525 errorstring <<
"Element " << indx <<
" must have "
526 << kNtfaces <<
" triangle face(s), and "
527 << kNqfaces <<
" quadrilateral face(s).";
529 for (
int i = 0; i < kNfaces; i++)
532 elementDataStrm >> faceID;
537 std::stringstream errorstring;
538 errorstring <<
"Element " << indx <<
" has invalid face: " << faceID;
539 ASSERTL0(
false, errorstring.str().c_str());
543 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
544 faces[Nfaces++] = boost::static_pointer_cast<
TriGeom>(face);
549 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
550 faces[Nfaces++] = boost::static_pointer_cast<
QuadGeom>(face);
556 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for PRISM: ") + elementStr).c_str());
557 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
558 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
561 prismgeom->SetGlobalID(indx);
569 (std::string(
"Unable to read element data for PRISM: ") + elementStr).c_str());
573 else if (elementType ==
"H")
587 std::stringstream errorstring;
588 errorstring <<
"Element " << indx <<
" must have " << kNtfaces <<
" triangle face(s), and " << kNqfaces <<
" quadrilateral face(s).";
589 for (
int i = 0; i < kNfaces; i++)
592 elementDataStrm >> faceID;
597 std::stringstream errorstring;
598 errorstring <<
"Element " << indx <<
" has invalid face: " << faceID;
599 ASSERTL0(
false, errorstring.str().c_str());
603 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
608 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
609 qfaces[Nqfaces++] = boost::static_pointer_cast<
QuadGeom>(face);
614 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for HEXAHEDRAL: ") + elementStr).c_str());
615 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
616 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
619 hexgeom->SetGlobalID(indx);
627 (std::string(
"Unable to read element data for HEXAHEDRAL: ") + elementStr).c_str());
632 element = element->NextSiblingElement();
638 TiXmlHandle docHandle(&doc);
641 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
642 TiXmlElement* field = NULL;
644 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
647 field = mesh->FirstChildElement(
"COMPOSITE");
649 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
651 int nextCompositeNumber = -1;
656 TiXmlElement *composite = field->FirstChildElement(
"C");
660 nextCompositeNumber++;
663 int err = composite->QueryIntAttribute(
"ID", &indx);
664 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
667 TiXmlNode* compositeChild = composite->FirstChild();
672 while(compositeChild && compositeChild->Type() != TiXmlNode::TEXT)
674 compositeChild = compositeChild->NextSibling();
677 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
678 std::string compositeStr = compositeChild->ToText()->ValueStr();
682 std::istringstream compositeDataStrm(compositeStr.c_str());
687 std::string prevCompositeElementStr;
689 while (!compositeDataStrm.fail())
691 std::string compositeElementStr;
692 compositeDataStrm >> compositeElementStr;
694 if (!compositeDataStrm.fail())
704 if (compositeElementStr.length() > 0)
708 prevCompositeElementStr = compositeElementStr;
715 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
719 composite = composite->NextSiblingElement(
"C");
729 + boost::lexical_cast<
string>(eID) +
" not found.");
760 std::istringstream tokenStream(token);
761 std::istringstream prevTokenStream(prevToken);
768 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
769 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
771 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
773 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
775 std::vector<unsigned int> seqVector;
780 ASSERTL0(err, (std::string(
"Error reading composite elements: ") + indxStr).c_str());
782 prevTokenStream >> prevType;
785 map<char, int> typeMap;
796 bool validSequence = (prevToken.empty() || (typeMap[type] == typeMap[prevType]));
798 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
799 + type +
" and " + prevType +
".").c_str());
804 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
808 char errStr[16] =
"";
809 ::sprintf(errStr,
"%d", *seqIter);
814 composite->push_back(
m_vertSet[*seqIter]);
820 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
824 char errStr[16] =
"";
825 ::sprintf(errStr,
"%d", *seqIter);
836 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
841 char errStr[16] =
"";
842 ::sprintf(errStr,
"%d", *seqIter);
849 composite->push_back(face);
856 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
860 char errStr[16] =
"";
861 ::sprintf(errStr,
"%d", *seqIter);
875 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
879 char errStr[16] =
"";
880 ::sprintf(errStr,
"%d", *seqIter);
895 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
899 char errStr[16] =
"";
900 ::sprintf(errStr,
"%d", *seqIter);
915 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
919 char errStr[16] =
"";
920 ::sprintf(errStr,
"%d", *seqIter);
935 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
939 char errStr[16] =
"";
940 ::sprintf(errStr,
"%d", *seqIter);
955 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
959 char errStr[16] =
"";
960 ::sprintf(errStr,
"%d", *seqIter);
1002 const std::string variable)
1008 ASSERTL0(elements->size() > 0,
"No elements for the given face."
1009 " Check all elements belong to the domain composite.");
1024 expansion->m_geomShPtr);
1029 int dir = geom3d->
GetDir((*elements)[0]->m_FaceIndx, facedir);
1033 int nummodes = (int) expansion->m_basisKeyVector[dir].GetNumModes();
1034 int numpoints = (int) expansion->m_basisKeyVector[dir].GetNumPoints();
1036 switch(expansion->m_basisKeyVector[dir].GetBasisType())
1053 if (face->GetNumVerts() == 3)
1065 ASSERTL0(
false,
"invalid value to flag");
1097 ASSERTL0(
false,
"invalid value to flag");
1103 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D failed");
1124 ASSERTL0(
false,
"invalid value to flag");
1136 ASSERTL0(
false,
"expansion type unknown");
1155 for (
int i = 0; i < kNfaces; ++i)
1157 int faceId = element->GetFace(i)->GetGlobalID();
1161 elementFace->m_Element = element;
1162 elementFace->m_FaceIndx = i;
1172 tmp->push_back(elementFace);
1178 tmp->push_back(elementFace);