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  {
66  const std::string &userDefined
67  = std::string("NoUserDefined")):
69  m_userDefined(userDefined),
70  m_isTimeDependent(false)
71  {
72  }
73 
75  {};
76 
78  {
80  }
81 
83  {
84  m_boundaryConditionType = boundaryType;
85  }
86 
87  void SetUserDefined(std::string &type)
88  {
89  m_userDefined = type;
90  }
91 
92  const std::string GetUserDefined() const
93  {
94  return m_userDefined;
95  }
96 
97  void SetIsTimeDependent(bool value)
98  {
99  m_isTimeDependent = value;
100  }
101 
102  bool IsTimeDependent(void)
103  {
104  return m_isTimeDependent;
105  }
106 
107  protected:
109  std::string m_userDefined;
111  };
112 
113 
115  {
116 
118  const LibUtilities::SessionReaderSharedPtr &pSession,
119  const std::string& eqn,
120  const std::string& userDefined = std::string("NoUserDefined"),
121  const std::string& filename=std::string("")):
122  BoundaryConditionBase(eDirichlet, userDefined),
123  m_dirichletCondition(pSession, eqn),
124  m_expr(eqn),
125  m_filename(filename)
126  {
127  }
128 
130  std::string m_expr;
131  std::string m_filename;
132  };
133 
135  {
137  const LibUtilities::SessionReaderSharedPtr &pSession,
138  const std::string& eqn,
139  const std::string& userDefined = std::string("NoUserDefined"),
140  const std::string& filename=std::string("")):
141  BoundaryConditionBase(eNeumann, userDefined),
142  m_neumannCondition(pSession, eqn),
143  m_filename(filename)
144  {
145  }
146 
148  std::string m_filename;
149  };
150 
152  {
154  const LibUtilities::SessionReaderSharedPtr &pSession,
155  const std::string &a,
156  const std::string &b,
157  const std::string &userDefined = std::string("NoUserDefined"),
158  const std::string& filename=std::string("")):
159  BoundaryConditionBase(eRobin, userDefined),
160  m_robinFunction(pSession, a),
161  m_robinPrimitiveCoeff(pSession, b),
162  m_filename(filename)
163  {
164  }
165  // \frac{\partial {u}}{\partial{n}} +
166  // m_robinPrimativeCoeff(x,y,z)*u = m_robinFunction(x,y,z)
169  std::string m_filename;
170  };
171 
172 
174  {
175  PeriodicBoundaryCondition(const unsigned int n):
178  {
179  }
180 
182  };
183 
185  {
186 
188  const LibUtilities::SessionReaderSharedPtr &pSession,
189  const std::string& eqn,
190  const std::string& userDefined = std::string("NoUserDefined"),
191  const std::string& filename=std::string("")):
192  BoundaryConditionBase(eNotDefined, userDefined),
193  m_notDefinedCondition(pSession, eqn),
194  m_filename(filename)
195  {
196  }
197 
199  std::string m_filename;
200  };
201 
202 
203  typedef std::map<int, Composite> BoundaryRegion;
204  typedef boost::shared_ptr<BoundaryRegion> BoundaryRegionShPtr;
205  typedef boost::shared_ptr<const BoundaryRegion> ConstBoundaryRegionShPtr;
206  typedef std::map<int, BoundaryRegionShPtr> BoundaryRegionCollection;
207 
208  typedef boost::shared_ptr<BoundaryConditionBase> BoundaryConditionShPtr;
209  typedef boost::shared_ptr<DirichletBoundaryCondition> DirichletBCShPtr;
210  typedef boost::shared_ptr<NeumannBoundaryCondition> NeumannBCShPtr;
211  typedef boost::shared_ptr<RobinBoundaryCondition> RobinBCShPtr;
212 
213  typedef std::map<std::string,BoundaryConditionShPtr> BoundaryConditionMap;
214  typedef boost::shared_ptr<BoundaryConditionMap> BoundaryConditionMapShPtr;
215  typedef std::map<int, BoundaryConditionMapShPtr> BoundaryConditionCollection;
216 
218 
220  {
221  public:
223 
226 
227  const BoundaryRegionCollection &GetBoundaryRegions(void) const
228  {
229  return m_boundaryRegions;
230  }
231 
232  void AddBoundaryRegions(const int regionID, BoundaryRegionShPtr &bRegion)
233  {
234  m_boundaryRegions[regionID] = bRegion;
235  }
236 
237  const BoundaryConditionCollection &GetBoundaryConditions(void) const
238  {
239  return m_boundaryConditions;
240  }
241 
242 
243  void AddBoundaryConditions(const int regionID, BoundaryConditionMapShPtr &bCond)
244  {
245  m_boundaryConditions[regionID] = bCond;
246  }
247 
248  const std::string GetVariable(unsigned int indx)
249  {
250  return m_session->GetVariable(indx);
251  }
252 
253  protected:
254  /// The mesh graph to use for referencing geometry info.
257 
258  BoundaryRegionCollection m_boundaryRegions;
259  BoundaryConditionCollection m_boundaryConditions;
260 
261  private:
262 
263  /// Read segments (and general MeshGraph) given TiXmlDocument.
264  void Read(TiXmlElement *conditions);
265 
266  void ReadBoundaryRegions(TiXmlElement *regions);
267  void ReadBoundaryConditions(TiXmlElement *conditions);
268  };
269 
270  typedef boost::shared_ptr<BoundaryConditions>
272  }
273 }
274 
275 #endif //NEKTAR_SPATIALDOMAINS_BOUNDARYCONDITIONS_H
276 
NotDefinedBoundaryCondition(const LibUtilities::SessionReaderSharedPtr &pSession, const std::string &eqn, const std::string &userDefined=std::string("NoUserDefined"), const std::string &filename=std::string(""))
Definition: Conditions.h:187
RobinBoundaryCondition(const LibUtilities::SessionReaderSharedPtr &pSession, const std::string &a, const std::string &b, const std::string &userDefined=std::string("NoUserDefined"), const std::string &filename=std::string(""))
Definition: Conditions.h:153
BoundaryRegionCollection m_boundaryRegions
Definition: Conditions.h:258
void AddBoundaryRegions(const int regionID, BoundaryRegionShPtr &bRegion)
Definition: Conditions.h:232
const BoundaryConditionCollection & GetBoundaryConditions(void) const
Definition: Conditions.h:237
static const Array< OneD, BoundaryConditionShPtr > NullBoundaryConditionShPtrArray
Definition: Conditions.h:217
boost::shared_ptr< const BoundaryRegion > ConstBoundaryRegionShPtr
Definition: Conditions.h:205
DirichletBoundaryCondition(const LibUtilities::SessionReaderSharedPtr &pSession, const std::string &eqn, const std::string &userDefined=std::string("NoUserDefined"), const std::string &filename=std::string(""))
Definition: Conditions.h:117
boost::shared_ptr< NeumannBoundaryCondition > NeumannBCShPtr
Definition: Conditions.h:210
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
NeumannBoundaryCondition(const LibUtilities::SessionReaderSharedPtr &pSession, const std::string &eqn, const std::string &userDefined=std::string("NoUserDefined"), const std::string &filename=std::string(""))
Definition: Conditions.h:136
const std::string GetVariable(unsigned int indx)
Definition: Conditions.h:248
boost::shared_ptr< DirichletBoundaryCondition > DirichletBCShPtr
Definition: Conditions.h:209
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition: Conditions.h:206
std::map< std::string, BoundaryConditionShPtr > BoundaryConditionMap
Definition: Conditions.h:213
std::map< int, BoundaryConditionMapShPtr > BoundaryConditionCollection
Definition: Conditions.h:215
std::map< int, Composite > BoundaryRegion
Definition: Conditions.h:203
void ReadBoundaryRegions(TiXmlElement *regions)
Definition: Conditions.cpp:84
void Read(TiXmlElement *conditions)
Read segments (and general MeshGraph) given TiXmlDocument.
Definition: Conditions.cpp:66
void SetBoundaryConditionType(BoundaryConditionType boundaryType)
Definition: Conditions.h:82
boost::shared_ptr< BoundaryConditionMap > BoundaryConditionMapShPtr
Definition: Conditions.h:214
LibUtilities::SessionReaderSharedPtr m_session
Definition: Conditions.h:256
BoundaryConditionCollection m_boundaryConditions
Definition: Conditions.h:259
boost::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
Definition: Conditions.h:271
BoundaryConditionType GetBoundaryConditionType() const
Definition: Conditions.h:77
MeshGraphSharedPtr m_meshGraph
The mesh graph to use for referencing geometry info.
Definition: Conditions.h:255
const BoundaryRegionCollection & GetBoundaryRegions(void) const
Definition: Conditions.h:227
void AddBoundaryConditions(const int regionID, BoundaryConditionMapShPtr &bCond)
Definition: Conditions.h:243
boost::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
Definition: Conditions.h:208
BoundaryConditionBase(BoundaryConditionType type, const std::string &userDefined=std::string("NoUserDefined"))
Definition: Conditions.h:64
void ReadBoundaryConditions(TiXmlElement *conditions)
Definition: Conditions.cpp:147
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
boost::shared_ptr< BoundaryRegion > BoundaryRegionShPtr
Definition: Conditions.h:204
const std::string GetUserDefined() const
Definition: Conditions.h:92
#define SPATIAL_DOMAINS_EXPORT
boost::shared_ptr< RobinBoundaryCondition > RobinBCShPtr
Definition: Conditions.h:211