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");
126 int err = edge->QueryIntAttribute(
"ID",&indx);
127 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read edge attribute ID.");
129 TiXmlNode *child = edge->FirstChild();
131 if (child->Type() == TiXmlNode::TINYXML_TEXT)
133 edgeStr += child->ToText()->ValueStr();
137 int vertex1, vertex2;
138 std::istringstream edgeDataStrm(edgeStr.c_str());
142 while (!edgeDataStrm.fail())
144 edgeDataStrm >> vertex1 >> vertex2;
149 if (!edgeDataStrm.fail())
173 edge = edge->NextSiblingElement(
"E");
180 TiXmlHandle docHandle(&doc);
181 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
182 TiXmlElement* field = NULL;
185 field = mesh->FirstChildElement(
"FACE");
187 ASSERTL0(field,
"Unable to find FACE tag in file.");
192 TiXmlElement *element = field->FirstChildElement();
197 std::string elementType(element->ValueStr());
199 ASSERTL0(elementType ==
"Q" || elementType ==
"T",
200 (std::string(
"Unknown 3D face type: ") + elementType).c_str());
204 int err = element->QueryIntAttribute(
"ID", &indx);
205 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read face attribute ID.");
211 TiXmlNode* elementChild = element->FirstChild();
212 std::string elementStr;
215 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
217 elementStr += elementChild->ToText()->ValueStr();
219 elementChild = elementChild->NextSibling();
222 ASSERTL0(!elementStr.empty(),
"Unable to read face description body.");
225 if (elementType ==
"T")
228 int edge1, edge2, edge3;
229 std::istringstream elementDataStrm(elementStr.c_str());
233 elementDataStrm >> edge1;
234 elementDataStrm >> edge2;
235 elementDataStrm >> edge3;
237 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read face data for TRIANGLE: ") + elementStr).c_str());
265 trigeom->SetGlobalID(indx);
272 (std::string(
"Unable to read face data for TRIANGLE: ") + elementStr).c_str());
275 else if (elementType ==
"Q")
278 int edge1, edge2, edge3, edge4;
279 std::istringstream elementDataStrm(elementStr.c_str());
283 elementDataStrm >> edge1;
284 elementDataStrm >> edge2;
285 elementDataStrm >> edge3;
286 elementDataStrm >> edge4;
288 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read face data for QUAD: ") + elementStr).c_str());
313 quadgeom->SetGlobalID(indx);
325 element = element->NextSiblingElement();
332 TiXmlHandle docHandle(&doc);
333 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
334 TiXmlElement* field = NULL;
337 field = mesh->FirstChildElement(
"ELEMENT");
339 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
341 int nextElementNumber = -1;
346 TiXmlElement *element = field->FirstChildElement();
350 std::string elementType(element->ValueStr());
353 ASSERTL0(elementType ==
"A" || elementType ==
"P" || elementType ==
"R" || elementType ==
"H",
354 (std::string(
"Unknown 3D element type: ") + elementType).c_str());
361 int err = element->QueryIntAttribute(
"ID", &indx);
362 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
366 TiXmlNode* elementChild = element->FirstChild();
367 std::string elementStr;
370 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
372 elementStr += elementChild->ToText()->ValueStr();
374 elementChild = elementChild->NextSibling();
377 ASSERTL0(!elementStr.empty(),
"Unable to read element description body.");
379 std::istringstream elementDataStrm(elementStr.c_str());
384 if (elementType ==
"A")
398 std::stringstream errorstring;
399 errorstring <<
"Element " << indx <<
" must have " << kNtfaces <<
" triangle face(s), and " << kNqfaces <<
" quadrilateral face(s).";
400 for (
int i = 0; i < kNfaces; i++)
403 elementDataStrm >> faceID;
408 std::stringstream errorstring;
409 errorstring <<
"Element " << indx <<
" has invalid face: " << faceID;
410 ASSERTL0(
false, errorstring.str().c_str());
414 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
415 tfaces[Ntfaces++] = boost::static_pointer_cast<
TriGeom>(face);
419 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
424 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for TETRAHEDRON: ") + elementStr).c_str());
425 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
426 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
429 tetgeom->SetGlobalID(indx);
437 (std::string(
"Unable to read element data for TETRAHEDRON: ") + elementStr).c_str());
441 else if (elementType ==
"P")
455 std::stringstream errorstring;
456 errorstring <<
"Element " << indx <<
" must have " << kNtfaces <<
" triangle face(s), and " << kNqfaces <<
" quadrilateral face(s).";
457 for (
int i = 0; i < kNfaces; i++)
460 elementDataStrm >> faceID;
465 std::stringstream errorstring;
466 errorstring <<
"Element " << indx <<
" has invalid face: " << faceID;
467 ASSERTL0(
false, errorstring.str().c_str());
471 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
472 faces[Nfaces++] = boost::static_pointer_cast<
TriGeom>(face);
477 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
478 faces[Nfaces++] = boost::static_pointer_cast<
QuadGeom>(face);
484 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for PYRAMID: ") + elementStr).c_str());
485 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
486 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
489 pyrgeom->SetGlobalID(indx);
497 (std::string(
"Unable to read element data for PYRAMID: ") + elementStr).c_str());
501 else if (elementType ==
"R")
515 std::stringstream errorstring;
516 errorstring <<
"Element " << indx <<
" must have "
517 << kNtfaces <<
" triangle face(s), and "
518 << kNqfaces <<
" quadrilateral face(s).";
520 for (
int i = 0; i < kNfaces; i++)
523 elementDataStrm >> faceID;
528 std::stringstream errorstring;
529 errorstring <<
"Element " << indx <<
" has invalid face: " << faceID;
530 ASSERTL0(
false, errorstring.str().c_str());
534 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
535 faces[Nfaces++] = boost::static_pointer_cast<
TriGeom>(face);
540 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
541 faces[Nfaces++] = boost::static_pointer_cast<
QuadGeom>(face);
547 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for PRISM: ") + elementStr).c_str());
548 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
549 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
552 prismgeom->SetGlobalID(indx);
560 (std::string(
"Unable to read element data for PRISM: ") + elementStr).c_str());
564 else if (elementType ==
"H")
578 std::stringstream errorstring;
579 errorstring <<
"Element " << indx <<
" must have " << kNtfaces <<
" triangle face(s), and " << kNqfaces <<
" quadrilateral face(s).";
580 for (
int i = 0; i < kNfaces; i++)
583 elementDataStrm >> faceID;
588 std::stringstream errorstring;
589 errorstring <<
"Element " << indx <<
" has invalid face: " << faceID;
590 ASSERTL0(
false, errorstring.str().c_str());
594 ASSERTL0(Ntfaces < kNtfaces, errorstring.str().c_str());
599 ASSERTL0(Nqfaces < kNqfaces, errorstring.str().c_str());
600 qfaces[Nqfaces++] = boost::static_pointer_cast<
QuadGeom>(face);
605 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for HEXAHEDRAL: ") + elementStr).c_str());
606 ASSERTL0(Ntfaces == kNtfaces, errorstring.str().c_str());
607 ASSERTL0(Nqfaces == kNqfaces, errorstring.str().c_str());
610 hexgeom->SetGlobalID(indx);
618 (std::string(
"Unable to read element data for HEXAHEDRAL: ") + elementStr).c_str());
623 element = element->NextSiblingElement();
629 TiXmlHandle docHandle(&doc);
632 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
633 TiXmlElement* field = NULL;
635 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
638 field = mesh->FirstChildElement(
"COMPOSITE");
640 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
642 int nextCompositeNumber = -1;
647 TiXmlElement *composite = field->FirstChildElement(
"C");
651 nextCompositeNumber++;
654 int err = composite->QueryIntAttribute(
"ID", &indx);
655 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
658 TiXmlNode* compositeChild = composite->FirstChild();
663 while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
665 compositeChild = compositeChild->NextSibling();
668 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
669 std::string compositeStr = compositeChild->ToText()->ValueStr();
673 std::istringstream compositeDataStrm(compositeStr.c_str());
678 std::string prevCompositeElementStr;
680 while (!compositeDataStrm.fail())
682 std::string compositeElementStr;
683 compositeDataStrm >> compositeElementStr;
685 if (!compositeDataStrm.fail())
695 if (compositeElementStr.length() > 0)
699 prevCompositeElementStr = compositeElementStr;
706 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
710 composite = composite->NextSiblingElement(
"C");
720 + boost::lexical_cast<
string>(eID) +
" not found.");
751 std::istringstream tokenStream(token);
752 std::istringstream prevTokenStream(prevToken);
759 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
760 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
762 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
764 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
766 std::vector<unsigned int> seqVector;
771 ASSERTL0(err, (std::string(
"Error reading composite elements: ") + indxStr).c_str());
773 prevTokenStream >> prevType;
776 map<char, int> typeMap;
787 bool validSequence = (prevToken.empty() || (typeMap[type] == typeMap[prevType]));
789 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
790 + type +
" and " + prevType +
".").c_str());
795 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
799 char errStr[16] =
"";
800 ::sprintf(errStr,
"%d", *seqIter);
805 composite->push_back(
m_vertSet[*seqIter]);
811 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
815 char errStr[16] =
"";
816 ::sprintf(errStr,
"%d", *seqIter);
827 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
832 char errStr[16] =
"";
833 ::sprintf(errStr,
"%d", *seqIter);
840 composite->push_back(face);
847 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
851 char errStr[16] =
"";
852 ::sprintf(errStr,
"%d", *seqIter);
866 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
870 char errStr[16] =
"";
871 ::sprintf(errStr,
"%d", *seqIter);
886 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
890 char errStr[16] =
"";
891 ::sprintf(errStr,
"%d", *seqIter);
906 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
910 char errStr[16] =
"";
911 ::sprintf(errStr,
"%d", *seqIter);
926 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
930 char errStr[16] =
"";
931 ::sprintf(errStr,
"%d", *seqIter);
946 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
950 char errStr[16] =
"";
951 ::sprintf(errStr,
"%d", *seqIter);
994 const std::string variable)
1000 ASSERTL0(elements->size() > 0,
"No elements for the given face."
1001 " Check all elements belong to the domain composite.");
1013 ASSERTL0(expansion,
"Could not find expansion connected to face "+
1014 boost::lexical_cast<string>(face->GetGlobalID()));
1019 expansion->m_geomShPtr);
1024 int dir = geom3d->
GetDir((*elements)[0]->m_FaceIndx, facedir);
1026 if(face->GetNumVerts() == 3)
1029 expansion->m_basisKeyVector[dir].GetBasisType(),
1030 expansion->m_basisKeyVector[dir].GetNumPoints(),
1031 expansion->m_basisKeyVector[dir].GetNumModes());
1036 expansion->m_basisKeyVector[dir].GetBasisType(),
1037 expansion->m_basisKeyVector[dir].GetNumPoints(),
1038 expansion->m_basisKeyVector[dir].GetNumModes());
1058 for (
int i = 0; i < kNfaces; ++i)
1060 int faceId = element->GetFace(i)->GetGlobalID();
1064 elementFace->m_Element = element;
1065 elementFace->m_FaceIndx = i;
1075 tmp->push_back(elementFace);
1081 tmp->push_back(elementFace);
boost::shared_ptr< PyrGeom > PyrGeomSharedPtr
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
boost::shared_ptr< ElementFaceVector > ElementFaceVectorSharedPtr
PrismGeomMap m_prismGeoms
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void ReadCurves(TiXmlDocument &doc)
int GetDir(const int faceidx, const int facedir) const
Returns the element coordinate direction corresponding to a given face coordinate direction...
void ReadFaces(TiXmlDocument &doc)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static const int kNtfaces
CompositeMap m_meshComposites
void PopulateFaceToElMap(Geometry3DSharedPtr element, int kNfaces)
Given a 3D geometry object #element, populate the face to element map m_faceToElMap which maps faces ...
void ReadGeometry(const std::string &infilename)
Read will read the meshgraph vertices given a filename.
boost::shared_ptr< QuadGeom > QuadGeomSharedPtr
LibUtilities::BasisKey EvaluateTriFaceBasisKey(const int facedir, const LibUtilities::BasisType faceDirBasisType, const int numpoints, const int nummodes)
PointGeomSharedPtr GetVertex(int id)
boost::unordered_map< int, ElementFaceVectorSharedPtr > m_faceToElMap
std::map< int, QuadGeomSharedPtr >::iterator QuadGeomMapIter
static const int kNtfaces
boost::shared_ptr< HexGeom > HexGeomSharedPtr
Geometry2DSharedPtr GetGeometry2D(int gID)
void ResolveGeomRef(const std::string &prevToken, const std::string &token, Composite &composite)
SegGeomSharedPtr GetSegGeom(int eID)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
virtual void ReadGeometry(const std::string &infilename)
Read will read the meshgraph vertices given a filename.
static StdRegions::Orientation GetEdgeOrientation(const SegGeom &edge1, const SegGeom &edge2)
Get the orientation of edge1.
std::map< int, TriGeomSharedPtr >::iterator TriGeomMapIter
ElementFaceVectorSharedPtr GetElementsFromFace(Geometry2DSharedPtr face)
Return the elements (shared ptrs) that have this face.
void ReadComposites(TiXmlDocument &doc)
LibUtilities::BasisKey EvaluateQuadFaceBasisKey(const int facedir, const LibUtilities::BasisType faceDirBasisType, const int numpoints, const int nummodes)
static const int kNqfaces
boost::shared_ptr< SegGeom > SegGeomSharedPtr
boost::shared_ptr< DomainRange > DomainRangeShPtr
void ReadElements(TiXmlDocument &doc)
boost::shared_ptr< GeometryVector > Composite
boost::shared_ptr< ElementFace > ElementFaceSharedPtr
static const int kNqfaces
static const int kNedges
Get the orientation of face1.
static const int kNtfaces
boost::shared_ptr< Geometry2D > Geometry2DSharedPtr
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
LibUtilities::BasisKey GetFaceBasisKey(Geometry2DSharedPtr face, const int flag, const std::string variable="DefaultVar")
Return the BasisKey corresponding to a face of an element.
void ReadEdges(TiXmlDocument &doc)
static const int kNqfaces
boost::shared_ptr< Expansion > ExpansionShPtr
Base class for a spectral/hp element mesh.
void ReadDomain(TiXmlDocument &doc)
boost::shared_ptr< PrismGeom > PrismGeomSharedPtr
bool CheckRange(Geometry2D &geom)
Check if goemetry is in range definition if activated.
ExpansionShPtr GetExpansion(GeometrySharedPtr geom, const std::string variable="DefaultVar")
boost::shared_ptr< TetGeom > TetGeomSharedPtr
boost::shared_ptr< TriGeom > TriGeomSharedPtr
static const BasisKey NullBasisKey(eNoBasisType, 0, NullPointsKey)
Defines a null basis with no type or points.
void ReadExpansions(const std::string &infilename)
Read the expansions given the XML file path.
static const int kNqfaces
static const int kNtfaces
Describes the specification for a Basis.
boost::shared_ptr< PointGeom > PointGeomSharedPtr
boost::shared_ptr< Geometry3D > Geometry3DSharedPtr