Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Nektar::SpatialDomains::BoundaryConditions Class Reference

#include <Conditions.h>

Collaboration diagram for Nektar::SpatialDomains::BoundaryConditions:
Collaboration graph
[legend]

Public Member Functions

 BoundaryConditions (const LibUtilities::SessionReaderSharedPtr &pSession, const MeshGraphSharedPtr &meshGraph)
 
 BoundaryConditions (void)
 
 ~BoundaryConditions (void)
 
const BoundaryRegionCollectionGetBoundaryRegions (void) const
 
void AddBoundaryRegions (const int regionID, BoundaryRegionShPtr &bRegion)
 
const BoundaryConditionCollectionGetBoundaryConditions (void) const
 
void AddBoundaryConditions (const int regionID, BoundaryConditionMapShPtr &bCond)
 
const std::string GetVariable (unsigned int indx)
 

Protected Attributes

MeshGraphSharedPtr m_meshGraph
 The mesh graph to use for referencing geometry info. More...
 
LibUtilities::SessionReaderSharedPtr m_session
 
BoundaryRegionCollection m_boundaryRegions
 
BoundaryConditionCollection m_boundaryConditions
 
std::map< int,
LibUtilities::CommSharedPtr
m_boundaryCommunicators
 

Private Member Functions

void Read (TiXmlElement *conditions)
 Read segments (and general MeshGraph) given TiXmlDocument. More...
 
void ReadBoundaryRegions (TiXmlElement *regions)
 
void ReadBoundaryConditions (TiXmlElement *conditions)
 
void CreateBoundaryComms ()
 

Detailed Description

Definition at line 230 of file Conditions.h.

Constructor & Destructor Documentation

Nektar::SpatialDomains::BoundaryConditions::BoundaryConditions ( const LibUtilities::SessionReaderSharedPtr pSession,
const MeshGraphSharedPtr meshGraph 
)

Constructor - collective on the session's communicator.

Definition at line 50 of file Conditions.cpp.

References m_session, and Read().

52  :
53  m_meshGraph(meshGraph), m_session(pSession)
54 
55  {
56  Read(m_session->GetElement("Nektar/Conditions"));
57  }
void Read(TiXmlElement *conditions)
Read segments (and general MeshGraph) given TiXmlDocument.
Definition: Conditions.cpp:205
LibUtilities::SessionReaderSharedPtr m_session
Definition: Conditions.h:267
MeshGraphSharedPtr m_meshGraph
The mesh graph to use for referencing geometry info.
Definition: Conditions.h:266
Nektar::SpatialDomains::BoundaryConditions::BoundaryConditions ( void  )

Definition at line 59 of file Conditions.cpp.

60  {
61  }
Nektar::SpatialDomains::BoundaryConditions::~BoundaryConditions ( void  )

Definition at line 63 of file Conditions.cpp.

64  {
65  }

Member Function Documentation

void Nektar::SpatialDomains::BoundaryConditions::AddBoundaryConditions ( const int  regionID,
BoundaryConditionMapShPtr bCond 
)
inline

Definition at line 254 of file Conditions.h.

References m_boundaryConditions.

255  {
256  m_boundaryConditions[regionID] = bCond;
257  }
BoundaryConditionCollection m_boundaryConditions
Definition: Conditions.h:270
void Nektar::SpatialDomains::BoundaryConditions::AddBoundaryRegions ( const int  regionID,
BoundaryRegionShPtr bRegion 
)
inline

Definition at line 243 of file Conditions.h.

References m_boundaryRegions.

244  {
245  m_boundaryRegions[regionID] = bRegion;
246  }
BoundaryRegionCollection m_boundaryRegions
Definition: Conditions.h:269
void Nektar::SpatialDomains::BoundaryConditions::CreateBoundaryComms ( )
private

Create a new communicator for each boundary region. Collective on the session's communicator.

Definition at line 175 of file Conditions.cpp.

References ASSERTL0, Nektar::iterator, m_boundaryCommunicators, m_boundaryRegions, m_session, and Nektar::SpatialDomains::ShareAllBoundaryIDs().

Referenced by Read().

176  {
177  LibUtilities::CommSharedPtr comm = m_session->GetComm();
178 
179  std::set<int> allids = ShareAllBoundaryIDs(m_boundaryRegions, comm);
180 
181  std::set<int>::const_iterator it = allids.begin(), end =
182  allids.end();
183  for (; it != end; ++it)
184  {
186  m_boundaryRegions.find(*it);
187  int this_rank_participates = (reg_it != m_boundaryRegions.end());
188  LibUtilities::CommSharedPtr comm_region = comm->CommCreateIf(
189  this_rank_participates);
190 
191  ASSERTL0(bool(comm_region) == bool(this_rank_participates),
192  "Rank should be in communicator but wasn't or is in "
193  "communicator but shouldn't be.");
194 
195  if (this_rank_participates)
196  {
197  m_boundaryCommunicators[reg_it->first] = comm_region;
198  }
199  }
200  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
BoundaryRegionCollection m_boundaryRegions
Definition: Conditions.h:269
std::map< int, LibUtilities::CommSharedPtr > m_boundaryCommunicators
Definition: Conditions.h:271
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
std::set< int > ShareAllBoundaryIDs(const BoundaryRegionCollection &boundaryRegions, LibUtilities::CommSharedPtr comm)
Definition: Conditions.cpp:90
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
LibUtilities::SessionReaderSharedPtr m_session
Definition: Conditions.h:267
const BoundaryConditionCollection& Nektar::SpatialDomains::BoundaryConditions::GetBoundaryConditions ( void  ) const
inline
const BoundaryRegionCollection& Nektar::SpatialDomains::BoundaryConditions::GetBoundaryRegions ( void  ) const
inline
const std::string Nektar::SpatialDomains::BoundaryConditions::GetVariable ( unsigned int  indx)
inline

Definition at line 259 of file Conditions.h.

References m_session.

260  {
261  return m_session->GetVariable(indx);
262  }
LibUtilities::SessionReaderSharedPtr m_session
Definition: Conditions.h:267
void Nektar::SpatialDomains::BoundaryConditions::Read ( TiXmlElement *  conditions)
private

Read segments (and general MeshGraph) given TiXmlDocument.

Collective on the session's communicator.

Definition at line 205 of file Conditions.cpp.

References ASSERTL0, CreateBoundaryComms(), ReadBoundaryConditions(), and ReadBoundaryRegions().

Referenced by BoundaryConditions().

206  {
207  ASSERTL0(conditions, "Unable to find CONDITIONS tag in file.");
208 
209  TiXmlElement *boundaryRegions = conditions->FirstChildElement(
210  "BOUNDARYREGIONS");
211 
212  if (boundaryRegions)
213  {
214  ReadBoundaryRegions(conditions);
216  ReadBoundaryConditions(conditions);
217  }
218  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
void ReadBoundaryRegions(TiXmlElement *regions)
Definition: Conditions.cpp:223
void ReadBoundaryConditions(TiXmlElement *conditions)
Definition: Conditions.cpp:301
void Nektar::SpatialDomains::BoundaryConditions::ReadBoundaryConditions ( TiXmlElement *  conditions)
private

Definition at line 301 of file Conditions.cpp.

References ASSERTL0, Nektar::StdRegions::find(), Nektar::ParseUtils::GenerateSeqVector(), Nektar::iterator, m_boundaryCommunicators, m_boundaryConditions, m_boundaryRegions, and m_session.

Referenced by Read().

303  {
304  // Protect against multiple reads.
305  if (m_boundaryConditions.size() != 0)
306  {
307  return;
308  }
309 
310  // Read REGION tags
311  TiXmlElement *boundaryConditionsElement =
312  conditions->FirstChildElement("BOUNDARYCONDITIONS");
313  ASSERTL0(boundaryConditionsElement,
314  "Boundary conditions must be specified.");
315 
316  TiXmlElement *regionElement =
317  boundaryConditionsElement->FirstChildElement("REGION");
318 
319  // Read R (Robin), D (Dirichlet), N (Neumann), P (Periodic) C(Cauchy) tags
320  while (regionElement)
321  {
322  BoundaryConditionMapShPtr boundaryConditions = MemoryManager<
323  BoundaryConditionMap>::AllocateSharedPtr();
324 
325  int boundaryRegionID;
326  int err = regionElement->QueryIntAttribute("REF",
327  &boundaryRegionID);
328  ASSERTL0(err == TIXML_SUCCESS,
329  "Error reading boundary region reference.");
330 
331  ASSERTL0(m_boundaryConditions.count(boundaryRegionID) == 0,
332  "Boundary region '" + boost::lexical_cast < std::string
333  > (boundaryRegionID)
334  + "' appears multiple times.");
335 
336  // Find the boundary region corresponding to this ID.
337  std::string boundaryRegionIDStr;
338  std::ostringstream boundaryRegionIDStrm(boundaryRegionIDStr);
339  boundaryRegionIDStrm << boundaryRegionID;
340 
341  ASSERTL0(m_boundaryRegions.count(boundaryRegionID) == 1,
342  "Boundary region " + boost::lexical_cast < string
343  > (boundaryRegionID) + " not found");
344 
345  // Find the communicator that belongs to this ID
346  LibUtilities::CommSharedPtr boundaryRegionComm =
347  m_boundaryCommunicators[boundaryRegionID];
348 
349  TiXmlElement *conditionElement =
350  regionElement->FirstChildElement();
351  std::vector < std::string > vars = m_session->GetVariables();
352 
353  while (conditionElement)
354  {
355  // Check type.
356  std::string conditionType = conditionElement->Value();
357  std::string attrData;
358  bool isTimeDependent = false;
359 
360  // All have var specified, or else all variables are zero.
361  TiXmlAttribute *attr = conditionElement->FirstAttribute();
362 
364  std::string attrName;
365 
366  attrData = conditionElement->Attribute("VAR");
367 
368  if (!attrData.empty())
369  {
370  iter = std::find(vars.begin(), vars.end(), attrData);
371  ASSERTL0(iter != vars.end(),
372  (std::string("Cannot find variable: ")
373  + attrData).c_str());
374  }
375 
376  if (conditionType == "N")
377  {
378  if (attrData.empty())
379  {
380  // All variables are Neumann and are set to zero.
382  vars.begin(); varIter != vars.end();
383  ++varIter)
384  {
385  BoundaryConditionShPtr neumannCondition(
386  MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(
387  m_session, "00.0"));
388  (*boundaryConditions)[*varIter] =
389  neumannCondition;
390  }
391  }
392  else
393  {
394  // Use the iterator from above, which must point to the variable.
395  attr = attr->Next();
396 
397  if (attr)
398  {
399  std::string equation, userDefined, filename;
400 
401  while (attr)
402  {
403 
404  attrName = attr->Name();
405 
406  if (attrName == "USERDEFINEDTYPE")
407  {
408  // Do stuff for the user defined attribute
409  attrData = attr->Value();
410  ASSERTL0(!attrData.empty(),
411  "USERDEFINEDTYPE attribute must have associated value.");
412 
413  // Suppose to go here?
414  m_session->SubstituteExpressions(
415  attrData);
416 
417  userDefined = attrData;
418  isTimeDependent = boost::iequals(attrData,"TimeDependent");
419  }
420  else if (attrName == "VALUE")
421  {
422  ASSERTL0(attrName == "VALUE",
423  (std::string(
424  "Unknown attribute: ")
425  + attrName).c_str());
426 
427  attrData = attr->Value();
428  ASSERTL0(!attrData.empty(),
429  "VALUE attribute must be specified.");
430 
431  m_session->SubstituteExpressions(
432  attrData);
433 
434  equation = attrData;
435  }
436  else if (attrName == "FILE")
437  {
438  ASSERTL0(attrName == "FILE",
439  (std::string(
440  "Unknown attribute: ")
441  + attrName).c_str());
442 
443  attrData = attr->Value();
444  ASSERTL0(!attrData.empty(),
445  "FILE attribute must be specified.");
446 
447  m_session->SubstituteExpressions(
448  attrData);
449 
450  filename = attrData;
451  }
452  else
453  {
454  ASSERTL0(false,
455  (std::string("Unknown boundary condition attribute: ") + attrName).c_str());
456  }
457  attr = attr->Next();
458  }
459 
460  BoundaryConditionShPtr neumannCondition(
461  MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(
462  m_session, equation,
463  userDefined, filename,
464  boundaryRegionComm));
465  neumannCondition->SetIsTimeDependent(isTimeDependent);
466  (*boundaryConditions)[*iter] = neumannCondition;
467  }
468  else
469  {
470  // This variable's condition is zero.
471  BoundaryConditionShPtr neumannCondition(
472  MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(
473  m_session, "0"));
474  (*boundaryConditions)[*iter] = neumannCondition;
475  }
476  }
477  }
478  else if (conditionType == "D")
479  {
480  if (attrData.empty())
481  {
482  // All variables are Dirichlet and are set to zero.
484  vars.begin(); varIter != vars.end();
485  ++varIter)
486  {
487  BoundaryConditionShPtr dirichletCondition(
488  MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(
489  m_session, "0"));
490  (*boundaryConditions)[*varIter] =
491  dirichletCondition;
492  }
493  }
494  else
495  {
496  // Use the iterator from above, which must point to the variable.
497  attr = attr->Next();
498 
499  if (attr)
500  {
501  std::string equation, userDefined, filename;
502 
503  while (attr)
504  {
505 
506  attrName = attr->Name();
507 
508  if (attrName == "USERDEFINEDTYPE")
509  {
510 
511  // Do stuff for the user defined attribute
512  attrData = attr->Value();
513  ASSERTL0(!attrData.empty(),
514  "USERDEFINEDTYPE attribute must have associated value.");
515 
516  m_session->SubstituteExpressions(
517  attrData);
518 
519  userDefined = attrData;
520  isTimeDependent = boost::iequals(attrData,"TimeDependent");
521  }
522  else if (attrName == "VALUE")
523  {
524  ASSERTL0(attrName == "VALUE",
525  (std::string(
526  "Unknown attribute: ")
527  + attrName).c_str());
528 
529  attrData = attr->Value();
530  ASSERTL0(!attrData.empty(),
531  "VALUE attribute must have associated value.");
532 
533  m_session->SubstituteExpressions(
534  attrData);
535 
536  equation = attrData;
537  }
538  else if (attrName == "FILE")
539  {
540  ASSERTL0(attrName == "FILE",
541  (std::string(
542  "Unknown attribute: ")
543  + attrName).c_str());
544 
545  attrData = attr->Value();
546  ASSERTL0(!attrData.empty(),
547  "FILE attribute must be specified.");
548 
549  m_session->SubstituteExpressions(
550  attrData);
551 
552  filename = attrData;
553  }
554  else
555  {
556  ASSERTL0(false,
557  (std::string("Unknown boundary condition attribute: ") + attrName).c_str());
558  }
559  attr = attr->Next();
560  }
561 
562  BoundaryConditionShPtr dirichletCondition(
563  MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(
564  m_session, equation,
565  userDefined, filename,
566  boundaryRegionComm));
567  dirichletCondition->SetIsTimeDependent(isTimeDependent);
568  (*boundaryConditions)[*iter] =
569  dirichletCondition;
570  }
571  else
572  {
573  // This variable's condition is zero.
574  BoundaryConditionShPtr dirichletCondition(
575  MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(
576  m_session, "0"));
577  (*boundaryConditions)[*iter] =
578  dirichletCondition;
579  }
580  }
581  }
582  else if (conditionType == "R") // Read du/dn + PRIMCOEFF u = VALUE
583  {
584  if (attrData.empty())
585  {
586  // All variables are Robin and are set to zero.
588  vars.begin(); varIter != vars.end();
589  ++varIter)
590  {
591  BoundaryConditionShPtr robinCondition(
592  MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(
593  m_session, "0", "0"));
594  (*boundaryConditions)[*varIter] =
595  robinCondition;
596  }
597  }
598  else
599  {
600  // Use the iterator from above, which must
601  // point to the variable. Read the A and
602  // B attributes.
603  attr = attr->Next();
604 
605  if (attr)
606  {
607  std::string attrName1;
608  std::string attrData1;
609  std::string equation1, equation2, userDefined;
610  std::string filename;
611 
612  bool primcoeffset = false;
613 
614  while(attr){
615 
616  attrName1 = attr->Name();
617 
618  if (attrName1=="USERDEFINEDTYPE") {
619 
620  // Do stuff for the user defined attribute
621  attrData1 = attr->Value();
622  ASSERTL0(!attrData1.empty(), "USERDEFINEDTYPE attribute must have associated value.");
623 
624  m_session->SubstituteExpressions(attrData1);
625  userDefined = attrData1;
626  isTimeDependent = boost::iequals(attrData,"TimeDependent");
627  }
628  else if(attrName1 == "VALUE"){
629 
630  attrData1 = attr->Value();
631  ASSERTL0(!attrData1.empty(), "VALUE attributes must have associated values.");
632 
633  m_session->SubstituteExpressions(attrData1);
634 
635  equation1 = attrData1;
636  }
637  else if(attrName1 == "PRIMCOEFF")
638  {
639 
640  attrData1 = attr->Value();
641  ASSERTL0(!attrData1.empty(), "PRIMCOEFF attributes must have associated values.");
642 
643  m_session->SubstituteExpressions(attrData1);
644 
645  equation2 = attrData1;
646 
647  primcoeffset = true;
648  }
649  else if(attrName1=="FILE")
650  {
651  attrData1 = attr->Value();
652  ASSERTL0(!attrData1.empty(), "FILE attribute must be specified.");
653 
654  m_session->SubstituteExpressions(attrData1);
655 
656  filename = attrData1;
657  }
658  else
659  {
660  ASSERTL0(false, (std::string("Unknown boundary condition attribute: ") + attrName1).c_str());
661 
662  }
663  attr = attr->Next();
664  }
665 
666  if(primcoeffset == false)
667  {
668  ASSERTL0(false,"PRIMCOEFF must be specified in a Robin boundary condition");
669  }
670  BoundaryConditionShPtr robinCondition(
671  MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(
672  m_session, equation1, equation2,
673  userDefined, filename,
674  boundaryRegionComm));
675  (*boundaryConditions)[*iter] = robinCondition;
676  }
677  else
678  {
679  // This variable's condition is zero.
680  BoundaryConditionShPtr robinCondition(
681  MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(
682  m_session, "0", "0"));
683  robinCondition->SetIsTimeDependent(isTimeDependent);
684  (*boundaryConditions)[*iter] = robinCondition;
685  }
686  }
687  }
688  else if (conditionType == "P")
689  {
690  if (attrData.empty())
691  {
692  attr = attr->Next();
693 
694  if (attr)
695  {
696  attrName = attr->Name();
697 
698  ASSERTL0(attrName == "VALUE",
699  (std::string("Unknown attribute: ")
700  + attrName).c_str());
701 
702  attrData = attr->Value();
703  ASSERTL0(!attrData.empty(),
704  "VALUE attribute must have associated value.");
705 
706  int beg = attrData.find_first_of("[");
707  int end = attrData.find_first_of("]");
708  std::string periodicBndRegionIndexStr =
709  attrData.substr(beg + 1, end - beg - 1);
710  ASSERTL0(beg < end,
711  (std::string(
712  "Error reading periodic boundary region definition for boundary region: ")
713  + boundaryRegionIDStrm.str()).c_str());
714 
715  vector<unsigned int> periodicBndRegionIndex;
716  bool parseGood = ParseUtils::GenerateSeqVector(
717  periodicBndRegionIndexStr.c_str(),
718  periodicBndRegionIndex);
719 
720  ASSERTL0(
721  parseGood
722  && (periodicBndRegionIndex.size()
723  == 1),
724  (std::string(
725  "Unable to read periodic boundary condition for boundary region: ")
726  + boundaryRegionIDStrm.str()).c_str());
727 
728  BoundaryConditionShPtr periodicCondition(
729  MemoryManager<PeriodicBoundaryCondition>::AllocateSharedPtr(
730  periodicBndRegionIndex[0]));
731 
733  vars.begin(); varIter != vars.end();
734  ++varIter)
735  {
736  (*boundaryConditions)[*varIter] =
737  periodicCondition;
738  }
739  }
740  else
741  {
742  ASSERTL0(false,
743  "Periodic boundary conditions should be explicitely defined");
744  }
745  }
746  else
747  {
748  // Use the iterator from above, which must point to the variable.
749  // Read the VALUE attribute. It is the next and only other attribute.
750  attr = attr->Next();
751 
752  if (attr)
753  {
754  attrName = attr->Name();
755 
756  ASSERTL0(attrName == "VALUE",
757  (std::string("Unknown attribute: ")
758  + attrName).c_str());
759 
760  attrData = attr->Value();
761  ASSERTL0(!attrData.empty(),
762  "VALUE attribute must have associated value.");
763 
764  int beg = attrData.find_first_of("[");
765  int end = attrData.find_first_of("]");
766  std::string periodicBndRegionIndexStr =
767  attrData.substr(beg + 1, end - beg - 1);
768  ASSERTL0(beg < end,
769  (std::string(
770  "Error reading periodic boundary "
771  "region definition for boundary "
772  "region: ")
773  + boundaryRegionIDStrm.str())
774  .c_str());
775 
776  vector<unsigned int> periodicBndRegionIndex;
777  bool parseGood = ParseUtils::GenerateSeqVector(
778  periodicBndRegionIndexStr.c_str(),
779  periodicBndRegionIndex);
780 
781  ASSERTL0(parseGood &&
782  periodicBndRegionIndex.size() == 1,
783  (std::string(
784  "Unable to read periodic boundary "
785  "condition for boundary region: "
786  + boundaryRegionIDStrm.str()))
787  .c_str());
788 
789  BoundaryConditionShPtr periodicCondition(
790  MemoryManager<PeriodicBoundaryCondition>::AllocateSharedPtr(
791  periodicBndRegionIndex[0]));
792  (*boundaryConditions)[*iter] =
793  periodicCondition;
794  }
795  else
796  {
797  ASSERTL0(false,
798  "Periodic boundary conditions should be explicitely defined");
799  }
800  }
801  }
802  else if (conditionType == "C")
803  {
804  ASSERTL0(false, "Cauchy type boundary conditions not "
805  "implemented.");
806  }
807 
808  conditionElement = conditionElement->NextSiblingElement();
809  }
810 
811  m_boundaryConditions[boundaryRegionID] = boundaryConditions;
812  regionElement = regionElement->NextSiblingElement("REGION");
813  }
814  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
BoundaryRegionCollection m_boundaryRegions
Definition: Conditions.h:269
std::map< int, LibUtilities::CommSharedPtr > m_boundaryCommunicators
Definition: Conditions.h:271
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
Definition: ParseUtils.hpp:79
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
std::map< std::string, BoundaryConditionShPtr > BoundaryConditionMap
Definition: Conditions.h:224
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< BoundaryConditionMap > BoundaryConditionMapShPtr
Definition: Conditions.h:225
LibUtilities::SessionReaderSharedPtr m_session
Definition: Conditions.h:267
BoundaryConditionCollection m_boundaryConditions
Definition: Conditions.h:270
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:316
boost::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
Definition: Conditions.h:219
void Nektar::SpatialDomains::BoundaryConditions::ReadBoundaryRegions ( TiXmlElement *  regions)
private

All elements are of the form: "<B ID="#"> ... </B>", with ? being the element type.

Definition at line 223 of file Conditions.cpp.

References ASSERTL0, m_boundaryRegions, and m_meshGraph.

Referenced by Read().

224  {
225  // ensure boundary regions only read once per class definition
226  if (m_boundaryRegions.size() != 0)
227  {
228  return;
229  }
230 
231  TiXmlElement *boundaryRegions = conditions->FirstChildElement(
232  "BOUNDARYREGIONS");
233  ASSERTL0(boundaryRegions, "Unable to find BOUNDARYREGIONS block.");
234 
235  // See if we have boundary regions defined.
236  TiXmlElement *boundaryRegionsElement =
237  boundaryRegions->FirstChildElement("B");
238 
239  while (boundaryRegionsElement)
240  {
241  /// All elements are of the form: "<B ID="#"> ... </B>", with
242  /// ? being the element type.
243  int indx;
244  int err = boundaryRegionsElement->QueryIntAttribute("ID",
245  &indx);
246  ASSERTL0(err == TIXML_SUCCESS, "Unable to read attribute ID.");
247 
248  TiXmlNode* boundaryRegionChild =
249  boundaryRegionsElement->FirstChild();
250  // This is primarily to skip comments that may be present.
251  // Comments appear as nodes just like elements.
252  // We are specifically looking for text in the body
253  // of the definition.
254  while (boundaryRegionChild
255  && boundaryRegionChild->Type()
256  != TiXmlNode::TINYXML_TEXT)
257  {
258  boundaryRegionChild = boundaryRegionChild->NextSibling();
259  }
260 
261  ASSERTL0(boundaryRegionChild,
262  "Unable to read variable definition body.");
263  std::string boundaryRegionStr =
264  boundaryRegionChild->ToText()->ValueStr();
265 
266  std::string::size_type indxBeg =
267  boundaryRegionStr.find_first_of('[') + 1;
268  std::string::size_type indxEnd = boundaryRegionStr.find_last_of(
269  ']') - 1;
270 
271  ASSERTL0(indxBeg <= indxEnd,
272  (std::string(
273  "Error reading boundary region definition:")
274  + boundaryRegionStr).c_str());
275 
276  std::string indxStr = boundaryRegionStr.substr(indxBeg,
277  indxEnd - indxBeg + 1);
278 
279  if (!indxStr.empty())
280  {
281  // Extract the composites from the string and return them in a list.
282  BoundaryRegionShPtr boundaryRegion(
283  MemoryManager<BoundaryRegion>::AllocateSharedPtr());
284 
285  ASSERTL0(m_boundaryRegions.count(indx) == 0,
286  "Boundary region " + indxStr + " defined more than "
287  "once!");
288 
289  m_meshGraph->GetCompositeList(indxStr, *boundaryRegion);
290  m_boundaryRegions[indx] = boundaryRegion;
291  }
292 
293  boundaryRegionsElement =
294  boundaryRegionsElement->NextSiblingElement("B");
295  }
296  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
BoundaryRegionCollection m_boundaryRegions
Definition: Conditions.h:269
MeshGraphSharedPtr m_meshGraph
The mesh graph to use for referencing geometry info.
Definition: Conditions.h:266
boost::shared_ptr< BoundaryRegion > BoundaryRegionShPtr
Definition: Conditions.h:215

Member Data Documentation

std::map<int, LibUtilities::CommSharedPtr> Nektar::SpatialDomains::BoundaryConditions::m_boundaryCommunicators
protected

Definition at line 271 of file Conditions.h.

Referenced by CreateBoundaryComms(), and ReadBoundaryConditions().

BoundaryConditionCollection Nektar::SpatialDomains::BoundaryConditions::m_boundaryConditions
protected
BoundaryRegionCollection Nektar::SpatialDomains::BoundaryConditions::m_boundaryRegions
protected
MeshGraphSharedPtr Nektar::SpatialDomains::BoundaryConditions::m_meshGraph
protected

The mesh graph to use for referencing geometry info.

Definition at line 266 of file Conditions.h.

Referenced by ReadBoundaryRegions().

LibUtilities::SessionReaderSharedPtr Nektar::SpatialDomains::BoundaryConditions::m_session
protected