From 990a4a8d52b9adc1e0e6a385a12eb39232a30e88 Mon Sep 17 00:00:00 2001 From: hamidrezanorouzi Date: Sun, 8 Jan 2023 08:06:15 +0330 Subject: [PATCH] multiRotatingAxisMotion added and tested --- .../geometryMotion/geometryMotion.cpp | 3 + .../geometryMotion/geometryMotions.hpp | 4 + .../geometryMotionsInstantiate.cpp | 5 +- .../sphereInteraction/sphereInteractions.cpp | 57 ++++- src/MotionModel/CMakeLists.txt | 4 +- .../multiRotatingAxis/multiRotatingAxis.cpp | 99 ++++++++ .../multiRotatingAxis/multiRotatingAxis.hpp | 180 +++++++++++++ .../entities/rotatingAxis/rotatingAxis.hpp | 6 + src/MotionModel/fixedWall/fixedWall.hpp | 2 +- .../multiRotatingAxisMotion.cpp | 238 ++++++++++++++++++ .../multiRotatingAxisMotion.hpp | 215 ++++++++++++++++ .../rotatingAxisMotion/rotatingAxisMotion.hpp | 2 +- .../vibratingMotion/vibratingMotion.hpp | 2 +- 13 files changed, 809 insertions(+), 8 deletions(-) create mode 100644 src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.cpp create mode 100644 src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.hpp create mode 100644 src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.cpp create mode 100644 src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.hpp diff --git a/src/Geometry/geometryMotion/geometryMotion.cpp b/src/Geometry/geometryMotion/geometryMotion.cpp index b3c00ed0..60401f91 100644 --- a/src/Geometry/geometryMotion/geometryMotion.cpp +++ b/src/Geometry/geometryMotion/geometryMotion.cpp @@ -41,6 +41,9 @@ bool pFlow::geometryMotion::moveGeometry() Kokkos::fence(); + // move the motion components + motionModel_.move(t,dt); + // end of calculations moveGeomTimer_.end(); diff --git a/src/Geometry/geometryMotion/geometryMotions.hpp b/src/Geometry/geometryMotion/geometryMotions.hpp index b701ef5e..cd636ae6 100644 --- a/src/Geometry/geometryMotion/geometryMotions.hpp +++ b/src/Geometry/geometryMotion/geometryMotions.hpp @@ -24,6 +24,7 @@ Licence: #include "geometryMotion.hpp" #include "fixedWall.hpp" #include "rotatingAxisMotion.hpp" +#include "multiRotatingAxisMotion.hpp" #include "vibratingMotion.hpp" @@ -34,9 +35,12 @@ typedef geometryMotion vibratingMotionGeometry; typedef geometryMotion rotationAxisMotionGeometry; +typedef geometryMotion multiRotationAxisMotionGeometry; + typedef geometryMotion fixedGeometry; + } diff --git a/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp b/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp index 2dc9bbe7..a8ec4fd9 100644 --- a/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp +++ b/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp @@ -20,12 +20,13 @@ Licence: #include "fixedWall.hpp" #include "rotatingAxisMotion.hpp" +#include "multiRotatingAxisMotion.hpp" #include "vibratingMotion.hpp" template class pFlow::geometryMotion; template class pFlow::geometryMotion; +template class pFlow::geometryMotion; + template class pFlow::geometryMotion; - - diff --git a/src/Interaction/sphereInteraction/sphereInteractions.cpp b/src/Interaction/sphereInteraction/sphereInteractions.cpp index df9c2e2c..569fa7ad 100644 --- a/src/Interaction/sphereInteraction/sphereInteractions.cpp +++ b/src/Interaction/sphereInteraction/sphereInteractions.cpp @@ -88,6 +88,25 @@ template class pFlow::sphereInteraction< pFlow::sortedContactList>; +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedLinearNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedLinearNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::sortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedLinearNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedLinearNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::sortedContactList>; /// non-linear models @@ -152,6 +171,25 @@ template class pFlow::sphereInteraction< pFlow::vibratingMotionGeometry, pFlow::sortedContactList>; +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedNonLinearNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedNonLinearNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::sortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedNonLinearNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedNonLinearNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::sortedContactList>; // - nonLinearMod models @@ -217,5 +255,22 @@ template class pFlow::sphereInteraction< pFlow::sortedContactList>; - +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedNonLinearModNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::unsortedContactList>; +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedNonLinearModNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::sortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedNonLinearModNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedNonLinearModNormalRolling, + pFlow::multiRotationAxisMotionGeometry, + pFlow::sortedContactList>; diff --git a/src/MotionModel/CMakeLists.txt b/src/MotionModel/CMakeLists.txt index bebc1f7a..9438c2ab 100644 --- a/src/MotionModel/CMakeLists.txt +++ b/src/MotionModel/CMakeLists.txt @@ -1,10 +1,12 @@ list(APPEND SourceFiles entities/rotatingAxis/rotatingAxis.cpp +entities/multiRotatingAxis/multiRotatingAxis.cpp entities/timeInterval/timeInterval.cpp entities/vibrating/vibrating.cpp fixedWall/fixedWall.cpp rotatingAxisMotion/rotatingAxisMotion.cpp +multiRotatingAxisMotion/multiRotatingAxisMotion.cpp vibratingMotion/vibratingMotion.cpp ) @@ -12,5 +14,3 @@ set(link_libs Kokkos::kokkos phasicFlow) pFlow_add_library_install(MotionModel SourceFiles link_libs) - - diff --git a/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.cpp b/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.cpp new file mode 100644 index 00000000..62733216 --- /dev/null +++ b/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.cpp @@ -0,0 +1,99 @@ +/*------------------------------- 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 "multiRotatingAxis.hpp" +#include "multiRotatingAxisMotion.hpp" +#include "dictionary.hpp" + +FUNCTION_H +pFlow::multiRotatingAxis::multiRotatingAxis +( + multiRotatingAxisMotion* axisMotion +) +{ + //axisList_ = axisMotion->getAxisListPtr(); +} + +FUNCTION_H +pFlow::multiRotatingAxis::multiRotatingAxis +( + multiRotatingAxisMotion* axisMotion, + const dictionary& dict +) +{ + + if(!read(axisMotion, dict)) + { + fatalErrorInFunction<< + " error in reading rotatingAxis from dictionary "<< dict.globalName()<getAxisListPtr(); +} + + + +FUNCTION_H +bool pFlow::multiRotatingAxis::read +( + multiRotatingAxisMotion* axisMotion, + const dictionary& dict +) +{ + + if(!rotatingAxis::read(dict))return false; + + word rotAxis = dict.getValOrSet("rotationAxis", "none"); + + if(rotAxis == "none") + { + parentAxisIndex_ = -1; + } + else + { + parentAxisIndex_ = axisMotion-> nameToIndex(rotAxis); + } + + return true; +} + +FUNCTION_H +bool pFlow::multiRotatingAxis::write +( + const multiRotatingAxisMotion* axisMotion, + dictionary& dict +) const +{ + if( !rotatingAxis::write(dict) ) return false; + + if(parentAxisIndex_ == -1) + { + dict.add("rotationAxis", "none"); + } + else + { + auto rotAxis = axisMotion->indexToName(parentAxisIndex_); + dict.add("rotationAxis", rotAxis); + } + + return true; +} + diff --git a/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.hpp b/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.hpp new file mode 100644 index 00000000..ded4f975 --- /dev/null +++ b/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.hpp @@ -0,0 +1,180 @@ +/*------------------------------- 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 __multiRotatingAxis_hpp__ +#define __multiRotatingAxis_hpp__ + + +#include "rotatingAxis.hpp" +#include "KokkosTypes.hpp" + + +namespace pFlow +{ + +class dictionary; +class multiRotatingAxisMotion; + + +class multiRotatingAxis +: + public rotatingAxis +{ +protected: + + // this is either host/device pointer + multiRotatingAxis* axisList_; + + int32 parentAxisIndex_ = -1; + +public: + + INLINE_FUNCTION_HD + multiRotatingAxis(){} + + FUNCTION_H + multiRotatingAxis(multiRotatingAxisMotion* axisMotion); + + FUNCTION_H + multiRotatingAxis(multiRotatingAxisMotion* axisMotion, const dictionary& dict); + + /*FUNCTION_HD + multiRotatingAxis(const realx3& p1, const realx3& p2, real omega = 0.0);*/ + + FUNCTION_HD + multiRotatingAxis(const multiRotatingAxis&) = default; + + FUNCTION_HD + multiRotatingAxis& operator=(const multiRotatingAxis&) = default; + + INLINE_FUNCTION_HD + realx3 pointTangentialVel(const realx3& p)const + { + realx3 parentVel(0); + auto parIndex = parentAxisIndex(); + + while(parIndex != -1) + { + auto& ax = axisList_[parIndex]; + parentVel += ax.linTangentialVelocityPoint(p); + parIndex = ax.parentAxisIndex(); + } + + return parentVel + rotatingAxis::linTangentialVelocityPoint(p); + } + + + + INLINE_FUNCTION_HD + realx3 transferPoint(const realx3& p, real dt)const + { + auto newP = p; + + // rotation around this axis + if(isRotating()) + { + newP = pFlow::rotate(p, *this, dt); + } + + auto parIndex = parentAxisIndex_; + while(parIndex != -1) + { + auto& ax = axisList_[parIndex]; + newP = pFlow::rotate(newP, ax, dt); + parIndex = ax.parentAxisIndex(); + } + + return newP; + } + + INLINE_FUNCTION_HD + bool hasParrent()const + { + return parentAxisIndex_ > -1; + } + + INLINE_FUNCTION_HD + int32 parentAxisIndex()const + { + return parentAxisIndex_; + } + + // this pointer is device pointer + INLINE_FUNCTION_H + void setAxisList(multiRotatingAxis* axisList) + { + axisList_ = axisList; + } + // it is assumed that the axis with deepest level + // (with more parrents) is moved first and then + // the axis with lower levels + void move(real dt) + { + + if( !hasParrent() ) return; + + auto lp1 = point1(); + auto lp2 = point2(); + + lp1 = axisList_[parentAxisIndex()].transferPoint(lp1, dt); + lp2 = axisList_[parentAxisIndex()].transferPoint(lp2, dt); + + set(lp1, lp2); + } + + + + // - IO operation + FUNCTION_H + bool read(multiRotatingAxisMotion* axisMotion, const dictionary& dict); + + FUNCTION_H + bool write(const multiRotatingAxisMotion* axisMotion, dictionary& dict) const; + + /*FUNCTION_H + bool read(iIstream& is); + + FUNCTION_H + bool write(iOstream& os)const;*/ + +}; + +/*inline iOstream& operator <<(iOstream& os, const multiRotatingAxis& ax) +{ + if(!ax.write(os)) + { + fatalExit; + } + return os; +} + +inline iIstream& operator >>(iIstream& is, multiRotatingAxis& ax) +{ + if( !ax.read(is) ) + { + fatalExit; + } + return is; +}*/ + +} + + +#endif diff --git a/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp b/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp index c506146f..07e8de5d 100644 --- a/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp +++ b/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp @@ -70,6 +70,12 @@ public: return omega_; } + INLINE_FUNCTION_HD + bool isRotating()const + { + return rotating_; + } + INLINE_FUNCTION_HD realx3 linTangentialVelocityPoint(const realx3 &p)const; diff --git a/src/MotionModel/fixedWall/fixedWall.hpp b/src/MotionModel/fixedWall/fixedWall.hpp index 4ddcc47b..68c246e5 100644 --- a/src/MotionModel/fixedWall/fixedWall.hpp +++ b/src/MotionModel/fixedWall/fixedWall.hpp @@ -151,7 +151,7 @@ public: return false; } - bool move(real dt) + bool move(real t, real dt) { return true; } diff --git a/src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.cpp b/src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.cpp new file mode 100644 index 00000000..360f1ee0 --- /dev/null +++ b/src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.cpp @@ -0,0 +1,238 @@ +/*------------------------------- 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 "multiRotatingAxisMotion.hpp" +#include "dictionary.hpp" +#include "vocabs.hpp" + + +bool pFlow::multiRotatingAxisMotion::readDictionary +( + const dictionary& dict +) +{ + + auto motionModel = dict.getVal("motionModel"); + + if(motionModel != "multiRotatingAxisMotion") + { + fatalErrorInFunction<< + " motionModel should be multiRotatingAxisMotion, but found " + << motionModel <(axDict); axPtr) + { + rotationAxis.push_back( + axDict.getValOrSet("rotationAxis", "none")); + } + else + { + fatalErrorInFunction<< + "could not read rotating axis from "<< axDict.globalName()<; + + std::vector numRotAxis; + + for(size_t i=0; i< axisNames.size(); i++) + { + word rotAxis = rotationAxis[i]; + int32 n=0; + while(rotAxis != "none") + { + n++; + if(int32 iAxis = axisNames.findi(rotAxis) ; iAxis != -1) + { + rotAxis = rotationAxis[iAxis]; + }else + { + fatalErrorInFunction<< + "rotation axis name "<< rotAxis << "is does not exist!"< b.first; }; + + algorithms::STD::sort(numRotAxis.data(), numRotAxis.size(), compareFunc); + + sortedIndex_.clear(); + axisName_.clear(); + + + for(auto ax:numRotAxis) + { + axisName_.push_back(axisNames[ax.second]); + sortedIndex_.push_back(ax.second); + } + + numAxis_ = axisName_.size(); + axis_.clear(); + axis_.reserve(numAxis_); + + + // create the actual axis vector + for(auto& aName: axisName_) + { + if(aName != "none") + { + auto& axDict = motionInfo.subDict(aName); + axis_.push_back( + multiRotatingAxis(this, axDict)); + } + else + { + axis_.push_back( + multiRotatingAxis(this)); + } + + } + + return true; +} + +bool pFlow::multiRotatingAxisMotion::writeDictionary +( + dictionary& dict +)const +{ + dict.add("motionModel", "multiRotatingAxisMotion"); + + auto& motionInfo = dict.subDictOrCreate("multiRotatingAxisMotionInfo"); + + ForAll(i, axis_) + { + + auto& axDict = motionInfo.subDictOrCreate(axisName_[i]); + if( !axis_.hostVectorAll()[i].write(this,axDict)) + { + fatalErrorInFunction<< + " error in writing axis "<< axisName_[i] << " to dicrionary " + << motionInfo.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].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; + + axisVector_HD axis_; + + VectorDual sortedIndex_; + + wordList axisName_; + + label numAxis_= 0; + + + + bool readDictionary(const dictionary& dict); + + bool writeDictionary(dictionary& dict)const; + +public: + + TypeInfoNV("multiRotatingAxisMotion"); + + // empty + FUNCTION_H + multiRotatingAxisMotion(); + + // construct with dictionary + FUNCTION_H + multiRotatingAxisMotion(const dictionary& dict); + + // copy + FUNCTION_H + multiRotatingAxisMotion(const multiRotatingAxisMotion&) = default; + + multiRotatingAxisMotion(multiRotatingAxisMotion&&) = delete; + + FUNCTION_H + multiRotatingAxisMotion& operator=(const multiRotatingAxisMotion&) = default; + + multiRotatingAxisMotion& operator=(multiRotatingAxisMotion&&) = delete; + + FUNCTION_H + ~multiRotatingAxisMotion() = default; + + + Model getModel(real t) + { + for(int32 i= 0; i