46 namespace SpatialDomains
49 MeshGraph1D::MeshGraph1D()
68 TiXmlDocument doc(infilename);
70 bool loadOkay = doc.LoadFile();
71 std::stringstream errstr;
72 errstr <<
"Unable to load file: " << infilename <<
"\n";
73 errstr << doc.ErrorDesc() <<
" (Line " << doc.ErrorRow()
74 <<
", Column " << doc.ErrorCol() <<
")";
85 TiXmlHandle docHandle(&doc);
87 TiXmlElement* mesh = NULL;
90 mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
92 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;
108 field = mesh->FirstChildElement(
"ELEMENT");
110 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
115 TiXmlElement *segment = field->FirstChildElement(
"S");
121 segment->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
123 if(IsCompressed.size())
125 ASSERTL0(boost::iequals(IsCompressed,
127 "Compressed formats do not match. Expected :"
129 +
" but got " + std::string(IsCompressed));
132 TiXmlNode* child = segment->FirstChild();
133 ASSERTL0(child,
"Unable to extract the data from "
134 "the compressed face tag.");
137 if (child->Type() == TiXmlNode::TINYXML_TEXT)
139 str += child->ToText()->ValueStr();
144 std::vector<LibUtilities::MeshEdge> data;
148 for(
int i = 0; i < data.size(); ++i)
163 seg->SetGlobalID(indx);
169 vertices, it->second);
170 seg->SetGlobalID(indx);
172 seg->SetGlobalID(indx);
180 int err = segment->QueryIntAttribute(
"ID", &indx);
181 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
183 TiXmlNode* elementChild = segment->FirstChild();
184 while(elementChild && elementChild->Type() != TiXmlNode::TINYXML_TEXT)
186 elementChild = elementChild->NextSibling();
189 ASSERTL0(elementChild,
"Unable to read element description body.");
190 std::string elementStr = elementChild->ToText()->ValueStr();
194 int vertex1, vertex2;
195 std::istringstream elementDataStrm(elementStr.c_str());
199 elementDataStrm >> vertex1;
200 elementDataStrm >> vertex2;
202 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for SEGMENT: ") + elementStr).c_str());
211 seg->SetGlobalID(indx);
216 seg->SetGlobalID(indx);
218 seg->SetGlobalID(indx);
224 (std::string(
"Unable to read element data for segment: ") + elementStr).c_str());
228 segment = segment->NextSiblingElement(
"S");
234 TiXmlHandle docHandle(&doc);
237 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
238 TiXmlElement* field = NULL;
240 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
243 field = mesh->FirstChildElement(
"COMPOSITE");
245 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
247 TiXmlElement *node = field->FirstChildElement(
"C");
250 int nextCompositeNumber = -1;
257 nextCompositeNumber++;
260 int err = node->QueryIntAttribute(
"ID", &indx);
261 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
264 TiXmlNode* compositeChild = node->FirstChild();
269 while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
271 compositeChild = compositeChild->NextSibling();
274 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
275 std::string compositeStr = compositeChild->ToText()->ValueStr();
279 std::istringstream compositeDataStrm(compositeStr.c_str());
284 std::string prevCompositeElementStr;
286 while (!compositeDataStrm.fail())
288 std::string compositeElementStr;
289 compositeDataStrm >> compositeElementStr;
291 if (!compositeDataStrm.fail())
301 if (compositeElementStr.length() > 0)
305 prevCompositeElementStr = compositeElementStr;
312 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
316 node = node->NextSiblingElement(
"C");
319 ASSERTL0(nextCompositeNumber >= 0,
"At least one composite must be specified.");
332 std::istringstream tokenStream(token);
333 std::istringstream prevTokenStream(prevToken);
340 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
341 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
343 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
345 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
347 typedef vector<unsigned int> SeqVectorType;
348 SeqVectorType seqVector;
355 prevTokenStream >> prevType;
358 bool validSequence = (prevToken.empty() ||
359 (type ==
'V' && prevType ==
'V') ||
360 (type ==
'S' && prevType ==
'S'));
362 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
363 + type +
" and " + prevType +
".").c_str());
372 char errStr[16] =
"";
373 ::sprintf(errStr,
"%d", *iter);
388 char errStr[16] =
"";
389 ::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)