mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
src folder
This commit is contained in:
144
src/MotionModel/entities/rotatingAxis/rotatingAxis.C
Normal file
144
src/MotionModel/entities/rotatingAxis/rotatingAxis.C
Normal file
@ -0,0 +1,144 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "rotatingAxis.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
/*FUNCTION_HD
|
||||
pFlow::rotatingAxis::rotatingAxis()
|
||||
:
|
||||
line(),
|
||||
omega_(0.0),
|
||||
rotating_(false)
|
||||
{}*/
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::rotatingAxis::rotatingAxis
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
|
||||
if(!read(dict))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in reading rotatingAxis from dictionary "<< dict.globalName()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
FUNCTION_HD
|
||||
pFlow::rotatingAxis::rotatingAxis
|
||||
(
|
||||
const realx3& p1,
|
||||
const realx3& p2,
|
||||
real omega
|
||||
)
|
||||
:
|
||||
line(p1, p2),
|
||||
omega_(omega),
|
||||
rotating_(!equal(omega,0.0))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//rotatingAxis(const dictionary& dict);
|
||||
FUNCTION_HD
|
||||
pFlow::real pFlow::rotatingAxis::setOmega(real omega)
|
||||
{
|
||||
auto tmp = omega_;
|
||||
omega_ = omega;
|
||||
rotating_ = !equal(omega, 0.0);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::rotatingAxis::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if(!line::read(dict)) return false;
|
||||
|
||||
real omega = dict.getValOrSet("omega", static_cast<real>(0.0));
|
||||
|
||||
setOmega(omega);
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::rotatingAxis::write
|
||||
(
|
||||
dictionary& dict
|
||||
) const
|
||||
{
|
||||
if( !line::write(dict) ) return false;
|
||||
|
||||
if( !dict.add("omega", omega_) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing omega to dictionary "<< dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::rotatingAxis::read
|
||||
(
|
||||
iIstream& is
|
||||
)
|
||||
{
|
||||
if( !rotatingAxis::line::read(is)) return false;
|
||||
|
||||
word omegaw;
|
||||
real omega;
|
||||
|
||||
is >> omegaw >> omega;
|
||||
if( !is.check(FUNCTION_NAME))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber());
|
||||
return false;
|
||||
}
|
||||
if(omegaw != "omega")
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
" expected omega but found "<< omegaw <<endl;
|
||||
return false;
|
||||
}
|
||||
is.readEndStatement(FUNCTION_NAME);
|
||||
|
||||
setOmega(omega);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::rotatingAxis::write
|
||||
(
|
||||
iOstream& os
|
||||
)const
|
||||
{
|
||||
if( !rotatingAxis::line::write(os) ) return false;
|
||||
|
||||
os.writeWordEntry("omega", omega());
|
||||
return os.check(FUNCTION_NAME);
|
||||
}
|
112
src/MotionModel/entities/rotatingAxis/rotatingAxis.H
Normal file
112
src/MotionModel/entities/rotatingAxis/rotatingAxis.H
Normal file
@ -0,0 +1,112 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __rotatingAxis_H__
|
||||
#define __rotatingAxis_H__
|
||||
|
||||
#include "line.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
class rotatingAxis;
|
||||
|
||||
#include "rotatingAxisFwd.H"
|
||||
|
||||
class rotatingAxis
|
||||
:
|
||||
public line
|
||||
{
|
||||
protected:
|
||||
|
||||
// rotation speed
|
||||
real omega_ = 0;
|
||||
|
||||
bool rotating_ = false;
|
||||
|
||||
public:
|
||||
|
||||
FUNCTION_HD
|
||||
rotatingAxis(){}
|
||||
|
||||
FUNCTION_H
|
||||
rotatingAxis(const dictionary& dict);
|
||||
|
||||
FUNCTION_HD
|
||||
rotatingAxis(const realx3& p1, const realx3& p2, real omega = 0.0);
|
||||
|
||||
FUNCTION_HD
|
||||
rotatingAxis(const rotatingAxis&) = default;
|
||||
|
||||
rotatingAxis& operator=(const rotatingAxis&) = default;
|
||||
|
||||
FUNCTION_HD
|
||||
real setOmega(real omega);
|
||||
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
real omega()const
|
||||
{
|
||||
return omega_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 linTangentialVelocityPoint(const realx3 &p)const;
|
||||
|
||||
// - IO operation
|
||||
FUNCTION_H
|
||||
bool read(const dictionary& dict);
|
||||
|
||||
FUNCTION_H
|
||||
bool write(dictionary& dict) const;
|
||||
|
||||
FUNCTION_H
|
||||
bool read(iIstream& is);
|
||||
|
||||
FUNCTION_H
|
||||
bool write(iOstream& os)const;
|
||||
|
||||
};
|
||||
|
||||
inline iOstream& operator <<(iOstream& os, const rotatingAxis& ax)
|
||||
{
|
||||
if(!ax.write(os))
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
inline iIstream& operator >>(iIstream& is, rotatingAxis& ax)
|
||||
{
|
||||
if( !ax.read(is) )
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "rotatingAxisI.H"
|
||||
|
||||
#endif
|
34
src/MotionModel/entities/rotatingAxis/rotatingAxisFwd.H
Executable file
34
src/MotionModel/entities/rotatingAxis/rotatingAxisFwd.H
Executable file
@ -0,0 +1,34 @@
|
||||
/*------------------------------- 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
|
||||
realx3 rotate(const realx3 &p, const line& ln, real theta);
|
||||
|
||||
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);
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void rotate(realx3* p, size_t n, const rotatingAxis& ax, real dt);
|
||||
|
||||
|
||||
|
164
src/MotionModel/entities/rotatingAxis/rotatingAxisI.H
Executable file
164
src/MotionModel/entities/rotatingAxis/rotatingAxisI.H
Executable file
@ -0,0 +1,164 @@
|
||||
/*------------------------------- 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
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user