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
41
43{
44
45/// Enum of zone movement type
47{
54};
55
56/// Map of zone movement type to movement type string
57const std::string MovementTypeStr[] = {"None", "Fixed", "Rotated", "Translated",
58 "Prescribed"};
59
60/// Zone base: Contains the shared functions and variables
62{
63 /// Constructor
64 SPATIAL_DOMAINS_EXPORT ZoneBase(MovementType type, int indx, int domainID,
65 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 /// Returns the ID of the domain making up this Zone
89 inline int &GetDomainID()
90 {
91 return m_domainID;
92 }
93
94 /// Performs the movement of the zone at @param time
95 inline bool Move(NekDouble time)
96 {
97 return v_Move(time);
98 }
99
100 /// Returns all highest dimension elements in the zone
101 inline std::vector<GeometrySharedPtr> const &GetElements() const
102 {
103 return m_elements;
104 }
105
106 /// Returns the flag which states if the zone has moved in this timestep
107 inline bool &GetMoved()
108 {
109 return m_moved;
110 }
111
112 /// Clears all bounding boxes associated with the zones elements
113 void ClearBoundingBoxes();
114
115protected:
116 /// Type of zone movement
118 /// Zone ID
119 int m_id;
120 /// ID for the composite making up this zone.
122 /// Zone domain
124 /// Vector of highest dimension zone elements
125 std::vector<GeometrySharedPtr> m_elements;
126 /// Moved flag
127 bool m_moved = true;
128 /// Coordinate dimension
130 /// Vector of all points in the zone
131 std::vector<PointGeomSharedPtr> m_verts;
132 /// Vector of all curves in the zone
133 std::vector<CurveSharedPtr> m_curves;
134 /// Vector of all points in the zone at initialisation
135 std::vector<PointGeom> m_origVerts;
136
137 /// Virtual function for movement of the zone at @param time
138 inline virtual bool v_Move([[maybe_unused]] NekDouble time)
139 {
140 return false;
141 }
142};
143
144typedef std::shared_ptr<ZoneBase> ZoneBaseShPtr;
145
146/// Rotating zone: Motion of every point around a given axis on an origin
147struct ZoneRotate final : public ZoneBase
148{
149 /**
150 * Constructor for rotating zones
151 *
152 * @param id Zone ID
153 * @param domainID ID associated with the the domain making up
154 * the zone
155 * @param domain Domain that the zone consists of
156 * @param coordDim Coordinate dimension
157 * @param origin Origin that the zone rotates about
158 * @param axis Axis that the zone rotates about
159 * @param angularVelEqn Equation for the angular velocity of rotation
160 */
162 int id, int domainID, const CompositeMap &domain, const int coordDim,
163 const NekPoint<NekDouble> &origin, const DNekVec &axis,
164 const LibUtilities::EquationSharedPtr &angularVelEqn);
165
166 /// Default destructor
167 ~ZoneRotate() override = default;
168
169 /// Return the angular velocity of the zone at @param time
171
172 /// Returns the origin the zone rotates about
173 inline const NekPoint<NekDouble> &GetOrigin() const
174 {
175 return m_origin;
176 }
177
178 /// Returns the axis the zone rotates about
179 inline const DNekVec &GetAxis() const
180 {
181 return m_axis;
182 }
183
184 /// Returns the equation for the angular velocity of the rotation
186 {
187 return m_angularVelEqn;
188 }
189
190protected:
191 /// Origin point rotation is performed around
193 /// Axis rotation is performed around
195 /// Equation defining angular velocity as a function of time
197 /// W matrix Rodrigues' rotation formula, cross product of axis
198 DNekMat m_W = DNekMat(3, 3, 0.0);
199 /// W^2 matrix Rodrigues' rotation formula, cross product of axis squared
200 DNekMat m_W2 = DNekMat(3, 3, 0.0);
201
202 /// Virtual function for movement of the zone at @param time
203 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
204};
205
206/// Translating zone: addition of a constant vector to every point
207struct ZoneTranslate final : public ZoneBase
208{
209 /**
210 * Constructor for translating zone
211 *
212 * @param id Zone ID
213 * @param domainID ID associated with the the domain making up
214 * the zone
215 * @param domain Domain that the zone consists of
216 * @param coordDim Coordinate dimension
217 * @param velocity Vector of translation velocity in x,y,z direction
218 */
219 ZoneTranslate(int id, int domainID, const CompositeMap &domain,
220 const int coordDim, const std::vector<NekDouble> &velocity)
221 : ZoneBase(MovementType::eTranslate, id, domainID, domain, coordDim),
223 {
224 }
225
226 /// Default destructor
227 ~ZoneTranslate() override = default;
228
229 /// Returns the velocity of the zone
230 inline std::vector<NekDouble> GetVel() const
231 {
232 return m_velocity;
233 }
234
235protected:
236 std::vector<NekDouble> m_velocity;
237
238 /// Virtual function for movement of the zone at @param time
239 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
240};
241
242/// Prescribed zone: applies equation to every point
243struct ZonePrescribe final : public ZoneBase
244{
245 /**
246 * Constructor for prescribed zone
247 *
248 * @param id Zone ID
249 * @param domainID ID associated with the the domain making up
250 * the zone
251 * @param domain Domain that the zone consists of
252 * @param coordDim Coordinate dimension
253 * @param xDeform Equation for prescribed motion of x-coordinate
254 * @param yDeform Equation for prescribed motion of y-coordinate
255 * @param zDeform Equation for prescribed motion of z-coordinate
256 */
257 ZonePrescribe(int id, int domainID, const CompositeMap &domain,
258 const int coordDim, LibUtilities::EquationSharedPtr xDeform,
261 : ZoneBase(MovementType::ePrescribe, id, domainID, domain, coordDim),
262 m_xDeform(xDeform), m_yDeform(yDeform), m_zDeform(zDeform)
263 {
264 }
265
266 /// Default destructor
267 ~ZonePrescribe() override = default;
268
269 /**
270 * Returns point @param x @param y @param z deformation in the x direction
271 * at time @param t
272 * @param x x-coordinate
273 * @param y y-coordinate
274 * @param z z-coordinate
275 * @param t time
276 * @return deformation in x direction
277 */
279 NekDouble t) const
280 {
281 return m_xDeform->Evaluate(x, y, z, t);
282 }
283
284 /**
285 * Returns point @param x @param y @param z deformation in the y direction
286 * at time @param t
287 * @param x x-coordinate
288 * @param y y-coordinate
289 * @param z z-coordinate
290 * @param t time
291 * @return deformation in y direction
292 */
294 NekDouble t) const
295 {
296 return m_yDeform->Evaluate(x, y, z, t);
297 }
298
299 /**
300 * Returns point @param x @param y @param z deformation in the z direction
301 * at time @param t
302 * @param x x-coordinate
303 * @param y y-coordinate
304 * @param z z-coordinate
305 * @param t time
306 * @return deformation in z direction
307 */
309 NekDouble t) const
310 {
311 return m_zDeform->Evaluate(x, y, z, t);
312 }
313
314 /// Returns the equation for the prescribed motion in the x-coordinate
316 {
317 return m_xDeform;
318 }
319
320 /// Returns the equation for the prescribed motion in the y-coordinate
322 {
323 return m_yDeform;
324 }
325
326 /// Returns the equation for the prescribed motion in the z-coordinate
328 {
329 return m_zDeform;
330 }
331
332protected:
333 /// Equation specifying prescribed motion in x-direction
335 /// Equation specifying prescribed motion in y-direction
337 /// Equation specifying prescribed motion in z-direction
339
340 /// Virtual function for movement of the zone at @param time
341 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
342};
343
344/// Fixed zone: does not move
345struct ZoneFixed final : public ZoneBase
346{
347 /// Constructor
348 ZoneFixed(int id, int domainID, const CompositeMap &domain,
349 const int coordDim)
350 : ZoneBase(MovementType::eFixed, id, domainID, domain, coordDim)
351 {
352 }
353
354 /// Default destructor
355 ~ZoneFixed() override = default;
356
357protected:
358 /// Virtual function for movement of the zone at @param time
359 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
360};
361
362typedef std::shared_ptr<ZoneRotate> ZoneRotateShPtr;
363typedef std::shared_ptr<ZoneTranslate> ZoneTranslateShPtr;
364typedef std::shared_ptr<ZonePrescribe> ZonePrescribeShPtr;
365typedef std::shared_ptr<ZoneFixed> ZoneFixedShPtr;
366
367} // namespace Nektar::SpatialDomains
368
369#endif // NEKTAR_SPATIALDOMAINS_ZONES_H
#define SPATIAL_DOMAINS_EXPORT
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:125
const std::vector< NekDouble > velocity
const NekPoint< NekDouble > origin
std::shared_ptr< ZoneBase > ZoneBaseShPtr
Definition: Zones.h:144
std::shared_ptr< ZonePrescribe > ZonePrescribeShPtr
Definition: Zones.h:364
std::shared_ptr< ZoneTranslate > ZoneTranslateShPtr
Definition: Zones.h:363
std::shared_ptr< ZoneRotate > ZoneRotateShPtr
Definition: Zones.h:362
MovementType
Enum of zone movement type.
Definition: Zones.h:47
std::shared_ptr< ZoneFixed > ZoneFixedShPtr
Definition: Zones.h:365
const std::string MovementTypeStr[]
Map of zone movement type to movement type string.
Definition: Zones.h:57
std::map< int, CompositeSharedPtr > CompositeMap
Definition: MeshGraph.h:136
std::vector< double > z(NPUPPER)
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
Definition: NekTypeDefs.hpp:50
double NekDouble
Zone base: Contains the shared functions and variables.
Definition: Zones.h:62
ZoneBase(MovementType type, int indx, int domainID, CompositeMap domain, int coordDim)
Constructor.
bool Move(NekDouble time)
Performs the movement of the zone at.
Definition: Zones.h:95
virtual ~ZoneBase()=default
Default destructor.
std::vector< PointGeomSharedPtr > m_verts
Vector of all points in the zone.
Definition: Zones.h:131
int m_coordDim
Coordinate dimension.
Definition: Zones.h:129
std::vector< GeometrySharedPtr > const & GetElements() const
Returns all highest dimension elements in the zone.
Definition: Zones.h:101
void ClearBoundingBoxes()
Clears all bounding boxes associated with the zones elements.
std::vector< PointGeom > m_origVerts
Vector of all points in the zone at initialisation.
Definition: Zones.h:135
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:107
std::vector< CurveSharedPtr > m_curves
Vector of all curves in the zone.
Definition: Zones.h:133
int m_domainID
ID for the composite making up this zone.
Definition: Zones.h:121
CompositeMap m_domain
Zone domain.
Definition: Zones.h:123
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:138
std::vector< GeometrySharedPtr > m_elements
Vector of highest dimension zone elements.
Definition: Zones.h:125
MovementType m_type
Type of zone movement.
Definition: Zones.h:117
int & GetDomainID()
Returns the ID of the domain making up this Zone.
Definition: Zones.h:89
bool m_moved
Moved flag.
Definition: Zones.h:127
int & GetId()
Returns the zone ID.
Definition: Zones.h:83
Fixed zone: does not move.
Definition: Zones.h:346
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
~ZoneFixed() override=default
Default destructor.
ZoneFixed(int id, int domainID, const CompositeMap &domain, const int coordDim)
Constructor.
Definition: Zones.h:348
Prescribed zone: applies equation to every point.
Definition: Zones.h:244
NekDouble GetXDeform(NekDouble x, NekDouble y, NekDouble z, NekDouble t) const
Definition: Zones.h:278
NekDouble GetYDeform(NekDouble x, NekDouble y, NekDouble z, NekDouble t) const
Definition: Zones.h:293
LibUtilities::EquationSharedPtr m_zDeform
Equation specifying prescribed motion in z-direction.
Definition: Zones.h:338
LibUtilities::EquationSharedPtr GetYDeformEquation() const
Returns the equation for the prescribed motion in the y-coordinate.
Definition: Zones.h:321
LibUtilities::EquationSharedPtr m_yDeform
Equation specifying prescribed motion in y-direction.
Definition: Zones.h:336
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
NekDouble GetZDeform(NekDouble x, NekDouble y, NekDouble z, NekDouble t) const
Definition: Zones.h:308
~ZonePrescribe() override=default
Default destructor.
ZonePrescribe(int id, int domainID, const CompositeMap &domain, const int coordDim, LibUtilities::EquationSharedPtr xDeform, LibUtilities::EquationSharedPtr yDeform, LibUtilities::EquationSharedPtr zDeform)
Definition: Zones.h:257
LibUtilities::EquationSharedPtr GetZDeformEquation() const
Returns the equation for the prescribed motion in the z-coordinate.
Definition: Zones.h:327
LibUtilities::EquationSharedPtr GetXDeformEquation() const
Returns the equation for the prescribed motion in the x-coordinate.
Definition: Zones.h:315
LibUtilities::EquationSharedPtr m_xDeform
Equation specifying prescribed motion in x-direction.
Definition: Zones.h:334
Rotating zone: Motion of every point around a given axis on an origin.
Definition: Zones.h:148
DNekVec m_axis
Axis rotation is performed around.
Definition: Zones.h:194
NekDouble GetAngularVel(NekDouble &time) const
Return the angular velocity of the zone at.
DNekMat m_W
W matrix Rodrigues' rotation formula, cross product of axis.
Definition: Zones.h:198
LibUtilities::EquationSharedPtr GetAngularVelEqn() const
Returns the equation for the angular velocity of the rotation.
Definition: Zones.h:185
NekPoint< NekDouble > m_origin
Origin point rotation is performed around.
Definition: Zones.h:192
LibUtilities::EquationSharedPtr m_angularVelEqn
Equation defining angular velocity as a function of time.
Definition: Zones.h:196
const DNekVec & GetAxis() const
Returns the axis the zone rotates about.
Definition: Zones.h:179
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
DNekMat m_W2
W^2 matrix Rodrigues' rotation formula, cross product of axis squared.
Definition: Zones.h:200
~ZoneRotate() override=default
Default destructor.
ZoneRotate(int id, int domainID, const CompositeMap &domain, const int coordDim, const NekPoint< NekDouble > &origin, const DNekVec &axis, const LibUtilities::EquationSharedPtr &angularVelEqn)
const NekPoint< NekDouble > & GetOrigin() const
Returns the origin the zone rotates about.
Definition: Zones.h:173
Translating zone: addition of a constant vector to every point.
Definition: Zones.h:208
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
std::vector< NekDouble > m_velocity
Definition: Zones.h:236
ZoneTranslate(int id, int domainID, const CompositeMap &domain, const int coordDim, const std::vector< NekDouble > &velocity)
Definition: Zones.h:219
~ZoneTranslate() override=default
Default destructor.
std::vector< NekDouble > GetVel() const
Returns the velocity of the zone.
Definition: Zones.h:230