mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
MotionModel CRTP, rotatingAxis and vibrating
This commit is contained in:
@ -28,7 +28,6 @@ pFlow::rotatingAxis::rotatingAxis
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
|
||||
if(!read(dict))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
@ -73,7 +72,7 @@ bool pFlow::rotatingAxis::read
|
||||
if(!timeInterval::read(dict))return false;
|
||||
if(!line::read(dict)) return false;
|
||||
|
||||
real omega = dict.getValOrSet("omega", static_cast<real>(0.0));
|
||||
real omega = dict.getValOrSet("omega", 0.0);
|
||||
|
||||
setOmega(omega);
|
||||
return true;
|
||||
|
@ -24,13 +24,12 @@ Licence:
|
||||
#include "timeInterval.hpp"
|
||||
#include "line.hpp"
|
||||
|
||||
#include "rotatingAxisFwd.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
class rotatingAxis;
|
||||
|
||||
#include "rotatingAxisFwd.hpp"
|
||||
|
||||
/**
|
||||
* An axis which rotates around itself at specified speed
|
||||
@ -64,7 +63,7 @@ class rotatingAxis
|
||||
public timeInterval,
|
||||
public line
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
/// rotation speed
|
||||
real omega_ = 0;
|
||||
@ -78,11 +77,11 @@ public:
|
||||
|
||||
/// Empty constructor
|
||||
FUNCTION_HD
|
||||
rotatingAxis(){}
|
||||
rotatingAxis()=default;
|
||||
|
||||
/// Construct from dictionary
|
||||
FUNCTION_H
|
||||
rotatingAxis(const dictionary& dict);
|
||||
explicit rotatingAxis(const dictionary& dict);
|
||||
|
||||
/// Construct from components
|
||||
FUNCTION_HD
|
||||
@ -92,9 +91,19 @@ public:
|
||||
FUNCTION_HD
|
||||
rotatingAxis(const rotatingAxis&) = default;
|
||||
|
||||
FUNCTION_HD
|
||||
rotatingAxis(rotatingAxis&&) = default;
|
||||
|
||||
/// Copy asssignment
|
||||
rotatingAxis& operator=(const rotatingAxis&) = default;
|
||||
|
||||
/// Copy asssignment
|
||||
rotatingAxis& operator=(rotatingAxis&&) = default;
|
||||
|
||||
/// destructor
|
||||
~rotatingAxis()=default;
|
||||
|
||||
|
||||
/// Set omega
|
||||
FUNCTION_HD
|
||||
real setOmega(real omega);
|
||||
@ -115,7 +124,10 @@ public:
|
||||
|
||||
/// Linear tangential velocity at point p
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 linTangentialVelocityPoint(const realx3 &p)const;
|
||||
realx3 linVelocityPoint(const realx3 &p)const;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 transferPoint(const realx3 p, real dt);
|
||||
|
||||
// - IO operation
|
||||
|
||||
|
@ -18,6 +18,11 @@ Licence:
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class rotatingAxis;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 rotate(const realx3 &p, const line& ln, real theta);
|
||||
|
||||
@ -25,10 +30,10 @@ INLINE_FUNCTION_HD
|
||||
realx3 rotate(const realx3& p, const rotatingAxis& ax, real dt);
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void rotate(realx3* p, size_t n, const line& ln, real theta);
|
||||
void rotate(realx3* p, uint32 n, const line& ln, real theta);
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void rotate(realx3* p, size_t n, const rotatingAxis& ax, real dt);
|
||||
|
||||
void rotate(realx3* p, uint32 n, const rotatingAxis& ax, real dt);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "rotatingAxis.hpp"
|
||||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
@ -19,7 +20,7 @@ Licence:
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
pFlow::realx3 pFlow::rotatingAxis::linTangentialVelocityPoint(const realx3 &p)const
|
||||
pFlow::realx3 pFlow::rotatingAxis::linVelocityPoint(const realx3 &p)const
|
||||
{
|
||||
|
||||
if(!inTimeRange()) return {0,0,0};
|
||||
@ -28,6 +29,12 @@ pFlow::realx3 pFlow::rotatingAxis::linTangentialVelocityPoint(const realx3 &p)co
|
||||
return cross(omega_*unitVector(),L);
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
pFlow::realx3 pFlow::rotatingAxis::transferPoint(const realx3 p, real dt)
|
||||
{
|
||||
return rotate(p, *this, dt);
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
pFlow::realx3 pFlow::rotate(const realx3& p, const rotatingAxis& ax, real dt)
|
||||
{
|
||||
@ -97,7 +104,7 @@ pFlow::realx3 pFlow::rotate(const realx3 &p, const line& ln, real theta)
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void pFlow::rotate(realx3* p, size_t n, const line& ln, real theta)
|
||||
void pFlow::rotate(realx3* p, uint32 n, const line& ln, real theta)
|
||||
{
|
||||
realx3 nv = ln.unitVector();
|
||||
real cos_tet = cos(theta);
|
||||
@ -110,7 +117,7 @@ void pFlow::rotate(realx3* p, size_t n, const line& ln, real theta)
|
||||
// (a(v2+w2) - u( bv + cw - ux - vy - wz)) (1-cos_tet) + x cos_tet + (- cv + bw - wy + vz) sin_tet
|
||||
realx3 res;
|
||||
|
||||
for(label i=0; i<n; i++ )
|
||||
for(uint32 i=0; i<n; i++ )
|
||||
{
|
||||
res.x_ = (lp1.x_*(v2 + w2) - (nv.x_*(lp1.y_*nv.y_ + lp1.z_*nv.z_ - nv.x_*p[i].x_ - nv.y_*p[i].y_ - nv.z_*p[i].z_)))*(1 - cos_tet) +
|
||||
p[i].x_ * cos_tet +
|
||||
@ -133,7 +140,7 @@ void pFlow::rotate(realx3* p, size_t n, const line& ln, real theta)
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void pFlow::rotate(realx3* p, size_t n, const rotatingAxis& ax, real dt)
|
||||
void pFlow::rotate(realx3* p, uint32 n, const rotatingAxis& ax, real dt)
|
||||
{
|
||||
if(!ax.inTimeRange()) return;
|
||||
|
||||
@ -148,7 +155,7 @@ void pFlow::rotate(realx3* p, size_t n, const rotatingAxis& ax, real dt)
|
||||
// (a(v2+w2) - u( bv + cw - ux - vy - wz)) (1-cos_tet) + x cos_tet + (- cv + bw - wy + vz) sin_tet
|
||||
realx3 res;
|
||||
|
||||
for(label i=0; i<n; i++ )
|
||||
for(uint32 i=0; i<n; i++ )
|
||||
{
|
||||
res.x_ = (lp1.x_*(v2 + w2) - (nv.x_*(lp1.y_*nv.y_ + lp1.z_*nv.z_ - nv.x_*p[i].x_ - nv.y_*p[i].y_ - nv.z_*p[i].z_)))*(1 - cos_tet) +
|
||||
p[i].x_ * cos_tet +
|
||||
|
@ -67,7 +67,7 @@ class vibrating
|
||||
public timeInterval
|
||||
{
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
// rotation speed
|
||||
realx3 angularFreq_{0,0,0};
|
||||
@ -95,10 +95,10 @@ protected:
|
||||
public:
|
||||
|
||||
FUNCTION_HD
|
||||
vibrating(){}
|
||||
vibrating()=default;
|
||||
|
||||
FUNCTION_H
|
||||
vibrating(const dictionary& dict);
|
||||
explicit vibrating(const dictionary& dict);
|
||||
|
||||
|
||||
FUNCTION_HD
|
||||
@ -115,7 +115,7 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 linTangentialVelocityPoint(const realx3 &p)const
|
||||
realx3 linTangentialVelocityPoint(const realx3 &)const
|
||||
{
|
||||
return velocity_;
|
||||
}
|
||||
@ -124,7 +124,7 @@ public:
|
||||
realx3 transferPoint(const realx3& p, real dt)
|
||||
{
|
||||
if(!inTimeRange()) return p;
|
||||
return p + static_cast<real>(0.5)*dt*(velocity0_+velocity_);
|
||||
return p + 0.5*dt*(velocity0_+velocity_);
|
||||
}
|
||||
|
||||
// - IO operation
|
||||
|
Reference in New Issue
Block a user