45 namespace SpatialDomains
48 MeshGraph1D::MeshGraph1D()
67 TiXmlDocument doc(infilename);
69 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.");
102 TiXmlHandle docHandle(&doc);
103 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
104 TiXmlElement* field = NULL;
107 field = mesh->FirstChildElement(
"ELEMENT");
109 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
114 TiXmlElement *segment = field->FirstChildElement(
"S");
120 segment->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
122 if(IsCompressed.size())
124 ASSERTL0(boost::iequals(IsCompressed,
126 "Compressed formats do not match. Expected :"
128 +
" but got " + std::string(IsCompressed));
131 TiXmlNode* child = segment->FirstChild();
132 ASSERTL0(child,
"Unable to extract the data from "
133 "the compressed face tag.");
136 if (child->Type() == TiXmlNode::TINYXML_TEXT)
138 str += child->ToText()->ValueStr();
143 std::vector<LibUtilities::MeshEdge> data;
147 for(
int i = 0; i < data.size(); ++i)
162 seg->SetGlobalID(indx);
168 vertices, it->second);
169 seg->SetGlobalID(indx);
171 seg->SetGlobalID(indx);
179 int err = segment->QueryIntAttribute(
"ID", &indx);
180 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
182 TiXmlNode* elementChild = segment->FirstChild();
183 while(elementChild && elementChild->Type() != TiXmlNode::TINYXML_TEXT)
185 elementChild = elementChild->NextSibling();
188 ASSERTL0(elementChild,
"Unable to read element description body.");
189 std::string elementStr = elementChild->ToText()->ValueStr();
193 int vertex1, vertex2;
194 std::istringstream elementDataStrm(elementStr.c_str());
198 elementDataStrm >> vertex1;
199 elementDataStrm >> vertex2;
201 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for SEGMENT: ") + elementStr).c_str());
210 seg->SetGlobalID(indx);
215 seg->SetGlobalID(indx);
217 seg->SetGlobalID(indx);
223 (std::string(
"Unable to read element data for segment: ") + elementStr).c_str());
227 segment = segment->NextSiblingElement(
"S");
233 TiXmlHandle docHandle(&doc);
236 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
237 TiXmlElement* field = NULL;
239 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
242 field = mesh->FirstChildElement(
"COMPOSITE");
244 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
246 TiXmlElement *node = field->FirstChildElement(
"C");
249 int nextCompositeNumber = -1;
256 nextCompositeNumber++;
259 int err = node->QueryIntAttribute(
"ID", &indx);
260 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
263 TiXmlNode* compositeChild = node->FirstChild();
268 while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
270 compositeChild = compositeChild->NextSibling();
273 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
274 std::string compositeStr = compositeChild->ToText()->ValueStr();
278 std::istringstream compositeDataStrm(compositeStr.c_str());
283 std::string prevCompositeElementStr;
285 while (!compositeDataStrm.fail())
287 std::string compositeElementStr;
288 compositeDataStrm >> compositeElementStr;
290 if (!compositeDataStrm.fail())
300 if (compositeElementStr.length() > 0)
304 prevCompositeElementStr = compositeElementStr;
311 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
315 node = node->NextSiblingElement(
"C");
318 ASSERTL0(nextCompositeNumber >= 0,
"At least one composite must be specified.");
331 std::istringstream tokenStream(token);
332 std::istringstream prevTokenStream(prevToken);
339 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
340 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
342 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
344 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
346 typedef vector<unsigned int> SeqVectorType;
347 SeqVectorType seqVector;
354 prevTokenStream >> prevType;
357 bool validSequence = (prevToken.empty() ||
358 (type ==
'V' && prevType ==
'V') ||
359 (type ==
'S' && prevType ==
'S'));
361 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
362 + type +
" and " + prevType +
".").c_str());
371 char errStr[16] =
"";
372 ::sprintf(errStr,
"%d", *iter);
387 char errStr[16] =
"";
388 ::sprintf(errStr,
"%d", *iter);
#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 ResolveGeomRef(const std::string &prevToken, const std::string &token, Composite &composite)
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
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.
void ReadGeometry(const std::string &infilename)
Read will read the meshgraph vertices given a filename.
std::string GetCompressString(void)
boost::shared_ptr< SegGeom > SegGeomSharedPtr
boost::shared_ptr< DomainRange > DomainRangeShPtr
boost::shared_ptr< GeometryVector > Composite
void ReadElements(TiXmlDocument &doc)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
Base class for a spectral/hp element mesh.
void ReadDomain(TiXmlDocument &doc)
void ReadComposites(TiXmlDocument &doc)
void ReadExpansions(const std::string &infilename)
Read the expansions given the XML file path.
boost::shared_ptr< PointGeom > PointGeomSharedPtr
int ZlibDecodeFromBase64Str(std::string &in64, std::vector< T > &out)