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 74 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  : m_meshGraph(meshGraph)
51 {
52 }

◆ ~Domain()

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

Definition at line 54 of file Domain.cpp.

55 {
56 }

◆ Domain() [2/2]

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

Definition at line 107 of file Domain.h.

108  {
110  "Must provide a meshgraph to create a Domain.");
111  }; // 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 90 of file Domain.h.

91  {
92  return m_Boundaries;
93  };

◆ GetDomain()

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

Definition at line 86 of file Domain.h.

87  {
88  return m_Domain;
89  };

◆ Read() [1/2]

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

Definition at line 58 of file Domain.cpp.

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

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

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 95 of file Domain.h.

96  {
97  m_FileName = inString;
98  };

Referenced by Read().

◆ Write()

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

Definition at line 254 of file Domain.cpp.

255 {
256 }

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().