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

#include <Domain.h>

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

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

Constructor & Destructor Documentation

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

Definition at line 51 of file Domain.cpp.

51  :
52  m_meshGraph(meshGraph)
53  {
54  }
Nektar::SpatialDomains::Domain::~Domain ( )
virtual

Definition at line 56 of file Domain.cpp.

57  {
58  }
Nektar::SpatialDomains::Domain::Domain ( )
inlineprivate

Definition at line 110 of file Domain.h.

References ErrorUtil::efatal, and NEKERROR.

110 { 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 mod...
Definition: ErrorUtil.hpp:158

Member Function Documentation

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

Definition at line 95 of file Domain.h.

95 { return m_Boundaries; };
CompositeVector Nektar::SpatialDomains::Domain::GetDomain ( void  ) const
inline

Definition at line 94 of file Domain.h.

94 { return m_Domain; };
void Nektar::SpatialDomains::Domain::Read ( std::string &  infilename)

Definition at line 60 of file Domain.cpp.

References ASSERTL0, and SetFileName().

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

Definition at line 72 of file Domain.cpp.

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

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

Definition at line 97 of file Domain.h.

Referenced by Read().

98  {
99  m_FileName = inString;
100  };
void Nektar::SpatialDomains::Domain::Write ( std::string &  outfilename)

Definition at line 228 of file Domain.cpp.

229  {
230  }

Member Data Documentation

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

Definition at line 107 of file Domain.h.

Referenced by Read().

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

Definition at line 106 of file Domain.h.

Referenced by Read().

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

Definition at line 100 of file Domain.h.

Referenced by Read().