# PhasicFlow: src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.hpp Source File

multiRotatingAxisMotion.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.
-----------------------------------------------------------------------------*/
#ifndef __multiRotatingAxisMotion_hpp__
#define __multiRotatingAxisMotion_hpp__
#include "types.hpp"
#include "typeInfo.hpp"
#include "VectorDual.hpp"
#include "List.hpp"
#include "multiRotatingAxis.hpp"
namespace pFlow
{
// forward
class dictionary;
class multiRotatingAxisMotion
{
public:
class Model
{
protected:
deviceViewType1D<multiRotatingAxis> axis_;
int32 numAxis_=0;
public:
INLINE_FUNCTION_HD
Model(deviceViewType1D<multiRotatingAxis> 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].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>;
axisVector_HD axis_;
VectorDual<int32> sortedIndex_;
wordList axisName_;
label numAxis_= 0;
bool readDictionary(const dictionary& dict);
bool writeDictionary(dictionary& dict)const;
public:
TypeInfoNV("multiRotatingAxisMotion");
// - Constructor
FUNCTION_H
multiRotatingAxisMotion();
FUNCTION_H
multiRotatingAxisMotion(const dictionary& dict);
FUNCTION_H
multiRotatingAxisMotion(const multiRotatingAxisMotion&) = default;
multiRotatingAxisMotion(multiRotatingAxisMotion&&) = delete;
FUNCTION_H
multiRotatingAxisMotion& operator=(const multiRotatingAxisMotion&) = default;
multiRotatingAxisMotion& operator=(multiRotatingAxisMotion&&) = delete;
FUNCTION_H
~multiRotatingAxisMotion() = default;
// - Methods
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_);
}
INLINE_FUNCTION_H
multiRotatingAxis* getAxisListPtrHost()
{
return axis_.hostVectorAll().data();
}
INLINE_FUNCTION_H
multiRotatingAxis* getAxisListPtrDevice()
{
return axis_.deviceVectorAll().data();
}
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_HD
bool isMoving()const
{
return true;
}
FUNCTION_H
bool move(real t, real dt);
// - IO operation
FUNCTION_H
bool read(iIstream& is);
FUNCTION_H
bool write(iOstream& os)const;
};
} // pFlow
#endif //__multiRotatingAxisMotion_hpp__
pFlow::multiRotatingAxisMotion::Model::pointVelocity
INLINE_FUNCTION_HD realx3 pointVelocity(int32 n, const realx3 &p) const
Definition: multiRotatingAxisMotion.hpp:96
pFlow::multiRotatingAxisMotion::axis_
axisVector_HD axis_
Vector of multiRotaingAxis axes.
Definition: multiRotatingAxisMotion.hpp:124
pFlow::List< word >
pFlow::multiRotatingAxisMotion::readDictionary
bool readDictionary(const dictionary &dict)
Read from a dictionary.
Definition: multiRotatingAxisMotion.cpp:27
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews()
Definition: VectorDual.hpp:875
pFlow::multiRotatingAxisMotion::getAxisListPtrDevice
INLINE_FUNCTION_H multiRotatingAxis * getAxisListPtrDevice()
Pointer to axis list on device.
Definition: multiRotatingAxisMotion.hpp:199
multiRotatingAxis.hpp
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::VectorDual::hostVectorAll
INLINE_FUNCTION_H hostViewType & hostVectorAll()
Definition: VectorDual.hpp:345
types.hpp
pFlow::multiRotatingAxisMotion::indexToName
INLINE_FUNCTION_H word indexToName(label i) const
Index of motion component to component name.
Definition: multiRotatingAxisMotion.hpp:224
List.hpp
pFlow::multiRotatingAxisMotion::Model::operator=
INLINE_FUNCTION_HD Model & operator=(const Model &)=default
pFlow::multiRotatingAxisMotion::Model::numComponents
INLINE_FUNCTION_HD int32 numComponents() const
Definition: multiRotatingAxisMotion.hpp:113
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::multiRotatingAxisMotion::write
FUNCTION_H bool write(iOstream &os) const
Write to output stream os.
Definition: multiRotatingAxisMotion.cpp:219
pFlow::multiRotatingAxisMotion::numAxis_
label numAxis_
Number of axes.
Definition: multiRotatingAxisMotion.hpp:133
pFlow::multiRotatingAxisMotion::nameToIndex
INLINE_FUNCTION_H int32 nameToIndex(const word &name) const
Name of motion component to index.
Definition: multiRotatingAxisMotion.hpp:206
pFlow::multiRotatingAxisMotion::~multiRotatingAxisMotion
FUNCTION_H ~multiRotatingAxisMotion()=default
Destructor.
pFlow::multiRotatingAxisMotion::Model::axis_
deviceViewType1D< multiRotatingAxis > axis_
Definition: multiRotatingAxisMotion.hpp:76
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::multiRotatingAxisMotion::sortedIndex_
VectorDual< int32 > sortedIndex_
Sorted index based on number of parrents each axis ha.
Definition: multiRotatingAxisMotion.hpp:127
pFlow::VectorDual::modifyOnHost
INLINE_FUNCTION_H void modifyOnHost()
Definition: VectorDual.hpp:796
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:93
VectorDual.hpp
pFlow
Definition: demComponent.hpp:28
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::List::findi
int32 findi(const T &val) const
Definition: ListI.hpp:109
pFlow::VectorDual::deviceVectorAll
INLINE_FUNCTION_H deviceViewType & deviceVectorAll()
Definition: VectorDual.hpp:335
n
int32 n
Definition: NBSCrossLoop.hpp:24
pFlow::multiRotatingAxis
Defines an axis of rotation that rotates around itself and rotates around another axis.
Definition: multiRotatingAxis.hpp:75
pFlow::iIstream
Definition: iIstream.hpp:33
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::VectorDual< multiRotatingAxis >
pFlow::multiRotatingAxisMotion::isMoving
INLINE_FUNCTION_HD bool isMoving() const
Is moving.
Definition: multiRotatingAxisMotion.hpp:240
pFlow::multiRotatingAxisMotion::writeDictionary
bool writeDictionary(dictionary &dict) const
Write to a dictionary.
Definition: multiRotatingAxisMotion.cpp:139
pFlow::multiRotatingAxisMotion::getModel
Model getModel(real t)
Retrun motion model at time t.
Definition: multiRotatingAxisMotion.hpp:177
pFlow::multiRotatingAxisMotion::move
FUNCTION_H bool move(real t, real dt)
Move points.
Definition: multiRotatingAxisMotion.cpp:178
pFlow::multiRotatingAxisMotion::Model
Motion model class to be passed to computational units/kernels for transfing points and returning vel...
Definition: multiRotatingAxisMotion.hpp:72
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::multiRotatingAxisMotion::TypeInfoNV
TypeInfoNV("multiRotatingAxisMotion")
Type info.
pFlow::multiRotatingAxisMotion::Model::Model
INLINE_FUNCTION_HD Model(deviceViewType1D< multiRotatingAxis > axis, int32 numAxis)
Definition: multiRotatingAxisMotion.hpp:82
pFlow::multiRotatingAxisMotion::getAxisListPtrHost
INLINE_FUNCTION_H multiRotatingAxis * getAxisListPtrHost()
Pointer to axis list on host side.
Definition: multiRotatingAxisMotion.hpp:192
pFlow::multiRotatingAxisMotion::read
FUNCTION_H bool read(iIstream &is)
Read from input stream is.
Definition: multiRotatingAxisMotion.cpp:198
pFlow::multiRotatingAxisMotion::axisName_
wordList axisName_
List of axes names.
Definition: multiRotatingAxisMotion.hpp:130
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion
FUNCTION_H multiRotatingAxisMotion()
Empty constructor.
Definition: multiRotatingAxisMotion.cpp:163
pFlow::multiRotatingAxisMotion
Rotating axis motion model for walls.
Definition: multiRotatingAxisMotion.hpp:65
pFlow::VectorDual::deviceVector
INLINE_FUNCTION_H deviceViewType & deviceVector()
Definition: VectorDual.hpp:354
pFlow::multiRotatingAxisMotion::operator=
FUNCTION_H multiRotatingAxisMotion & operator=(const multiRotatingAxisMotion &)=default
Copy assignment.
typeInfo.hpp
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::multiRotatingAxisMotion::Model::numAxis_
int32 numAxis_
Definition: multiRotatingAxisMotion.hpp:77
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::multiRotatingAxisMotion::Model::transferPoint
INLINE_FUNCTION_HD realx3 transferPoint(int32 n, const realx3 p, real dt) const
Definition: multiRotatingAxisMotion.hpp:108
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::multiRotatingAxisMotion::Model::operator()
INLINE_FUNCTION_HD realx3 operator()(int32 n, const realx3 &p) const
Definition: multiRotatingAxisMotion.hpp:102
pFlow::dictionary
Definition: dictionary.hpp:38