Nektar++
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// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description:
32//
33//
34////////////////////////////////////////////////////////////////////////////////
35#ifndef NEKTAR_SPATIALDOMAINS_BOUNDARYCONDITIONS_H
36#define NEKTAR_SPATIALDOMAINS_BOUNDARYCONDITIONS_H
37
38#include <map>
39#include <string>
40
44
45namespace Nektar
46{
47struct OneD;
48
49namespace SpatialDomains
50{
52{
58};
59
61{
64 const std::string &userDefined = std::string("NoUserDefined"),
66 : m_boundaryConditionType(type), m_userDefined(userDefined),
67 m_isTimeDependent(false), m_comm(comm)
68 {
69 }
70
72
74 {
76 }
77
79 {
80 m_boundaryConditionType = boundaryType;
81 }
82
83 void SetUserDefined(std::string &type)
84 {
85 m_userDefined = type;
86 }
87
88 const std::string GetUserDefined() const
89 {
90 return m_userDefined;
91 }
92
93 void SetIsTimeDependent(bool value)
94 {
95 m_isTimeDependent = value;
96 }
97
98 bool IsTimeDependent(void)
99 {
100 return m_isTimeDependent;
101 }
102
104 {
105 return m_comm;
106 }
107
108protected:
110 std::string m_userDefined;
113};
114
116{
117
120 const std::string &eqn,
121 const std::string &userDefined = std::string("NoUserDefined"),
122 const std::string &filename = std::string(""),
124 : BoundaryConditionBase(eDirichlet, userDefined, comm),
125 m_dirichletCondition(pSession->GetInterpreter(), eqn), m_expr(eqn),
126 m_filename(filename)
127 {
128 }
129
131 std::string m_expr;
132 std::string m_filename;
133};
134
136{
139 const std::string &eqn,
140 const std::string &userDefined = std::string("NoUserDefined"),
141 const std::string &filename = std::string(""),
143 : BoundaryConditionBase(eNeumann, userDefined, comm),
144 m_neumannCondition(pSession->GetInterpreter(), eqn),
145 m_filename(filename)
146 {
147 }
148
150 std::string m_filename;
151};
152
154{
157 const std::string &a, const std::string &b,
158 const std::string &userDefined = std::string("NoUserDefined"),
159 const std::string &filename = std::string(""),
161 : BoundaryConditionBase(eRobin, userDefined, comm),
162 m_robinFunction(pSession->GetInterpreter(), a),
163 m_robinPrimitiveCoeff(pSession->GetInterpreter(), b),
164 m_filename(filename)
165 {
166 }
167 // \frac{\partial {u}}{\partial{n}} +
168 // m_robinPrimativeCoeff(x,y,z)*u = m_robinFunction(x,y,z)
171 std::string m_filename;
172};
173
175{
177 const unsigned int n,
178 const std::string &userDefined = std::string("NoUserDefined"),
180 : BoundaryConditionBase(ePeriodic, userDefined, comm),
182 {
183 }
184
186};
187
189{
190
193 const std::string &eqn,
194 const std::string &userDefined = std::string("NoUserDefined"),
195 const std::string &filename = std::string(""),
197 : BoundaryConditionBase(eNotDefined, userDefined, comm),
198 m_notDefinedCondition(pSession->GetInterpreter(), eqn),
199 m_filename(filename)
200 {
201 }
202
204 std::string m_filename;
205};
206
207typedef std::map<int, CompositeSharedPtr> BoundaryRegion;
208typedef std::shared_ptr<BoundaryRegion> BoundaryRegionShPtr;
209typedef std::shared_ptr<const BoundaryRegion> ConstBoundaryRegionShPtr;
210typedef std::map<int, BoundaryRegionShPtr> BoundaryRegionCollection;
211
212typedef std::shared_ptr<BoundaryConditionBase> BoundaryConditionShPtr;
213typedef std::shared_ptr<DirichletBoundaryCondition> DirichletBCShPtr;
214typedef std::shared_ptr<NeumannBoundaryCondition> NeumannBCShPtr;
215typedef std::shared_ptr<RobinBoundaryCondition> RobinBCShPtr;
216
217typedef std::map<std::string, BoundaryConditionShPtr> BoundaryConditionMap;
218typedef std::shared_ptr<BoundaryConditionMap> BoundaryConditionMapShPtr;
219typedef std::map<int, BoundaryConditionMapShPtr> BoundaryConditionCollection;
220
223
225{
226public:
229 const MeshGraphSharedPtr &meshGraph);
230
233
235 {
236 return m_boundaryRegions;
237 }
238
239 void AddBoundaryRegions(const int regionID, BoundaryRegionShPtr &bRegion)
240 {
241 m_boundaryRegions[regionID] = bRegion;
242 }
243
245 {
247 }
248
249 void AddBoundaryConditions(const int regionID,
251 {
252 m_boundaryConditions[regionID] = bCond;
253 }
254
255 const std::string GetVariable(unsigned int indx)
256 {
257 return m_session->GetVariable(indx);
258 }
259
260 std::map<int, LibUtilities::CommSharedPtr> GetBoundaryCommunicators() const
261 {
263 }
264
265 const std::map<int, std::string> &GetBoundaryLabels(void) const
266 {
267 return m_boundaryLabels;
268 }
269
270protected:
271 /// The mesh graph to use for referencing geometry info.
274
276 std::map<int, std::string> m_boundaryLabels;
278 std::map<int, LibUtilities::CommSharedPtr> m_boundaryCommunicators;
279
280private:
281 /// Read segments (and general MeshGraph) given TiXmlDocument.
282 void Read(TiXmlElement *conditions);
283
284 void ReadBoundaryRegions(TiXmlElement *regions);
285 void ReadBoundaryConditions(TiXmlElement *conditions);
286 void CreateBoundaryComms();
287};
288
289typedef std::shared_ptr<BoundaryConditions> BoundaryConditionsSharedPtr;
290} // namespace SpatialDomains
291} // namespace Nektar
292
293#endif // NEKTAR_SPATIALDOMAINS_BOUNDARYCONDITIONS_H
#define SPATIAL_DOMAINS_EXPORT
const std::map< int, std::string > & GetBoundaryLabels(void) const
Definition: Conditions.h:265
std::map< int, LibUtilities::CommSharedPtr > m_boundaryCommunicators
Definition: Conditions.h:278
BoundaryRegionCollection m_boundaryRegions
Definition: Conditions.h:275
std::map< int, LibUtilities::CommSharedPtr > GetBoundaryCommunicators() const
Definition: Conditions.h:260
void ReadBoundaryConditions(TiXmlElement *conditions)
Definition: Conditions.cpp:328
void Read(TiXmlElement *conditions)
Read segments (and general MeshGraph) given TiXmlDocument.
Definition: Conditions.cpp:220
void AddBoundaryRegions(const int regionID, BoundaryRegionShPtr &bRegion)
Definition: Conditions.h:239
LibUtilities::SessionReaderSharedPtr m_session
Definition: Conditions.h:273
const std::string GetVariable(unsigned int indx)
Definition: Conditions.h:255
BoundaryConditionCollection m_boundaryConditions
Definition: Conditions.h:277
const BoundaryRegionCollection & GetBoundaryRegions(void) const
Definition: Conditions.h:234
std::map< int, std::string > m_boundaryLabels
Definition: Conditions.h:276
MeshGraphSharedPtr m_meshGraph
The mesh graph to use for referencing geometry info.
Definition: Conditions.h:272
void ReadBoundaryRegions(TiXmlElement *regions)
Definition: Conditions.cpp:238
const BoundaryConditionCollection & GetBoundaryConditions(void) const
Definition: Conditions.h:244
void AddBoundaryConditions(const int regionID, BoundaryConditionMapShPtr &bCond)
Definition: Conditions.h:249
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
std::map< int, CompositeSharedPtr > BoundaryRegion
Definition: Conditions.h:207
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition: Conditions.h:210
std::shared_ptr< BoundaryRegion > BoundaryRegionShPtr
Definition: Conditions.h:208
std::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
Definition: Conditions.h:289
std::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
Definition: Conditions.h:212
std::map< std::string, BoundaryConditionShPtr > BoundaryConditionMap
Definition: Conditions.h:217
std::shared_ptr< DirichletBoundaryCondition > DirichletBCShPtr
Definition: Conditions.h:213
std::map< int, BoundaryConditionMapShPtr > BoundaryConditionCollection
Definition: Conditions.h:219
std::shared_ptr< const BoundaryRegion > ConstBoundaryRegionShPtr
Definition: Conditions.h:209
static const Array< OneD, BoundaryConditionShPtr > NullBoundaryConditionShPtrArray
Definition: Conditions.h:222
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
std::shared_ptr< NeumannBoundaryCondition > NeumannBCShPtr
Definition: Conditions.h:214
std::shared_ptr< BoundaryConditionMap > BoundaryConditionMapShPtr
Definition: Conditions.h:218
std::shared_ptr< RobinBoundaryCondition > RobinBCShPtr
Definition: Conditions.h:215
BoundaryConditionType GetBoundaryConditionType() const
Definition: Conditions.h:73
void SetBoundaryConditionType(BoundaryConditionType boundaryType)
Definition: Conditions.h:78
const std::string GetUserDefined() const
Definition: Conditions.h:88
LibUtilities::CommSharedPtr m_comm
Definition: Conditions.h:112
BoundaryConditionBase(BoundaryConditionType type, const std::string &userDefined=std::string("NoUserDefined"), LibUtilities::CommSharedPtr comm=LibUtilities::CommSharedPtr())
Definition: Conditions.h:62
LibUtilities::CommSharedPtr GetComm()
Definition: Conditions.h:103
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:118
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:137
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:191
PeriodicBoundaryCondition(const unsigned int n, const std::string &userDefined=std::string("NoUserDefined"), const LibUtilities::CommSharedPtr comm=LibUtilities::CommSharedPtr())
Definition: Conditions.h:176
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:155