47 namespace SpatialDomains
49 MeshGraph2D::MeshGraph2D()
53 MeshGraph2D::~MeshGraph2D()
67 TiXmlDocument doc(infilename);
68 bool loadOkay = doc.LoadFile();
70 std::stringstream errstr;
71 errstr <<
"Unable to load file: " << infilename <<
"\n";
72 errstr << doc.ErrorDesc() <<
" (Line " << doc.ErrorRow()
73 <<
", Column " << doc.ErrorCol() <<
")";
84 TiXmlHandle docHandle(&doc);
86 TiXmlElement* mesh = NULL;
89 mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
91 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
103 TiXmlHandle docHandle(&doc);
104 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
105 TiXmlElement* field = NULL;
109 field = mesh->FirstChildElement(
"EDGE");
111 ASSERTL0(field,
"Unable to find EDGE tag in file.");
114 field->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
116 if(IsCompressed.size())
118 ASSERTL0(boost::iequals(IsCompressed,
120 "Compressed formats do not match. Expected :"
122 +
" but got " + std::string(IsCompressed));
125 TiXmlNode* edgeChild = field->FirstChild();
126 ASSERTL0(edgeChild,
"Unable to extract the data from "
127 "the compressed edge tag.");
130 if (edgeChild->Type() == TiXmlNode::TINYXML_TEXT)
132 edgeStr += edgeChild->ToText()->ValueStr();
135 std::vector<LibUtilities::MeshEdge> edgeData;
139 for(
int i = 0; i < edgeData.size(); ++i)
141 indx = edgeData[i].id;
167 TiXmlElement *edge = field->FirstChildElement(
"E");
180 int err = edge->QueryIntAttribute(
"ID",&indx);
181 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read edge attribute ID.");
183 TiXmlNode *child = edge->FirstChild();
185 if (child->Type() == TiXmlNode::TINYXML_TEXT)
187 edgeStr += child->ToText()->ValueStr();
191 int vertex1, vertex2;
192 std::istringstream edgeDataStrm(edgeStr.c_str());
196 while (!edgeDataStrm.fail())
198 edgeDataStrm >> vertex1 >> vertex2;
204 if (!edgeDataStrm.fail())
215 edge->SetGlobalID(indx);
220 edge->SetGlobalID(indx);
232 edge = edge->NextSiblingElement(
"E");
240 TiXmlHandle docHandle(&doc);
241 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
242 TiXmlElement* field = NULL;
245 field = mesh->FirstChildElement(
"ELEMENT");
247 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
255 TiXmlElement *element = field->FirstChildElement();
259 std::string elementType(element->ValueStr());
261 ASSERTL0(elementType ==
"Q" || elementType ==
"T",
262 (std::string(
"Unknown 2D element type: ") + elementType).c_str());
265 element->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
267 if(IsCompressed.size())
269 ASSERTL0(boost::iequals(IsCompressed,
271 "Compressed formats do not match. Expected :"
273 +
" but got " + std::string(IsCompressed));
276 TiXmlNode* faceChild = element->FirstChild();
277 ASSERTL0(faceChild,
"Unable to extract the data from "
278 "the compressed face tag.");
281 if (faceChild->Type() == TiXmlNode::TINYXML_TEXT)
283 faceStr += faceChild->ToText()->ValueStr();
287 if(elementType ==
"T")
289 std::vector<LibUtilities::MeshTri> faceData;
293 for(
int i = 0; i < faceData.size(); ++i)
295 indx = faceData[i].id;
320 indx, edges, edgeorient);
326 indx, edges, edgeorient,
329 trigeom->SetGlobalID(indx);
333 else if (elementType ==
"Q")
335 std::vector<LibUtilities::MeshQuad> faceData;
339 for(
int i = 0; i < faceData.size(); ++i)
341 indx = faceData[i].id;
366 indx, edges, edgeorient);
372 indx, edges, edgeorient,
375 quadgeom->SetGlobalID(indx);
384 int err = element->QueryIntAttribute(
"ID", &indx);
385 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
390 TiXmlNode* elementChild = element->FirstChild();
391 std::string elementStr;
394 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
396 elementStr += elementChild->ToText()->ValueStr();
398 elementChild = elementChild->NextSibling();
401 ASSERTL0(!elementStr.empty(),
"Unable to read element description body.");
404 if (elementType ==
"T")
407 int edge1, edge2, edge3;
408 std::istringstream elementDataStrm(elementStr.c_str());
412 elementDataStrm >> edge1;
413 elementDataStrm >> edge2;
414 elementDataStrm >> edge3;
416 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for TRIANGLE: ") + elementStr).c_str());
449 trigeom->SetGlobalID(indx);
458 else if (elementType ==
"Q")
461 int edge1, edge2, edge3, edge4;
462 std::istringstream elementDataStrm(elementStr.c_str());
466 elementDataStrm >> edge1;
467 elementDataStrm >> edge2;
468 elementDataStrm >> edge3;
469 elementDataStrm >> edge4;
471 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for QUAD: ") + elementStr).c_str());
502 quadgeom->SetGlobalID(indx);
514 element = element->NextSiblingElement();
520 TiXmlHandle docHandle(&doc);
523 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
524 TiXmlElement* field = NULL;
526 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
529 field = mesh->FirstChildElement(
"COMPOSITE");
531 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
533 int nextCompositeNumber = -1;
537 TiXmlElement *composite = field->FirstChildElement(
"C");
541 nextCompositeNumber++;
544 int err = composite->QueryIntAttribute(
"ID", &indx);
545 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
549 err = composite->QueryStringAttribute(
"LABEL", &labelstr);
550 if(err == TIXML_SUCCESS)
555 TiXmlNode* compositeChild = composite->FirstChild();
560 while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
562 compositeChild = compositeChild->NextSibling();
565 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
566 std::string compositeStr = compositeChild->ToText()->ValueStr();
570 std::istringstream compositeDataStrm(compositeStr.c_str());
575 std::string prevCompositeElementStr;
577 while (!compositeDataStrm.fail())
579 std::string compositeElementStr;
580 compositeDataStrm >> compositeElementStr;
582 if (!compositeDataStrm.fail())
592 if (compositeElementStr.length() > 0)
596 prevCompositeElementStr = compositeElementStr;
603 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
607 composite = composite->NextSiblingElement(
"C");
632 std::istringstream tokenStream(token);
633 std::istringstream prevTokenStream(prevToken);
640 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
641 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
643 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
645 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
646 std::vector<unsigned int> seqVector;
651 ASSERTL0(err, (std::string(
"Error reading composite elements: ") + indxStr).c_str());
653 prevTokenStream >> prevType;
656 bool validSequence = (prevToken.empty() ||
657 (type ==
'V' && prevType ==
'V') ||
658 (type ==
'E' && prevType ==
'E') ||
659 ((type ==
'T' || type ==
'Q') &&
660 (prevType ==
'T' || prevType ==
'Q')));
662 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
663 + type +
" and " + prevType +
".").c_str());
669 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
673 char errStr[16] =
"";
674 ::sprintf(errStr,
"%d", *seqIter);
686 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
690 char errStr[16] =
"";
691 ::sprintf(errStr,
"%d", *seqIter);
707 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
711 char errStr[16] =
"";
712 ::sprintf(errStr,
"%d", *seqIter);
727 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
731 char errStr[16] =
"";
732 ::sprintf(errStr,
"%d", *seqIter);
737 composite->push_back(
m_vertSet[*seqIter]);
758 if(!(Sedge = boost::dynamic_pointer_cast<SegGeom>(edge)))
760 ASSERTL0(
false,
"Dynamics cast failed");
782 for(
int d = 0; d <
m_domain.size(); ++d)
784 for (compIter =
m_domain[d].begin(); compIter !=
m_domain[d].end(); ++compIter)
786 for (geomIter = (compIter->second)->begin(); geomIter != (compIter->second)->end(); ++geomIter)
788 triGeomShPtr = boost::dynamic_pointer_cast<
TriGeom>(*geomIter);
789 quadGeomShPtr = boost::dynamic_pointer_cast<
QuadGeom>(*geomIter);
791 if (triGeomShPtr || quadGeomShPtr)
796 if ((edgeNum = triGeomShPtr->WhichEdge(edge)) > -1)
799 elementEdge->m_Element = triGeomShPtr;
800 elementEdge->m_EdgeIndx = edgeNum;
801 returnval->push_back(elementEdge);
804 else if (quadGeomShPtr)
806 if ((edgeNum = quadGeomShPtr->WhichEdge(edge)) > -1)
809 elementEdge->m_Element = quadGeomShPtr;
810 elementEdge->m_EdgeIndx = edgeNum;
811 returnval->push_back(elementEdge);
831 int edge_id = (*elements)[0]->m_EdgeIndx;
835 edge_id = (edge_id)? 1:0;
842 int nummodes = expansion->m_basisKeyVector[edge_id].GetNumModes();
843 int numpoints = expansion->m_basisKeyVector[edge_id].GetNumPoints();
848 switch(expansion->m_basisKeyVector[edge_id].GetBasisType())
852 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
862 ASSERTL0(
false,
"Unexpected points distribution");
876 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
886 ASSERTL0(
false,
"Unexpected points distribution");
900 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
916 ASSERTL0(
false,
"Unexpected points distribution");
930 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
939 ASSERTL0(
false,
"Unexpected points distribution");
952 ASSERTL0(
false,
"Unexpected basis distribution");
967 ASSERTL0(
false,
"Unable to determine edge points type.");
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
void ReadEdges(TiXmlDocument &doc)
void ReadComposites(TiXmlDocument &doc)
std::map< int, std::string > m_compositesLabels
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void ReadCurves(TiXmlDocument &doc)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
CompositeMap m_meshComposites
boost::shared_ptr< QuadGeom > QuadGeomSharedPtr
void ReadElements(TiXmlDocument &doc)
LibUtilities::BasisKey GetEdgeBasisKey(SegGeomSharedPtr edge, const std::string variable="DefaultVar")
Return the BasisKey corresponding to an edge of an element If the expansion is a triangle the Modifie...
Principle Modified Functions .
PointGeomSharedPtr GetVertex(int id)
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.
Gauss Radau pinned at x=-1, .
std::string GetCompressString(void)
std::vector< GeometrySharedPtr >::iterator GeometryVectorIter
Principle Orthogonal Functions .
boost::shared_ptr< ElementEdge > ElementEdgeSharedPtr
void ReadGeometry(const std::string &infilename)
Read will read the meshgraph vertices given a filename.
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Principle Modified Functions .
boost::shared_ptr< DomainRange > DomainRangeShPtr
std::map< int, Composite >::iterator CompositeMapIter
Defines a specification for a set of points.
boost::shared_ptr< GeometryVector > Composite
ElementEdgeVectorSharedPtr GetElementsFromEdge(SegGeomSharedPtr edge)
Return the elements (shared ptrs) that have this edge.
static const int kNedges
Get the orientation of face1.
boost::shared_ptr< ElementEdgeVector > ElementEdgeVectorSharedPtr
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::vector< CompositeMap > m_domain
boost::shared_ptr< Expansion > ExpansionShPtr
Base class for a spectral/hp element mesh.
void ReadDomain(TiXmlDocument &doc)
bool CheckRange(Geometry2D &geom)
Check if goemetry is in range definition if activated.
boost::shared_ptr< Geometry1D > Geometry1DSharedPtr
ExpansionShPtr GetExpansion(GeometrySharedPtr geom, const std::string variable="DefaultVar")
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.
void ResolveGeomRef(const std::string &prevToken, const std::string &token, Composite &composite)
Describes the specification for a Basis.
boost::shared_ptr< PointGeom > PointGeomSharedPtr
1D Gauss-Lobatto-Legendre quadrature points
int ZlibDecodeFromBase64Str(std::string &in64, std::vector< T > &out)
SegGeomSharedPtr GetSegGeom(int eID)