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;
105 field = mesh->FirstChildElement(
"EDGE");
107 ASSERTL0(field,
"Unable to find EDGE tag in file.");
112 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;
150 if (!edgeDataStrm.fail())
161 edge->SetGlobalID(indx);
166 edge->SetGlobalID(indx);
178 edge = edge->NextSiblingElement(
"E");
186 TiXmlHandle docHandle(&doc);
187 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
188 TiXmlElement* field = NULL;
191 field = mesh->FirstChildElement(
"ELEMENT");
193 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
201 TiXmlElement *element = field->FirstChildElement();
205 std::string elementType(element->ValueStr());
207 ASSERTL0(elementType ==
"Q" || elementType ==
"T",
208 (std::string(
"Unknown 2D element type: ") + elementType).c_str());
212 int err = element->QueryIntAttribute(
"ID", &indx);
213 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
218 TiXmlNode* elementChild = element->FirstChild();
219 std::string elementStr;
222 if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
224 elementStr += elementChild->ToText()->ValueStr();
226 elementChild = elementChild->NextSibling();
229 ASSERTL0(!elementStr.empty(),
"Unable to read element description body.");
232 if (elementType ==
"T")
235 int edge1, edge2, edge3;
236 std::istringstream elementDataStrm(elementStr.c_str());
240 elementDataStrm >> edge1;
241 elementDataStrm >> edge2;
242 elementDataStrm >> edge3;
244 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for TRIANGLE: ") + elementStr).c_str());
277 trigeom->SetGlobalID(indx);
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 element data for QUAD: ") + elementStr).c_str());
330 quadgeom->SetGlobalID(indx);
342 element = element->NextSiblingElement();
348 TiXmlHandle docHandle(&doc);
351 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
352 TiXmlElement* field = NULL;
354 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
357 field = mesh->FirstChildElement(
"COMPOSITE");
359 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
361 int nextCompositeNumber = -1;
365 TiXmlElement *composite = field->FirstChildElement(
"C");
369 nextCompositeNumber++;
372 int err = composite->QueryIntAttribute(
"ID", &indx);
373 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
376 TiXmlNode* compositeChild = composite->FirstChild();
381 while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
383 compositeChild = compositeChild->NextSibling();
386 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
387 std::string compositeStr = compositeChild->ToText()->ValueStr();
391 std::istringstream compositeDataStrm(compositeStr.c_str());
396 std::string prevCompositeElementStr;
398 while (!compositeDataStrm.fail())
400 std::string compositeElementStr;
401 compositeDataStrm >> compositeElementStr;
403 if (!compositeDataStrm.fail())
413 if (compositeElementStr.length() > 0)
417 prevCompositeElementStr = compositeElementStr;
424 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
428 composite = composite->NextSiblingElement(
"C");
453 std::istringstream tokenStream(token);
454 std::istringstream prevTokenStream(prevToken);
461 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
462 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
464 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
466 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
467 std::vector<unsigned int> seqVector;
472 ASSERTL0(err, (std::string(
"Error reading composite elements: ") + indxStr).c_str());
474 prevTokenStream >> prevType;
477 bool validSequence = (prevToken.empty() ||
478 (type ==
'V' && prevType ==
'V') ||
479 (type ==
'E' && prevType ==
'E') ||
480 ((type ==
'T' || type ==
'Q') &&
481 (prevType ==
'T' || prevType ==
'Q')));
483 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
484 + type +
" and " + prevType +
".").c_str());
490 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
494 char errStr[16] =
"";
495 ::sprintf(errStr,
"%d", *seqIter);
507 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
511 char errStr[16] =
"";
512 ::sprintf(errStr,
"%d", *seqIter);
528 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
532 char errStr[16] =
"";
533 ::sprintf(errStr,
"%d", *seqIter);
548 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
552 char errStr[16] =
"";
553 ::sprintf(errStr,
"%d", *seqIter);
558 composite->push_back(
m_vertSet[*seqIter]);
579 if(!(Sedge = boost::dynamic_pointer_cast<SegGeom>(edge)))
581 ASSERTL0(
false,
"Dynamics cast failed");
603 for(
int d = 0; d <
m_domain.size(); ++d)
605 for (compIter =
m_domain[d].begin(); compIter !=
m_domain[d].end(); ++compIter)
607 for (geomIter = (compIter->second)->begin(); geomIter != (compIter->second)->end(); ++geomIter)
609 triGeomShPtr = boost::dynamic_pointer_cast<
TriGeom>(*geomIter);
610 quadGeomShPtr = boost::dynamic_pointer_cast<
QuadGeom>(*geomIter);
612 if (triGeomShPtr || quadGeomShPtr)
617 if ((edgeNum = triGeomShPtr->WhichEdge(edge)) > -1)
620 elementEdge->m_Element = triGeomShPtr;
621 elementEdge->m_EdgeIndx = edgeNum;
622 returnval->push_back(elementEdge);
625 else if (quadGeomShPtr)
627 if ((edgeNum = quadGeomShPtr->WhichEdge(edge)) > -1)
630 elementEdge->m_Element = quadGeomShPtr;
631 elementEdge->m_EdgeIndx = edgeNum;
632 returnval->push_back(elementEdge);
652 int edge_id = (*elements)[0]->m_EdgeIndx;
656 edge_id = (edge_id)? 1:0;
663 int nummodes = expansion->m_basisKeyVector[edge_id].GetNumModes();
664 int numpoints = expansion->m_basisKeyVector[edge_id].GetNumPoints();
669 switch(expansion->m_basisKeyVector[edge_id].GetBasisType())
673 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
683 ASSERTL0(
false,
"Unexpected points distribution");
697 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
707 ASSERTL0(
false,
"Unexpected points distribution");
721 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
737 ASSERTL0(
false,
"Unexpected points distribution");
751 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
760 ASSERTL0(
false,
"Unexpected points distribution");
773 ASSERTL0(
false,
"Unexpected basis distribution");
788 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::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
SegGeomSharedPtr GetSegGeom(int eID)