src folder

This commit is contained in:
hamidrezanorouzi
2022-09-05 01:56:29 +04:30
parent 9d177aba28
commit ac5c3f08af
97 changed files with 11707 additions and 13 deletions

View File

@ -0,0 +1,13 @@
list(APPEND SourceFiles
entities/rotatingAxis/rotatingAxis.C
fixedWall/fixedWall.C
rotatingAxisMotion/rotatingAxisMotion.C
)
set(link_libs Kokkos::kokkos phasicFlow)
pFlow_add_library_install(MotionModel SourceFiles link_libs)

View 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);
}

View 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

View 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);

View 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;
}
}

View File

@ -0,0 +1,110 @@
/*------------------------------- 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 "fixedWall.H"
#include "dictionary.H"
#include "vocabs.H"
bool pFlow::fixedWall::readDictionary
(
const dictionary& dict
)
{
auto motionModel = dict.getVal<word>("motionModel");
if(motionModel != "fixedWall")
{
fatalErrorInFunction<<
" motionModel should be fixedWall, but found " << motionModel <<endl;
return false;
}
return true;
}
bool pFlow::fixedWall::writeDictionary
(
dictionary& dict
)const
{
dict.add("motionModel", "fixedWall");
auto& motionInfo = dict.subDictOrCreate("fixedWallInfo");
return true;
}
pFlow::fixedWall::fixedWall()
{}
pFlow::fixedWall::fixedWall
(
const dictionary& dict
)
{
if(! readDictionary(dict) )
{
fatalExit;
}
}
bool pFlow::fixedWall::read
(
iIstream& is
)
{
// create an empty file dictionary
dictionary motionInfo(motionModelFile__, true);
// read dictionary from stream
if( !motionInfo.read(is) )
{
ioErrorInFile(is.name(), is.lineNumber()) <<
" error in reading dictionray " << motionModelFile__ <<" from file. \n";
return false;
}
if( !readDictionary(motionInfo) ) return false;
return true;
}
bool pFlow::fixedWall::write
(
iOstream& os
)const
{
// create an empty file dictionary
dictionary motionInfo(motionModelFile__, true);
if( !writeDictionary(motionInfo))
{
return false;
}
if( !motionInfo.write(os) )
{
ioErrorInFile( os.name(), os.lineNumber() )<<
" error in writing dictionray to file. \n";
return false;
}
return true;
}

View File

@ -0,0 +1,170 @@
/*------------------------------- 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 __fixedWall_H__
#define __fixedWall_H__
#include "types.H"
#include "typeInfo.H"
#include "Vectors.H"
#include "uniquePtr.H"
namespace pFlow
{
class dictionary;
class fixedWall
{
public:
// - this class shuold be decleared in every motion model with
// exact methods
class Model
{
public:
INLINE_FUNCTION_HD
Model(){}
INLINE_FUNCTION_HD
Model(const Model&) = default;
INLINE_FUNCTION_HD
Model& operator=(const Model&) = default;
INLINE_FUNCTION_HD
realx3 pointVelocity(int32 n, const realx3 p)const
{
return 0.0;
}
INLINE_FUNCTION_HD
realx3 operator()(int32 n, const realx3& p)const
{
return 0.0;
}
INLINE_FUNCTION_HD
realx3 transferPoint(int32 n, const realx3 p, real dt)const
{
return p;
}
INLINE_FUNCTION_HD int32 numComponents()const
{
return 0;
}
};
protected:
const word name_ = "none";
bool readDictionary(const dictionary& dict);
bool writeDictionary(dictionary& dict)const;
public:
TypeNameNV("fixedWall");
// empty
fixedWall();
// construct with dictionary
fixedWall(const dictionary& dict);
fixedWall(const fixedWall&) = default;
fixedWall(fixedWall&&) = default;
fixedWall& operator=(const fixedWall&) = default;
fixedWall& operator=(fixedWall&&) = default;
~fixedWall() = default;
Model getModel()const
{
return Model();
}
int32 nameToIndex(const word& name)const
{
return 0;
}
word indexToName(label i)const
{
return name_;
}
INLINE_FUNCTION_HD
realx3 pointVelocity(label n, const realx3& p)const
{
return zero3;
}
INLINE_FUNCTION_HD
realx3 transferPoint(label n, const realx3 p, real dt)const
{
return p;
}
INLINE_FUNCTION_HD
bool transferPoint(label n, realx3* pVec, size_t numP, real dt)
{
return true;
}
INLINE_FUNCTION_HD
bool isMoving()const
{
return false;
}
bool move(real dt)
{
return true;
}
FUNCTION_H
bool read(iIstream& is);
FUNCTION_H
bool write(iOstream& os)const;
};
} // pFlow
#endif //__fixed_H__

View File

@ -0,0 +1,170 @@
/*------------------------------- 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 "rotatingAxisMotion.H"
#include "dictionary.H"
#include "vocabs.H"
bool pFlow::rotatingAxisMotion::readDictionary
(
const dictionary& dict
)
{
auto motionModel = dict.getVal<word>("motionModel");
if(motionModel != "rotatingAxisMotion")
{
fatalErrorInFunction<<
" motionModel should be rotatingAxisMotion, but found "
<< motionModel <<endl;
return false;
}
auto& motionInfo = dict.subDict("rotatingAxisMotionInfo");
auto axisNames = motionInfo.dictionaryKeywords();
axis_.reserve(axisNames.size()+1);
axis_.clear();
axisName_.clear();
for(auto& aName: axisNames)
{
auto& axDict = motionInfo.subDict(aName);
if(auto axPtr = makeUnique<rotatingAxis>(axDict); axPtr)
{
axis_.push_back(axPtr());
axisName_.push_back(aName);
}
else
{
fatalErrorInFunction<<
"could not read rotating axis from "<< axDict.globalName()<<endl;
return false;
}
}
if( !axisName_.search("none") )
{
axis_.push_back
(
rotatingAxis(
realx3(0.0,0.0,0.0),
realx3(1.0,0.0,0.0),
0.0
)
);
axisName_.push_back("none");
}
axis_.syncViews();
numAxis_ = axis_.size();
return true;
}
bool pFlow::rotatingAxisMotion::writeDictionary
(
dictionary& dict
)const
{
dict.add("motionModel", "rotatingAxisMotion");
auto& motionInfo = dict.subDictOrCreate("rotatingAxisMotionInfo");
forAll(i, axis_)
{
auto& axDict = motionInfo.subDictOrCreate(axisName_[i]);
if( !axis_.hostVectorAll()[i].write(axDict))
{
fatalErrorInFunction<<
" error in writing axis "<< axisName_[i] << " to dicrionary "
<< motionInfo.globalName()<<endl;
return false;
}
}
return true;
}
pFlow::rotatingAxisMotion::rotatingAxisMotion()
{}
pFlow::rotatingAxisMotion::rotatingAxisMotion
(
const dictionary& dict
)
{
if(! readDictionary(dict) )
{
fatalExit;
}
}
bool pFlow::rotatingAxisMotion::read
(
iIstream& is
)
{
// create an empty file dictionary
dictionary motionInfo(motionModelFile__, true);
// read dictionary from stream
if( !motionInfo.read(is) )
{
ioErrorInFile(is.name(), is.lineNumber()) <<
" error in reading dictionray " << motionModelFile__ <<" from file. \n";
return false;
}
if( !readDictionary(motionInfo) ) return false;
return true;
}
bool pFlow::rotatingAxisMotion::write
(
iOstream& os
)const
{
// create an empty file dictionary
dictionary motionInfo(motionModelFile__, true);
if( !writeDictionary(motionInfo))
{
return false;
}
if( !motionInfo.write(os) )
{
ioErrorInFile( os.name(), os.lineNumber() )<<
" error in writing dictionray to file. \n";
return false;
}
return true;
}

View File

@ -0,0 +1,218 @@
/*------------------------------- 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 __rotatingAxisMotion_H__
#define __rotatingAxisMotion_H__
#include "types.H"
#include "typeInfo.H"
#include "VectorDual.H"
#include "Vectors.H"
#include "List.H"
#include "rotatingAxis.H"
namespace pFlow
{
class dictionary;
class rotatingAxisMotion
{
public:
// - this class shuold be decleared in every motion model with
// exact methods
class Model
{
protected:
deviceViewType1D<rotatingAxis> axis_;
int32 numAxis_=0;
public:
INLINE_FUNCTION_HD
Model(deviceViewType1D<rotatingAxis> axis, int32 numAxis):
axis_(axis),
numAxis_(numAxis)
{}
INLINE_FUNCTION_HD
Model(const Model&) = default;
INLINE_FUNCTION_HD
Model& operator=(const Model&) = default;
INLINE_FUNCTION_HD
realx3 pointVelocity(int32 n, const realx3& p)const
{
return axis_[n].linTangentialVelocityPoint(p);
}
INLINE_FUNCTION_HD
realx3 operator()(int32 n, const realx3& p)const
{
return pointVelocity(n,p);
}
INLINE_FUNCTION_HD
realx3 transferPoint(int32 n, const realx3 p, real dt)const
{
return rotate(p, axis_[n], dt);
}
INLINE_FUNCTION_HD int32 numComponents()const
{
return numAxis_;
}
};
protected:
using axisVector_HD = VectorDual<rotatingAxis>;
axisVector_HD axis_;
wordList axisName_;
label numAxis_= 0;
bool readDictionary(const dictionary& dict);
bool writeDictionary(dictionary& dict)const;
public:
TypeNameNV("rotatingAxisMotion");
// empty
FUNCTION_H
rotatingAxisMotion();
// construct with dictionary
FUNCTION_H
rotatingAxisMotion(const dictionary& dict);
// copy
FUNCTION_H
rotatingAxisMotion(const rotatingAxisMotion&) = default;
rotatingAxisMotion(rotatingAxisMotion&&) = delete;
FUNCTION_H
rotatingAxisMotion& operator=(const rotatingAxisMotion&) = default;
rotatingAxisMotion& operator=(rotatingAxisMotion&&) = delete;
FUNCTION_H
~rotatingAxisMotion() = default;
Model getModel()const
{
return Model(axis_.deviceVector(), numAxis_);
}
INLINE_FUNCTION_H
int32 nameToIndex(const word& name)const
{
if( auto i = axisName_.findi(name); i == -1)
{
fatalErrorInFunction<<
"axis name " << name << " does not exist. \n";
fatalExit;
return i;
}
else
{
return i;
}
}
INLINE_FUNCTION_H
word indexToName(label i)const
{
if(i < numAxis_ )
return axisName_[i];
else
{
fatalErrorInFunction<<
"out of range access to the list of axes " << i <<endl<<
" size of axes_ is "<<numAxis_<<endl;
fatalExit;
return "";
}
}
INLINE_FUNCTION_D
realx3 pointVelocity(label n, const realx3& p)const
{
return axis_.deviceVectorAll()[n].linTangentialVelocityPoint(p);
}
INLINE_FUNCTION_D
realx3 transferPoint(label n, const realx3 p, real dt)const
{
return rotate(p, axis_.deviceVectorAll()[n], dt);
}
INLINE_FUNCTION_D
bool transferPoint(label n, realx3* pVec, size_t numP, real dt)
{
if( n>=numAxis_)return false;
rotate( pVec, numP, axis_.deviceVectorAll()[n], dt);
return true;
}
INLINE_FUNCTION_HD
bool isMoving()const
{
return true;
}
INLINE_FUNCTION_H
bool move(real dt)
{
return true;
}
FUNCTION_H
bool read(iIstream& is);
FUNCTION_H
bool write(iOstream& os)const;
};
} // pFlow
#endif //__rotatingAxisMotion_H__