45 #include <tinyxml/tinyxml.h>
49 namespace SpatialDomains
52 m_meshGraph(meshGraph)
63 TiXmlDocument doc(infilename);
64 bool loadOkay = doc.LoadFile();
66 ASSERTL0(loadOkay, (std::string(
"Unable to load file: ") + infilename).c_str());
74 TiXmlElement* master = NULL;
75 TiXmlElement* domain = NULL;
76 TiXmlElement* boundary = NULL;
78 master = doc.FirstChildElement(
"NEKTAR");
79 ASSERTL0(master,
"Unable to find NEKTAR tag in file");
81 domain = master->FirstChildElement(
"DOMAIN");
83 ASSERTL0(domain,
"Unable to find DOMAIN tag in file.");
85 TiXmlNode *node = domain->FirstChild();
86 std::string components(node->ValueStr());
87 std::istringstream domainStrm(components);
97 ASSERTL0(entry[0] ==
'C',
"Only composites are allowed in a definition of a domain.");
101 std::string::size_type indxBeg = entry.find_first_of(
'[') + 1;
102 std::string::size_type indxEnd = entry.find_last_of(
']') - 1;
104 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading DOMAIN definition:") + entry).c_str());
106 std::string indxStr = entry.substr(indxBeg, indxEnd - indxBeg + 1);
108 std::istringstream indexStrm(indxStr);
109 int indx1=-1, indx2=-1;
118 ASSERTL0(indx1 >= 0, (std::string(
"Error reading collection range: ") + indxStr).c_str());
121 std::string::size_type dashLoc=indxStr.find(
'-');
122 if (dashLoc != std::string::npos)
127 indexStrm.seekg(dashLoc+1);
130 ASSERTL0(indx1 < indx2 && indx2 >= 0,
131 (std::string(
"Error reading collection range: ") + indxStr).c_str());
134 for (
int i=indx1; i<=indx2; ++i)
143 boundary = master->FirstChildElement(
"BOUNDARY");
144 ASSERTL0(boundary,
"Unable to find BOUNDARY tag in file.");
146 TiXmlElement *bc = boundary->FirstChildElement();
151 std::string bcType(bc->ValueStr());
153 TiXmlNode *node = bc->FirstChild();
154 std::string components(node->ValueStr());
155 std::istringstream boundaryStrm(components);
162 const char* indx =
std::find(beginName, endName, bcType[0]);
165 ASSERTL0(indx != endName, (std::string(
"Unable to read boundary type tag: ") + bcType).c_str());
178 ASSERTL0(entry[0] ==
'C',
"Only composites are allowed in a definition of a boundary condition.");
182 std::string::size_type indxBeg = entry.find_first_of(
'[') + 1;
183 std::string::size_type indxEnd = entry.find_last_of(
']') - 1;
185 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading BOUNDARY definition:") + entry).c_str());
188 std::string indxStr = entry.substr(indxBeg, indxEnd - indxBeg + 1);
190 std::istringstream indexStrm(indxStr);
191 int indx1=-1, indx2=-1;
200 ASSERTL0(indx1 >= 0, (std::string(
"Error reading collection range: ") + indxStr).c_str());
202 std::string::size_type dashLoc=indxStr.find(
'-');
203 if (dashLoc != std::string::npos)
208 while(indexStrm.get() !=
'-');
211 ASSERTL0(indx1 < indx2 && indx2 >= 0,
212 (std::string(
"Error reading collection range: ") + indxStr).c_str());
215 for (
int i=indx1; i<=indx2; ++i)
218 boundary->m_BoundaryComposites.push_back(composite);
224 bc = bc->NextSiblingElement();