Nektar++
Public 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, const CompositeMap &domain, const int coordDim, const NekPoint< NekDouble > &origin, const DNekVec &axis, const LibUtilities::EquationSharedPtr &angularVelEqn)
 
virtual ~ZoneRotate ()=default
 Default destructor. More...
 
NekDouble GetAngularVel (NekDouble &time) const
 Return the angular velocity of the zone at. More...
 
virtual bool v_Move (NekDouble time) final
 Virtual function for movement of the zone at. More...
 
- Public Member Functions inherited from Nektar::SpatialDomains::ZoneBase
 ZoneBase (MovementType type, int indx, 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...
 
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...
 

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...
 
CompositeMap m_domain
 Zone domain. More...
 
std::vector< GeometrySharedPtrm_elements
 Vector of highest dimension zone elements. 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 140 of file Zones.h.

Constructor & Destructor Documentation

◆ ZoneRotate()

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

Constructor for rotating zones

Parameters
idZone ID
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 141 of file Zones.cpp.

144  : ZoneBase(MovementType::eRotate, id, domain, coordDim), m_origin(origin),
145  m_axis(axis), m_angularVelEqn(angularVelEqn)
146 {
147  // Construct rotation matrix
148  m_W(0, 1) = -m_axis[2];
149  m_W(0, 2) = m_axis[1];
150  m_W(1, 0) = m_axis[2];
151  m_W(1, 2) = -m_axis[0];
152  m_W(2, 0) = -m_axis[1];
153  m_W(2, 1) = m_axis[0];
154 
155  m_W2 = m_W * m_W;
156 }
ZoneBase(MovementType type, int indx, CompositeMap domain, int coordDim)
Constructor.
Definition: Zones.cpp:47
DNekVec m_axis
Axis rotation is performed around.
Definition: Zones.h:169
DNekMat m_W
W matrix Rodrigues' rotation formula, cross product of axis.
Definition: Zones.h:173
NekPoint< NekDouble > m_origin
Origin point rotation is performed around.
Definition: Zones.h:167
LibUtilities::EquationSharedPtr m_angularVelEqn
Equation defining angular velocity as a function of time.
Definition: Zones.h:171
DNekMat m_W2
W^2 matrix Rodrigues' rotation formula, cross product of axis squared.
Definition: Zones.h:175

References Nektar::SpatialDomains::eRotate, m_axis, m_W, and m_W2.

◆ ~ZoneRotate()

virtual Nektar::SpatialDomains::ZoneRotate::~ZoneRotate ( )
virtualdefault

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 180 of file Zones.cpp.

181 {
182  return m_angularVelEqn->Evaluate(0, 0, 0, time);
183 }

References m_angularVelEqn.

Referenced by v_Move().

◆ v_Move()

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

Virtual function for movement of the zone at.

Parameters
time

Reimplemented from Nektar::SpatialDomains::ZoneBase.

Definition at line 186 of file Zones.cpp.

187 {
188  // Currently only valid for constant angular velocity
189  NekDouble angle = GetAngularVel(time) * time;
190 
191  // Identity matrix
192  DNekMat rot(3, 3, 0.0);
193  rot(0, 0) = 1.0;
194  rot(1, 1) = 1.0;
195  rot(2, 2) = 1.0;
196 
197  // Rodrigues' rotation formula in matrix form
198  rot = rot + sin(angle) * m_W + (1 - cos(angle)) * m_W2;
199 
200  int cnt = 0;
201  for (auto &vert : m_verts)
202  {
203  NekPoint<NekDouble> pnt = m_origVerts[cnt] - m_origin;
204  DNekVec pntVec = {pnt[0], pnt[1], pnt[2]};
205 
206  DNekVec newLoc = rot * pntVec;
207 
208  vert->UpdatePosition(newLoc(0) + m_origin[0], newLoc(1) + m_origin[1],
209  newLoc(2) + m_origin[2]);
210  cnt++;
211  }
212 
213  for (auto &curve : m_curves)
214  {
215  for (auto &vert : curve->m_points)
216  {
217  NekPoint<NekDouble> pnt = m_origVerts[cnt] - m_origin;
218  DNekVec pntVec = {pnt[0], pnt[1], pnt[2]};
219 
220  DNekVec newLoc = rot * pntVec;
221 
222  vert->UpdatePosition(newLoc(0) + m_origin[0],
223  newLoc(1) + m_origin[1],
224  newLoc(2) + m_origin[2]);
225  cnt++;
226  }
227  }
228 
230 
231  return true;
232 }
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
Definition: NekTypeDefs.hpp:50
NekVector< NekDouble > DNekVec
Definition: NekTypeDefs.hpp:48
double NekDouble
std::vector< PointGeomSharedPtr > m_verts
Vector of all points in the zone.
Definition: Zones.h:130
void ClearBoundingBoxes()
Clears all bounding boxes associated with the zones elements.
Definition: Zones.cpp:158
std::vector< PointGeom > m_origVerts
Vector of all points in the zone at initialisation.
Definition: Zones.h:134
std::vector< CurveSharedPtr > m_curves
Vector of all curves in the zone.
Definition: Zones.h:132
NekDouble GetAngularVel(NekDouble &time) const
Return the angular velocity of the zone at.
Definition: Zones.cpp:180

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

Referenced by GetAngularVel().

◆ m_axis

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

Axis rotation is performed around.

Definition at line 169 of file Zones.h.

Referenced by ZoneRotate().

◆ m_origin

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

Origin point rotation is performed around.

Definition at line 167 of file Zones.h.

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

Referenced by v_Move(), and ZoneRotate().