Nektar++
Loading...
Searching...
No Matches
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
37#ifndef NEKTAR_SPATIALDOMAINS_ZONES_H
38#define NEKTAR_SPATIALDOMAINS_ZONES_H
39
42
44{
45
46/// Enum of zone movement type
55
56/// Map of zone movement type to movement type string
57const std::string MovementTypeStr[] = {"None", "Fixed", "Rotated",
58 "Translated"};
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<Geometry *> 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
115 /// Returns constituent elements, i.e. faces + edges
116 inline std::array<std::set<Geometry *>, 3> &GetConstituentElements()
117 {
119 }
120
121 /// Returns all points in the zone at initialisation
122 inline std::vector<PointGeom> &GetOriginalVertex()
123 {
124 return m_origVerts;
125 }
126
127 /// Returns zone displacment
128 SPATIAL_DOMAINS_EXPORT virtual std::vector<NekDouble> v_GetDisp() const
129 {
130 std::vector<NekDouble> disp(m_coordDim);
131 for (int i = 0; i < m_coordDim; ++i)
132 {
133 disp[i] = 0.0;
134 }
135
136 return disp;
137 }
138
139 /// Returns zone rotate angle
141 {
142 return 0.0;
143 }
144
145protected:
146 /// Type of zone movement
148 /// Zone ID
149 int m_id;
150 /// ID for the composite making up this zone.
152 /// Zone domain
154 /// Vector of highest dimension zone elements
155 std::vector<Geometry *> m_elements;
156 /// Array of all dimension elements i.e. faces = [2], edges = [1], geom =
157 /// [0]
158 std::array<std::set<Geometry *>, 3> m_constituentElements;
159 /// Moved flag
160 bool m_moved = true;
161 /// Coordinate dimension
163 /// Vector of all points in the zone
164 std::vector<PointGeomUniquePtr> m_verts;
165 /// Vector of all curves in the zone
166 std::vector<CurveSharedPtr> m_curves;
167 /// Vector of all points in the zone at initialisation
168 std::vector<PointGeom> m_origVerts;
169
170 /// Virtual function for movement of the zone at @param time
171 inline virtual bool v_Move([[maybe_unused]] NekDouble time)
172 {
173 return false;
174 }
175};
176
177typedef std::shared_ptr<ZoneBase> ZoneBaseShPtr;
178
179/// Rotating zone: Motion of every point around a given axis on an origin
180struct ZoneRotate final : public ZoneBase
181{
182 /**
183 * Constructor for rotating zones
184 *
185 * @param id Zone ID
186 * @param domainID ID associated with the the domain making up
187 * the zone
188 * @param domain Domain that the zone consists of
189 * @param coordDim Coordinate dimension
190 * @param origin Origin that the zone rotates about
191 * @param axis Axis that the zone rotates about
192 * @param angularVelEqn Equation for the angular velocity of rotation
193 */
195 int id, int domainID, const CompositeMap &domain, const int coordDim,
196 const NekPoint<NekDouble> &origin, const DNekVec &axis,
197 const LibUtilities::EquationSharedPtr &angularVelEqn,
198 const NekDouble rampTime, const NekDouble sector,
199 const Array<OneD, NekDouble> &base);
200
201 /// Default destructor
202 ~ZoneRotate() override = default;
203
204 /// Return the angular velocity of the zone at @param time
206
207 /// Returns the rotation angle of the zone
209
210 /// Rotates the given global coordinate by the given angle
212 const NekDouble &angle);
213
214 /// Returns the origin the zone rotates about
215 inline const NekPoint<NekDouble> &GetOrigin() const
216 {
217 return m_origin;
218 }
219
220 /// Returns the axis the zone rotates about
221 inline const DNekVec &GetAxis() const
222 {
223 return m_axis;
224 }
225
226 /// Returns the equation for the angular velocity of the rotation
231
232 /// Returns zone rotate angle
233 NekDouble v_GetAngle() const override
234 {
235 return m_angle;
236 }
237
238 /// Returns the angle of rotating sector.
239 inline const NekDouble &GetSectorAngle() const
240 {
241 return m_sector;
242 }
243
244 /// Returns the angle of rotating sector.
246 {
247 return m_base;
248 }
249
250protected:
251 /// Origin point rotation is performed around
253 /// Axis rotation is performed around
255 /// Equation defining angular velocity as a function of time
257 /// Rotate angle
259 /// Ramp time
261 /// Sector angle
263 /// Base axis of sector
265 /// W matrix Rodrigues' rotation formula, cross product of axis
266 DNekMat m_W = DNekMat(3, 3, 0.0);
267 /// W^2 matrix Rodrigues' rotation formula, cross product of axis squared
268 DNekMat m_W2 = DNekMat(3, 3, 0.0);
269
270 /// Virtual function for movement of the zone at @param time
271 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
272};
273
274/// Translating zone: addition of a constant vector to every point
275struct ZoneTranslate final : public ZoneBase
276{
277 /**
278 * Constructor for translating zone
279 *
280 * @param id Zone ID
281 * @param domainID ID associated with the the domain making up
282 * the zone
283 * @param domain Domain that the zone consists of
284 * @param coordDim Coordinate dimension
285 * @param velocity Vector of translation velocity in x,y,z direction
286 */
288 int id, int domainID, const CompositeMap &domain, const int coordDim,
290 const Array<OneD, LibUtilities::EquationSharedPtr> &displacementEqns);
291
292 /// Default destructor
293 ~ZoneTranslate() override = default;
294
295 /// Returns the velocity of the zone
296 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> GetVel(NekDouble &time) const;
297
298 /// Returns the displacement of the zone
299 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> GetDisp(NekDouble &time);
300
301 std::vector<NekDouble> v_GetDisp() const override
302 {
303 return m_disp;
304 }
305
306 /// Returns the equation for the velocity of the translation
312
313 /// Returns the equation for the displacement of the translation
319
321 const
322 {
323 return m_ZoneBox;
324 }
325
327 const
328 {
329 return m_ZoneLength;
330 }
331
333 const Array<OneD, NekDouble> &ZoneBox,
334 const Array<OneD, NekDouble> &ZoneLength)
335 {
336 m_ZoneBox = ZoneBox;
337 m_ZoneLength = ZoneLength;
338 }
339
340protected:
343 std::vector<NekDouble> m_disp;
346
347 /// Virtual function for movement of the zone at @param time
348 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
349};
350
351/// Fixed zone: does not move
352struct ZoneFixed final : public ZoneBase
353{
354 /// Constructor
355 ZoneFixed(int id, int domainID, const CompositeMap &domain,
356 const int coordDim)
357 : ZoneBase(MovementType::eFixed, id, domainID, domain, coordDim)
358 {
359 }
360
361 /// Default destructor
362 ~ZoneFixed() override = default;
363
364protected:
365 /// Virtual function for movement of the zone at @param time
366 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
367
368 /// Returns the displacement of the zone
369 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> v_GetDisp() const override;
370
371 /// Returns the displacement of the zone
373};
374
375typedef std::shared_ptr<ZoneRotate> ZoneRotateShPtr;
376typedef std::shared_ptr<ZoneTranslate> ZoneTranslateShPtr;
377typedef std::shared_ptr<ZoneFixed> ZoneFixedShPtr;
378
379} // namespace Nektar::SpatialDomains
380
381#endif // NEKTAR_SPATIALDOMAINS_ZONES_H
#define SPATIAL_DOMAINS_EXPORT
std::shared_ptr< Equation > EquationSharedPtr
Definition Equation.h:131
std::shared_ptr< ZoneBase > ZoneBaseShPtr
Definition Zones.h:177
std::shared_ptr< ZoneTranslate > ZoneTranslateShPtr
Definition Zones.h:376
std::shared_ptr< ZoneRotate > ZoneRotateShPtr
Definition Zones.h:375
MovementType
Enum of zone movement type.
Definition Zones.h:48
std::shared_ptr< ZoneFixed > ZoneFixedShPtr
Definition Zones.h:377
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:179
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
Zone base: Contains the shared functions and variables.
Definition Zones.h:62
bool Move(NekDouble time)
Performs the movement of the zone at.
Definition Zones.h:95
virtual ~ZoneBase()=default
Default destructor.
std::array< std::set< Geometry * >, 3 > m_constituentElements
Array of all dimension elements i.e. faces = [2], edges = [1], geom = [0].
Definition Zones.h:158
int m_coordDim
Coordinate dimension.
Definition Zones.h:162
void ClearBoundingBoxes()
Clears all bounding boxes associated with the zones elements.
std::array< std::set< Geometry * >, 3 > & GetConstituentElements()
Returns constituent elements, i.e. faces + edges.
Definition Zones.h:116
std::vector< PointGeom > m_origVerts
Vector of all points in the zone at initialisation.
Definition Zones.h:168
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:166
int m_domainID
ID for the composite making up this zone.
Definition Zones.h:151
std::vector< PointGeom > & GetOriginalVertex()
Returns all points in the zone at initialisation.
Definition Zones.h:122
CompositeMap m_domain
Zone domain.
Definition Zones.h:153
MovementType GetMovementType() const
Returns the type of movement.
Definition Zones.h:71
virtual std::vector< NekDouble > v_GetDisp() const
Returns zone displacment.
Definition Zones.h:128
virtual bool v_Move(NekDouble time)
Virtual function for movement of the zone at.
Definition Zones.h:171
std::vector< Geometry * > const & GetElements() const
Returns all highest dimension elements in the zone.
Definition Zones.h:101
virtual NekDouble v_GetAngle() const
Returns zone rotate angle.
Definition Zones.h:140
MovementType m_type
Type of zone movement.
Definition Zones.h:147
int & GetDomainID()
Returns the ID of the domain making up this Zone.
Definition Zones.h:89
std::vector< Geometry * > m_elements
Vector of highest dimension zone elements.
Definition Zones.h:155
std::vector< PointGeomUniquePtr > m_verts
Vector of all points in the zone.
Definition Zones.h:164
int & GetId()
Returns the zone ID.
Definition Zones.h:83
Fixed zone: does not move.
Definition Zones.h:353
std::vector< NekDouble > v_GetDisp() const override
Returns the displacement of the zone.
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
NekDouble v_GetAngle() const override
Returns the displacement of the zone.
~ZoneFixed() override=default
Default destructor.
ZoneFixed(int id, int domainID, const CompositeMap &domain, const int coordDim)
Constructor.
Definition Zones.h:355
Rotating zone: Motion of every point around a given axis on an origin.
Definition Zones.h:181
NekDouble m_sector
Sector angle.
Definition Zones.h:262
DNekVec m_axis
Axis rotation is performed around.
Definition Zones.h:254
NekDouble GetAngle(const NekDouble &time)
Returns the rotation angle of the zone.
DNekMat m_W
W matrix Rodrigues' rotation formula, cross product of axis.
Definition Zones.h:266
LibUtilities::EquationSharedPtr GetAngularVelEqn() const
Returns the equation for the angular velocity of the rotation.
Definition Zones.h:227
NekPoint< NekDouble > m_origin
Origin point rotation is performed around.
Definition Zones.h:252
NekDouble GetAngularVel(const NekDouble &time) const
Return the angular velocity of the zone at.
LibUtilities::EquationSharedPtr m_angularVelEqn
Equation defining angular velocity as a function of time.
Definition Zones.h:256
void Rotate(Array< OneD, NekDouble > &gloCoord, const NekDouble &angle)
Rotates the given global coordinate by the given angle.
NekDouble m_angle
Rotate angle.
Definition Zones.h:258
const DNekVec & GetAxis() const
Returns the axis the zone rotates about.
Definition Zones.h:221
NekDouble m_rampTime
Ramp time.
Definition Zones.h:260
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
const NekDouble & GetSectorAngle() const
Returns the angle of rotating sector.
Definition Zones.h:239
DNekMat m_W2
W^2 matrix Rodrigues' rotation formula, cross product of axis squared.
Definition Zones.h:268
Array< OneD, NekDouble > m_base
Base axis of sector.
Definition Zones.h:264
~ZoneRotate() override=default
Default destructor.
NekDouble v_GetAngle() const override
Returns zone rotate angle.
Definition Zones.h:233
const NekPoint< NekDouble > & GetOrigin() const
Returns the origin the zone rotates about.
Definition Zones.h:215
const Array< OneD, NekDouble > & GetSectorBase() const
Returns the angle of rotating sector.
Definition Zones.h:245
Translating zone: addition of a constant vector to every point.
Definition Zones.h:276
const Array< OneD, NekDouble > & GetZoneBox() const
Definition Zones.h:320
std::vector< NekDouble > GetDisp(NekDouble &time)
Returns the displacement of the zone.
Array< OneD, NekDouble > m_ZoneLength
Definition Zones.h:345
std::vector< NekDouble > m_disp
Definition Zones.h:343
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
Array< OneD, LibUtilities::EquationSharedPtr > m_displacementEqns
Definition Zones.h:342
Array< OneD, LibUtilities::EquationSharedPtr > GetDisplacementEquation() const
Returns the equation for the displacement of the translation.
Definition Zones.h:314
Array< OneD, LibUtilities::EquationSharedPtr > m_velocityEqns
Definition Zones.h:341
std::vector< NekDouble > v_GetDisp() const override
Returns zone displacment.
Definition Zones.h:301
std::vector< NekDouble > GetVel(NekDouble &time) const
Returns the velocity of the zone.
~ZoneTranslate() override=default
Default destructor.
const Array< OneD, NekDouble > & GetZoneLength() const
Definition Zones.h:326
void UpdateZoneBox(const Array< OneD, NekDouble > &ZoneBox, const Array< OneD, NekDouble > &ZoneLength)
Definition Zones.h:332
Array< OneD, NekDouble > m_ZoneBox
Definition Zones.h:344
Array< OneD, LibUtilities::EquationSharedPtr > GetVelocityEquation() const
Returns the equation for the velocity of the translation.
Definition Zones.h:307