diff --git a/src/MotionModel/MotionModel/MotionModel.hpp b/src/MotionModel/MotionModel/MotionModel.hpp index db1cdf46..6dae3175 100644 --- a/src/MotionModel/MotionModel/MotionModel.hpp +++ b/src/MotionModel/MotionModel/MotionModel.hpp @@ -32,7 +32,9 @@ Licence: namespace pFlow { - +/** + * @brief Motion model abstract class (CRTP) for all the motion models +*/ template class MotionModel { @@ -123,49 +125,45 @@ private: protected: + /// @brief obtain a reference to the actual motion model inline auto& getModel() { return static_cast(*this); } + /// @brief Obtain a const reference to the actual motion model inline const auto& getModel()const { return static_cast(*this); } - // implementation details goes here + /// Return a none object for the motion model inline auto impl_noneComponent()const { return ModelType::noneComponent(); } - /// name of the compoenent to index of the component + /// Name of the compoenent to index of the component bool impl_nameToIndex(const word& name, uint32& idx)const; /// Component index to motion component name - bool impl_indexToName(uint32 i, word& name)const; + /// const reference to the list of component names + inline const wordList& impl_componentNames()const { return componentNames_; } - bool impl_isMoving()const - { - return false; - } - - bool impl_move(uint32, real, real)const - { - return true; - } - + /// Return model interface auto impl_getModelInterface(uint32 iter, real t, real dt)const { + getModel().impl_setTime(iter, t, dt); + return ModelInterface( motionComponents_.deviceViewAll(), numComponents_); @@ -174,6 +172,7 @@ protected: /// Read from dictionary bool impl_readDictionary(const dictionary& dict); + /// Write to dictionary bool impl_writeDictionary(dictionary& dict)const; public: @@ -199,21 +198,7 @@ public: ~MotionModel() = default; // - Methods - /// Return the motion model at time t - /*Model getModel(real t) - { - for(int32 i= 0; i("motionModel"); - - if(motionModel != "rotatingAxisMotion") - { - fatalErrorInFunction<< - " motionModel should be rotatingAxisMotion, but found " - << motionModel <(axDict); axPtr) - { - axis_.push_back(axPtr()); - axisName_.push_back(aName); - } - else - { - fatalErrorInFunction<< - "could not read rotating axis from "<< axDict.globalName()< axis_; - int32 numAxis_=0; - - public: - - INLINE_FUNCTION_HD - Model(deviceViewType1D 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; - - /// Vector to store axes - axisVector_HD axis_; - - /// Names of axes - wordList axisName_; - - /// Number of axes components - label numAxis_= 0; - - /// Read from dictionary - bool readDictionary(const dictionary& dict); - - /// Write to dictionary - bool writeDictionary(dictionary& dict)const; - -public: - - /// Type info - TypeInfoNV("rotatingAxisMotion"); - - // - Constructors - - /// Empty - FUNCTION_H - rotatingAxisMotion(); - - /// Construct with dictionary - FUNCTION_H - rotatingAxisMotion(const dictionary& dict); - - /// Copy constructor - FUNCTION_H - rotatingAxisMotion(const rotatingAxisMotion&) = default; - - /// No move constructor - rotatingAxisMotion(rotatingAxisMotion&&) = delete; - - /// Copy assignment - FUNCTION_H - rotatingAxisMotion& operator=(const rotatingAxisMotion&) = default; - - /// No move assignment - rotatingAxisMotion& operator=(rotatingAxisMotion&&) = delete; - - /// Destructor - FUNCTION_H - ~rotatingAxisMotion() = default; - - // - Methods - /// Return the motion model at time t - Model getModel(real t) - { - for(int32 i= 0; i; + + /// is the geometry attached to this component moving bool impl_isMoving()const { return true; } + + /// move the component itself + bool impl_move(uint32, real, real)const + { + return true; + } + + void impl_setTime(uint32 iter, real t, real dt)const; public: diff --git a/src/MotionModel/stationaryWall/stationaryWall.cpp b/src/MotionModel/stationaryWall/stationaryWall.cpp index 1440c094..ff581496 100644 --- a/src/MotionModel/stationaryWall/stationaryWall.cpp +++ b/src/MotionModel/stationaryWall/stationaryWall.cpp @@ -30,7 +30,7 @@ pFlow::stationaryWall::stationaryWall fileDictionary(objf, owner) { - if(! getModel().impl_readDictionary(*this) ) + if(!impl_readDictionary(*this) ) { fatalErrorInFunction; fatalExit; @@ -46,7 +46,7 @@ pFlow::stationaryWall::stationaryWall : fileDictionary(objf, dict, owner) { - if(! getModel().impl_readDictionary(*this) ) + if(!impl_readDictionary(*this) ) { fatalErrorInFunction; fatalExit; diff --git a/src/MotionModel/stationaryWall/stationaryWall.hpp b/src/MotionModel/stationaryWall/stationaryWall.hpp index f440cfdd..514cba1d 100644 --- a/src/MotionModel/stationaryWall/stationaryWall.hpp +++ b/src/MotionModel/stationaryWall/stationaryWall.hpp @@ -30,6 +30,26 @@ namespace pFlow { +/** + * stationary model for walls + * + * This class is used for simulaiton that all wall components + * are fixed. + * +\verbatim +// In geometryDict file, this will defines stationary walls +... +motionModel stationary; + +// this dictionary is optional +stationaryInfo +{ + +} +... +\endverbatim + * + */ class stationaryWall : public fileDictionary, @@ -37,11 +57,21 @@ class stationaryWall { protected: + friend MotionModel; + bool impl_isMoving()const { return false; } + + bool impl_move(uint32, real, real)const + { + return true; + } + void impl_setTime(uint32 ,real ,real )const + {} + public: TypeInfo("stationaryWall"); diff --git a/src/MotionModel/vibratingMotion/vibratingMotion-old.cpp b/src/MotionModel/vibratingMotion/vibratingMotion-old.cpp deleted file mode 100644 index 1cc472a8..00000000 --- a/src/MotionModel/vibratingMotion/vibratingMotion-old.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/*------------------------------- 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 "vibratingMotion.hpp" -#include "dictionary.hpp" -#include "vocabs.hpp" - - -bool pFlow::vibratingMotion::readDictionary -( - const dictionary& dict -) -{ - - auto motionModel = dict.getVal("motionModel"); - - if(motionModel != "vibratingMotion") - { - fatalErrorInFunction<< - " motionModel should be vibratingMotion, but found " - << motionModel <(compDict); compPtr) - { - components_.push_back(compPtr()); - componentName_.push_back(cName); - } - else - { - fatalErrorInFunction<< - "could not read vibrating motion from "<< compDict.globalName()< components_; - int32 numComponents_=0; - - public: - - INLINE_FUNCTION_HD - Model(deviceViewType1D 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 motion components - axisVector_HD components_; - - /// Names of components - wordList componentName_; - - /// Number of components - label numComponents_= 0; - - /// Read from a dictionary - bool readDictionary(const dictionary& dict); - - /// Write to a dictionary - bool writeDictionary(dictionary& dict)const; - -public: - - /// Type info - TypeInfoNV("vibratingMotion"); - - /// Empty - FUNCTION_H - vibratingMotion(); - - /// Construct with dictionary - FUNCTION_H - vibratingMotion(const dictionary& dict); - - /// Copy constructor - FUNCTION_H - vibratingMotion(const vibratingMotion&) = default; - - /// No move - vibratingMotion(vibratingMotion&&) = delete; - - /// Copy assignment - FUNCTION_H - vibratingMotion& operator=(const vibratingMotion&) = default; - - /// No Move assignment - vibratingMotion& operator=(vibratingMotion&&) = delete; - - /// Destructor - FUNCTION_H - ~vibratingMotion() = default; - - /// Return motion model at time t - Model getModel(real t) - { - for(int32 i= 0; i; bool impl_isMoving()const { return true; } + /// move the component itself + bool impl_move(uint32, real, real)const + { + return true; + } + + void impl_setTime(uint32 iter, real t, real dt)const; + public: /// Type info