phasicFlow/src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.hpp

265 lines
5.6 KiB
C++
Raw Normal View History

/*------------------------------- 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
{
2023-04-02 16:17:16 +00:00
// forward
class dictionary;
2023-04-02 16:17:16 +00:00
/**
* Rotating axis motion model for walls
*
* This class is used for simulaiton that at least one wall components
* is moving according to multiRotatingAxis motion mode. One or more than one
* motion components can be defined in multiRotatingAxisMotionInfo dictionary
*
\verbatim
// In geometryDict file, this will defines multi-rotating walls during simulation
...
motionModel multiRotatingAxisMotion;
multiRotatingAxisMotionInfo
{
rotationAxis1
{
// the definition based on class multiRotatingAxis
}
rotatoinAxis2
{
// the definition based on calss multiRotatingAxis
}
}
...
\endverbatim
*
*/
class multiRotatingAxisMotion
{
public:
2023-04-02 16:17:16 +00:00
/** Motion model class to be passed to computational units/kernels for
* transfing points and returning velocities at various positions
*/
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>;
2023-04-02 16:17:16 +00:00
/// Vector of multiRotaingAxis axes
axisVector_HD axis_;
2023-04-02 16:17:16 +00:00
/// Sorted index based on number of parrents each axis ha
VectorDual<int32> sortedIndex_;
2023-04-02 16:17:16 +00:00
/// List of axes names
wordList axisName_;
2023-04-02 16:17:16 +00:00
/// Number of axes
label numAxis_= 0;
2023-04-02 16:17:16 +00:00
/// Read from a dictionary
bool readDictionary(const dictionary& dict);
2023-04-02 16:17:16 +00:00
/// Write to a dictionary
bool writeDictionary(dictionary& dict)const;
public:
2023-04-02 16:17:16 +00:00
/// Type info
TypeInfoNV("multiRotatingAxisMotion");
2023-04-02 16:17:16 +00:00
// - Constructor
2023-04-02 16:17:16 +00:00
/// Empty constructor
FUNCTION_H
multiRotatingAxisMotion();
2023-04-02 16:17:16 +00:00
/// Construct with dictionary
FUNCTION_H
multiRotatingAxisMotion(const dictionary& dict);
2023-04-02 16:17:16 +00:00
/// Copy constructor
FUNCTION_H
multiRotatingAxisMotion(const multiRotatingAxisMotion&) = default;
2023-04-02 16:17:16 +00:00
/// No Move
multiRotatingAxisMotion(multiRotatingAxisMotion&&) = delete;
2023-04-02 16:17:16 +00:00
/// Copy assignment
FUNCTION_H
multiRotatingAxisMotion& operator=(const multiRotatingAxisMotion&) = default;
2023-04-02 16:17:16 +00:00
/// No move assignment
multiRotatingAxisMotion& operator=(multiRotatingAxisMotion&&) = delete;
2023-04-02 16:17:16 +00:00
/// Destructor
FUNCTION_H
~multiRotatingAxisMotion() = default;
2023-04-02 16:17:16 +00:00
// - Methods
/// Retrun motion model at time t
Model getModel(real t)
{
2023-04-02 16:17:16 +00:00
for(int32 i= 0; i<numAxis_; i++ )
{
axis_[i].setTime(t);
axis_[i].setAxisList(getAxisListPtrDevice());
}
axis_.modifyOnHost();
axis_.syncViews();
return Model(axis_.deviceVector(), numAxis_);
}
2023-04-02 16:17:16 +00:00
/// Pointer to axis list on host side
INLINE_FUNCTION_H
multiRotatingAxis* getAxisListPtrHost()
{
2023-04-02 16:17:16 +00:00
return axis_.hostVectorAll().data();
}
2023-04-02 16:17:16 +00:00
/// Pointer to axis list on device
INLINE_FUNCTION_H
multiRotatingAxis* getAxisListPtrDevice()
{
2023-04-02 16:17:16 +00:00
return axis_.deviceVectorAll().data();
}
2023-04-02 16:17:16 +00:00
/// Name of motion component to index
INLINE_FUNCTION_H
int32 nameToIndex(const word& name)const
{
2023-04-02 16:17:16 +00:00
if( auto i = axisName_.findi(name); i == -1)
{
fatalErrorInFunction<<
"axis name " << name << " does not exist. \n";
fatalExit;
return i;
}
else
{
return i;
}
}
2023-04-02 16:17:16 +00:00
/// 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 "";
}
}
2023-04-02 16:17:16 +00:00
/// Is moving
INLINE_FUNCTION_HD
bool isMoving()const
{
return true;
}
2023-04-02 16:17:16 +00:00
/// Move points
FUNCTION_H
bool move(real t, real dt);
// - IO operation
2023-04-02 16:17:16 +00:00
/// Read from input stream is
FUNCTION_H
bool read(iIstream& is);
2023-04-02 16:17:16 +00:00
/// Write to output stream os
FUNCTION_H
bool write(iOstream& os)const;
};
} // pFlow
#endif //__multiRotatingAxisMotion_hpp__