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

vibratingMotion.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 __vibratingMotion_hpp__
#define __vibratingMotion_hpp__
#include "types.hpp"
#include "typeInfo.hpp"
#include "VectorDual.hpp"
#include "Vectors.hpp"
#include "List.hpp"
#include "vibrating.hpp"
namespace pFlow
{
// forward
class dictionary;
class vibratingMotion
{
public:
class Model
{
protected:
deviceViewType1D<vibrating> components_;
int32 numComponents_=0;
public:
INLINE_FUNCTION_HD
Model(deviceViewType1D<vibrating> comps, int32 numComps):
components_(comps),
numComponents_(numComps)
{}
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 components_[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 components_[n].transferPoint(p, dt);
}
INLINE_FUNCTION_HD int32 numComponents()const
{
return numComponents_;
}
};
protected:
using axisVector_HD = VectorDual<vibrating>;
axisVector_HD components_;
wordList componentName_;
label numComponents_= 0;
bool readDictionary(const dictionary& dict);
bool writeDictionary(dictionary& dict)const;
public:
TypeInfoNV("vibratingMotion");
FUNCTION_H
vibratingMotion();
FUNCTION_H
vibratingMotion(const dictionary& dict);
FUNCTION_H
vibratingMotion(const vibratingMotion&) = default;
vibratingMotion(vibratingMotion&&) = delete;
FUNCTION_H
vibratingMotion& operator=(const vibratingMotion&) = default;
vibratingMotion& operator=(vibratingMotion&&) = delete;
FUNCTION_H
~vibratingMotion() = default;
Model getModel(real t)
{
for(int32 i= 0; i<numComponents_; i++ )
{
components_[i].setTime(t);
}
components_.modifyOnHost();
components_.syncViews();
return Model(components_.deviceVectorAll(), numComponents_);
}
INLINE_FUNCTION_H
int32 nameToIndex(const word& name)const
{
if( auto i = componentName_.findi(name); i == -1)
{
fatalErrorInFunction<<
"component name " << name << " does not exist. \n";
fatalExit;
return i;
}
else
{
return i;
}
}
INLINE_FUNCTION_H
word indexToName(label i)const
{
if(i < numComponents_ )
return componentName_[i];
else
{
fatalErrorInFunction<<
"out of range access to the list of axes " << i <<endl<<
" size of components_ is "<<numComponents_<<endl;
fatalExit;
return "";
}
}
INLINE_FUNCTION_H
realx3 pointVelocity(label n, const realx3& p)const
{
return components_.hostVectorAll()[n].linTangentialVelocityPoint(p);
}
INLINE_FUNCTION_H
realx3 transferPoint(label n, const realx3 p, real dt)const
{
return components_.hostVectorAll()[n].transferPoint(p, dt);
}
INLINE_FUNCTION_HD
bool isMoving()const
{
return true;
}
INLINE_FUNCTION_H
bool move(real t, real dt)
{
return true;
}
FUNCTION_H
bool read(iIstream& is);
FUNCTION_H
bool write(iOstream& os)const;
};
} // pFlow
#endif //__rotatingAxisMotion_hpp__
pFlow::vibratingMotion::nameToIndex
INLINE_FUNCTION_H int32 nameToIndex(const word &name) const
Name to component index.
Definition: vibratingMotion.hpp:187
pFlow::vibratingMotion::isMoving
INLINE_FUNCTION_HD bool isMoving() const
Is moving.
Definition: vibratingMotion.hpp:235
pFlow::vibratingMotion
Vibrating motion model for walls.
Definition: vibratingMotion.hpp:68
pFlow::vibratingMotion::read
FUNCTION_H bool read(iIstream &is)
Read from input stream is.
Definition: vibratingMotion.cpp:127
pFlow::List< word >
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews()
Definition: VectorDual.hpp:875
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::vibratingMotion::transferPoint
INLINE_FUNCTION_H realx3 transferPoint(label n, const realx3 p, real dt) const
Transfer point p for dt seconds based on motion component n.
Definition: vibratingMotion.hpp:228
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::vibratingMotion::TypeInfoNV
TypeInfoNV("vibratingMotion")
Type info.
pFlow::vibratingMotion::Model::numComponents
INLINE_FUNCTION_HD int32 numComponents() const
Definition: vibratingMotion.hpp:116
pFlow::vibratingMotion::Model
Motion model class to be passed to computational units/kernels for transfing points and returning vel...
Definition: vibratingMotion.hpp:75
pFlow::VectorDual::hostVectorAll
INLINE_FUNCTION_H hostViewType & hostVectorAll()
Definition: VectorDual.hpp:345
types.hpp
List.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::vibratingMotion::Model::operator=
INLINE_FUNCTION_HD Model & operator=(const Model &)=default
Vectors.hpp
pFlow::vibratingMotion::Model::components_
deviceViewType1D< vibrating > components_
Definition: vibratingMotion.hpp:79
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::vibratingMotion::components_
axisVector_HD components_
Vibrating motion components.
Definition: vibratingMotion.hpp:127
pFlow::VectorDual::modifyOnHost
INLINE_FUNCTION_H void modifyOnHost()
Definition: VectorDual.hpp:796
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:93
pFlow::vibratingMotion::pointVelocity
INLINE_FUNCTION_H realx3 pointVelocity(label n, const realx3 &p) const
velocity at point p according to motion component n
Definition: vibratingMotion.hpp:221
pFlow::vibratingMotion::numComponents_
label numComponents_
Number of components.
Definition: vibratingMotion.hpp:133
VectorDual.hpp
pFlow
Definition: demComponent.hpp:28
vibrating.hpp
pFlow::vibratingMotion::Model::transferPoint
INLINE_FUNCTION_HD realx3 transferPoint(int32 n, const realx3 p, real dt) const
Definition: vibratingMotion.hpp:111
pFlow::vibratingMotion::~vibratingMotion
FUNCTION_H ~vibratingMotion()=default
Destructor.
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::iIstream
Definition: iIstream.hpp:33
pFlow::vibratingMotion::operator=
FUNCTION_H vibratingMotion & operator=(const vibratingMotion &)=default
Copy assignment.
pFlow::vibratingMotion::readDictionary
bool readDictionary(const dictionary &dict)
Read from a dictionary.
Definition: vibratingMotion.cpp:27
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::VectorDual< vibrating >
pFlow::vibratingMotion::Model::operator()
INLINE_FUNCTION_HD realx3 operator()(int32 n, const realx3 &p) const
Definition: vibratingMotion.hpp:105
pFlow::vibratingMotion::Model::pointVelocity
INLINE_FUNCTION_HD realx3 pointVelocity(int32 n, const realx3 &p) const
Definition: vibratingMotion.hpp:99
pFlow::vibratingMotion::move
INLINE_FUNCTION_H bool move(real t, real dt)
Move ponits at time t for dt seconds.
Definition: vibratingMotion.hpp:242
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::vibratingMotion::Model::numComponents_
int32 numComponents_
Definition: vibratingMotion.hpp:80
pFlow::vibratingMotion::Model::Model
INLINE_FUNCTION_HD Model(deviceViewType1D< vibrating > comps, int32 numComps)
Definition: vibratingMotion.hpp:85
pFlow::vibratingMotion::componentName_
wordList componentName_
Names of components.
Definition: vibratingMotion.hpp:130
pFlow::vibratingMotion::writeDictionary
bool writeDictionary(dictionary &dict) const
Write to a dictionary.
Definition: vibratingMotion.cpp:88
typeInfo.hpp
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::vibratingMotion::vibratingMotion
FUNCTION_H vibratingMotion()
Empty.
Definition: vibratingMotion.cpp:112
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::vibratingMotion::write
FUNCTION_H bool write(iOstream &os) const
Write to output stream os.
Definition: vibratingMotion.cpp:148
pFlow::vibratingMotion::getModel
Model getModel(real t)
Return motion model at time t.
Definition: vibratingMotion.hpp:173
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::vibratingMotion::indexToName
INLINE_FUNCTION_H word indexToName(label i) const
Index to name.
Definition: vibratingMotion.hpp:205
pFlow::dictionary
Definition: dictionary.hpp:38