46 namespace SpatialDomains
48 MeshGraph2D::MeshGraph2D()
52 MeshGraph2D::~MeshGraph2D()
66 TiXmlDocument doc(infilename);
67 bool loadOkay = doc.LoadFile();
69 std::stringstream errstr;
70 errstr <<
"Unable to load file: " << infilename <<
"\n";
71 errstr << doc.ErrorDesc() <<
" (Line " << doc.ErrorRow()
72 <<
", Column " << doc.ErrorCol() <<
")";
83 TiXmlHandle docHandle(&doc);
85 TiXmlElement* mesh = NULL;
88 mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
90 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
102 TiXmlHandle docHandle(&doc);
103 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
104 TiXmlElement* field = NULL;
108 field = mesh->FirstChildElement(
"EDGE");
110 ASSERTL0(field,
"Unable to find EDGE tag in file.");
113 field->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
115 if(IsCompressed.size())
117 ASSERTL0(boost::iequals(IsCompressed,
119 "Compressed formats do not match. Expected :"
121 +
" but got " + std::string(IsCompressed));
124 TiXmlNode* edgeChild = field->FirstChild();
125 ASSERTL0(edgeChild,
"Unable to extract the data from "
126 "the compressed edge tag.");
129 if (edgeChild->Type() == TiXmlNode::TINYXML_TEXT)
131 edgeStr += edgeChild->ToText()->ValueStr();
134 std::vector<LibUtilities::MeshEdge> edgeData;
138 for(
int i = 0; i < edgeData.size(); ++i)
140 indx = edgeData[i].id;
166 TiXmlElement *edge = field->FirstChildElement(
"E");
179 int err = edge->QueryIntAttribute(
"ID",&indx);
180 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read edge attribute ID.");
182 TiXmlNode *child = edge->FirstChild();
184 if (child->Type() == TiXmlNode::TINYXML_TEXT)
186 edgeStr += child->ToText()->ValueStr();
190 int vertex1, vertex2;
191 std::istringstream edgeDataStrm(edgeStr.c_str());
195 while (!edgeDataStrm.fail())
197 edgeDataStrm >> vertex1 >> vertex2;
203 if (!edgeDataStrm.fail())
214 edge->SetGlobalID(indx);
219 edge->SetGlobalID(indx);
231 edge = edge->NextSiblingElement(
"E");
239 TiXmlHandle docHandle(&doc);
240 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
241 TiXmlElement* field = NULL;
244 field = mesh->FirstChildElement(
"ELEMENT");
246 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
254 TiXmlElement *element = field->FirstChildElement();
258 std::string elementType(element->ValueStr());
260 ASSERTL0(elementType ==
"Q" || elementType ==
"T",
261 (std::string(
"Unknown 2D element type: ") + elementType).c_str());
264 element->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
266 if(IsCompressed.size())
268 ASSERTL0(boost::iequals(IsCompressed,
270 "Compressed formats do not match. Expected :"
272 +
" but got " + std::string(IsCompressed));
275 TiXmlNode* faceChild = element->FirstChild();
276 ASSERTL0(faceChild,
"Unable to extract the data from "
277 "the compressed face tag.");
280 if (faceChild->Type() == TiXmlNode::TINYXML_TEXT)
282 faceStr += faceChild->ToText()->ValueStr();
286 if(elementType ==
"T")
288 std::vector<LibUtilities::MeshTri> faceData;
292 for(
int i = 0; i < faceData.size(); ++i)
294 indx = faceData[i].id;
319 indx, edges, edgeorient);
325 indx, edges, edgeorient,
328 trigeom->SetGlobalID(indx);
332 else if (elementType ==
"Q")
334 std::vector<LibUtilities::MeshQuad> faceData;
338 for(
int i = 0; i < faceData.size(); ++i)
340 indx = faceData[i].id;
365 indx, edges, edgeorient);
371 indx, edges, edgeorient,
374 quadgeom->SetGlobalID(indx);
383 int err = element->QueryIntAttribute(
"ID", &indx);
384 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
389 TiXmlNode* elementChild = element->FirstChild();
390 std::string elementStr;
393 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
395 elementStr += elementChild->ToText()->ValueStr();
397 elementChild = elementChild->NextSibling();
400 ASSERTL0(!elementStr.empty(),
"Unable to read element description body.");
403 if (elementType ==
"T")
406 int edge1, edge2, edge3;
407 std::istringstream elementDataStrm(elementStr.c_str());
411 elementDataStrm >> edge1;
412 elementDataStrm >> edge2;
413 elementDataStrm >> edge3;
415 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for TRIANGLE: ") + elementStr).c_str());
448 trigeom->SetGlobalID(indx);
457 else if (elementType ==
"Q")
460 int edge1, edge2, edge3, edge4;
461 std::istringstream elementDataStrm(elementStr.c_str());
465 elementDataStrm >> edge1;
466 elementDataStrm >> edge2;
467 elementDataStrm >> edge3;
468 elementDataStrm >> edge4;
470 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for QUAD: ") + elementStr).c_str());
501 quadgeom->SetGlobalID(indx);
513 element = element->NextSiblingElement();
519 TiXmlHandle docHandle(&doc);
522 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
523 TiXmlElement* field = NULL;
525 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
528 field = mesh->FirstChildElement(
"COMPOSITE");
530 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
532 int nextCompositeNumber = -1;
536 TiXmlElement *composite = field->FirstChildElement(
"C");
540 nextCompositeNumber++;
543 int err = composite->QueryIntAttribute(
"ID", &indx);
544 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
548 err = composite->QueryStringAttribute(
"LABEL", &labelstr);
549 if(err == TIXML_SUCCESS)
554 TiXmlNode* compositeChild = composite->FirstChild();
559 while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
561 compositeChild = compositeChild->NextSibling();
564 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
565 std::string compositeStr = compositeChild->ToText()->ValueStr();
569 std::istringstream compositeDataStrm(compositeStr.c_str());
574 std::string prevCompositeElementStr;
576 while (!compositeDataStrm.fail())
578 std::string compositeElementStr;
579 compositeDataStrm >> compositeElementStr;
581 if (!compositeDataStrm.fail())
591 if (compositeElementStr.length() > 0)
595 prevCompositeElementStr = compositeElementStr;
602 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
606 composite = composite->NextSiblingElement(
"C");
631 std::istringstream tokenStream(token);
632 std::istringstream prevTokenStream(prevToken);
639 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
640 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
642 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
644 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
645 std::vector<unsigned int> seqVector;
650 ASSERTL0(err, (std::string(
"Error reading composite elements: ") + indxStr).c_str());
652 prevTokenStream >> prevType;
655 bool validSequence = (prevToken.empty() ||
656 (type ==
'V' && prevType ==
'V') ||
657 (type ==
'E' && prevType ==
'E') ||
658 ((type ==
'T' || type ==
'Q') &&
659 (prevType ==
'T' || prevType ==
'Q')));
661 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
662 + type +
" and " + prevType +
".").c_str());
668 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
672 char errStr[16] =
"";
673 ::sprintf(errStr,
"%d", *seqIter);
685 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
689 char errStr[16] =
"";
690 ::sprintf(errStr,
"%d", *seqIter);
706 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
710 char errStr[16] =
"";
711 ::sprintf(errStr,
"%d", *seqIter);
726 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
730 char errStr[16] =
"";
731 ::sprintf(errStr,
"%d", *seqIter);
736 composite->push_back(
m_vertSet[*seqIter]);
757 if(!(Sedge = boost::dynamic_pointer_cast<SegGeom>(edge)))
759 ASSERTL0(
false,
"Dynamics cast failed");
781 for(
int d = 0; d <
m_domain.size(); ++d)
783 for (compIter =
m_domain[d].begin(); compIter !=
m_domain[d].end(); ++compIter)
785 for (geomIter = (compIter->second)->begin(); geomIter != (compIter->second)->end(); ++geomIter)
787 triGeomShPtr = boost::dynamic_pointer_cast<
TriGeom>(*geomIter);
788 quadGeomShPtr = boost::dynamic_pointer_cast<
QuadGeom>(*geomIter);
790 if (triGeomShPtr || quadGeomShPtr)
795 if ((edgeNum = triGeomShPtr->WhichEdge(edge)) > -1)
798 elementEdge->m_Element = triGeomShPtr;
799 elementEdge->m_EdgeIndx = edgeNum;
800 returnval->push_back(elementEdge);
803 else if (quadGeomShPtr)
805 if ((edgeNum = quadGeomShPtr->WhichEdge(edge)) > -1)
808 elementEdge->m_Element = quadGeomShPtr;
809 elementEdge->m_EdgeIndx = edgeNum;
810 returnval->push_back(elementEdge);
830 int edge_id = (*elements)[0]->m_EdgeIndx;
834 edge_id = (edge_id)? 1:0;
841 int nummodes = expansion->m_basisKeyVector[edge_id].GetNumModes();
842 int numpoints = expansion->m_basisKeyVector[edge_id].GetNumPoints();
847 switch(expansion->m_basisKeyVector[edge_id].GetBasisType())
851 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
861 ASSERTL0(
false,
"Unexpected points distribution");
875 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
885 ASSERTL0(
false,
"Unexpected points distribution");
899 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
915 ASSERTL0(
false,
"Unexpected points distribution");
929 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
938 ASSERTL0(
false,
"Unexpected points distribution");
951 ASSERTL0(
false,
"Unexpected basis distribution");
966 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)