Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
41namespace Nektar
42{
43
44namespace SpatialDomains
45{
46
47/// Enum of zone movement type
48enum class MovementType
49{
50 eNone,
51 eFixed,
52 eRotate,
55};
56
57/// Map of zone movement type to movement type string
58const std::string MovementTypeStr[] = {"None", "Fixed", "Rotated", "Translated",
59 "Prescribed"};
60
61/// Zone base: Contains the shared functions and variables
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 /// Performs the movement of the zone at @param time
89 inline bool Move(NekDouble time)
90 {
91 return v_Move(time);
92 }
93
94 /// Returns all highest dimension elements in the zone
95 inline std::vector<GeometrySharedPtr> const &GetElements() const
96 {
97 return m_elements;
98 }
99
100 /// Returns the flag which states if the zone has moved in this timestep
101 inline bool &GetMoved()
102 {
103 return m_moved;
104 }
105
106 /// Clears all bounding boxes associated with the zones elements
107 void ClearBoundingBoxes();
108
109protected:
110 /// Type of zone movement
112 /// Zone ID
113 int m_id;
114 /// Zone domain
116 /// Vector of highest dimension zone elements
117 std::vector<GeometrySharedPtr> m_elements;
118 /// Moved flag
119 bool m_moved = true;
120 /// Coordinate dimension
122 /// Vector of all points in the zone
123 std::vector<PointGeomSharedPtr> m_verts;
124 /// Vector of all curves in the zone
125 std::vector<CurveSharedPtr> m_curves;
126 /// Vector of all points in the zone at initialisation
127 std::vector<PointGeom> m_origVerts;
128
129 /// Virtual function for movement of the zone at @param time
130 inline virtual bool v_Move(NekDouble time)
131 {
132 boost::ignore_unused(time);
133 return false;
134 }
135};
136
137typedef std::shared_ptr<ZoneBase> ZoneBaseShPtr;
138
139/// Rotating zone: Motion of every point around a given axis on an origin
140struct 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
162protected:
163 /// Origin point rotation is performed around
165 /// Axis rotation is performed around
167 /// Equation defining angular velocity as a function of time
169 /// W matrix Rodrigues' rotation formula, cross product of axis
170 DNekMat m_W = DNekMat(3, 3, 0.0);
171 /// W^2 matrix Rodrigues' rotation formula, cross product of axis squared
172 DNekMat m_W2 = DNekMat(3, 3, 0.0);
173
174 /// Virtual function for movement of the zone at @param time
175 virtual bool v_Move(NekDouble time) final;
176};
177
178/// Translating zone: addition of a constant vector to every point
179struct 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
205protected:
206 std::vector<NekDouble> m_velocity;
207
208 /// Virtual function for movement of the zone at @param time
209 virtual bool v_Move(NekDouble time) final;
210};
211
212/// Prescribed zone: applies equation to every point
213struct 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
282protected:
283 /// Equation specifying prescribed motion in x-direction
285 /// Equation specifying prescribed motion in y-direction
287 /// Equation specifying prescribed motion in z-direction
289
290 /// Virtual function for movement of the zone at @param time
291 virtual bool v_Move(NekDouble time) final;
292};
293
294/// Fixed zone: does not move
295struct 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
306protected:
307 /// Virtual function for movement of the zone at @param time
308 virtual bool v_Move(NekDouble time) final;
309};
310
311typedef std::shared_ptr<ZoneRotate> ZoneRotateShPtr;
312typedef std::shared_ptr<ZoneTranslate> ZoneTranslateShPtr;
313typedef std::shared_ptr<ZonePrescribe> ZonePrescribeShPtr;
314typedef std::shared_ptr<ZoneFixed> ZoneFixedShPtr;
315
316} // namespace SpatialDomains
317} // namespace Nektar
318
319#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:313
std::shared_ptr< ZoneTranslate > ZoneTranslateShPtr
Definition: Zones.h:312
std::shared_ptr< ZoneRotate > ZoneRotateShPtr
Definition: Zones.h:311
MovementType
Enum of zone movement type.
Definition: Zones.h:49
std::shared_ptr< ZoneFixed > ZoneFixedShPtr
Definition: Zones.h:314
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
std::vector< double > z(NPUPPER)
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:89
virtual ~ZoneBase()=default
Default destructor.
std::vector< PointGeomSharedPtr > m_verts
Vector of all points in the zone.
Definition: Zones.h:123
int m_coordDim
Coordinate dimension.
Definition: Zones.h:121
std::vector< GeometrySharedPtr > const & GetElements() const
Returns all highest dimension elements in the zone.
Definition: Zones.h:95
void ClearBoundingBoxes()
Clears all bounding boxes associated with the zones elements.
Definition: Zones.cpp:158
std::vector< PointGeom > m_origVerts
Vector of all points in the zone at initialisation.
Definition: Zones.h:127
CompositeMap GetDomain() const
Returns the domain the zone is on.
Definition: Zones.h:77
bool & GetMoved()
Returns the flag which states if the zone has moved in this timestep.
Definition: Zones.h:101
std::vector< CurveSharedPtr > m_curves
Vector of all curves in the zone.
Definition: Zones.h:125
CompositeMap m_domain
Zone domain.
Definition: Zones.h:115
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:130
std::vector< GeometrySharedPtr > m_elements
Vector of highest dimension zone elements.
Definition: Zones.h:117
MovementType m_type
Type of zone movement.
Definition: Zones.h:111
bool m_moved
Moved flag.
Definition: Zones.h:119
int & GetId()
Returns the zone ID.
Definition: Zones.h:83
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:288
virtual ~ZonePrescribe()=default
Default destructor.
LibUtilities::EquationSharedPtr m_yDeform
Equation specifying prescribed motion in y-direction.
Definition: Zones.h:286
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:284
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:166
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:170
NekPoint< NekDouble > m_origin
Origin point rotation is performed around.
Definition: Zones.h:164
LibUtilities::EquationSharedPtr m_angularVelEqn
Equation defining angular velocity as a function of time.
Definition: Zones.h:168
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:172
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:206
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