Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Conditions.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Conditions.h
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description:
33 //
34 //
35 ////////////////////////////////////////////////////////////////////////////////
36 #ifndef NEKTAR_SPATIALDOMAINS_BOUNDARYCONDITIONS_H
37 #define NEKTAR_SPATIALDOMAINS_BOUNDARYCONDITIONS_H
38 
39 #include <string>
40 #include <map>
41 
45 
46 
47 namespace Nektar
48 {
49  struct OneD;
50 
51  namespace SpatialDomains
52  {
54  {
60  };
61 
63  {
64  eI,
65  eMG,
88  };
89 
90  const char* const BndUserDefinedTypeMap[] =
91  {
92  "I",
93  "MG",
94  "High",
95  "HighOutflow",
96  "Wall_Forces",
97  "Wall",
98  "WallViscous",
99  "ArtificialVisc",
100  "Symmetry",
101  "RinglebFlow",
102  "TimeDependent",
103  "Radiation",
104  "IsentropicVortex",
105  "CalcBC",
106  "Qinflow",
107  "Terminal",
108  "Rterminal",
109  "CRterminal",
110  "RCRterminal",
111  "InflowCFS",
112  "OutflowCFS",
113  "RiemannInvariant",
114  "ExtrapOrder0",
115  "NoUserDefined"
116  };
117 
119  {
122  const std::string &userDefined = std::string("NoUserDefined")):
124  {
125  std::map<const std::string, BndUserDefinedType> known_type;
126  known_type["H"] = eHigh;
127  known_type["HOutflow"] = eHighOutflow;
128  known_type["I"] = eI;
129  known_type["MG"] = eMG;
130  known_type["Wall"] = eWall;
131  known_type["WallViscous"] = eWallViscous;
132  known_type["ArtificialVisc"] = eArtificialViscosity;
133  known_type["Q-inflow"] = eQinflow;
134  known_type["Terminal"] = eTerminal;
135  known_type["R-terminal"] = eRterminal;
136  known_type["CR-terminal"] = eCRterminal;
137  known_type["RCR-terminal"] = eRCRterminal;
138  known_type["CalcBC"] = eCalcBC;
139  known_type["RinglebFlow"] = eRinglebFlow;
140  known_type["Symmetry"] = eSymmetry;
141  known_type["TimeDependent"] = eTimeDependent;
142  known_type["Radiation"] = eRadiation;
143  known_type["IsentropicVortex"] = eIsentropicVortex;
144  known_type["RiemannInvariant"] = eRiemannInvariant;
145  known_type["ExtrapOrder0"] = eExtrapOrder0;
146  known_type["NoUserDefined"] = eNoUserDefined;
147 
148  std::map<const std::string, BndUserDefinedType>::
149  const_iterator it = known_type.find(userDefined);
150  if (it != known_type.end())
151  {
152  m_userDefined = it->second;
153  }
154  else
155  {
156  //ASSERTL0(false, std::string("Unknown boundary condition "
157  //"user defined type [") + userDefined + std::string("]"));
159  }
160  }
161 
163  {};
164 
166  {
168  }
169 
171  {
172  m_boundaryConditionType = boundaryType;
173  }
174 
176  {
177  m_userDefined = type;
178  }
179 
181  {
182  return m_userDefined;
183  }
184 
185  const std::string GetBndTypeAsString(BndUserDefinedType type)
186  {
187  return BndUserDefinedTypeMap[type];
188  }
189 
190  protected:
193  };
194 
195 
197  {
198 
200  const LibUtilities::SessionReaderSharedPtr &pSession,
201  const std::string& eqn,
202  const std::string& userDefined = std::string("NoUserDefined"),
203  const std::string& filename=std::string("")):
204  BoundaryConditionBase(eDirichlet, userDefined),
205  m_dirichletCondition(pSession, eqn),
206  m_filename(filename)
207  {
208  }
209 
211  std::string m_filename;
212  };
213 
215  {
217  const LibUtilities::SessionReaderSharedPtr &pSession,
218  const std::string& eqn,
219  const std::string& userDefined = std::string("NoUserDefined"),
220  const std::string& filename=std::string("")):
221  BoundaryConditionBase(eNeumann, userDefined),
222  m_neumannCondition(pSession, eqn),
223  m_filename(filename)
224  {
225  }
226 
228  std::string m_filename;
229  };
230 
232  {
234  const LibUtilities::SessionReaderSharedPtr &pSession,
235  const std::string &a,
236  const std::string &b,
237  const std::string &userDefined = std::string("NoUserDefined"),
238  const std::string& filename=std::string("")):
239  BoundaryConditionBase(eRobin, userDefined),
240  m_robinFunction(pSession, a),
241  m_robinPrimitiveCoeff(pSession, b),
242  m_filename(filename)
243  {
244  }
245  // \frac{\partial {u}}{\partial{n}} +
246  // m_robinPrimativeCoeff(x,y,z)*u = m_robinFunction(x,y,z)
249  std::string m_filename;
250  };
251 
252 
254  {
255  PeriodicBoundaryCondition(const unsigned int n):
258  {
259  }
260 
262  };
263 
265  {
266 
268  const LibUtilities::SessionReaderSharedPtr &pSession,
269  const std::string& eqn,
270  const std::string& userDefined = std::string("NoUserDefined"),
271  const std::string& filename=std::string("")):
272  BoundaryConditionBase(eNotDefined, userDefined),
273  m_notDefinedCondition(pSession, eqn),
274  m_filename(filename)
275  {
276  }
277 
279  std::string m_filename;
280  };
281 
282 
283  typedef std::map<int, Composite> BoundaryRegion;
284  typedef boost::shared_ptr<BoundaryRegion> BoundaryRegionShPtr;
285  typedef boost::shared_ptr<const BoundaryRegion> ConstBoundaryRegionShPtr;
286  typedef std::map<int, BoundaryRegionShPtr> BoundaryRegionCollection;
287 
288  typedef boost::shared_ptr<BoundaryConditionBase> BoundaryConditionShPtr;
289  typedef boost::shared_ptr<DirichletBoundaryCondition> DirichletBCShPtr;
290  typedef boost::shared_ptr<NeumannBoundaryCondition> NeumannBCShPtr;
291  typedef boost::shared_ptr<RobinBoundaryCondition> RobinBCShPtr;
292 
293  typedef std::map<std::string,BoundaryConditionShPtr> BoundaryConditionMap;
294  typedef boost::shared_ptr<BoundaryConditionMap> BoundaryConditionMapShPtr;
295  typedef std::map<int, BoundaryConditionMapShPtr> BoundaryConditionCollection;
296 
297  const static Array<OneD, BoundaryConditionShPtr> NullBoundaryConditionShPtrArray;
298 
300  {
301  public:
303 
306 
308  {
309  return m_boundaryRegions;
310  }
311 
312  void AddBoundaryRegions(const int regionID, BoundaryRegionShPtr &bRegion)
313  {
314  m_boundaryRegions[regionID] = bRegion;
315  }
316 
318  {
319  return m_boundaryConditions;
320  }
321 
322 
323  void AddBoundaryConditions(const int regionID, BoundaryConditionMapShPtr &bCond)
324  {
325  m_boundaryConditions[regionID] = bCond;
326  }
327 
328  const std::string GetVariable(unsigned int indx)
329  {
330  return m_session->GetVariable(indx);
331  }
332 
333  protected:
334  /// The mesh graph to use for referencing geometry info.
337 
340 
341  private:
342 
343  /// Read segments (and general MeshGraph) given TiXmlDocument.
344  void Read(TiXmlElement *conditions);
345 
346  void ReadBoundaryRegions(TiXmlElement *regions);
347  void ReadBoundaryConditions(TiXmlElement *conditions);
348  };
349 
350  typedef boost::shared_ptr<BoundaryConditions>
352  }
353 }
354 
355 #endif //NEKTAR_SPATIALDOMAINS_BOUNDARYCONDITIONS_H
356