45 namespace SpatialDomains
48 : m_meshGraph(meshGraph),
70 ASSERTL0(conditions,
"Unable to find CONDITIONS tag in file.");
72 TiXmlElement *boundaryRegions = conditions->FirstChildElement(
"BOUNDARYREGIONS");
94 TiXmlElement *boundaryRegions = conditions->FirstChildElement(
"BOUNDARYREGIONS");
95 ASSERTL0(boundaryRegions,
"Unable to find BOUNDARYREGIONS block.");
98 TiXmlElement *boundaryRegionsElement = boundaryRegions->FirstChildElement(
"B");
100 while (boundaryRegionsElement)
105 int err = boundaryRegionsElement->QueryIntAttribute(
"ID", &indx);
106 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
108 TiXmlNode* boundaryRegionChild = boundaryRegionsElement->FirstChild();
113 while(boundaryRegionChild && boundaryRegionChild->Type() != TiXmlNode::TINYXML_TEXT)
115 boundaryRegionChild = boundaryRegionChild->NextSibling();
118 ASSERTL0(boundaryRegionChild,
"Unable to read variable definition body.");
119 std::string boundaryRegionStr = boundaryRegionChild->ToText()->ValueStr();
121 std::string::size_type indxBeg = boundaryRegionStr.find_first_of(
'[') + 1;
122 std::string::size_type indxEnd = boundaryRegionStr.find_last_of(
']') - 1;
124 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading boundary region definition:") + boundaryRegionStr).c_str());
126 std::string indxStr = boundaryRegionStr.substr(indxBeg, indxEnd - indxBeg + 1);
128 if (!indxStr.empty())
134 "Boundary region "+indxStr+
" defined more than "
137 m_meshGraph->GetCompositeList(indxStr, *boundaryRegion);
141 boundaryRegionsElement = boundaryRegionsElement->NextSiblingElement(
"B");
158 TiXmlElement *boundaryConditionsElement = conditions->FirstChildElement(
"BOUNDARYCONDITIONS");
159 ASSERTL0(boundaryConditionsElement,
"Boundary conditions must be specified.");
161 TiXmlElement *regionElement = boundaryConditionsElement->FirstChildElement(
"REGION");
164 while (regionElement)
168 int boundaryRegionID;
169 int err = regionElement->QueryIntAttribute(
"REF", &boundaryRegionID);
170 ASSERTL0(err == TIXML_SUCCESS,
"Error reading boundary region reference.");
173 "Boundary region '" + boost::lexical_cast<std::string>(boundaryRegionID)
174 +
"' appears multiple times.");
177 std::string boundaryRegionIDStr;
178 std::ostringstream boundaryRegionIDStrm(boundaryRegionIDStr);
179 boundaryRegionIDStrm << boundaryRegionID;
182 "Boundary region " + boost::lexical_cast<
183 string>(boundaryRegionID)+
" not found");
185 TiXmlElement *conditionElement = regionElement->FirstChildElement();
186 std::vector<std::string> vars =
m_session->GetVariables();
188 while (conditionElement)
191 std::string conditionType = conditionElement->Value();
192 std::string attrData;
193 bool isTimeDependent =
false;
196 TiXmlAttribute *attr = conditionElement->FirstAttribute();
199 std::string attrName;
201 attrData = conditionElement->Attribute(
"VAR");
203 if (!attrData.empty())
205 iter =
std::find(vars.begin(), vars.end(), attrData);
207 (std::string(
"Cannot find variable: ")
208 + attrData).c_str());
211 if (conditionType ==
"N")
213 if (attrData.empty())
217 varIter != vars.end(); ++varIter)
220 (*boundaryConditions)[*varIter] = neumannCondition;
230 std::string equation, userDefined, filename;
235 attrName = attr->Name();
237 if (attrName==
"USERDEFINEDTYPE")
240 attrData = attr->Value();
242 "USERDEFINEDTYPE attribute must have associated value.");
244 m_session->SubstituteExpressions(attrData);
246 userDefined = attrData;
247 isTimeDependent = boost::iequals(attrData,
"TimeDependent");
249 else if(attrName==
"VALUE")
251 attrData = attr->Value();
253 "VALUE attribute must be specified.");
255 m_session->SubstituteExpressions(attrData);
259 else if(attrName==
"FILE")
261 attrData = attr->Value();
262 ASSERTL0(!attrData.empty(),
"FILE attribute must be specified.");
264 m_session->SubstituteExpressions(attrData);
271 (std::string(
"Unknown boundary condition attribute: ") + attrName).c_str());
277 neumannCondition->SetIsTimeDependent(isTimeDependent);
278 (*boundaryConditions)[*iter] = neumannCondition;
284 (*boundaryConditions)[*iter] = neumannCondition;
288 else if (conditionType ==
"D")
290 if (attrData.empty())
294 varIter != vars.end(); ++varIter)
297 (*boundaryConditions)[*varIter] = dirichletCondition;
307 std::string equation, userDefined, filename;
311 attrName = attr->Name();
313 if (attrName==
"USERDEFINEDTYPE") {
316 attrData = attr->Value();
317 ASSERTL0(!attrData.empty(),
"USERDEFINEDTYPE attribute must have associated value.");
319 m_session->SubstituteExpressions(attrData);
321 userDefined = attrData;
322 isTimeDependent = boost::iequals(attrData,
"TimeDependent");
324 else if(attrName==
"VALUE")
326 attrData = attr->Value();
327 ASSERTL0(!attrData.empty(),
"VALUE attribute must have associated value.");
329 m_session->SubstituteExpressions(attrData);
333 else if(attrName==
"FILE")
335 attrData = attr->Value();
336 ASSERTL0(!attrData.empty(),
"FILE attribute must be specified.");
338 m_session->SubstituteExpressions(attrData);
345 (std::string(
"Unknown boundary condition attribute: ") + attrName).c_str());
351 dirichletCondition->SetIsTimeDependent(isTimeDependent);
352 (*boundaryConditions)[*iter] = dirichletCondition;
358 (*boundaryConditions)[*iter] = dirichletCondition;
362 else if (conditionType ==
"R")
364 if (attrData.empty())
368 varIter != vars.end(); ++varIter)
371 (*boundaryConditions)[*varIter] = robinCondition;
383 std::string attrName1;
384 std::string attrData1;
385 std::string equation1, equation2, userDefined;
386 std::string filename;
388 bool primcoeffset =
false;
392 attrName1 = attr->Name();
394 if (attrName1==
"USERDEFINEDTYPE") {
397 attrData1 = attr->Value();
398 ASSERTL0(!attrData1.empty(),
"USERDEFINEDTYPE attribute must have associated value.");
400 m_session->SubstituteExpressions(attrData1);
401 userDefined = attrData1;
402 isTimeDependent = boost::iequals(attrData,
"TimeDependent");
404 else if(attrName1 ==
"VALUE"){
406 attrData1 = attr->Value();
407 ASSERTL0(!attrData1.empty(),
"VALUE attributes must have associated values.");
409 m_session->SubstituteExpressions(attrData1);
411 equation1 = attrData1;
413 else if(attrName1 ==
"PRIMCOEFF")
416 attrData1 = attr->Value();
417 ASSERTL0(!attrData1.empty(),
"PRIMCOEFF attributes must have associated values.");
419 m_session->SubstituteExpressions(attrData1);
421 equation2 = attrData1;
425 else if(attrName1==
"FILE")
427 attrData1 = attr->Value();
428 ASSERTL0(!attrData1.empty(),
"FILE attribute must be specified.");
430 m_session->SubstituteExpressions(attrData1);
432 filename = attrData1;
436 ASSERTL0(
false, (std::string(
"Unknown boundary condition attribute: ") + attrName1).c_str());
441 if(primcoeffset ==
false)
443 ASSERTL0(
false,
"PRIMCOEFF must be specified in a Robin boundary condition");
447 (*boundaryConditions)[*iter] = robinCondition;
453 robinCondition->SetIsTimeDependent(isTimeDependent);
454 (*boundaryConditions)[*iter] = robinCondition;
458 else if (conditionType ==
"P")
460 if (attrData.empty())
466 attrName = attr->Name();
468 ASSERTL0(attrName ==
"VALUE", (std::string(
"Unknown attribute: ") + attrName).c_str());
470 attrData = attr->Value();
471 ASSERTL0(!attrData.empty(),
"VALUE attribute must have associated value.");
473 int beg = attrData.find_first_of(
"[");
474 int end = attrData.find_first_of(
"]");
475 std::string periodicBndRegionIndexStr = attrData.substr(beg+1,end-beg-1);
476 ASSERTL0(beg < end, (std::string(
"Error reading periodic boundary region definition for boundary region: ")
477 + boundaryRegionIDStrm.str()).c_str());
479 vector<unsigned int> periodicBndRegionIndex;
482 ASSERTL0(parseGood && (periodicBndRegionIndex.size()==1), (std::string(
"Unable to read periodic boundary condition for boundary region: ")
483 + boundaryRegionIDStrm.str()).c_str());
488 varIter != vars.end(); ++varIter)
490 (*boundaryConditions)[*varIter] = periodicCondition;
495 ASSERTL0(
false,
"Periodic boundary conditions should be explicitely defined");
506 attrName = attr->Name();
508 ASSERTL0(attrName ==
"VALUE", (std::string(
"Unknown attribute: ") + attrName).c_str());
510 attrData = attr->Value();
511 ASSERTL0(!attrData.empty(),
"VALUE attribute must have associated value.");
513 int beg = attrData.find_first_of(
"[");
514 int end = attrData.find_first_of(
"]");
515 std::string periodicBndRegionIndexStr = attrData.substr(beg+1,end-beg-1);
516 ASSERTL0(beg < end, (std::string(
"Error reading periodic boundary region definition for boundary region: ") + boundaryRegionIDStrm.str()).c_str());
518 vector<unsigned int> periodicBndRegionIndex;
521 ASSERTL0(parseGood && (periodicBndRegionIndex.size()==1), (std::string(
"Unable to read periodic boundary condition for boundary region: ") + boundaryRegionIDStrm.str()).c_str());
524 (*boundaryConditions)[*iter] = periodicCondition;
528 ASSERTL0(
false,
"Periodic boundary conditions should be explicitely defined");
532 else if (conditionType ==
"C")
537 conditionElement = conditionElement->NextSiblingElement();
541 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