Nektar++
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Nektar::SpatialDomains::Domain Class Reference

#include <Domain.h>

Public Member Functions

 Domain (MeshGraph *meshGraph)
 
virtual ~Domain ()
 
void Read (std::string &infilename)
 
void Read (TiXmlDocument &doc)
 
void Write (std::string &outfilename)
 
CompositeVector GetDomain (void) const
 
BoundaryVector GetBoundaries (void) const
 
void SetFileName (const std::string &inString)
 

Protected Attributes

MeshGraphm_meshGraph
 
CompositeVector m_domain
 
BoundaryVector m_boundaries
 

Private Member Functions

 Domain ()
 

Detailed Description

Definition at line 79 of file Domain.h.

Constructor & Destructor Documentation

◆ Domain() [1/2]

Nektar::SpatialDomains::Domain::Domain ( MeshGraph meshGraph)

Definition at line 50 of file Domain.cpp.

50  :
51  m_meshGraph(meshGraph)
52  {
53  }

◆ ~Domain()

Nektar::SpatialDomains::Domain::~Domain ( )
virtual

Definition at line 55 of file Domain.cpp.

56  {
57  }

◆ Domain() [2/2]

Nektar::SpatialDomains::Domain::Domain ( )
inlineprivate

Definition at line 107 of file Domain.h.

107 { NEKERROR(ErrorUtil::efatal, "Must provide a meshgraph to create a Domain."); }; // Don't call this.
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209

References Nektar::ErrorUtil::efatal, and NEKERROR.

Member Function Documentation

◆ GetBoundaries()

BoundaryVector Nektar::SpatialDomains::Domain::GetBoundaries ( void  ) const
inline

Definition at line 92 of file Domain.h.

92 { return m_Boundaries; };

◆ GetDomain()

CompositeVector Nektar::SpatialDomains::Domain::GetDomain ( void  ) const
inline

Definition at line 91 of file Domain.h.

91 { return m_Domain; };

◆ Read() [1/2]

void Nektar::SpatialDomains::Domain::Read ( std::string &  infilename)

Definition at line 59 of file Domain.cpp.

60  {
61  SetFileName(infilename);
62  TiXmlDocument doc(infilename);
63  bool loadOkay = doc.LoadFile();
64 
65  ASSERTL0(loadOkay, (std::string("Unable to load file: ") + infilename).c_str());
66 
67  Read(doc);
68  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
void SetFileName(const std::string &inString)
Definition: Domain.h:94
void Read(std::string &infilename)
Definition: Domain.cpp:59

References ASSERTL0, and SetFileName().

◆ Read() [2/2]

void Nektar::SpatialDomains::Domain::Read ( TiXmlDocument &  doc)

Definition at line 71 of file Domain.cpp.

72  {
73  TiXmlElement* master = NULL; // Master tag within which all data is contained.
74  TiXmlElement* domain = NULL;
75  TiXmlElement* boundary = NULL;
76 
77  master = doc.FirstChildElement("NEKTAR");
78  ASSERTL0(master, "Unable to find NEKTAR tag in file");
79 
80  domain = master->FirstChildElement("DOMAIN");
81 
82  ASSERTL0(domain, "Unable to find DOMAIN tag in file.");
83 
84  TiXmlNode *node = domain->FirstChild();
85  std::string components(node->ValueStr());
86  std::istringstream domainStrm(components);
87  std::string entry;
88 
89  // May have multiple composites defined.
90  if(domainStrm)
91  {
92  domainStrm >> entry;
93 
94  if (entry.length())
95  {
96  ASSERTL0(entry[0] == 'C', "Only composites are allowed in a definition of a domain.");
97 
98  // Determine the index associated with the C. Allow range syntax.
99 
100  std::string::size_type indxBeg = entry.find_first_of('[') + 1;
101  std::string::size_type indxEnd = entry.find_last_of(']') - 1;
102 
103  ASSERTL0(indxBeg <= indxEnd, (std::string("Error reading DOMAIN definition:") + entry).c_str());
104 
105  std::string indxStr = entry.substr(indxBeg, indxEnd - indxBeg + 1);
106 
107  std::istringstream indexStrm(indxStr);
108  int indx1=-1, indx2=-1;
109  if (indexStrm)
110  {
111  // Should read either [a] where a is a nonnegative integer, or
112  // [a-b] where a and b are nonnegative integers, b>a.
113  // Easiest way to know is if a '-' is present we have the latter
114  // case.
115 
116  indexStrm >> indx1;
117  ASSERTL0(indx1 >= 0, (std::string("Error reading collection range: ") + indxStr).c_str());
118  indx2 = indx1;
119 
120  std::string::size_type dashLoc=indxStr.find('-');
121  if (dashLoc != std::string::npos)
122  {
123  // Skip up to and including the '-' character, then read
124  // the other index. We are safe in doing this because we
125  // already know it is there...somewhere.
126  indexStrm.seekg(dashLoc+1);
127  indexStrm >> indx2;
128 
129  ASSERTL0(indx1 < indx2 && indx2 >= 0,
130  (std::string("Error reading collection range: ") + indxStr).c_str());
131  }
132 
133  for (int i=indx1; i<=indx2; ++i)
134  {
135  Composite composite = m_meshGraph->GetComposite(i);
136  m_domain.push_back(composite);
137  }
138  }
139  }
140  }
141 
142  boundary = master->FirstChildElement("BOUNDARY");
143  ASSERTL0(boundary, "Unable to find BOUNDARY tag in file.");
144 
145  TiXmlElement *bc = boundary->FirstChildElement();
146 
147  // Boundary will have type and composite list.
148  while(bc)
149  {
150  std::string bcType(bc->ValueStr());
151 
152  TiXmlNode *node = bc->FirstChild();
153  std::string components(node->ValueStr());
154  std::istringstream boundaryStrm(components);
155  std::string entry;
156 
157  // Index of the tag letter into the type enum.
158  const char *beginName = BoundaryTypeNameMap;
159  // std::find needs the end to be one past the last element.
160  const char *endName = BoundaryTypeNameMap+eBoundaryTypeLastElement + 1;
161  const char* indx = std::find(beginName, endName, bcType[0]);
162 
163  // Not found if the index (ptr) is past the last element.
164  ASSERTL0(indx != endName, (std::string("Unable to read boundary type tag: ") + bcType).c_str());
165 
166  BoundarySharedPtr boundary(new BoundaryEntry);
167  boundary->m_BoundaryType = BoundaryType(indx - BoundaryTypeNameMap);
168  m_boundaries.push_back(boundary);
169 
170  // May have multiple composites defined.
171  if(boundaryStrm)
172  {
173  domainStrm >> entry;
174 
175  if (entry.length())
176  {
177  ASSERTL0(entry[0] == 'C', "Only composites are allowed in a definition of a boundary condition.");
178 
179  // Determine the index associated with the C. Allow range syntax.
180 
181  std::string::size_type indxBeg = entry.find_first_of('[') + 1;
182  std::string::size_type indxEnd = entry.find_last_of(']') - 1;
183 
184  ASSERTL0(indxBeg <= indxEnd, (std::string("Error reading BOUNDARY definition:") + entry).c_str());
185 
186  // Read between the brackets.
187  std::string indxStr = entry.substr(indxBeg, indxEnd - indxBeg + 1);
188 
189  std::istringstream indexStrm(indxStr);
190  int indx1=-1, indx2=-1;
191  if(indexStrm)
192  {
193  // Should read either [a] where a is a nonnegative integer, or
194  // [a-b] where a and b are nonnegative integers, b>a.
195  // Easiest way to know is if a '-' is present we have the latter
196  // case.
197 
198  indexStrm >> indx1;
199  ASSERTL0(indx1 >= 0, (std::string("Error reading collection range: ") + indxStr).c_str());
200 
201  std::string::size_type dashLoc=indxStr.find('-');
202  if (dashLoc != std::string::npos)
203  {
204  // Skip up to and including the '-' character, then read
205  // the other index. We are safe in doing this because we
206  // already know it is there...somewhere.
207  while(indexStrm.get() != '-');
208  indexStrm >> indx2;
209 
210  ASSERTL0(indx1 < indx2 && indx2 >= 0,
211  (std::string("Error reading collection range: ") + indxStr).c_str());
212  }
213 
214  for (int i=indx1; i<=indx2; ++i)
215  {
216  Composite composite = m_meshGraph->GetComposite(i);
217  boundary->m_BoundaryComposites.push_back(composite);
218  }
219  }
220  }
221  }
222 
223  bc = bc->NextSiblingElement();
224  }
225  }
BoundaryVector m_boundaries
Definition: Domain.h:104
CompositeVector m_domain
Definition: Domain.h:103
CompositeSharedPtr GetComposite(int whichComposite)
Definition: MeshGraph.h:240
std::shared_ptr< BoundaryEntry > BoundarySharedPtr
Definition: Domain.h:75
const char BoundaryTypeNameMap[]
Definition: Domain.h:60
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:362

References ASSERTL0, Nektar::SpatialDomains::BoundaryTypeNameMap, Nektar::SpatialDomains::eBoundaryTypeLastElement, Nektar::StdRegions::find(), Nektar::SpatialDomains::MeshGraph::GetComposite(), m_boundaries, m_domain, and m_meshGraph.

◆ SetFileName()

void Nektar::SpatialDomains::Domain::SetFileName ( const std::string &  inString)
inline

Definition at line 94 of file Domain.h.

95  {
96  m_FileName = inString;
97  };

Referenced by Read().

◆ Write()

void Nektar::SpatialDomains::Domain::Write ( std::string &  outfilename)

Definition at line 227 of file Domain.cpp.

228  {
229  }

Member Data Documentation

◆ m_boundaries

BoundaryVector Nektar::SpatialDomains::Domain::m_boundaries
protected

Definition at line 104 of file Domain.h.

Referenced by Read().

◆ m_domain

CompositeVector Nektar::SpatialDomains::Domain::m_domain
protected

Definition at line 103 of file Domain.h.

Referenced by Read().

◆ m_meshGraph

MeshGraph* Nektar::SpatialDomains::Domain::m_meshGraph
protected

Definition at line 102 of file Domain.h.

Referenced by Read().