43 namespace SpatialDomains
46 : m_meshGraph(meshGraph),
68 ASSERTL0(conditions,
"Unable to find CONDITIONS tag in file.");
70 TiXmlElement *boundaryRegions = conditions->FirstChildElement(
"BOUNDARYREGIONS");
92 TiXmlElement *boundaryRegions = conditions->FirstChildElement(
"BOUNDARYREGIONS");
93 ASSERTL0(boundaryRegions,
"Unable to find BOUNDARYREGIONS block.");
96 TiXmlElement *boundaryRegionsElement = boundaryRegions->FirstChildElement(
"B");
98 while (boundaryRegionsElement)
103 int err = boundaryRegionsElement->QueryIntAttribute(
"ID", &indx);
104 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
106 TiXmlNode* boundaryRegionChild = boundaryRegionsElement->FirstChild();
111 while(boundaryRegionChild && boundaryRegionChild->Type() != TiXmlNode::TINYXML_TEXT)
113 boundaryRegionChild = boundaryRegionChild->NextSibling();
116 ASSERTL0(boundaryRegionChild,
"Unable to read variable definition body.");
117 std::string boundaryRegionStr = boundaryRegionChild->ToText()->ValueStr();
119 std::string::size_type indxBeg = boundaryRegionStr.find_first_of(
'[') + 1;
120 std::string::size_type indxEnd = boundaryRegionStr.find_last_of(
']') - 1;
122 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading boundary region definition:") + boundaryRegionStr).c_str());
124 std::string indxStr = boundaryRegionStr.substr(indxBeg, indxEnd - indxBeg + 1);
126 if (!indxStr.empty())
132 "Boundary region "+indxStr+
" defined more than "
135 m_meshGraph->GetCompositeList(indxStr, *boundaryRegion);
139 boundaryRegionsElement = boundaryRegionsElement->NextSiblingElement(
"B");
156 TiXmlElement *boundaryConditionsElement = conditions->FirstChildElement(
"BOUNDARYCONDITIONS");
157 ASSERTL0(boundaryConditionsElement,
"Boundary conditions must be specified.");
159 TiXmlElement *regionElement = boundaryConditionsElement->FirstChildElement(
"REGION");
162 while (regionElement)
166 int boundaryRegionID;
167 int err = regionElement->QueryIntAttribute(
"REF", &boundaryRegionID);
168 ASSERTL0(err == TIXML_SUCCESS,
"Error reading boundary region reference.");
171 "Boundary region '" + boost::lexical_cast<std::string>(boundaryRegionID)
172 +
"' appears multiple times.");
175 std::string boundaryRegionIDStr;
176 std::ostringstream boundaryRegionIDStrm(boundaryRegionIDStr);
177 boundaryRegionIDStrm << boundaryRegionID;
180 "Boundary region " + boost::lexical_cast<
181 string>(boundaryRegionID)+
" not found");
183 TiXmlElement *conditionElement = regionElement->FirstChildElement();
184 std::vector<std::string> vars =
m_session->GetVariables();
186 while (conditionElement)
189 std::string conditionType = conditionElement->Value();
190 std::string attrData;
191 bool isTimeDependent =
false;
194 TiXmlAttribute *attr = conditionElement->FirstAttribute();
197 std::string attrName;
199 attrData = conditionElement->Attribute(
"VAR");
201 if (!attrData.empty())
203 iter =
std::find(vars.begin(), vars.end(), attrData);
205 (std::string(
"Cannot find variable: ")
206 + attrData).c_str());
209 if (conditionType ==
"N")
211 if (attrData.empty())
215 varIter != vars.end(); ++varIter)
218 (*boundaryConditions)[*varIter] = neumannCondition;
228 std::string equation, userDefined, filename;
233 attrName = attr->Name();
235 if (attrName==
"USERDEFINEDTYPE")
238 attrData = attr->Value();
240 "USERDEFINEDTYPE attribute must have associated value.");
242 m_session->SubstituteExpressions(attrData);
244 userDefined = attrData;
245 isTimeDependent = boost::iequals(attrData,
"TimeDependent");
247 else if(attrName==
"VALUE")
249 attrData = attr->Value();
251 "VALUE attribute must be specified.");
253 m_session->SubstituteExpressions(attrData);
257 else if(attrName==
"FILE")
259 attrData = attr->Value();
260 ASSERTL0(!attrData.empty(),
"FILE attribute must be specified.");
262 m_session->SubstituteExpressions(attrData);
269 (std::string(
"Unknown boundary condition attribute: ") + attrName).c_str());
275 neumannCondition->SetIsTimeDependent(isTimeDependent);
276 (*boundaryConditions)[*iter] = neumannCondition;
282 (*boundaryConditions)[*iter] = neumannCondition;
286 else if (conditionType ==
"D")
288 if (attrData.empty())
292 varIter != vars.end(); ++varIter)
295 (*boundaryConditions)[*varIter] = dirichletCondition;
305 std::string equation, userDefined, filename;
309 attrName = attr->Name();
311 if (attrName==
"USERDEFINEDTYPE") {
314 attrData = attr->Value();
315 ASSERTL0(!attrData.empty(),
"USERDEFINEDTYPE attribute must have associated value.");
317 m_session->SubstituteExpressions(attrData);
319 userDefined = attrData;
320 isTimeDependent = boost::iequals(attrData,
"TimeDependent");
322 else if(attrName==
"VALUE")
324 attrData = attr->Value();
325 ASSERTL0(!attrData.empty(),
"VALUE attribute must have associated value.");
327 m_session->SubstituteExpressions(attrData);
331 else if(attrName==
"FILE")
333 attrData = attr->Value();
334 ASSERTL0(!attrData.empty(),
"FILE attribute must be specified.");
336 m_session->SubstituteExpressions(attrData);
343 (std::string(
"Unknown boundary condition attribute: ") + attrName).c_str());
349 dirichletCondition->SetIsTimeDependent(isTimeDependent);
350 (*boundaryConditions)[*iter] = dirichletCondition;
356 (*boundaryConditions)[*iter] = dirichletCondition;
360 else if (conditionType ==
"R")
362 if (attrData.empty())
366 varIter != vars.end(); ++varIter)
369 (*boundaryConditions)[*varIter] = robinCondition;
381 std::string attrName1;
382 std::string attrData1;
383 std::string equation1, equation2, userDefined;
384 std::string filename;
388 attrName1 = attr->Name();
390 if (attrName1==
"USERDEFINEDTYPE") {
393 attrData1 = attr->Value();
394 ASSERTL0(!attrData1.empty(),
"USERDEFINEDTYPE attribute must have associated value.");
396 m_session->SubstituteExpressions(attrData1);
397 userDefined = attrData1;
398 isTimeDependent = boost::iequals(attrData,
"TimeDependent");
400 else if(attrName1 ==
"VALUE"){
402 attrData1 = attr->Value();
403 ASSERTL0(!attrData1.empty(),
"VALUE attributes must have associated values.");
405 m_session->SubstituteExpressions(attrData1);
407 equation1 = attrData1;
410 ASSERTL0(attr,
"Unable to read PRIMCOEFF attribute.");
412 attrName1= attr->Name();
413 ASSERTL0(attrName1 ==
"PRIMCOEFF", (std::string(
"Unknown attribute: ") + attrName1).c_str());
415 attrData1 = attr->Value();
416 ASSERTL0(!attrData1.empty(),
"PRIMCOEFF attributes must have associated values.");
418 m_session->SubstituteExpressions(attrData1);
420 equation2 = attrData1;
423 else if(attrName1==
"FILE")
425 attrData1 = attr->Value();
426 ASSERTL0(!attrData1.empty(),
"FILE attribute must be specified.");
428 m_session->SubstituteExpressions(attrData1);
430 filename = attrData1;
434 ASSERTL0(
false, (std::string(
"Unknown boundary condition attribute: ") + attrName1).c_str());
441 (*boundaryConditions)[*iter] = robinCondition;
447 robinCondition->SetIsTimeDependent(isTimeDependent);
448 (*boundaryConditions)[*iter] = robinCondition;
452 else if (conditionType ==
"P")
454 if (attrData.empty())
460 attrName = attr->Name();
462 ASSERTL0(attrName ==
"VALUE", (std::string(
"Unknown attribute: ") + attrName).c_str());
464 attrData = attr->Value();
465 ASSERTL0(!attrData.empty(),
"VALUE attribute must have associated value.");
467 int beg = attrData.find_first_of(
"[");
468 int end = attrData.find_first_of(
"]");
469 std::string periodicBndRegionIndexStr = attrData.substr(beg+1,end-beg-1);
470 ASSERTL0(beg < end, (std::string(
"Error reading periodic boundary region definition for boundary region: ")
471 + boundaryRegionIDStrm.str()).c_str());
473 vector<unsigned int> periodicBndRegionIndex;
476 ASSERTL0(parseGood && (periodicBndRegionIndex.size()==1), (std::string(
"Unable to read periodic boundary condition for boundary region: ")
477 + boundaryRegionIDStrm.str()).c_str());
482 varIter != vars.end(); ++varIter)
484 (*boundaryConditions)[*varIter] = periodicCondition;
489 ASSERTL0(
false,
"Periodic boundary conditions should be explicitely defined");
500 attrName = attr->Name();
502 ASSERTL0(attrName ==
"VALUE", (std::string(
"Unknown attribute: ") + attrName).c_str());
504 attrData = attr->Value();
505 ASSERTL0(!attrData.empty(),
"VALUE attribute must have associated value.");
507 int beg = attrData.find_first_of(
"[");
508 int end = attrData.find_first_of(
"]");
509 std::string periodicBndRegionIndexStr = attrData.substr(beg+1,end-beg-1);
510 ASSERTL0(beg < end, (std::string(
"Error reading periodic boundary region definition for boundary region: ") + boundaryRegionIDStrm.str()).c_str());
512 vector<unsigned int> periodicBndRegionIndex;
515 ASSERTL0(parseGood && (periodicBndRegionIndex.size()==1), (std::string(
"Unable to read periodic boundary condition for boundary region: ") + boundaryRegionIDStrm.str()).c_str());
518 (*boundaryConditions)[*iter] = periodicCondition;
522 ASSERTL0(
false,
"Periodic boundary conditions should be explicitely defined");
526 else if (conditionType ==
"C")
531 conditionElement = conditionElement->NextSiblingElement();
535 regionElement = regionElement->NextSiblingElement(
"REGION");
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
BoundaryRegionCollection m_boundaryRegions
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void ReadBoundaryRegions(TiXmlElement *regions)
void Read(TiXmlElement *conditions)
Read segments (and general MeshGraph) given TiXmlDocument.
boost::shared_ptr< BoundaryConditionMap > BoundaryConditionMapShPtr
LibUtilities::SessionReaderSharedPtr m_session
BoundaryConditionCollection m_boundaryConditions
~BoundaryConditions(void)
MeshGraphSharedPtr m_meshGraph
The mesh graph to use for referencing geometry info.
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
boost::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
void ReadBoundaryConditions(TiXmlElement *conditions)
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
boost::shared_ptr< BoundaryRegion > BoundaryRegionShPtr