44 #include <tinyxml/tinyxml.h> 48 namespace SpatialDomains
51 m_meshGraph(meshGraph)
62 TiXmlDocument doc(infilename);
63 bool loadOkay = doc.LoadFile();
65 ASSERTL0(loadOkay, (std::string(
"Unable to load file: ") + infilename).c_str());
73 TiXmlElement* master = NULL;
74 TiXmlElement* domain = NULL;
75 TiXmlElement* boundary = NULL;
77 master = doc.FirstChildElement(
"NEKTAR");
78 ASSERTL0(master,
"Unable to find NEKTAR tag in file");
80 domain = master->FirstChildElement(
"DOMAIN");
82 ASSERTL0(domain,
"Unable to find DOMAIN tag in file.");
84 TiXmlNode *node = domain->FirstChild();
85 std::string components(node->ValueStr());
86 std::istringstream domainStrm(components);
96 ASSERTL0(entry[0] ==
'C',
"Only composites are allowed in a definition of a domain.");
100 std::string::size_type indxBeg = entry.find_first_of(
'[') + 1;
101 std::string::size_type indxEnd = entry.find_last_of(
']') - 1;
103 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading DOMAIN definition:") + entry).c_str());
105 std::string indxStr = entry.substr(indxBeg, indxEnd - indxBeg + 1);
107 std::istringstream indexStrm(indxStr);
108 int indx1=-1, indx2=-1;
117 ASSERTL0(indx1 >= 0, (std::string(
"Error reading collection range: ") + indxStr).c_str());
120 std::string::size_type dashLoc=indxStr.find(
'-');
121 if (dashLoc != std::string::npos)
126 indexStrm.seekg(dashLoc+1);
129 ASSERTL0(indx1 < indx2 && indx2 >= 0,
130 (std::string(
"Error reading collection range: ") + indxStr).c_str());
133 for (
int i=indx1; i<=indx2; ++i)
142 boundary = master->FirstChildElement(
"BOUNDARY");
143 ASSERTL0(boundary,
"Unable to find BOUNDARY tag in file.");
145 TiXmlElement *bc = boundary->FirstChildElement();
150 std::string bcType(bc->ValueStr());
152 TiXmlNode *node = bc->FirstChild();
153 std::string components(node->ValueStr());
154 std::istringstream boundaryStrm(components);
161 const char* indx =
std::find(beginName, endName, bcType[0]);
164 ASSERTL0(indx != endName, (std::string(
"Unable to read boundary type tag: ") + bcType).c_str());
177 ASSERTL0(entry[0] ==
'C',
"Only composites are allowed in a definition of a boundary condition.");
181 std::string::size_type indxBeg = entry.find_first_of(
'[') + 1;
182 std::string::size_type indxEnd = entry.find_last_of(
']') - 1;
184 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading BOUNDARY definition:") + entry).c_str());
187 std::string indxStr = entry.substr(indxBeg, indxEnd - indxBeg + 1);
189 std::istringstream indexStrm(indxStr);
190 int indx1=-1, indx2=-1;
199 ASSERTL0(indx1 >= 0, (std::string(
"Error reading collection range: ") + indxStr).c_str());
201 std::string::size_type dashLoc=indxStr.find(
'-');
202 if (dashLoc != std::string::npos)
207 while(indexStrm.get() !=
'-');
210 ASSERTL0(indx1 < indx2 && indx2 >= 0,
211 (std::string(
"Error reading collection range: ") + indxStr).c_str());
214 for (
int i=indx1; i<=indx2; ++i)
217 boundary->m_BoundaryComposites.push_back(composite);
223 bc = bc->NextSiblingElement();
void SetFileName(const std::string &inString)
#define ASSERTL0(condition, msg)
const char BoundaryTypeNameMap[]
CompositeSharedPtr GetComposite(int whichComposite)
void Write(std::string &outfilename)
std::shared_ptr< BoundaryEntry > BoundarySharedPtr
BoundaryVector m_boundaries
void Read(std::string &infilename)
Base class for a spectral/hp element mesh.
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)