Merge pull request #191 from PhasicFlow/multiRotatingAxis
Multi rotating axis
This commit is contained in:
commit
3441b03167
|
@ -21,7 +21,6 @@ Licence:
|
||||||
template<typename MotionModel>
|
template<typename MotionModel>
|
||||||
bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
|
bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(motionComponentName().size() != numSurfaces() )
|
if(motionComponentName().size() != numSurfaces() )
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
|
|
|
@ -28,4 +28,4 @@ template class pFlow::geometryMotion<pFlow::stationaryWall>;
|
||||||
|
|
||||||
template class pFlow::geometryMotion<pFlow::conveyorBeltMotion>;
|
template class pFlow::geometryMotion<pFlow::conveyorBeltMotion>;
|
||||||
|
|
||||||
//template class pFlow::geometryMotion<pFlow::multiRotatingAxisMotion>;
|
template class pFlow::geometryMotion<pFlow::multiRotatingAxisMotion>;
|
||||||
|
|
|
@ -25,7 +25,7 @@ Licence:
|
||||||
#include "stationaryWall.hpp"
|
#include "stationaryWall.hpp"
|
||||||
#include "rotatingAxisMotion.hpp"
|
#include "rotatingAxisMotion.hpp"
|
||||||
#include "conveyorBeltMotion.hpp"
|
#include "conveyorBeltMotion.hpp"
|
||||||
//#include "multiRotatingAxisMotion.hpp"
|
#include "multiRotatingAxisMotion.hpp"
|
||||||
#include "vibratingMotion.hpp"
|
#include "vibratingMotion.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,10 +40,7 @@ using stationaryGeometry = geometryMotion<stationaryWall>;
|
||||||
|
|
||||||
using conveyorBeltMotionGeometry = geometryMotion<conveyorBeltMotion>;
|
using conveyorBeltMotionGeometry = geometryMotion<conveyorBeltMotion>;
|
||||||
|
|
||||||
//typedef geometryMotion<multiRotatingAxisMotion> multiRotationAxisMotionGeometry;
|
using multiRotationAxisMotionGeometry = geometryMotion<multiRotatingAxisMotion>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,5 +58,5 @@ createInteraction(pFlow::cfModels::limitedNonLinearModNormalRolling, pFlow::conv
|
||||||
createInteraction(pFlow::cfModels::nonLimitedNonLinearModNormalRolling,pFlow::conveyorBeltMotionGeometry);
|
createInteraction(pFlow::cfModels::nonLimitedNonLinearModNormalRolling,pFlow::conveyorBeltMotionGeometry);
|
||||||
|
|
||||||
// multiRotationAxisMotionGeometry
|
// multiRotationAxisMotionGeometry
|
||||||
//createInteraction(pFlow::cfModels::limitedNonLinearModNormalRolling, pFlow::multiRotationAxisMotionGeometry);
|
createInteraction(pFlow::cfModels::limitedNonLinearModNormalRolling, pFlow::multiRotationAxisMotionGeometry);
|
||||||
//createInteraction(pFlow::cfModels::nonLimitedNonLinearModNormalRolling,pFlow::multiRotationAxisMotionGeometry);
|
createInteraction(pFlow::cfModels::nonLimitedNonLinearModNormalRolling,pFlow::multiRotationAxisMotionGeometry);
|
||||||
|
|
|
@ -14,8 +14,8 @@ entities/stationary/stationary.cpp
|
||||||
conveyorBeltMotion/conveyorBeltMotion.cpp
|
conveyorBeltMotion/conveyorBeltMotion.cpp
|
||||||
entities/conveyorBelt/conveyorBelt.cpp
|
entities/conveyorBelt/conveyorBelt.cpp
|
||||||
|
|
||||||
#entities/multiRotatingAxis/multiRotatingAxis.cpp
|
entities/multiRotatingAxis/multiRotatingAxis.cpp
|
||||||
#multiRotatingAxisMotion/multiRotatingAxisMotion.cpp
|
multiRotatingAxisMotion/multiRotatingAxisMotion.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ bool pFlow::MotionModel<Model, Component>::impl_nameToIndex(const word& name, ui
|
||||||
indx = static_cast<uint32>(i);
|
indx = static_cast<uint32>(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Model, typename Component>
|
template<typename Model, typename Component>
|
||||||
|
|
|
@ -22,31 +22,32 @@ Licence:
|
||||||
#include "multiRotatingAxisMotion.hpp"
|
#include "multiRotatingAxisMotion.hpp"
|
||||||
#include "dictionary.hpp"
|
#include "dictionary.hpp"
|
||||||
|
|
||||||
|
/// Construct from dictionary
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
pFlow::multiRotatingAxis::multiRotatingAxis
|
pFlow::multiRotatingAxis::multiRotatingAxis(const dictionary& dict)
|
||||||
(
|
:
|
||||||
multiRotatingAxisMotion* axisMotion
|
rotatingAxis(dict)
|
||||||
)
|
{}
|
||||||
{
|
|
||||||
//axisList_ = axisMotion->getAxisListPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
pFlow::multiRotatingAxis::multiRotatingAxis
|
pFlow::multiRotatingAxis::multiRotatingAxis
|
||||||
(
|
(
|
||||||
multiRotatingAxisMotion* axisMotion,
|
multiRotatingAxis* axisListPtr,
|
||||||
|
const wordList& componentsNames,
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
|
:
|
||||||
|
rotatingAxis(dict),
|
||||||
|
axisList_(axisListPtr)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!read(axisMotion, dict))
|
if(!read(dict, componentsNames))
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" error in reading rotatingAxis from dictionary "<< dict.globalName()<<endl;
|
" error in reading rotatingAxis from dictionary "<< dict.globalName()<<endl;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//axisList_ = axisMotion->getAxisListPtr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,22 +55,29 @@ pFlow::multiRotatingAxis::multiRotatingAxis
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
bool pFlow::multiRotatingAxis::read
|
bool pFlow::multiRotatingAxis::read
|
||||||
(
|
(
|
||||||
multiRotatingAxisMotion* axisMotion,
|
const dictionary& dict,
|
||||||
const dictionary& dict
|
const wordList& componentNames
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!rotatingAxis::read(dict))return false;
|
|
||||||
|
|
||||||
word rotAxis = dict.getValOrSet<word>("rotationAxis", "none");
|
word rotAxis = dict.getValOrSet<word>("rotationAxis", "none");
|
||||||
|
|
||||||
if(rotAxis == "none")
|
if(rotAxis == "none")
|
||||||
{
|
{
|
||||||
parentAxisIndex_ = -1;
|
parentAxisIndex_ = static_cast<uint32>(-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parentAxisIndex_ = axisMotion-> nameToIndex(rotAxis);
|
if( auto i = componentNames.findi(rotAxis); i != -1 )
|
||||||
|
{
|
||||||
|
parentAxisIndex_ = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fatalErrorInFunction<<"crotationAxis "<< rotAxis<<" in dictionary "<<
|
||||||
|
dict.globalName()<<" is not found in list of axis names "<< componentNames<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -78,8 +86,8 @@ bool pFlow::multiRotatingAxis::read
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
bool pFlow::multiRotatingAxis::write
|
bool pFlow::multiRotatingAxis::write
|
||||||
(
|
(
|
||||||
const multiRotatingAxisMotion* axisMotion,
|
dictionary& dict,
|
||||||
dictionary& dict
|
const wordList& componentNames
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if( !rotatingAxis::write(dict) ) return false;
|
if( !rotatingAxis::write(dict) ) return false;
|
||||||
|
@ -90,10 +98,8 @@ bool pFlow::multiRotatingAxis::write
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto rotAxis = axisMotion->indexToName(parentAxisIndex_);
|
dict.add("rotationAxis", componentNames[parentAxisIndex_]);
|
||||||
dict.add("rotationAxis", rotAxis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ Licence:
|
||||||
|
|
||||||
#include "rotatingAxis.hpp"
|
#include "rotatingAxis.hpp"
|
||||||
#include "KokkosTypes.hpp"
|
#include "KokkosTypes.hpp"
|
||||||
|
#include "List.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
@ -79,26 +79,31 @@ class multiRotatingAxis
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// This is device pointer to all axes
|
/// This is device pointer to all axes
|
||||||
multiRotatingAxis* axisList_;
|
multiRotatingAxis* axisList_ = nullptr;
|
||||||
|
|
||||||
/// Index of parent axis
|
/// Index of parent axis
|
||||||
int32 parentAxisIndex_ = -1;
|
uint32 parentAxisIndex_ = static_cast<uint32>(-1);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
TypeInfoNV("multiRotatingAxis");
|
||||||
|
|
||||||
// - Constructors
|
// - Constructors
|
||||||
|
|
||||||
/// Empty Constructor
|
/// Empty Constructor
|
||||||
INLINE_FUNCTION_HD
|
FUNCTION_HD
|
||||||
multiRotatingAxis(){}
|
multiRotatingAxis() = default;
|
||||||
|
|
||||||
/// Empty with list of axes
|
/// Construct from dictionary
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
multiRotatingAxis(multiRotatingAxisMotion* axisMotion);
|
explicit multiRotatingAxis(const dictionary& dict);
|
||||||
|
|
||||||
/// Construct from dictionary and list of axes
|
/// Construct from dictionary and list of axes
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
multiRotatingAxis(multiRotatingAxisMotion* axisMotion, const dictionary& dict);
|
multiRotatingAxis(
|
||||||
|
multiRotatingAxis* axisListPtr,
|
||||||
|
const wordList& componentsNames,
|
||||||
|
const dictionary& dict);
|
||||||
|
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
FUNCTION_HD
|
FUNCTION_HD
|
||||||
|
@ -123,11 +128,11 @@ public:
|
||||||
while(parIndex != -1)
|
while(parIndex != -1)
|
||||||
{
|
{
|
||||||
auto& ax = axisList_[parIndex];
|
auto& ax = axisList_[parIndex];
|
||||||
parentVel += ax.linTangentialVelocityPoint(p);
|
parentVel += ax.linVelocityPoint(p);
|
||||||
parIndex = ax.parentAxisIndex();
|
parIndex = ax.parentAxisIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parentVel + rotatingAxis::linTangentialVelocityPoint(p);
|
return parentVel + rotatingAxis::linVelocityPoint(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translate point p for dt seconds based on the axis information
|
/// Translate point p for dt seconds based on the axis information
|
||||||
|
@ -143,7 +148,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
auto parIndex = parentAxisIndex_;
|
auto parIndex = parentAxisIndex_;
|
||||||
while(parIndex != -1)
|
while(parIndex != static_cast<uint32>(-1))
|
||||||
{
|
{
|
||||||
auto& ax = axisList_[parIndex];
|
auto& ax = axisList_[parIndex];
|
||||||
newP = pFlow::rotate(newP, ax, dt);
|
newP = pFlow::rotate(newP, ax, dt);
|
||||||
|
@ -157,12 +162,12 @@ public:
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
bool hasParent()const
|
bool hasParent()const
|
||||||
{
|
{
|
||||||
return parentAxisIndex_ > -1;
|
return parentAxisIndex_ != static_cast<uint32>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the index of parent axis
|
/// Return the index of parent axis
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
int32 parentAxisIndex()const
|
uint32 parentAxisIndex()const
|
||||||
{
|
{
|
||||||
return parentAxisIndex_;
|
return parentAxisIndex_;
|
||||||
}
|
}
|
||||||
|
@ -201,11 +206,12 @@ public:
|
||||||
|
|
||||||
/// Read from dictionary
|
/// Read from dictionary
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
bool read(multiRotatingAxisMotion* axisMotion, const dictionary& dict);
|
bool read(const dictionary& dict, const wordList& componentNames);
|
||||||
|
|
||||||
/// Write to dictionary
|
/// Write to dictionary
|
||||||
FUNCTION_H
|
FUNCTION_H
|
||||||
bool write(const multiRotatingAxisMotion* axisMotion, dictionary& dict) const;
|
bool write(dictionary& dict, const wordList& componentNames) const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,40 +19,64 @@ Licence:
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "multiRotatingAxisMotion.hpp"
|
#include "multiRotatingAxisMotion.hpp"
|
||||||
#include "dictionary.hpp"
|
|
||||||
#include "vocabs.hpp"
|
|
||||||
|
|
||||||
|
void pFlow::multiRotatingAxisMotion::impl_setTime
|
||||||
bool pFlow::multiRotatingAxisMotion::readDictionary
|
|
||||||
(
|
(
|
||||||
const dictionary& dict
|
uint32 iter,
|
||||||
)
|
real t,
|
||||||
|
real dt
|
||||||
|
)const
|
||||||
|
{
|
||||||
|
auto motion = motionComponents_.deviceViewAll();
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"multiRotatingAxisMotion::impl_setTime",
|
||||||
|
deviceRPolicyStatic(0, numComponents_),
|
||||||
|
LAMBDA_D(uint32 i){
|
||||||
|
motion[i].setTime(t);
|
||||||
|
});
|
||||||
|
Kokkos::fence();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::multiRotatingAxisMotion::impl_move(uint32 iter, real t , real dt ) const
|
||||||
{
|
{
|
||||||
|
|
||||||
auto motionModel = dict.getVal<word>("motionModel");
|
auto motion = motionComponents_.deviceViewAll();
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"multiRotatingAxisMotion::impl_move",
|
||||||
|
deviceRPolicyStatic(0, numComponents_),
|
||||||
|
LAMBDA_D(uint32 i){
|
||||||
|
motion[i].move(dt);
|
||||||
|
});
|
||||||
|
Kokkos::fence();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(motionModel != "multiRotatingAxisMotion")
|
bool pFlow::multiRotatingAxisMotion::impl_readDictionary(const dictionary &dict)
|
||||||
|
{
|
||||||
|
auto modelName = dict.getVal<word>("motionModel");
|
||||||
|
|
||||||
|
if(modelName != getTypeName<ModelComponent>())
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" motionModel should be multiRotatingAxisMotion, but found "
|
" motionModel should be "<< Yellow_Text(getTypeName<ModelComponent>())<<
|
||||||
<< motionModel <<endl;
|
", but found "<< Yellow_Text(modelName)<<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& motionInfo = dict.subDict("multiRotatingAxisMotionInfo");
|
auto& motionInfo = dict.subDict(modelName+"Info");
|
||||||
auto axisNames = motionInfo.dictionaryKeywords();
|
auto compNames = motionInfo.dictionaryKeywords();
|
||||||
wordList rotationAxis;
|
|
||||||
|
|
||||||
// first check if
|
wordList rotationAxisNames;
|
||||||
|
|
||||||
|
|
||||||
for(auto& aName: axisNames)
|
// in the first round read all dictionaries
|
||||||
|
for(auto& compName: compNames)
|
||||||
{
|
{
|
||||||
auto& axDict = motionInfo.subDict(aName);
|
auto& axDict = motionInfo.subDict(compName);
|
||||||
|
|
||||||
if(auto axPtr = makeUnique<rotatingAxis>(axDict); axPtr)
|
if(auto axPtr = makeUnique<rotatingAxis>(axDict); axPtr)
|
||||||
{
|
{
|
||||||
rotationAxis.push_back(
|
rotationAxisNames.push_back(
|
||||||
axDict.getValOrSet<word>("rotationAxis", "none"));
|
axDict.getValOrSet<word>("rotationAxis", "none"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -63,26 +87,26 @@ bool pFlow::multiRotatingAxisMotion::readDictionary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !axisNames.search("none") )
|
if( !compNames.search("none") )
|
||||||
{
|
{
|
||||||
axisNames.push_back("none");
|
compNames.push_back("none");
|
||||||
rotationAxis.push_back("none");
|
rotationAxisNames.push_back("none");
|
||||||
}
|
}
|
||||||
|
|
||||||
using intPair = std::pair<int32, int32>;
|
using intPair = std::pair<int32, int32>;
|
||||||
|
|
||||||
std::vector<intPair> numRotAxis;
|
std::vector<intPair> numRotAxis;
|
||||||
|
|
||||||
for(size_t i=0; i< axisNames.size(); i++)
|
for(size_t i=0; i< compNames.size(); i++)
|
||||||
{
|
{
|
||||||
word rotAxis = rotationAxis[i];
|
word rotAxis = rotationAxisNames[i];
|
||||||
int32 n=0;
|
int32 n=0;
|
||||||
while(rotAxis != "none")
|
while(rotAxis != "none")
|
||||||
{
|
{
|
||||||
n++;
|
n++;
|
||||||
if(int32 iAxis = axisNames.findi(rotAxis) ; iAxis != -1)
|
if(int32 iAxis = compNames.findi(rotAxis) ; iAxis != -1)
|
||||||
{
|
{
|
||||||
rotAxis = rotationAxis[iAxis];
|
rotAxis = rotationAxisNames[iAxis];
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
|
@ -98,60 +122,73 @@ bool pFlow::multiRotatingAxisMotion::readDictionary
|
||||||
auto compareFunc = [](const intPair& a, const intPair& b)
|
auto compareFunc = [](const intPair& a, const intPair& b)
|
||||||
{ return a.first > b.first; };
|
{ return a.first > b.first; };
|
||||||
|
|
||||||
algorithms::STD::sort(numRotAxis.data(), numRotAxis.size(), compareFunc);
|
std::sort(numRotAxis.begin(), numRotAxis.end(), compareFunc);
|
||||||
|
Vector<int> sortedIndex;
|
||||||
sortedIndex_.clear();
|
componentNames_.clear();
|
||||||
axisName_.clear();
|
|
||||||
|
|
||||||
|
output<<compNames<<endl;
|
||||||
|
|
||||||
for(auto ax:numRotAxis)
|
for(auto ax:numRotAxis)
|
||||||
{
|
{
|
||||||
axisName_.push_back(axisNames[ax.second]);
|
componentNames_.push_back(compNames[ax.second]);
|
||||||
sortedIndex_.push_back(ax.second);
|
sortedIndex.push_back(ax.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
numAxis_ = axisName_.size();
|
numComponents_ = componentNames_.size();
|
||||||
axis_.clear();
|
motionComponents_.reserve(numComponents_);
|
||||||
axis_.reserve(numAxis_);
|
sortedIndex_.assign(sortedIndex);
|
||||||
|
|
||||||
|
Vector<ModelComponent> components("Read::modelComponent",
|
||||||
|
compNames.size()+1,
|
||||||
|
0,
|
||||||
|
RESERVE());
|
||||||
|
|
||||||
|
|
||||||
// create the actual axis vector
|
for(auto& compName: componentNames_)
|
||||||
for(auto& aName: axisName_)
|
|
||||||
{
|
{
|
||||||
if(aName != "none")
|
|
||||||
|
if(compName != "none")
|
||||||
{
|
{
|
||||||
auto& axDict = motionInfo.subDict(aName);
|
auto& compDict = motionInfo.subDict(compName);
|
||||||
axis_.push_back(
|
components.emplace_back(
|
||||||
multiRotatingAxis(this, axDict));
|
motionComponents_.data(),
|
||||||
|
componentNames_,
|
||||||
|
compDict);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
axis_.push_back(
|
components.emplace_back(impl_noneComponent());
|
||||||
multiRotatingAxis(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
motionComponents_.assign(components);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::multiRotatingAxisMotion::writeDictionary
|
|
||||||
|
bool pFlow::multiRotatingAxisMotion::impl_writeDictionary
|
||||||
(
|
(
|
||||||
dictionary& dict
|
dictionary& dict
|
||||||
)const
|
)const
|
||||||
{
|
{
|
||||||
dict.add("motionModel", "multiRotatingAxisMotion");
|
word modelName = "multiRotatingAxis";
|
||||||
|
|
||||||
auto& motionInfo = dict.subDictOrCreate("multiRotatingAxisMotionInfo");
|
dict.add("motionModel", modelName );
|
||||||
|
|
||||||
ForAll(i, axis_)
|
auto modelDictName = modelName+"Info";
|
||||||
|
|
||||||
|
auto& motionInfo = dict.subDictOrCreate(modelDictName);
|
||||||
|
auto hostComponents = motionComponents_.hostView();
|
||||||
|
|
||||||
|
ForAll(i, motionComponents_)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto& axDict = motionInfo.subDictOrCreate(axisName_[i]);
|
auto& axDict = motionInfo.subDictOrCreate(componentNames_[i]);
|
||||||
if( !axis_.hostVectorAll()[i].write(this,axDict))
|
if( !hostComponents[i].write(axDict, componentNames_))
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction<<
|
||||||
" error in writing axis "<< axisName_[i] << " to dicrionary "
|
" error in writing axis "<< componentNames_[i] << " to dicrionary "
|
||||||
<< motionInfo.globalName()<<endl;
|
<< motionInfo.globalName()<<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -160,79 +197,52 @@ bool pFlow::multiRotatingAxisMotion::writeDictionary
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion()
|
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion(
|
||||||
{}
|
const objectFile &objf,
|
||||||
|
repository *owner)
|
||||||
|
: fileDictionary(objf, owner)
|
||||||
|
{
|
||||||
|
|
||||||
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion
|
if(! getModel().impl_readDictionary(*this) )
|
||||||
(
|
|
||||||
const dictionary& dict
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if(! readDictionary(dict) )
|
|
||||||
{
|
{
|
||||||
|
fatalErrorInFunction;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FUNCTION_H
|
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion
|
||||||
bool pFlow::multiRotatingAxisMotion::move(real t, real dt)
|
|
||||||
{
|
|
||||||
|
|
||||||
// every thing is done on host
|
|
||||||
for(int32 i=0; i<numAxis_; i++)
|
|
||||||
{
|
|
||||||
auto& ax = axis_[sortedIndex_[i]];
|
|
||||||
ax.setTime(t);
|
|
||||||
ax.setAxisList(getAxisListPtrHost());
|
|
||||||
ax.move(dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
// transfer to device
|
|
||||||
axis_.modifyOnHost();
|
|
||||||
axis_.syncViews();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pFlow::multiRotatingAxisMotion::read
|
|
||||||
(
|
(
|
||||||
iIstream& is
|
const objectFile &objf,
|
||||||
|
const dictionary &dict,
|
||||||
|
repository *owner
|
||||||
)
|
)
|
||||||
|
:
|
||||||
|
fileDictionary(objf, dict, owner)
|
||||||
{
|
{
|
||||||
// create an empty file dictionary
|
if(!getModel().impl_readDictionary(*this) )
|
||||||
dictionary motionInfo(motionModelFile__, true);
|
|
||||||
|
|
||||||
// read dictionary from stream
|
|
||||||
if( !motionInfo.read(is) )
|
|
||||||
{
|
{
|
||||||
ioErrorInFile(is.name(), is.lineNumber()) <<
|
fatalErrorInFunction;
|
||||||
" error in reading dictionray " << motionModelFile__ <<" from file. \n";
|
fatalExit;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !readDictionary(motionInfo) ) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::multiRotatingAxisMotion::write
|
bool pFlow::multiRotatingAxisMotion::write
|
||||||
(
|
(
|
||||||
iOstream& os
|
iOstream &os,
|
||||||
|
const IOPattern &iop
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// create an empty file dictionary
|
// a global dictionary
|
||||||
dictionary motionInfo(motionModelFile__, true);
|
dictionary newDict(fileDictionary::dictionary::name(), true);
|
||||||
|
if( iop.thisProcWriteData() )
|
||||||
if( !writeDictionary(motionInfo))
|
|
||||||
{
|
{
|
||||||
|
if( !getModel().impl_writeDictionary(newDict) ||
|
||||||
|
!newDict.write(os))
|
||||||
|
{
|
||||||
|
fatalErrorInFunction<<
|
||||||
|
" error in writing to dictionary "<< newDict.globalName()<<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !motionInfo.write(os) )
|
|
||||||
{
|
|
||||||
ioErrorInFile( os.name(), os.lineNumber() )<<
|
|
||||||
" error in writing dictionray to file. \n";
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -22,18 +22,16 @@ Licence:
|
||||||
#define __multiRotatingAxisMotion_hpp__
|
#define __multiRotatingAxisMotion_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "types.hpp"
|
#include "MotionModel.hpp"
|
||||||
#include "typeInfo.hpp"
|
|
||||||
#include "VectorDual.hpp"
|
|
||||||
#include "List.hpp"
|
|
||||||
#include "multiRotatingAxis.hpp"
|
#include "multiRotatingAxis.hpp"
|
||||||
|
#include "fileDictionary.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
class dictionary;
|
// class dictionary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotating axis motion model for walls
|
* Rotating axis motion model for walls
|
||||||
|
@ -63,200 +61,53 @@ multiRotatingAxisMotionInfo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class multiRotatingAxisMotion
|
class multiRotatingAxisMotion
|
||||||
{
|
:
|
||||||
public:
|
public fileDictionary,
|
||||||
|
public MotionModel<multiRotatingAxisMotion, multiRotatingAxis>
|
||||||
/** Motion model class to be passed to computational units/kernels for
|
|
||||||
* transfing points and returning velocities at various positions
|
|
||||||
*/
|
|
||||||
class Model
|
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
deviceViewType1D<multiRotatingAxis> axis_;
|
VectorSingle<int32> sortedIndex_;
|
||||||
int32 numAxis_=0;
|
|
||||||
|
|
||||||
public:
|
friend MotionModel<multiRotatingAxisMotion, multiRotatingAxis>;
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
/// is the geometry attached to this component moving
|
||||||
Model(deviceViewType1D<multiRotatingAxis> axis, int32 numAxis):
|
bool impl_isMoving()const
|
||||||
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].pointTangentialVel(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 axis_[n].transferPoint(p, dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
INLINE_FUNCTION_HD int32 numComponents()const
|
|
||||||
{
|
|
||||||
return numAxis_;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
using axisVector_HD = VectorDual<multiRotatingAxis>;
|
|
||||||
|
|
||||||
/// Vector of multiRotaingAxis axes
|
|
||||||
axisVector_HD axis_;
|
|
||||||
|
|
||||||
/// Sorted index based on number of parrents each axis ha
|
|
||||||
VectorDual<int32> sortedIndex_;
|
|
||||||
|
|
||||||
/// List of axes names
|
|
||||||
wordList axisName_;
|
|
||||||
|
|
||||||
/// Number of axes
|
|
||||||
label numAxis_= 0;
|
|
||||||
|
|
||||||
/// Read from a dictionary
|
|
||||||
bool readDictionary(const dictionary& dict);
|
|
||||||
|
|
||||||
/// Write to a dictionary
|
|
||||||
bool writeDictionary(dictionary& dict)const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Type info
|
|
||||||
TypeInfoNV("multiRotatingAxisMotion");
|
|
||||||
|
|
||||||
// - Constructor
|
|
||||||
|
|
||||||
/// Empty constructor
|
|
||||||
FUNCTION_H
|
|
||||||
multiRotatingAxisMotion();
|
|
||||||
|
|
||||||
/// Construct with dictionary
|
|
||||||
FUNCTION_H
|
|
||||||
multiRotatingAxisMotion(const dictionary& dict);
|
|
||||||
|
|
||||||
/// Copy constructor
|
|
||||||
FUNCTION_H
|
|
||||||
multiRotatingAxisMotion(const multiRotatingAxisMotion&) = default;
|
|
||||||
|
|
||||||
/// No Move
|
|
||||||
multiRotatingAxisMotion(multiRotatingAxisMotion&&) = delete;
|
|
||||||
|
|
||||||
/// Copy assignment
|
|
||||||
FUNCTION_H
|
|
||||||
multiRotatingAxisMotion& operator=(const multiRotatingAxisMotion&) = default;
|
|
||||||
|
|
||||||
/// No move assignment
|
|
||||||
multiRotatingAxisMotion& operator=(multiRotatingAxisMotion&&) = delete;
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
FUNCTION_H
|
|
||||||
~multiRotatingAxisMotion() = default;
|
|
||||||
|
|
||||||
// - Methods
|
|
||||||
|
|
||||||
/// Retrun motion model at time t
|
|
||||||
Model getModel(real t)
|
|
||||||
{
|
|
||||||
for(int32 i= 0; i<numAxis_; i++ )
|
|
||||||
{
|
|
||||||
axis_[i].setTime(t);
|
|
||||||
axis_[i].setAxisList(getAxisListPtrDevice());
|
|
||||||
}
|
|
||||||
axis_.modifyOnHost();
|
|
||||||
axis_.syncViews();
|
|
||||||
|
|
||||||
return Model(axis_.deviceVector(), numAxis_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pointer to axis list on host side
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
multiRotatingAxis* getAxisListPtrHost()
|
|
||||||
{
|
|
||||||
return axis_.hostVectorAll().data();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pointer to axis list on device
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
multiRotatingAxis* getAxisListPtrDevice()
|
|
||||||
{
|
|
||||||
return axis_.deviceVectorAll().data();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Name of motion component to index
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Index of motion component to component name
|
|
||||||
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 "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Is moving
|
|
||||||
INLINE_FUNCTION_HD
|
|
||||||
bool isMoving()const
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Move points
|
/// move the component itself
|
||||||
FUNCTION_H
|
bool impl_move(uint32 iter, real t, real dt)const;
|
||||||
bool move(real t, real dt);
|
|
||||||
|
|
||||||
// - IO operation
|
/// Read from dictionary
|
||||||
|
bool impl_readDictionary(const dictionary& dict);
|
||||||
|
|
||||||
/// Read from input stream is
|
bool impl_writeDictionary(dictionary& dict)const;
|
||||||
FUNCTION_H
|
|
||||||
bool read(iIstream& is);
|
|
||||||
|
|
||||||
/// Write to output stream os
|
public:
|
||||||
FUNCTION_H
|
|
||||||
bool write(iOstream& os)const;
|
|
||||||
|
|
||||||
|
TypeInfo("multiRotatingAxisMotion");
|
||||||
|
|
||||||
|
multiRotatingAxisMotion(const objectFile& objf, repository* owner);
|
||||||
|
|
||||||
|
multiRotatingAxisMotion(
|
||||||
|
const objectFile& objf,
|
||||||
|
const dictionary& dict,
|
||||||
|
repository* owner);
|
||||||
|
|
||||||
|
using fileDictionary::write;
|
||||||
|
|
||||||
|
bool write(iOstream& os, const IOPattern& iop)const override;
|
||||||
|
|
||||||
|
static
|
||||||
|
multiRotatingAxis noneComponent()
|
||||||
|
{
|
||||||
|
return multiRotatingAxis();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: make this method protected
|
||||||
|
void impl_setTime(uint32 iter, real t, real dt)const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
Loading…
Reference in New Issue