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.");
100 TiXmlHandle docHandle(&doc);
101 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
102 TiXmlElement* field = NULL;
106 field = mesh->FirstChildElement(
"EDGE");
108 ASSERTL0(field,
"Unable to find EDGE tag in file.");
111 field->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
113 if(IsCompressed.size())
115 ASSERTL0(boost::iequals(IsCompressed,
117 "Compressed formats do not match. Expected :"
119 +
" but got " + std::string(IsCompressed));
122 TiXmlNode* edgeChild = field->FirstChild();
123 ASSERTL0(edgeChild,
"Unable to extract the data from "
124 "the compressed edge tag.");
127 if (edgeChild->Type() == TiXmlNode::TINYXML_TEXT)
129 edgeStr += edgeChild->ToText()->ValueStr();
132 std::vector<LibUtilities::MeshEdge> edgeData;
136 for(
int i = 0; i < edgeData.size(); ++i)
138 indx = edgeData[i].id;
164 TiXmlElement *edge = field->FirstChildElement(
"E");
177 int err = edge->QueryIntAttribute(
"ID",&indx);
178 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read edge attribute ID.");
180 TiXmlNode *child = edge->FirstChild();
182 if (child->Type() == TiXmlNode::TINYXML_TEXT)
184 edgeStr += child->ToText()->ValueStr();
188 int vertex1, vertex2;
189 std::istringstream edgeDataStrm(edgeStr.c_str());
193 while (!edgeDataStrm.fail())
195 edgeDataStrm >> vertex1 >> vertex2;
201 if (!edgeDataStrm.fail())
212 edge->SetGlobalID(indx);
217 edge->SetGlobalID(indx);
229 edge = edge->NextSiblingElement(
"E");
237 TiXmlHandle docHandle(&doc);
238 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
239 TiXmlElement* field = NULL;
242 field = mesh->FirstChildElement(
"ELEMENT");
244 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
252 TiXmlElement *element = field->FirstChildElement();
256 std::string elementType(element->ValueStr());
258 ASSERTL0(elementType ==
"Q" || elementType ==
"T",
259 (std::string(
"Unknown 2D element type: ") + elementType).c_str());
262 element->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
264 if(IsCompressed.size())
266 ASSERTL0(boost::iequals(IsCompressed,
268 "Compressed formats do not match. Expected :"
270 +
" but got " + std::string(IsCompressed));
273 TiXmlNode* faceChild = element->FirstChild();
274 ASSERTL0(faceChild,
"Unable to extract the data from "
275 "the compressed face tag.");
278 if (faceChild->Type() == TiXmlNode::TINYXML_TEXT)
280 faceStr += faceChild->ToText()->ValueStr();
284 if(elementType ==
"T")
286 std::vector<LibUtilities::MeshTri> faceData;
290 for(
int i = 0; i < faceData.size(); ++i)
292 indx = faceData[i].id;
317 indx, edges, edgeorient);
323 indx, edges, edgeorient,
326 trigeom->SetGlobalID(indx);
330 else if (elementType ==
"Q")
332 std::vector<LibUtilities::MeshQuad> faceData;
336 for(
int i = 0; i < faceData.size(); ++i)
338 indx = faceData[i].id;
363 indx, edges, edgeorient);
369 indx, edges, edgeorient,
372 quadgeom->SetGlobalID(indx);
381 int err = element->QueryIntAttribute(
"ID", &indx);
382 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
387 TiXmlNode* elementChild = element->FirstChild();
388 std::string elementStr;
391 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
393 elementStr += elementChild->ToText()->ValueStr();
395 elementChild = elementChild->NextSibling();
398 ASSERTL0(!elementStr.empty(),
"Unable to read element description body.");
401 if (elementType ==
"T")
404 int edge1, edge2, edge3;
405 std::istringstream elementDataStrm(elementStr.c_str());
409 elementDataStrm >> edge1;
410 elementDataStrm >> edge2;
411 elementDataStrm >> edge3;
413 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for TRIANGLE: ") + elementStr).c_str());
446 trigeom->SetGlobalID(indx);
455 else if (elementType ==
"Q")
458 int edge1, edge2, edge3, edge4;
459 std::istringstream elementDataStrm(elementStr.c_str());
463 elementDataStrm >> edge1;
464 elementDataStrm >> edge2;
465 elementDataStrm >> edge3;
466 elementDataStrm >> edge4;
468 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for QUAD: ") + elementStr).c_str());
499 quadgeom->SetGlobalID(indx);
511 element = element->NextSiblingElement();
517 TiXmlHandle docHandle(&doc);
520 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
521 TiXmlElement* field = NULL;
523 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
526 field = mesh->FirstChildElement(
"COMPOSITE");
528 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
530 int nextCompositeNumber = -1;
534 TiXmlElement *composite = field->FirstChildElement(
"C");
538 nextCompositeNumber++;
541 int err = composite->QueryIntAttribute(
"ID", &indx);
542 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
546 err = composite->QueryStringAttribute(
"LABEL", &labelstr);
547 if(err == TIXML_SUCCESS)
552 TiXmlNode* compositeChild = composite->FirstChild();
557 while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
559 compositeChild = compositeChild->NextSibling();
562 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
563 std::string compositeStr = compositeChild->ToText()->ValueStr();
567 std::istringstream compositeDataStrm(compositeStr.c_str());
572 std::string prevCompositeElementStr;
574 while (!compositeDataStrm.fail())
576 std::string compositeElementStr;
577 compositeDataStrm >> compositeElementStr;
579 if (!compositeDataStrm.fail())
589 if (compositeElementStr.length() > 0)
593 prevCompositeElementStr = compositeElementStr;
600 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
604 composite = composite->NextSiblingElement(
"C");
629 std::istringstream tokenStream(token);
630 std::istringstream prevTokenStream(prevToken);
637 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
638 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
640 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
642 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
643 std::vector<unsigned int> seqVector;
648 ASSERTL0(err, (std::string(
"Error reading composite elements: ") + indxStr).c_str());
650 prevTokenStream >> prevType;
653 bool validSequence = (prevToken.empty() ||
654 (type ==
'V' && prevType ==
'V') ||
655 (type ==
'E' && prevType ==
'E') ||
656 ((type ==
'T' || type ==
'Q') &&
657 (prevType ==
'T' || prevType ==
'Q')));
659 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
660 + type +
" and " + prevType +
".").c_str());
666 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
670 char errStr[16] =
"";
671 ::sprintf(errStr,
"%d", *seqIter);
683 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
687 char errStr[16] =
"";
688 ::sprintf(errStr,
"%d", *seqIter);
704 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
708 char errStr[16] =
"";
709 ::sprintf(errStr,
"%d", *seqIter);
724 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
728 char errStr[16] =
"";
729 ::sprintf(errStr,
"%d", *seqIter);
734 composite->push_back(
m_vertSet[*seqIter]);
755 if(!(Sedge = boost::dynamic_pointer_cast<SegGeom>(edge)))
757 ASSERTL0(
false,
"Dynamics cast failed");
779 for(
int d = 0; d <
m_domain.size(); ++d)
781 for (compIter =
m_domain[d].begin(); compIter !=
m_domain[d].end(); ++compIter)
783 for (geomIter = (compIter->second)->begin(); geomIter != (compIter->second)->end(); ++geomIter)
785 triGeomShPtr = boost::dynamic_pointer_cast<
TriGeom>(*geomIter);
786 quadGeomShPtr = boost::dynamic_pointer_cast<
QuadGeom>(*geomIter);
788 if (triGeomShPtr || quadGeomShPtr)
793 if ((edgeNum = triGeomShPtr->WhichEdge(edge)) > -1)
796 elementEdge->m_Element = triGeomShPtr;
797 elementEdge->m_EdgeIndx = edgeNum;
798 returnval->push_back(elementEdge);
801 else if (quadGeomShPtr)
803 if ((edgeNum = quadGeomShPtr->WhichEdge(edge)) > -1)
806 elementEdge->m_Element = quadGeomShPtr;
807 elementEdge->m_EdgeIndx = edgeNum;
808 returnval->push_back(elementEdge);
828 int edge_id = (*elements)[0]->m_EdgeIndx;
832 edge_id = (edge_id)? 1:0;
839 int nummodes = expansion->m_basisKeyVector[edge_id].GetNumModes();
840 int numpoints = expansion->m_basisKeyVector[edge_id].GetNumPoints();
845 switch(expansion->m_basisKeyVector[edge_id].GetBasisType())
849 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
859 ASSERTL0(
false,
"Unexpected points distribution");
873 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
883 ASSERTL0(
false,
"Unexpected points distribution");
897 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
913 ASSERTL0(
false,
"Unexpected points distribution");
927 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
936 ASSERTL0(
false,
"Unexpected points distribution");
949 ASSERTL0(
false,
"Unexpected basis distribution");
964 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)
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.
map< int, string > m_compositesLabels
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)