Nektar++
Zones.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Zones.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 s:
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: Zones used in the non-conformal interfaces
33 // and ALE implementations
34 //
35 ////////////////////////////////////////////////////////////////////////////////
36 #ifndef NEKTAR_SPATIALDOMAINS_ZONES_H
37 #define NEKTAR_SPATIALDOMAINS_ZONES_H
38 
40 
41 namespace Nektar
42 {
43 
44 namespace SpatialDomains
45 {
46 
47 /// Enum of zone movement type
48 enum class MovementType
49 {
50  eNone,
51  eFixed,
52  eRotate,
53  eTranslate,
55 };
56 
57 /// Map of zone movement type to movement type string
58 const std::string MovementTypeStr[] = {"None", "Fixed", "Rotated", "Translated",
59  "Prescribed"};
60 
61 /// Zone base: Contains the shared functions and variables
62 struct ZoneBase
63 {
64  /// Constructor
65  ZoneBase(MovementType type, int indx, CompositeMap domain, int coordDim);
66 
67  /// Default destructor
68  virtual ~ZoneBase() = default;
69 
70  /// Returns the type of movement
72  {
73  return m_type;
74  }
75 
76  /// Returns the domain the zone is on
77  inline CompositeMap GetDomain() const
78  {
79  return m_domain;
80  }
81 
82  /// Returns the zone ID
83  inline int &GetId()
84  {
85  return m_id;
86  }
87 
88  /// Virtual function for movement of the zone at @param time
89  inline virtual bool v_Move(NekDouble time)
90  {
91  boost::ignore_unused(time);
92  return false;
93  }
94 
95  /// Performs the movement of the zone at @param time
96  inline bool Move(NekDouble time)
97  {
98  return v_Move(time);
99  }
100 
101  /// Returns all highest dimension elements in the zone
102  inline std::vector<GeometrySharedPtr> const &GetElements() const
103  {
104  return m_elements;
105  }
106 
107  /// Returns the flag which states if the zone has moved in this timestep
108  inline bool &GetMoved()
109  {
110  return m_moved;
111  }
112 
113  /// Clears all bounding boxes associated with the zones elements
114  void ClearBoundingBoxes();
115 
116 protected:
117  /// Type of zone movement
119  /// Zone ID
120  int m_id;
121  /// Zone domain
123  /// Vector of highest dimension zone elements
124  std::vector<GeometrySharedPtr> m_elements;
125  /// Moved flag
126  bool m_moved = true;
127  /// Coordinate dimension
129  /// Vector of all points in the zone
130  std::vector<PointGeomSharedPtr> m_verts;
131  /// Vector of all curves in the zone
132  std::vector<CurveSharedPtr> m_curves;
133  /// Vector of all points in the zone at initialisation
134  std::vector<PointGeom> m_origVerts;
135 };
136 
137 typedef std::shared_ptr<ZoneBase> ZoneBaseShPtr;
138 
139 /// Rotating zone: Motion of every point around a given axis on an origin
140 struct ZoneRotate final : public ZoneBase
141 {
142  /**
143  * Constructor for rotating zones
144  *
145  * @param id Zone ID
146  * @param domain Domain that the zone consists of
147  * @param coordDim Coordinate dimension
148  * @param origin Origin that the zone rotates about
149  * @param axis Axis that the zone rotates about
150  * @param angularVelEqn Equation for the angular velocity of rotation
151  */
152  ZoneRotate(int id, const CompositeMap &domain, const int coordDim,
153  const NekPoint<NekDouble> &origin, const DNekVec &axis,
154  const LibUtilities::EquationSharedPtr &angularVelEqn);
155 
156  /// Default destructor
157  virtual ~ZoneRotate() = default;
158 
159  /// Return the angular velocity of the zone at @param time
160  NekDouble GetAngularVel(NekDouble &time) const;
161 
162  /// Virtual function for movement of the zone at @param time
163  virtual bool v_Move(NekDouble time) final;
164 
165 protected:
166  /// Origin point rotation is performed around
168  /// Axis rotation is performed around
170  /// Equation defining angular velocity as a function of time
172  /// W matrix Rodrigues' rotation formula, cross product of axis
173  DNekMat m_W = DNekMat(3, 3, 0.0);
174  /// W^2 matrix Rodrigues' rotation formula, cross product of axis squared
175  DNekMat m_W2 = DNekMat(3, 3, 0.0);
176 };
177 
178 /// Translating zone: addition of a constant vector to every point
179 struct ZoneTranslate final : public ZoneBase
180 {
181  /**
182  * Constructor for translating zone
183  *
184  * @param id Zone ID
185  * @param domain Domain that the zone consists of
186  * @param coordDim Coordinate dimension
187  * @param velocity Vector of translation velocity in x,y,z direction
188  */
189  ZoneTranslate(int id, const CompositeMap &domain, const int coordDim,
190  const std::vector<NekDouble> &velocity)
191  : ZoneBase(MovementType::eTranslate, id, domain, coordDim),
192  m_velocity(velocity)
193  {
194  }
195 
196  /// Default destructor
197  virtual ~ZoneTranslate() = default;
198 
199  /// Returns the velocity of the zone
200  inline std::vector<NekDouble> GetVel() const
201  {
202  return m_velocity;
203  }
204 
205  /// Virtual function for movement of the zone at @param time
206  virtual bool v_Move(NekDouble time) final;
207 
208 protected:
209  std::vector<NekDouble> m_velocity;
210 };
211 
212 /// Prescribed zone: applies equation to every point
213 struct ZonePrescribe final : public ZoneBase
214 {
215  /**
216  * Constructor for prescribed zone
217  *
218  * @param id Zone ID
219  * @param domain Domain that the zone consists of
220  * @param coordDim Coordinate dimension
221  * @param xDeform Equation for prescribed motion of x-coordinate
222  * @param yDeform Equation for prescribed motion of y-coordinate
223  * @param zDeform Equation for prescribed motion of z-coordinate
224  */
225  ZonePrescribe(int id, const CompositeMap &domain, const int coordDim,
229  : ZoneBase(MovementType::ePrescribe, id, domain, coordDim),
230  m_xDeform(xDeform), m_yDeform(yDeform), m_zDeform(zDeform)
231  {
232  }
233 
234  /// Default destructor
235  virtual ~ZonePrescribe() = default;
236 
237  /**
238  * Returns point @param x @param y @param z deformation in the x direction
239  * at time @param t
240  * @param x x-coordinate
241  * @param y y-coordinate
242  * @param z z-coordinate
243  * @param t time
244  * @return deformation in x direction
245  */
247  NekDouble t) const
248  {
249  return m_xDeform->Evaluate(x, y, z, t);
250  }
251 
252  /**
253  * Returns point @param x @param y @param z deformation in the y direction
254  * at time @param t
255  * @param x x-coordinate
256  * @param y y-coordinate
257  * @param z z-coordinate
258  * @param t time
259  * @return deformation in y direction
260  */
262  NekDouble t) const
263  {
264  return m_yDeform->Evaluate(x, y, z, t);
265  }
266 
267  /**
268  * Returns point @param x @param y @param z deformation in the z direction
269  * at time @param t
270  * @param x x-coordinate
271  * @param y y-coordinate
272  * @param z z-coordinate
273  * @param t time
274  * @return deformation in z direction
275  */
277  NekDouble t) const
278  {
279  return m_zDeform->Evaluate(x, y, z, t);
280  }
281 
282  /// Virtual function for movement of the zone at @param time
283  virtual bool v_Move(NekDouble time) final;
284 
285 protected:
286  /// Equation specifying prescribed motion in x-direction
288  /// Equation specifying prescribed motion in y-direction
290  /// Equation specifying prescribed motion in z-direction
292 };
293 
294 /// Fixed zone: does not move
295 struct ZoneFixed final : public ZoneBase
296 {
297  /// Constructor
298  ZoneFixed(int id, const CompositeMap &domain, const int coordDim)
299  : ZoneBase(MovementType::eFixed, id, domain, coordDim)
300  {
301  }
302 
303  /// Default destructor
304  virtual ~ZoneFixed() = default;
305 
306  /// Virtual function for movement of the zone at @param time
307  virtual bool v_Move(NekDouble time) final;
308 };
309 
310 typedef std::shared_ptr<ZoneRotate> ZoneRotateShPtr;
311 typedef std::shared_ptr<ZoneTranslate> ZoneTranslateShPtr;
312 typedef std::shared_ptr<ZonePrescribe> ZonePrescribeShPtr;
313 typedef std::shared_ptr<ZoneFixed> ZoneFixedShPtr;
314 
315 } // namespace SpatialDomains
316 } // namespace Nektar
317 
318 #endif // NEKTAR_SPATIALDOMAINS_ZONES_H
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:129
std::shared_ptr< ZoneBase > ZoneBaseShPtr
Definition: Zones.h:137
std::shared_ptr< ZonePrescribe > ZonePrescribeShPtr
Definition: Zones.h:312
std::shared_ptr< ZoneTranslate > ZoneTranslateShPtr
Definition: Zones.h:311
std::shared_ptr< ZoneRotate > ZoneRotateShPtr
Definition: Zones.h:310
MovementType
Enum of zone movement type.
Definition: Zones.h:49
std::shared_ptr< ZoneFixed > ZoneFixedShPtr
Definition: Zones.h:313
const std::string MovementTypeStr[]
Map of zone movement type to movement type string.
Definition: Zones.h:58
std::map< int, CompositeSharedPtr > CompositeMap
Definition: MeshGraph.h:138
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
Definition: NekTypeDefs.hpp:50
double NekDouble
Zone base: Contains the shared functions and variables.
Definition: Zones.h:63
bool Move(NekDouble time)
Performs the movement of the zone at.
Definition: Zones.h:96
virtual ~ZoneBase()=default
Default destructor.
std::vector< GeometrySharedPtr > const & GetElements() const
Returns all highest dimension elements in the zone.
Definition: Zones.h:102
bool & GetMoved()
Returns the flag which states if the zone has moved in this timestep.
Definition: Zones.h:108
std::vector< PointGeomSharedPtr > m_verts
Vector of all points in the zone.
Definition: Zones.h:130
int m_coordDim
Coordinate dimension.
Definition: Zones.h:128
void ClearBoundingBoxes()
Clears all bounding boxes associated with the zones elements.
Definition: Zones.cpp:158
int & GetId()
Returns the zone ID.
Definition: Zones.h:83
std::vector< PointGeom > m_origVerts
Vector of all points in the zone at initialisation.
Definition: Zones.h:134
CompositeMap GetDomain() const
Returns the domain the zone is on.
Definition: Zones.h:77
std::vector< CurveSharedPtr > m_curves
Vector of all curves in the zone.
Definition: Zones.h:132
CompositeMap m_domain
Zone domain.
Definition: Zones.h:122
ZoneBase(MovementType type, int indx, CompositeMap domain, int coordDim)
Constructor.
Definition: Zones.cpp:47
MovementType GetMovementType() const
Returns the type of movement.
Definition: Zones.h:71
virtual bool v_Move(NekDouble time)
Virtual function for movement of the zone at.
Definition: Zones.h:89
std::vector< GeometrySharedPtr > m_elements
Vector of highest dimension zone elements.
Definition: Zones.h:124
MovementType m_type
Type of zone movement.
Definition: Zones.h:118
bool m_moved
Moved flag.
Definition: Zones.h:126
Fixed zone: does not move.
Definition: Zones.h:296
virtual bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
Definition: Zones.cpp:279
ZoneFixed(int id, const CompositeMap &domain, const int coordDim)
Constructor.
Definition: Zones.h:298
virtual ~ZoneFixed()=default
Default destructor.
Prescribed zone: applies equation to every point.
Definition: Zones.h:214
NekDouble GetXDeform(NekDouble x, NekDouble y, NekDouble z, NekDouble t) const
Definition: Zones.h:246
NekDouble GetYDeform(NekDouble x, NekDouble y, NekDouble z, NekDouble t) const
Definition: Zones.h:261
LibUtilities::EquationSharedPtr m_zDeform
Equation specifying prescribed motion in z-direction.
Definition: Zones.h:291
virtual ~ZonePrescribe()=default
Default destructor.
LibUtilities::EquationSharedPtr m_yDeform
Equation specifying prescribed motion in y-direction.
Definition: Zones.h:289
virtual bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
Definition: Zones.cpp:285
NekDouble GetZDeform(NekDouble x, NekDouble y, NekDouble z, NekDouble t) const
Definition: Zones.h:276
ZonePrescribe(int id, const CompositeMap &domain, const int coordDim, LibUtilities::EquationSharedPtr xDeform, LibUtilities::EquationSharedPtr yDeform, LibUtilities::EquationSharedPtr zDeform)
Definition: Zones.h:225
LibUtilities::EquationSharedPtr m_xDeform
Equation specifying prescribed motion in x-direction.
Definition: Zones.h:287
Rotating zone: Motion of every point around a given axis on an origin.
Definition: Zones.h:141
DNekVec m_axis
Axis rotation is performed around.
Definition: Zones.h:169
NekDouble GetAngularVel(NekDouble &time) const
Return the angular velocity of the zone at.
Definition: Zones.cpp:180
ZoneRotate(int id, const CompositeMap &domain, const int coordDim, const NekPoint< NekDouble > &origin, const DNekVec &axis, const LibUtilities::EquationSharedPtr &angularVelEqn)
Definition: Zones.cpp:141
DNekMat m_W
W matrix Rodrigues' rotation formula, cross product of axis.
Definition: Zones.h:173
NekPoint< NekDouble > m_origin
Origin point rotation is performed around.
Definition: Zones.h:167
LibUtilities::EquationSharedPtr m_angularVelEqn
Equation defining angular velocity as a function of time.
Definition: Zones.h:171
virtual ~ZoneRotate()=default
Default destructor.
virtual bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
Definition: Zones.cpp:186
DNekMat m_W2
W^2 matrix Rodrigues' rotation formula, cross product of axis squared.
Definition: Zones.h:175
Translating zone: addition of a constant vector to every point.
Definition: Zones.h:180
virtual bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
Definition: Zones.cpp:234
std::vector< NekDouble > m_velocity
Definition: Zones.h:209
virtual ~ZoneTranslate()=default
Default destructor.
std::vector< NekDouble > GetVel() const
Returns the velocity of the zone.
Definition: Zones.h:200
ZoneTranslate(int id, const CompositeMap &domain, const int coordDim, const std::vector< NekDouble > &velocity)
Definition: Zones.h:189