Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 
114  {
115 
117  const LibUtilities::SessionReaderSharedPtr &pSession,
118  const std::string& eqn,
119  const std::string& userDefined = std::string("NoUserDefined"),
120  const std::string& filename=std::string(""),
122  BoundaryConditionBase(eDirichlet, userDefined),
123  m_dirichletCondition(pSession, eqn),
124  m_expr(eqn),
125  m_filename(filename),
126  m_comm(comm)
127  {
128  }
129 
131  std::string m_expr;
132  std::string m_filename;
134  };
135 
137  {
139  const LibUtilities::SessionReaderSharedPtr &pSession,
140  const std::string& eqn,
141  const std::string& userDefined = std::string("NoUserDefined"),
142  const std::string& filename=std::string(""),
144  BoundaryConditionBase(eNeumann, userDefined),
145  m_neumannCondition(pSession, eqn),
146  m_filename(filename),
147  m_comm(comm)
148  {
149  }
150 
152  std::string m_filename;
154  };
155 
157  {
159  const LibUtilities::SessionReaderSharedPtr &pSession,
160  const std::string &a,
161  const std::string &b,
162  const std::string &userDefined = std::string("NoUserDefined"),
163  const std::string& filename=std::string(""),
165  BoundaryConditionBase(eRobin, userDefined),
166  m_robinFunction(pSession, a),
167  m_robinPrimitiveCoeff(pSession, b),
168  m_filename(filename),
169  m_comm(comm)
170  {
171  }
172  // \frac{\partial {u}}{\partial{n}} +
173  // m_robinPrimativeCoeff(x,y,z)*u = m_robinFunction(x,y,z)
176  std::string m_filename;
178  };
179 
180 
182  {
183  PeriodicBoundaryCondition(const unsigned int n):
186  {
187  }
188 
190  };
191 
193  {
194 
196  const LibUtilities::SessionReaderSharedPtr &pSession,
197  const std::string& eqn,
198  const std::string& userDefined = std::string("NoUserDefined"),
199  const std::string& filename=std::string(""),
201  BoundaryConditionBase(eNotDefined, userDefined),
202  m_notDefinedCondition(pSession, eqn),
203  m_filename(filename),
204  m_comm(comm)
205  {
206  }
207 
209  std::string m_filename;
211  };
212 
213 
214  typedef std::map<int, Composite> BoundaryRegion;
215  typedef boost::shared_ptr<BoundaryRegion> BoundaryRegionShPtr;
216  typedef boost::shared_ptr<const BoundaryRegion> ConstBoundaryRegionShPtr;
217  typedef std::map<int, BoundaryRegionShPtr> BoundaryRegionCollection;
218 
219  typedef boost::shared_ptr<BoundaryConditionBase> BoundaryConditionShPtr;
220  typedef boost::shared_ptr<DirichletBoundaryCondition> DirichletBCShPtr;
221  typedef boost::shared_ptr<NeumannBoundaryCondition> NeumannBCShPtr;
222  typedef boost::shared_ptr<RobinBoundaryCondition> RobinBCShPtr;
223 
224  typedef std::map<std::string,BoundaryConditionShPtr> BoundaryConditionMap;
225  typedef boost::shared_ptr<BoundaryConditionMap> BoundaryConditionMapShPtr;
226  typedef std::map<int, BoundaryConditionMapShPtr> BoundaryConditionCollection;
227 
229 
231  {
232  public:
234 
237 
238  const BoundaryRegionCollection &GetBoundaryRegions(void) const
239  {
240  return m_boundaryRegions;
241  }
242 
243  void AddBoundaryRegions(const int regionID, BoundaryRegionShPtr &bRegion)
244  {
245  m_boundaryRegions[regionID] = bRegion;
246  }
247 
248  const BoundaryConditionCollection &GetBoundaryConditions(void) const
249  {
250  return m_boundaryConditions;
251  }
252 
253 
254  void AddBoundaryConditions(const int regionID, BoundaryConditionMapShPtr &bCond)
255  {
256  m_boundaryConditions[regionID] = bCond;
257  }
258 
259  const std::string GetVariable(unsigned int indx)
260  {
261  return m_session->GetVariable(indx);
262  }
263 
264  protected:
265  /// The mesh graph to use for referencing geometry info.
268 
269  BoundaryRegionCollection m_boundaryRegions;
270  BoundaryConditionCollection m_boundaryConditions;
271  std::map<int, LibUtilities::CommSharedPtr> m_boundaryCommunicators;
272 
273  private:
274 
275  /// Read segments (and general MeshGraph) given TiXmlDocument.
276  void Read(TiXmlElement *conditions);
277 
278  void ReadBoundaryRegions(TiXmlElement *regions);
279  void ReadBoundaryConditions(TiXmlElement *conditions);
280  void CreateBoundaryComms();
281  };
282 
283  typedef boost::shared_ptr<BoundaryConditions>
285  }
286 }
287 
288 #endif //NEKTAR_SPATIALDOMAINS_BOUNDARYCONDITIONS_H
289 
BoundaryRegionCollection m_boundaryRegions
Definition: Conditions.h:269
void AddBoundaryRegions(const int regionID, BoundaryRegionShPtr &bRegion)
Definition: Conditions.h:243
const BoundaryConditionCollection & GetBoundaryConditions(void) const
Definition: Conditions.h:248
static const Array< OneD, BoundaryConditionShPtr > NullBoundaryConditionShPtrArray
Definition: Conditions.h:228
boost::shared_ptr< const BoundaryRegion > ConstBoundaryRegionShPtr
Definition: Conditions.h:216
NeumannBoundaryCondition(const LibUtilities::SessionReaderSharedPtr &pSession, const std::string &eqn, const std::string &userDefined=std::string("NoUserDefined"), const std::string &filename=std::string(""), const LibUtilities::CommSharedPtr comm=LibUtilities::CommSharedPtr())
Definition: Conditions.h:138
NotDefinedBoundaryCondition(const LibUtilities::SessionReaderSharedPtr &pSession, const std::string &eqn, const std::string &userDefined=std::string("NoUserDefined"), const std::string &filename=std::string(""), const LibUtilities::CommSharedPtr comm=LibUtilities::CommSharedPtr())
Definition: Conditions.h:195
boost::shared_ptr< NeumannBoundaryCondition > NeumannBCShPtr
Definition: Conditions.h:221
std::map< int, LibUtilities::CommSharedPtr > m_boundaryCommunicators
Definition: Conditions.h:271
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
const std::string GetVariable(unsigned int indx)
Definition: Conditions.h:259
boost::shared_ptr< DirichletBoundaryCondition > DirichletBCShPtr
Definition: Conditions.h:220
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition: Conditions.h:217
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(""), const LibUtilities::CommSharedPtr comm=LibUtilities::CommSharedPtr())
Definition: Conditions.h:158
std::map< std::string, BoundaryConditionShPtr > BoundaryConditionMap
Definition: Conditions.h:224
std::map< int, BoundaryConditionMapShPtr > BoundaryConditionCollection
Definition: Conditions.h:226
std::map< int, Composite > BoundaryRegion
Definition: Conditions.h:214
void ReadBoundaryRegions(TiXmlElement *regions)
Definition: Conditions.cpp:223
void Read(TiXmlElement *conditions)
Read segments (and general MeshGraph) given TiXmlDocument.
Definition: Conditions.cpp:205
void SetBoundaryConditionType(BoundaryConditionType boundaryType)
Definition: Conditions.h:82
boost::shared_ptr< BoundaryConditionMap > BoundaryConditionMapShPtr
Definition: Conditions.h:225
LibUtilities::SessionReaderSharedPtr m_session
Definition: Conditions.h:267
BoundaryConditionCollection m_boundaryConditions
Definition: Conditions.h:270
boost::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
Definition: Conditions.h:284
BoundaryConditionType GetBoundaryConditionType() const
Definition: Conditions.h:77
MeshGraphSharedPtr m_meshGraph
The mesh graph to use for referencing geometry info.
Definition: Conditions.h:266
const BoundaryRegionCollection & GetBoundaryRegions(void) const
Definition: Conditions.h:238
void AddBoundaryConditions(const int regionID, BoundaryConditionMapShPtr &bCond)
Definition: Conditions.h:254
boost::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
Definition: Conditions.h:219
BoundaryConditionBase(BoundaryConditionType type, const std::string &userDefined=std::string("NoUserDefined"))
Definition: Conditions.h:64
void ReadBoundaryConditions(TiXmlElement *conditions)
Definition: Conditions.cpp:301
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
boost::shared_ptr< BoundaryRegion > BoundaryRegionShPtr
Definition: Conditions.h:215
DirichletBoundaryCondition(const LibUtilities::SessionReaderSharedPtr &pSession, const std::string &eqn, const std::string &userDefined=std::string("NoUserDefined"), const std::string &filename=std::string(""), const LibUtilities::CommSharedPtr comm=LibUtilities::CommSharedPtr())
Definition: Conditions.h:116
const std::string GetUserDefined() const
Definition: Conditions.h:92
#define SPATIAL_DOMAINS_EXPORT
boost::shared_ptr< RobinBoundaryCondition > RobinBCShPtr
Definition: Conditions.h:222