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
37#ifndef NEKTAR_SPATIALDOMAINS_ZONES_H
38#define NEKTAR_SPATIALDOMAINS_ZONES_H
39
42
44{
45
46/// Enum of zone movement type
48{
54};
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<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
115 /// Returns constituent elements, i.e. faces + edges
116 inline std::array<std::set<GeometrySharedPtr>, 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
139protected:
140 /// Type of zone movement
142 /// Zone ID
143 int m_id;
144 /// ID for the composite making up this zone.
146 /// Zone domain
148 /// Vector of highest dimension zone elements
149 std::vector<GeometrySharedPtr> m_elements;
150 /// Array of all dimension elements i.e. faces = [2], edges = [1], geom =
151 /// [0]
152 std::array<std::set<GeometrySharedPtr>, 3> m_constituentElements;
153 /// Moved flag
154 bool m_moved = true;
155 /// Coordinate dimension
157 /// Vector of all points in the zone
158 std::vector<PointGeomSharedPtr> m_verts;
159 /// Vector of all curves in the zone
160 std::vector<CurveSharedPtr> m_curves;
161 /// Vector of all points in the zone at initialisation
162 std::vector<PointGeom> m_origVerts;
163
164 /// Virtual function for movement of the zone at @param time
165 inline virtual bool v_Move([[maybe_unused]] NekDouble time)
166 {
167 return false;
168 }
169};
170
171typedef std::shared_ptr<ZoneBase> ZoneBaseShPtr;
172
173/// Rotating zone: Motion of every point around a given axis on an origin
174struct ZoneRotate final : public ZoneBase
175{
176 /**
177 * Constructor for rotating zones
178 *
179 * @param id Zone ID
180 * @param domainID ID associated with the the domain making up
181 * the zone
182 * @param domain Domain that the zone consists of
183 * @param coordDim Coordinate dimension
184 * @param origin Origin that the zone rotates about
185 * @param axis Axis that the zone rotates about
186 * @param angularVelEqn Equation for the angular velocity of rotation
187 */
189 int id, int domainID, const CompositeMap &domain, const int coordDim,
190 const NekPoint<NekDouble> &origin, const DNekVec &axis,
191 const LibUtilities::EquationSharedPtr &angularVelEqn);
192
193 /// Default destructor
194 ~ZoneRotate() override = default;
195
196 /// Return the angular velocity of the zone at @param time
198
199 /// Returns the origin the zone rotates about
200 inline const NekPoint<NekDouble> &GetOrigin() const
201 {
202 return m_origin;
203 }
204
205 /// Returns the axis the zone rotates about
206 inline const DNekVec &GetAxis() const
207 {
208 return m_axis;
209 }
210
211 /// Returns the equation for the angular velocity of the rotation
213 {
214 return m_angularVelEqn;
215 }
216
217protected:
218 /// Origin point rotation is performed around
220 /// Axis rotation is performed around
222 /// Equation defining angular velocity as a function of time
224 /// W matrix Rodrigues' rotation formula, cross product of axis
225 DNekMat m_W = DNekMat(3, 3, 0.0);
226 /// W^2 matrix Rodrigues' rotation formula, cross product of axis squared
227 DNekMat m_W2 = DNekMat(3, 3, 0.0);
228
229 /// Virtual function for movement of the zone at @param time
230 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
231};
232
233/// Translating zone: addition of a constant vector to every point
234struct ZoneTranslate final : public ZoneBase
235{
236 /**
237 * Constructor for translating zone
238 *
239 * @param id Zone ID
240 * @param domainID ID associated with the the domain making up
241 * the zone
242 * @param domain Domain that the zone consists of
243 * @param coordDim Coordinate dimension
244 * @param velocity Vector of translation velocity in x,y,z direction
245 */
247 int id, int domainID, const CompositeMap &domain, const int coordDim,
249 const Array<OneD, LibUtilities::EquationSharedPtr> &displacementEqns)
250 : ZoneBase(MovementType::eTranslate, id, domainID, domain, coordDim),
251 m_velocityEqns(velocityEqns), m_displacementEqns(displacementEqns)
252 {
253 }
254
255 /// Default destructor
256 ~ZoneTranslate() override = default;
257
258 /// Returns the velocity of the zone
259 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> GetVel(NekDouble &time) const;
260
261 /// Returns the displacement of the zone
262 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> GetDisp(NekDouble &time);
263
264 std::vector<NekDouble> v_GetDisp() const override
265 {
266 return m_disp;
267 }
268
269 /// Returns the equation for the velocity of the translation
271 const
272 {
273 return m_velocityEqns;
274 }
275
276 /// Returns the equation for the displacement of the translation
278 const
279 {
280 return m_displacementEqns;
281 }
282
283protected:
286 std::vector<NekDouble> m_disp;
287
288 /// Virtual function for movement of the zone at @param time
289 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
290};
291
292/// Fixed zone: does not move
293struct ZoneFixed final : public ZoneBase
294{
295 /// Constructor
296 ZoneFixed(int id, int domainID, const CompositeMap &domain,
297 const int coordDim)
298 : ZoneBase(MovementType::eFixed, id, domainID, domain, coordDim)
299 {
300 }
301
302 /// Default destructor
303 ~ZoneFixed() override = default;
304
305protected:
306 /// Virtual function for movement of the zone at @param time
307 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
308
309 /// Returns the displacement of the zone
310 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> v_GetDisp() const override;
311};
312
313typedef std::shared_ptr<ZoneRotate> ZoneRotateShPtr;
314typedef std::shared_ptr<ZoneTranslate> ZoneTranslateShPtr;
315typedef std::shared_ptr<ZoneFixed> ZoneFixedShPtr;
316
317} // namespace Nektar::SpatialDomains
318
319#endif // NEKTAR_SPATIALDOMAINS_ZONES_H
#define SPATIAL_DOMAINS_EXPORT
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:125
const NekPoint< NekDouble > origin
std::shared_ptr< ZoneBase > ZoneBaseShPtr
Definition: Zones.h:171
std::shared_ptr< ZoneTranslate > ZoneTranslateShPtr
Definition: Zones.h:314
std::shared_ptr< ZoneRotate > ZoneRotateShPtr
Definition: Zones.h:313
MovementType
Enum of zone movement type.
Definition: Zones.h:48
std::shared_ptr< ZoneFixed > ZoneFixedShPtr
Definition: Zones.h:315
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
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::array< std::set< GeometrySharedPtr >, 3 > m_constituentElements
Array of all dimension elements i.e. faces = [2], edges = [1], geom = [0].
Definition: Zones.h:152
std::vector< PointGeomSharedPtr > m_verts
Vector of all points in the zone.
Definition: Zones.h:158
int m_coordDim
Coordinate dimension.
Definition: Zones.h:156
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:162
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:160
int m_domainID
ID for the composite making up this zone.
Definition: Zones.h:145
std::vector< PointGeom > & GetOriginalVertex()
Returns all points in the zone at initialisation.
Definition: Zones.h:122
CompositeMap m_domain
Zone domain.
Definition: Zones.h:147
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:165
std::vector< GeometrySharedPtr > m_elements
Vector of highest dimension zone elements.
Definition: Zones.h:149
MovementType m_type
Type of zone movement.
Definition: Zones.h:141
int & GetDomainID()
Returns the ID of the domain making up this Zone.
Definition: Zones.h:89
std::array< std::set< GeometrySharedPtr >, 3 > & GetConstituentElements()
Returns constituent elements, i.e. faces + edges.
Definition: Zones.h:116
bool m_moved
Moved flag.
Definition: Zones.h:154
int & GetId()
Returns the zone ID.
Definition: Zones.h:83
Fixed zone: does not move.
Definition: Zones.h:294
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.
~ZoneFixed() override=default
Default destructor.
ZoneFixed(int id, int domainID, const CompositeMap &domain, const int coordDim)
Constructor.
Definition: Zones.h:296
Rotating zone: Motion of every point around a given axis on an origin.
Definition: Zones.h:175
DNekVec m_axis
Axis rotation is performed around.
Definition: Zones.h:221
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:225
LibUtilities::EquationSharedPtr GetAngularVelEqn() const
Returns the equation for the angular velocity of the rotation.
Definition: Zones.h:212
NekPoint< NekDouble > m_origin
Origin point rotation is performed around.
Definition: Zones.h:219
LibUtilities::EquationSharedPtr m_angularVelEqn
Equation defining angular velocity as a function of time.
Definition: Zones.h:223
const DNekVec & GetAxis() const
Returns the axis the zone rotates about.
Definition: Zones.h:206
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:227
~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:200
Translating zone: addition of a constant vector to every point.
Definition: Zones.h:235
std::vector< NekDouble > GetDisp(NekDouble &time)
Returns the displacement of the zone.
std::vector< NekDouble > m_disp
Definition: Zones.h:286
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
Array< OneD, LibUtilities::EquationSharedPtr > m_displacementEqns
Definition: Zones.h:285
Array< OneD, LibUtilities::EquationSharedPtr > GetDisplacementEquation() const
Returns the equation for the displacement of the translation.
Definition: Zones.h:277
Array< OneD, LibUtilities::EquationSharedPtr > m_velocityEqns
Definition: Zones.h:284
std::vector< NekDouble > v_GetDisp() const override
Returns zone displacment.
Definition: Zones.h:264
std::vector< NekDouble > GetVel(NekDouble &time) const
Returns the velocity of the zone.
~ZoneTranslate() override=default
Default destructor.
ZoneTranslate(int id, int domainID, const CompositeMap &domain, const int coordDim, const Array< OneD, LibUtilities::EquationSharedPtr > &velocityEqns, const Array< OneD, LibUtilities::EquationSharedPtr > &displacementEqns)
Definition: Zones.h:246
Array< OneD, LibUtilities::EquationSharedPtr > GetVelocityEquation() const
Returns the equation for the velocity of the translation.
Definition: Zones.h:270