Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::SpatialDomains::ZoneRotate Struct Referencefinal

Rotating zone: Motion of every point around a given axis on an origin. More...

#include <Zones.h>

Inheritance diagram for Nektar::SpatialDomains::ZoneRotate:
[legend]

Public Member Functions

 ZoneRotate (int id, int domainID, const CompositeMap &domain, const int coordDim, const NekPoint< NekDouble > &origin, const DNekVec &axis, const LibUtilities::EquationSharedPtr &angularVelEqn, const NekDouble rampTime, const NekDouble sector, const Array< OneD, NekDouble > &base)
 
 ~ZoneRotate () override=default
 Default destructor.
 
NekDouble GetAngularVel (const NekDouble &time) const
 Return the angular velocity of the zone at.
 
NekDouble GetAngle (const NekDouble &time)
 Returns the rotation angle of the zone.
 
void Rotate (Array< OneD, NekDouble > &gloCoord, const NekDouble &angle)
 Rotates the given global coordinate by the given angle.
 
const NekPoint< NekDouble > & GetOrigin () const
 Returns the origin the zone rotates about.
 
const DNekVecGetAxis () const
 Returns the axis the zone rotates about.
 
LibUtilities::EquationSharedPtr GetAngularVelEqn () const
 Returns the equation for the angular velocity of the rotation.
 
NekDouble v_GetAngle () const override
 Returns zone rotate angle.
 
const NekDoubleGetSectorAngle () const
 Returns the angle of rotating sector.
 
const Array< OneD, NekDouble > & GetSectorBase () const
 Returns the angle of rotating sector.
 
- Public Member Functions inherited from Nektar::SpatialDomains::ZoneBase
 ZoneBase (MovementType type, int indx, int domainID, CompositeMap domain, int coordDim)
 Constructor.
 
virtual ~ZoneBase ()=default
 Default destructor.
 
MovementType GetMovementType () const
 Returns the type of movement.
 
CompositeMap GetDomain () const
 Returns the domain the zone is on.
 
int & GetId ()
 Returns the zone ID.
 
int & GetDomainID ()
 Returns the ID of the domain making up this Zone.
 
bool Move (NekDouble time)
 Performs the movement of the zone at.
 
std::vector< Geometry * > const & GetElements () const
 Returns all highest dimension elements in the zone.
 
bool & GetMoved ()
 Returns the flag which states if the zone has moved in this timestep.
 
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.
 
std::vector< PointGeom > & GetOriginalVertex ()
 Returns all points in the zone at initialisation.
 
virtual std::vector< NekDoublev_GetDisp () const
 Returns zone displacment.
 

Protected Member Functions

bool v_Move (NekDouble time) final
 Virtual function for movement of the zone at.
 

Protected Attributes

NekPoint< NekDoublem_origin
 Origin point rotation is performed around.
 
DNekVec m_axis
 Axis rotation is performed around.
 
LibUtilities::EquationSharedPtr m_angularVelEqn
 Equation defining angular velocity as a function of time.
 
NekDouble m_angle
 Rotate angle.
 
NekDouble m_rampTime
 Ramp time.
 
NekDouble m_sector
 Sector angle.
 
Array< OneD, NekDoublem_base
 Base axis of sector.
 
DNekMat m_W = DNekMat(3, 3, 0.0)
 W matrix Rodrigues' rotation formula, cross product of axis.
 
DNekMat m_W2 = DNekMat(3, 3, 0.0)
 W^2 matrix Rodrigues' rotation formula, cross product of axis squared.
 
- Protected Attributes inherited from Nektar::SpatialDomains::ZoneBase
MovementType m_type = MovementType::eNone
 Type of zone movement.
 
int m_id
 Zone ID.
 
int m_domainID
 ID for the composite making up this zone.
 
CompositeMap m_domain
 Zone domain.
 
std::vector< Geometry * > m_elements
 Vector of highest dimension zone elements.
 
std::array< std::set< Geometry * >, 3 > m_constituentElements
 Array of all dimension elements i.e. faces = [2], edges = [1], geom = [0].
 
bool m_moved = true
 Moved flag.
 
int m_coordDim
 Coordinate dimension.
 
std::vector< PointGeomUniquePtrm_verts
 Vector of all points in the zone.
 
std::vector< CurveSharedPtrm_curves
 Vector of all curves in the zone.
 
std::vector< PointGeomm_origVerts
 Vector of all points in the zone at initialisation.
 

Detailed Description

Rotating zone: Motion of every point around a given axis on an origin.

Definition at line 180 of file Zones.h.

Constructor & Destructor Documentation

◆ ZoneRotate()

Nektar::SpatialDomains::ZoneRotate::ZoneRotate ( int  id,
int  domainID,
const CompositeMap domain,
const int  coordDim,
const NekPoint< NekDouble > &  origin,
const DNekVec axis,
const LibUtilities::EquationSharedPtr angularVelEqn,
const NekDouble  rampTime,
const NekDouble  sector,
const Array< OneD, NekDouble > &  base 
)

Constructor for rotating zones

Parameters
idZone ID
domainIDID associated with the the domain making up the zone
domainDomain that the zone consists of
coordDimCoordinate dimension
originOrigin that the zone rotates about
axisAxis that the zone rotates about
angularVelEqnEquation for the angular velocity of rotation

Definition at line 159 of file Movement/Zones.cpp.

165 : ZoneBase(MovementType::eRotate, id, domainID, domain, coordDim),
166 m_origin(origin), m_axis(axis), m_angularVelEqn(angularVelEqn),
167 m_rampTime(rampTime), m_sector(sector), m_base(base)
168{
169 // Construct rotation matrix
170 m_W(0, 1) = -m_axis[2];
171 m_W(0, 2) = m_axis[1];
172 m_W(1, 0) = m_axis[2];
173 m_W(1, 2) = -m_axis[0];
174 m_W(2, 0) = -m_axis[1];
175 m_W(2, 1) = m_axis[0];
176
177 m_W2 = m_W * m_W;
178}
ZoneBase(MovementType type, int indx, int domainID, CompositeMap domain, int coordDim)
Constructor.
NekDouble m_sector
Sector angle.
Definition Zones.h:262
DNekVec m_axis
Axis rotation is performed around.
Definition Zones.h:254
DNekMat m_W
W matrix Rodrigues' rotation formula, cross product of axis.
Definition Zones.h:266
NekPoint< NekDouble > m_origin
Origin point rotation is performed around.
Definition Zones.h:252
LibUtilities::EquationSharedPtr m_angularVelEqn
Equation defining angular velocity as a function of time.
Definition Zones.h:256
NekDouble m_rampTime
Ramp time.
Definition Zones.h:260
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

References m_axis, m_W, and m_W2.

◆ ~ZoneRotate()

Nektar::SpatialDomains::ZoneRotate::~ZoneRotate ( )
overridedefault

Default destructor.

Member Function Documentation

◆ GetAngle()

NekDouble Nektar::SpatialDomains::ZoneRotate::GetAngle ( const NekDouble time)

Returns the rotation angle of the zone.

Definition at line 215 of file Movement/Zones.cpp.

216{
217 // This works for a linear ramp
218 if (time < m_rampTime)
219 {
220 m_angle = GetAngularVel(time) * (time) / 2;
221 }
222 else
223 {
225 GetAngularVel(time) * (time - m_rampTime);
226 }
227 return m_angle;
228}
NekDouble GetAngularVel(const NekDouble &time) const
Return the angular velocity of the zone at.
NekDouble m_angle
Rotate angle.
Definition Zones.h:258

References GetAngularVel(), m_angle, and m_rampTime.

Referenced by v_Move().

◆ GetAngularVel()

NekDouble Nektar::SpatialDomains::ZoneRotate::GetAngularVel ( const NekDouble time) const

Return the angular velocity of the zone at.

Parameters
time

Definition at line 202 of file Movement/Zones.cpp.

203{
204 if (time < m_rampTime)
205 {
206 return m_angularVelEqn->Evaluate(0, 0, 0, time) * time / m_rampTime;
207 }
208 else
209 {
210 return m_angularVelEqn->Evaluate(0, 0, 0, time);
211 }
212}

References m_angularVelEqn, and m_rampTime.

Referenced by export_Zones(), and GetAngle().

◆ GetAngularVelEqn()

LibUtilities::EquationSharedPtr Nektar::SpatialDomains::ZoneRotate::GetAngularVelEqn ( ) const
inline

Returns the equation for the angular velocity of the rotation.

Definition at line 227 of file Zones.h.

228 {
229 return m_angularVelEqn;
230 }

References m_angularVelEqn.

Referenced by export_Zones().

◆ GetAxis()

const DNekVec & Nektar::SpatialDomains::ZoneRotate::GetAxis ( ) const
inline

Returns the axis the zone rotates about.

Definition at line 221 of file Zones.h.

222 {
223 return m_axis;
224 }

References m_axis.

Referenced by export_Zones().

◆ GetOrigin()

const NekPoint< NekDouble > & Nektar::SpatialDomains::ZoneRotate::GetOrigin ( ) const
inline

Returns the origin the zone rotates about.

Definition at line 215 of file Zones.h.

216 {
217 return m_origin;
218 }

References m_origin.

Referenced by export_Zones().

◆ GetSectorAngle()

const NekDouble & Nektar::SpatialDomains::ZoneRotate::GetSectorAngle ( ) const
inline

Returns the angle of rotating sector.

Definition at line 239 of file Zones.h.

240 {
241 return m_sector;
242 }

References m_sector.

◆ GetSectorBase()

const Array< OneD, NekDouble > & Nektar::SpatialDomains::ZoneRotate::GetSectorBase ( ) const
inline

Returns the angle of rotating sector.

Definition at line 245 of file Zones.h.

246 {
247 return m_base;
248 }

References m_base.

◆ Rotate()

void Nektar::SpatialDomains::ZoneRotate::Rotate ( Array< OneD, NekDouble > &  gloCoord,
const NekDouble angle 
)

Rotates the given global coordinate by the given angle.

Definition at line 283 of file Movement/Zones.cpp.

285{
286 // Identity matrix
287 DNekMat rot(3, 3, 0.0);
288 rot(0, 0) = 1.0;
289 rot(1, 1) = 1.0;
290 rot(2, 2) = 1.0;
291
292 // Rodrigues' rotation formula in matrix form
293 rot = rot + sin(angle) * m_W + (1 - cos(angle)) * m_W2;
294
295 DNekVec pntVec = {gloCoord[0] - m_origin[0], gloCoord[1] - m_origin[1],
296 gloCoord[2] - m_origin[2]};
297
298 DNekVec newLoc = rot * pntVec;
299
300 gloCoord[0] = newLoc(0) + m_origin[0];
301 gloCoord[1] = newLoc(1) + m_origin[1];
302 gloCoord[2] = newLoc(2) + m_origin[2];
303}
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
NekVector< NekDouble > DNekVec

References m_origin, m_W, and m_W2.

◆ v_GetAngle()

NekDouble Nektar::SpatialDomains::ZoneRotate::v_GetAngle ( ) const
inlineoverridevirtual

Returns zone rotate angle.

Reimplemented from Nektar::SpatialDomains::ZoneBase.

Definition at line 233 of file Zones.h.

234 {
235 return m_angle;
236 }

References m_angle.

◆ v_Move()

bool Nektar::SpatialDomains::ZoneRotate::v_Move ( NekDouble  time)
finalprotectedvirtual

Virtual function for movement of the zone at.

Parameters
time

Reimplemented from Nektar::SpatialDomains::ZoneBase.

Definition at line 231 of file Movement/Zones.cpp.

232{
233 NekDouble angle = GetAngle(time);
234
235 if (angle == 0.0)
236 {
237 return false;
238 }
239
240 // Identity matrix
241 DNekMat rot(3, 3, 0.0);
242 rot(0, 0) = 1.0;
243 rot(1, 1) = 1.0;
244 rot(2, 2) = 1.0;
245
246 // Rodrigues' rotation formula in matrix form
247 rot = rot + sin(angle) * m_W + (1 - cos(angle)) * m_W2;
248
249 int cnt = 0;
250 for (auto &vert : m_verts)
251 {
252 NekPoint<NekDouble> pnt = m_origVerts[cnt] - m_origin;
253 DNekVec pntVec = {pnt[0], pnt[1], pnt[2]};
254
255 DNekVec newLoc = rot * pntVec;
256
257 vert->UpdatePosition(newLoc(0) + m_origin[0], newLoc(1) + m_origin[1],
258 newLoc(2) + m_origin[2]);
259 cnt++;
260 }
261
262 for (auto &curve : m_curves)
263 {
264 for (auto &vert : curve->m_points)
265 {
266 NekPoint<NekDouble> pnt = m_origVerts[cnt] - m_origin;
267 DNekVec pntVec = {pnt[0], pnt[1], pnt[2]};
268
269 DNekVec newLoc = rot * pntVec;
270
271 vert->UpdatePosition(newLoc(0) + m_origin[0],
272 newLoc(1) + m_origin[1],
273 newLoc(2) + m_origin[2]);
274 cnt++;
275 }
276 }
277
279
280 return true;
281}
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:168
std::vector< CurveSharedPtr > m_curves
Vector of all curves in the zone.
Definition Zones.h:166
std::vector< PointGeomUniquePtr > m_verts
Vector of all points in the zone.
Definition Zones.h:164
NekDouble GetAngle(const NekDouble &time)
Returns the rotation angle of the zone.

References Nektar::SpatialDomains::ZoneBase::ClearBoundingBoxes(), GetAngle(), Nektar::SpatialDomains::ZoneBase::m_curves, m_origin, Nektar::SpatialDomains::ZoneBase::m_origVerts, Nektar::SpatialDomains::ZoneBase::m_verts, m_W, and m_W2.

Member Data Documentation

◆ m_angle

NekDouble Nektar::SpatialDomains::ZoneRotate::m_angle
protected

Rotate angle.

Definition at line 258 of file Zones.h.

Referenced by GetAngle(), and v_GetAngle().

◆ m_angularVelEqn

LibUtilities::EquationSharedPtr Nektar::SpatialDomains::ZoneRotate::m_angularVelEqn
protected

Equation defining angular velocity as a function of time.

Definition at line 256 of file Zones.h.

Referenced by GetAngularVel(), and GetAngularVelEqn().

◆ m_axis

DNekVec Nektar::SpatialDomains::ZoneRotate::m_axis
protected

Axis rotation is performed around.

Definition at line 254 of file Zones.h.

Referenced by GetAxis(), and ZoneRotate().

◆ m_base

Array<OneD, NekDouble> Nektar::SpatialDomains::ZoneRotate::m_base
protected

Base axis of sector.

Definition at line 264 of file Zones.h.

Referenced by GetSectorBase().

◆ m_origin

NekPoint<NekDouble> Nektar::SpatialDomains::ZoneRotate::m_origin
protected

Origin point rotation is performed around.

Definition at line 252 of file Zones.h.

Referenced by GetOrigin(), Rotate(), and v_Move().

◆ m_rampTime

NekDouble Nektar::SpatialDomains::ZoneRotate::m_rampTime
protected

Ramp time.

Definition at line 260 of file Zones.h.

Referenced by GetAngle(), and GetAngularVel().

◆ m_sector

NekDouble Nektar::SpatialDomains::ZoneRotate::m_sector
protected

Sector angle.

Definition at line 262 of file Zones.h.

Referenced by GetSectorAngle().

◆ m_W

DNekMat Nektar::SpatialDomains::ZoneRotate::m_W = DNekMat(3, 3, 0.0)
protected

W matrix Rodrigues' rotation formula, cross product of axis.

Definition at line 266 of file Zones.h.

Referenced by Rotate(), v_Move(), and ZoneRotate().

◆ m_W2

DNekMat Nektar::SpatialDomains::ZoneRotate::m_W2 = DNekMat(3, 3, 0.0)
protected

W^2 matrix Rodrigues' rotation formula, cross product of axis squared.

Definition at line 268 of file Zones.h.

Referenced by Rotate(), v_Move(), and ZoneRotate().