Nektar++
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)
 
 ~ZoneRotate () override=default
 Default destructor. More...
 
NekDouble GetAngularVel (NekDouble &time) const
 Return the angular velocity of the zone at. More...
 
const NekPoint< NekDouble > & GetOrigin () const
 Returns the origin the zone rotates about. More...
 
const DNekVecGetAxis () const
 Returns the axis the zone rotates about. More...
 
LibUtilities::EquationSharedPtr GetAngularVelEqn () const
 Returns the equation for the angular velocity of the rotation. More...
 
- Public Member Functions inherited from Nektar::SpatialDomains::ZoneBase
 ZoneBase (MovementType type, int indx, int domainID, CompositeMap domain, int coordDim)
 Constructor. More...
 
virtual ~ZoneBase ()=default
 Default destructor. More...
 
MovementType GetMovementType () const
 Returns the type of movement. More...
 
CompositeMap GetDomain () const
 Returns the domain the zone is on. More...
 
int & GetId ()
 Returns the zone ID. More...
 
int & GetDomainID ()
 Returns the ID of the domain making up this Zone. More...
 
bool Move (NekDouble time)
 Performs the movement of the zone at. More...
 
std::vector< GeometrySharedPtr > const & GetElements () const
 Returns all highest dimension elements in the zone. More...
 
bool & GetMoved ()
 Returns the flag which states if the zone has moved in this timestep. More...
 
void ClearBoundingBoxes ()
 Clears all bounding boxes associated with the zones elements. More...
 
std::array< std::set< GeometrySharedPtr >, 3 > & GetConstituentElements ()
 Returns constituent elements, i.e. faces + edges. More...
 
std::vector< PointGeom > & GetOriginalVertex ()
 Returns all points in the zone at initialisation. More...
 
virtual std::vector< NekDoublev_GetDisp () const
 Returns zone displacment. More...
 

Protected Member Functions

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

Protected Attributes

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

Detailed Description

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

Definition at line 173 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 
)

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 161 of file Movement/Zones.cpp.

165 : ZoneBase(MovementType::eRotate, id, domainID, domain, coordDim),
166 m_origin(origin), m_axis(axis), m_angularVelEqn(angularVelEqn)
167{
168 // Construct rotation matrix
169 m_W(0, 1) = -m_axis[2];
170 m_W(0, 2) = m_axis[1];
171 m_W(1, 0) = m_axis[2];
172 m_W(1, 2) = -m_axis[0];
173 m_W(2, 0) = -m_axis[1];
174 m_W(2, 1) = m_axis[0];
175
176 m_W2 = m_W * m_W;
177}
const NekPoint< NekDouble > origin
ZoneBase(MovementType type, int indx, int domainID, CompositeMap domain, int coordDim)
Constructor.
DNekVec m_axis
Axis rotation is performed around.
Definition: Zones.h:220
DNekMat m_W
W matrix Rodrigues' rotation formula, cross product of axis.
Definition: Zones.h:224
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
DNekMat m_W2
W^2 matrix Rodrigues' rotation formula, cross product of axis squared.
Definition: Zones.h:226

References m_axis, m_W, and m_W2.

◆ ~ZoneRotate()

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

Default destructor.

Member Function Documentation

◆ GetAngularVel()

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

Return the angular velocity of the zone at.

Parameters
time

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

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

References m_angularVelEqn.

Referenced by v_Move().

◆ GetAngularVelEqn()

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

Returns the equation for the angular velocity of the rotation.

Definition at line 211 of file Zones.h.

212 {
213 return m_angularVelEqn;
214 }

References m_angularVelEqn.

◆ GetAxis()

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

Returns the axis the zone rotates about.

Definition at line 205 of file Zones.h.

206 {
207 return m_axis;
208 }

References m_axis.

◆ GetOrigin()

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

Returns the origin the zone rotates about.

Definition at line 199 of file Zones.h.

200 {
201 return m_origin;
202 }

References m_origin.

◆ 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 215 of file Movement/Zones.cpp.

216{
217 // This works for a linear ramp
218 NekDouble rampTime = 1;
219 NekDouble angle;
220 if (time < rampTime)
221 {
222 angle = GetAngularVel(time) * (time / rampTime) / 2;
223 }
224 else
225 {
226 angle = GetAngularVel(rampTime) * rampTime / 2 +
227 GetAngularVel(time) * (time - rampTime);
228 }
229
230 // TODO: I want to integrate m_angularVelEqn up to current time
231
232 // Identity matrix
233 DNekMat rot(3, 3, 0.0);
234 rot(0, 0) = 1.0;
235 rot(1, 1) = 1.0;
236 rot(2, 2) = 1.0;
237
238 // Rodrigues' rotation formula in matrix form
239 rot = rot + sin(angle) * m_W + (1 - cos(angle)) * m_W2;
240
241 int cnt = 0;
242 for (auto &vert : m_verts)
243 {
244 NekPoint<NekDouble> pnt = m_origVerts[cnt] - m_origin;
245 DNekVec pntVec = {pnt[0], pnt[1], pnt[2]};
246
247 DNekVec newLoc = rot * pntVec;
248
249 vert->UpdatePosition(newLoc(0) + m_origin[0], newLoc(1) + m_origin[1],
250 newLoc(2) + m_origin[2]);
251 cnt++;
252 }
253
254 for (auto &curve : m_curves)
255 {
256 for (auto &vert : curve->m_points)
257 {
258 NekPoint<NekDouble> pnt = m_origVerts[cnt] - m_origin;
259 DNekVec pntVec = {pnt[0], pnt[1], pnt[2]};
260
261 DNekVec newLoc = rot * pntVec;
262
263 vert->UpdatePosition(newLoc(0) + m_origin[0],
264 newLoc(1) + m_origin[1],
265 newLoc(2) + m_origin[2]);
266 cnt++;
267 }
268 }
269
271
272 return true;
273}
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
Definition: NekTypeDefs.hpp:50
NekVector< NekDouble > DNekVec
Definition: NekTypeDefs.hpp:48
std::vector< PointGeomSharedPtr > m_verts
Vector of all points in the zone.
Definition: Zones.h:157
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
std::vector< CurveSharedPtr > m_curves
Vector of all curves in the zone.
Definition: Zones.h:159
NekDouble GetAngularVel(NekDouble &time) const
Return the angular velocity of the zone at.

References Nektar::SpatialDomains::ZoneBase::ClearBoundingBoxes(), GetAngularVel(), 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_angularVelEqn

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

Equation defining angular velocity as a function of time.

Definition at line 222 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 220 of file Zones.h.

Referenced by GetAxis(), and ZoneRotate().

◆ m_origin

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

Origin point rotation is performed around.

Definition at line 218 of file Zones.h.

Referenced by GetOrigin(), and v_Move().

◆ 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 224 of file Zones.h.

Referenced by 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 226 of file Zones.h.

Referenced by v_Move(), and ZoneRotate().