# PhasicFlow: src/MotionModel/entities/rotatingAxis/rotatingAxisI.hpp Source File

rotatingAxisI.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
INLINE_FUNCTION_HD
pFlow::realx3 pFlow::rotatingAxis::linTangentialVelocityPoint(const realx3 &p)const
{
if(!inTimeRange()) return {0,0,0};
realx3 L = p - projectPoint(p);
return cross(omega_*unitVector(),L);
}
INLINE_FUNCTION_HD
pFlow::realx3 pFlow::rotate(const realx3& p, const rotatingAxis& ax, real dt)
{
if(!ax.inTimeRange()) return p;
realx3 nv = ax.unitVector();
real cos_tet = cos(ax.omega()*dt);
real sin_tet = sin(ax.omega()*dt);
real u2 = nv.x()*nv.x();
real v2 = nv.y()*nv.y();
real w2 = nv.z()*nv.z();
realx3 lp1 = ax.point1();
// (a(v2+w2) - u( bv + cw - ux - vy - wz)) (1-cos_tet) + x cos_tet + (- cv + bw - wy + vz) sin_tet
realx3 res;
res.x_ = (lp1.x_*(v2 + w2) - (nv.x_*(lp1.y_*nv.y_ + lp1.z_*nv.z_ - nv.x_*p.x_ - nv.y_*p.y_ - nv.z_*p.z_)))*(1 - cos_tet) +
p.x_ * cos_tet +
(-lp1.z_*nv.y_ + lp1.y_*nv.z_ - nv.z_*p.y_ + nv.y_*p.z_) * sin_tet;
// ( b(u2+w2) - v( au + cw - ux - vy - wz))(1-cos_tet) + y cos_tet + ( cu - aw + wx - uz ) sin_tet
res.y_ = (lp1.y_*(u2 + w2) - (nv.y_*(lp1.x_*nv.x_ + lp1.z_*nv.z_ - nv.x_*p.x_ - nv.y_*p.y_ - nv.z_*p.z_)))*(1 - cos_tet) +
p.y_ * cos_tet +
(lp1.z_*nv.x_ - lp1.x_*nv.z_ + nv.z_*p.x_ - nv.x_*p.z_) * sin_tet;
// (c(u2+v2) - w( au + bv - ux - vy - wz ))(1-cos_tet) + z cos_tet + (-bu + av - vx + uy) sin_tet
res.z_ = (lp1.z_*(u2 + v2) - (nv.z_*(lp1.x_*nv.x_ + lp1.y_*nv.y_ - nv.x_*p.x_ - nv.y_*p.y_ - nv.z_*p.z_)))*(1 - cos_tet) +
p.z_ * cos_tet +
(-lp1.y_*nv.x_ + lp1.x_*nv.y_ - nv.y_*p.x_ + nv.x_*p.y_) * sin_tet;
return res;
}
INLINE_FUNCTION_HD
pFlow::realx3 pFlow::rotate(const realx3 &p, const line& ln, real theta)
{
realx3 nv = ln.unitVector();
real cos_tet = cos(theta);
real sin_tet = sin(theta);
real u2 = nv.x()*nv.x();
real v2 = nv.y()*nv.y();
real w2 = nv.z()*nv.z();
realx3 lp1 = ln.point1();
// (a(v2+w2) - u( bv + cw - ux - vy - wz)) (1-cos_tet) + x cos_tet + (- cv + bw - wy + vz) sin_tet
realx3 res;
res.x_ = (lp1.x_*(v2 + w2) - (nv.x_*(lp1.y_*nv.y_ + lp1.z_*nv.z_ - nv.x_*p.x_ - nv.y_*p.y_ - nv.z_*p.z_)))*(1 - cos_tet) +
p.x_ * cos_tet +
(-lp1.z_*nv.y_ + lp1.y_*nv.z_ - nv.z_*p.y_ + nv.y_*p.z_) * sin_tet;
// ( b(u2+w2) - v( au + cw - ux - vy - wz))(1-cos_tet) + y cos_tet + ( cu - aw + wx - uz ) sin_tet
res.y_ = (lp1.y_*(u2 + w2) - (nv.y_*(lp1.x_*nv.x_ + lp1.z_*nv.z_ - nv.x_*p.x_ - nv.y_*p.y_ - nv.z_*p.z_)))*(1 - cos_tet) +
p.y_ * cos_tet +
(lp1.z_*nv.x_ - lp1.x_*nv.z_ + nv.z_*p.x_ - nv.x_*p.z_) * sin_tet;
// (c(u2+v2) - w( au + bv - ux - vy - wz ))(1-cos_tet) + z cos_tet + (-bu + av - vx + uy) sin_tet
res.z_ = (lp1.z_*(u2 + v2) - (nv.z_*(lp1.x_*nv.x_ + lp1.y_*nv.y_ - nv.x_*p.x_ - nv.y_*p.y_ - nv.z_*p.z_)))*(1 - cos_tet) +
p.z_ * cos_tet +
(-lp1.y_*nv.x_ + lp1.x_*nv.y_ - nv.y_*p.x_ + nv.x_*p.y_) * sin_tet;
return res;
}
INLINE_FUNCTION_HD
void pFlow::rotate(realx3* p, size_t n, const line& ln, real theta)
{
realx3 nv = ln.unitVector();
real cos_tet = cos(theta);
real sin_tet = sin(theta);
real u2 = nv.x()*nv.x();
real v2 = nv.y()*nv.y();
real w2 = nv.z()*nv.z();
realx3 lp1 = ln.point1();
// (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++ )
{
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 +
(-lp1.z_*nv.y_ + lp1.y_*nv.z_ - nv.z_*p[i].y_ + nv.y_*p[i].z_) * sin_tet;
// ( b(u2+w2) - v( au + cw - ux - vy - wz))(1-cos_tet) + y cos_tet + ( cu - aw + wx - uz ) sin_tet
res.y_ = (lp1.y_*(u2 + w2) - (nv.y_*(lp1.x_*nv.x_ + lp1.z_*nv.z_ - nv.x_*p[i].x_ - nv.y_*p[i].y_ - nv.z_*p[i].z_)))*(1 - cos_tet) +
p[i].y_ * cos_tet +
(lp1.z_*nv.x_ - lp1.x_*nv.z_ + nv.z_*p[i].x_ - nv.x_*p[i].z_) * sin_tet;
// (c(u2+v2) - w( au + bv - ux - vy - wz ))(1-cos_tet) + z cos_tet + (-bu + av - vx + uy) sin_tet
res.z_ = (lp1.z_*(u2 + v2) - (nv.z_*(lp1.x_*nv.x_ + lp1.y_*nv.y_ - nv.x_*p[i].x_ - nv.y_*p[i].y_ - nv.z_*p[i].z_)))*(1 - cos_tet) +
p[i].z_ * cos_tet +
(-lp1.y_*nv.x_ + lp1.x_*nv.y_ - nv.y_*p[i].x_ + nv.x_*p[i].y_) * sin_tet;
p[i] = res;
}
}
INLINE_FUNCTION_HD
void pFlow::rotate(realx3* p, size_t n, const rotatingAxis& ax, real dt)
{
if(!ax.inTimeRange()) return;
realx3 nv = ax.unitVector();
real cos_tet = cos(ax.omega()*dt);
real sin_tet = sin(ax.omega()*dt);
real u2 = nv.x()*nv.x();
real v2 = nv.y()*nv.y();
real w2 = nv.z()*nv.z();
realx3 lp1 = ax.point1();
// (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++ )
{
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 +
(-lp1.z_*nv.y_ + lp1.y_*nv.z_ - nv.z_*p[i].y_ + nv.y_*p[i].z_) * sin_tet;
// ( b(u2+w2) - v( au + cw - ux - vy - wz))(1-cos_tet) + y cos_tet + ( cu - aw + wx - uz ) sin_tet
res.y_ = (lp1.y_*(u2 + w2) - (nv.y_*(lp1.x_*nv.x_ + lp1.z_*nv.z_ - nv.x_*p[i].x_ - nv.y_*p[i].y_ - nv.z_*p[i].z_)))*(1 - cos_tet) +
p[i].y_ * cos_tet +
(lp1.z_*nv.x_ - lp1.x_*nv.z_ + nv.z_*p[i].x_ - nv.x_*p[i].z_) * sin_tet;
// (c(u2+v2) - w( au + bv - ux - vy - wz ))(1-cos_tet) + z cos_tet + (-bu + av - vx + uy) sin_tet
res.z_ = (lp1.z_*(u2 + v2) - (nv.z_*(lp1.x_*nv.x_ + lp1.y_*nv.y_ - nv.x_*p[i].x_ - nv.y_*p[i].y_ - nv.z_*p[i].z_)))*(1 - cos_tet) +
p[i].z_ * cos_tet +
(-lp1.y_*nv.x_ + lp1.x_*nv.y_ - nv.y_*p[i].x_ + nv.x_*p[i].y_) * sin_tet;
p[i] = res;
}
}
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::cos
INLINE_FUNCTION_HD real cos(real x)
Definition: math.hpp:178
pFlow::sin
INLINE_FUNCTION_HD real sin(real x)
Definition: math.hpp:168
pFlow::realx3
triple< real > realx3
Definition: types.hpp:48
pFlow::triple::y
INLINE_FUNCTION_HD T & y()
Definition: triple.hpp:141
cross
INLINE_FUNCTION_HD triple< T > cross(const triple< T > &v1, const triple< T > &v2)
n
int32 n
Definition: NBSCrossLoop.hpp:24
pFlow::line::projectPoint
INLINE_FUNCTION_HD realx3 projectPoint(const realx3 &p) const
Definition: line.hpp:106
pFlow::rotatingAxis::omega_
real omega_
rotation speed
Definition: rotatingAxis.hpp:70
pFlow::rotatingAxis
An axis which rotates around itself at specified speed.
Definition: rotatingAxis.hpp:62
pFlow::timeInterval::inTimeRange
INLINE_FUNCTION_HD bool inTimeRange(real t) const
Definition: timeInterval.hpp:70
pFlow::timeInterval::inTimeRange
INLINE_FUNCTION_HD bool inTimeRange() const
Definition: timeInterval.hpp:76
pFlow::rotatingAxis::omega
INLINE_FUNCTION_HD real omega() const
Return omega.
Definition: rotatingAxis.hpp:104
pFlow::triple::x_
T x_
Definition: triple.hpp:49
pFlow::triple::z
INLINE_FUNCTION_HD T & z()
Definition: triple.hpp:144
rotate
INLINE_FUNCTION_HD realx3 rotate(const realx3 &p, const line &ln, real theta)
pFlow::triple::y_
T y_
Definition: triple.hpp:50
pFlow::triple::z_
T z_
Definition: triple.hpp:51
pFlow::line::point1
INLINE_FUNCTION_HD realx3 point1() const
Definition: line.hpp:86
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::rotatingAxis::linTangentialVelocityPoint
INLINE_FUNCTION_HD realx3 linTangentialVelocityPoint(const realx3 &p) const
Linear tangential velocity at point p.
Definition: rotatingAxisI.hpp:22
pFlow::triple::x
INLINE_FUNCTION_HD T & x()
Definition: triple.hpp:138
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::line::unitVector
INLINE_FUNCTION_HD realx3 unitVector() const
Definition: line.hpp:102
pFlow::triple< real >