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{
53};
54
55/// Map of zone movement type to movement type string
56const std::string MovementTypeStr[] = {"None", "Fixed", "Rotated",
57 "Translated"};
58
59/// Zone base: Contains the shared functions and variables
61{
62 /// Constructor
63 SPATIAL_DOMAINS_EXPORT ZoneBase(MovementType type, int indx, int domainID,
64 CompositeMap domain, int coordDim);
65
66 /// Default destructor
67 virtual ~ZoneBase() = default;
68
69 /// Returns the type of movement
71 {
72 return m_type;
73 }
74
75 /// Returns the domain the zone is on
76 inline CompositeMap GetDomain() const
77 {
78 return m_domain;
79 }
80
81 /// Returns the zone ID
82 inline int &GetId()
83 {
84 return m_id;
85 }
86
87 /// Returns the ID of the domain making up this Zone
88 inline int &GetDomainID()
89 {
90 return m_domainID;
91 }
92
93 /// Performs the movement of the zone at @param time
94 inline bool Move(NekDouble time)
95 {
96 return v_Move(time);
97 }
98
99 /// Returns all highest dimension elements in the zone
100 inline std::vector<GeometrySharedPtr> const &GetElements() const
101 {
102 return m_elements;
103 }
104
105 /// Returns the flag which states if the zone has moved in this timestep
106 inline bool &GetMoved()
107 {
108 return m_moved;
109 }
110
111 /// Clears all bounding boxes associated with the zones elements
112 void ClearBoundingBoxes();
113
114 /// Returns constituent elements, i.e. faces + edges
115 inline std::array<std::set<GeometrySharedPtr>, 3> &GetConstituentElements()
116 {
118 }
119
120 /// Returns all points in the zone at initialisation
121 inline std::vector<PointGeom> &GetOriginalVertex()
122 {
123 return m_origVerts;
124 }
125
126 /// Returns zone displacment
127 SPATIAL_DOMAINS_EXPORT virtual std::vector<NekDouble> v_GetDisp() const
128 {
129 std::vector<NekDouble> disp(m_coordDim);
130 for (int i = 0; i < m_coordDim; ++i)
131 {
132 disp[i] = 0.0;
133 }
134
135 return disp;
136 }
137
138protected:
139 /// Type of zone movement
141 /// Zone ID
142 int m_id;
143 /// ID for the composite making up this zone.
145 /// Zone domain
147 /// Vector of highest dimension zone elements
148 std::vector<GeometrySharedPtr> m_elements;
149 /// Array of all dimension elements i.e. faces = [2], edges = [1], geom =
150 /// [0]
151 std::array<std::set<GeometrySharedPtr>, 3> m_constituentElements;
152 /// Moved flag
153 bool m_moved = true;
154 /// Coordinate dimension
156 /// Vector of all points in the zone
157 std::vector<PointGeomSharedPtr> m_verts;
158 /// Vector of all curves in the zone
159 std::vector<CurveSharedPtr> m_curves;
160 /// Vector of all points in the zone at initialisation
161 std::vector<PointGeom> m_origVerts;
162
163 /// Virtual function for movement of the zone at @param time
164 inline virtual bool v_Move([[maybe_unused]] NekDouble time)
165 {
166 return false;
167 }
168};
169
170typedef std::shared_ptr<ZoneBase> ZoneBaseShPtr;
171
172/// Rotating zone: Motion of every point around a given axis on an origin
173struct ZoneRotate final : public ZoneBase
174{
175 /**
176 * Constructor for rotating zones
177 *
178 * @param id Zone ID
179 * @param domainID ID associated with the the domain making up
180 * the zone
181 * @param domain Domain that the zone consists of
182 * @param coordDim Coordinate dimension
183 * @param origin Origin that the zone rotates about
184 * @param axis Axis that the zone rotates about
185 * @param angularVelEqn Equation for the angular velocity of rotation
186 */
188 int id, int domainID, const CompositeMap &domain, const int coordDim,
189 const NekPoint<NekDouble> &origin, const DNekVec &axis,
190 const LibUtilities::EquationSharedPtr &angularVelEqn);
191
192 /// Default destructor
193 ~ZoneRotate() override = default;
194
195 /// Return the angular velocity of the zone at @param time
197
198 /// Returns the origin the zone rotates about
199 inline const NekPoint<NekDouble> &GetOrigin() const
200 {
201 return m_origin;
202 }
203
204 /// Returns the axis the zone rotates about
205 inline const DNekVec &GetAxis() const
206 {
207 return m_axis;
208 }
209
210 /// Returns the equation for the angular velocity of the rotation
212 {
213 return m_angularVelEqn;
214 }
215
216protected:
217 /// Origin point rotation is performed around
219 /// Axis rotation is performed around
221 /// Equation defining angular velocity as a function of time
223 /// W matrix Rodrigues' rotation formula, cross product of axis
224 DNekMat m_W = DNekMat(3, 3, 0.0);
225 /// W^2 matrix Rodrigues' rotation formula, cross product of axis squared
226 DNekMat m_W2 = DNekMat(3, 3, 0.0);
227
228 /// Virtual function for movement of the zone at @param time
229 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
230};
231
232/// Translating zone: addition of a constant vector to every point
233struct ZoneTranslate final : public ZoneBase
234{
235 /**
236 * Constructor for translating zone
237 *
238 * @param id Zone ID
239 * @param domainID ID associated with the the domain making up
240 * the zone
241 * @param domain Domain that the zone consists of
242 * @param coordDim Coordinate dimension
243 * @param velocity Vector of translation velocity in x,y,z direction
244 */
246 int id, int domainID, const CompositeMap &domain, const int coordDim,
248 const Array<OneD, LibUtilities::EquationSharedPtr> &displacementEqns)
249 : ZoneBase(MovementType::eTranslate, id, domainID, domain, coordDim),
250 m_velocityEqns(velocityEqns), m_displacementEqns(displacementEqns)
251 {
252 }
253
254 /// Default destructor
255 ~ZoneTranslate() override = default;
256
257 /// Returns the velocity of the zone
258 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> GetVel(NekDouble &time) const;
259
260 /// Returns the displacement of the zone
261 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> GetDisp(NekDouble &time);
262
263 std::vector<NekDouble> v_GetDisp() const override
264 {
265 return m_disp;
266 }
267
268 /// Returns the equation for the velocity of the translation
270 const
271 {
272 return m_velocityEqns;
273 }
274
275 /// Returns the equation for the displacement of the translation
277 const
278 {
279 return m_displacementEqns;
280 }
281
282protected:
285 std::vector<NekDouble> m_disp;
286
287 /// Virtual function for movement of the zone at @param time
288 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
289};
290
291/// Fixed zone: does not move
292struct ZoneFixed final : public ZoneBase
293{
294 /// Constructor
295 ZoneFixed(int id, int domainID, const CompositeMap &domain,
296 const int coordDim)
297 : ZoneBase(MovementType::eFixed, id, domainID, domain, coordDim)
298 {
299 }
300
301 /// Default destructor
302 ~ZoneFixed() override = default;
303
304protected:
305 /// Virtual function for movement of the zone at @param time
306 SPATIAL_DOMAINS_EXPORT bool v_Move(NekDouble time) final;
307
308 /// Returns the displacement of the zone
309 SPATIAL_DOMAINS_EXPORT std::vector<NekDouble> v_GetDisp() const override;
310};
311
312typedef std::shared_ptr<ZoneRotate> ZoneRotateShPtr;
313typedef std::shared_ptr<ZoneTranslate> ZoneTranslateShPtr;
314typedef std::shared_ptr<ZoneFixed> ZoneFixedShPtr;
315
316} // namespace Nektar::SpatialDomains
317
318#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:170
std::shared_ptr< ZoneTranslate > ZoneTranslateShPtr
Definition: Zones.h:313
std::shared_ptr< ZoneRotate > ZoneRotateShPtr
Definition: Zones.h:312
MovementType
Enum of zone movement type.
Definition: Zones.h:47
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:56
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:61
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:94
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:151
std::vector< PointGeomSharedPtr > m_verts
Vector of all points in the zone.
Definition: Zones.h:157
int m_coordDim
Coordinate dimension.
Definition: Zones.h:155
std::vector< GeometrySharedPtr > const & GetElements() const
Returns all highest dimension elements in the zone.
Definition: Zones.h:100
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:161
CompositeMap GetDomain() const
Returns the domain the zone is on.
Definition: Zones.h:76
bool & GetMoved()
Returns the flag which states if the zone has moved in this timestep.
Definition: Zones.h:106
std::vector< CurveSharedPtr > m_curves
Vector of all curves in the zone.
Definition: Zones.h:159
int m_domainID
ID for the composite making up this zone.
Definition: Zones.h:144
std::vector< PointGeom > & GetOriginalVertex()
Returns all points in the zone at initialisation.
Definition: Zones.h:121
CompositeMap m_domain
Zone domain.
Definition: Zones.h:146
MovementType GetMovementType() const
Returns the type of movement.
Definition: Zones.h:70
virtual std::vector< NekDouble > v_GetDisp() const
Returns zone displacment.
Definition: Zones.h:127
virtual bool v_Move(NekDouble time)
Virtual function for movement of the zone at.
Definition: Zones.h:164
std::vector< GeometrySharedPtr > m_elements
Vector of highest dimension zone elements.
Definition: Zones.h:148
MovementType m_type
Type of zone movement.
Definition: Zones.h:140
int & GetDomainID()
Returns the ID of the domain making up this Zone.
Definition: Zones.h:88
std::array< std::set< GeometrySharedPtr >, 3 > & GetConstituentElements()
Returns constituent elements, i.e. faces + edges.
Definition: Zones.h:115
bool m_moved
Moved flag.
Definition: Zones.h:153
int & GetId()
Returns the zone ID.
Definition: Zones.h:82
Fixed zone: does not move.
Definition: Zones.h:293
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:295
Rotating zone: Motion of every point around a given axis on an origin.
Definition: Zones.h:174
DNekVec m_axis
Axis rotation is performed around.
Definition: Zones.h:220
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:224
LibUtilities::EquationSharedPtr GetAngularVelEqn() const
Returns the equation for the angular velocity of the rotation.
Definition: Zones.h:211
NekPoint< NekDouble > m_origin
Origin point rotation is performed around.
Definition: Zones.h:218
LibUtilities::EquationSharedPtr m_angularVelEqn
Equation defining angular velocity as a function of time.
Definition: Zones.h:222
const DNekVec & GetAxis() const
Returns the axis the zone rotates about.
Definition: Zones.h:205
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:226
~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:199
Translating zone: addition of a constant vector to every point.
Definition: Zones.h:234
std::vector< NekDouble > GetDisp(NekDouble &time)
Returns the displacement of the zone.
std::vector< NekDouble > m_disp
Definition: Zones.h:285
bool v_Move(NekDouble time) final
Virtual function for movement of the zone at.
Array< OneD, LibUtilities::EquationSharedPtr > m_displacementEqns
Definition: Zones.h:284
Array< OneD, LibUtilities::EquationSharedPtr > GetDisplacementEquation() const
Returns the equation for the displacement of the translation.
Definition: Zones.h:276
Array< OneD, LibUtilities::EquationSharedPtr > m_velocityEqns
Definition: Zones.h:283
std::vector< NekDouble > v_GetDisp() const override
Returns zone displacment.
Definition: Zones.h:263
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:245
Array< OneD, LibUtilities::EquationSharedPtr > GetVelocityEquation() const
Returns the equation for the velocity of the translation.
Definition: Zones.h:269