From 0d45a2b8a54972b69716904e74f900d2a36cdda1 Mon Sep 17 00:00:00 2001 From: hamidrezanorouzi Date: Tue, 3 Jan 2023 19:31:12 +0330 Subject: [PATCH] vibrating wall added, tested; time interval for wall motion added, tested --- .../geometryMotion/geometryMotion.cpp | 3 +- .../geometryMotion/geometryMotion.hpp | 4 +- .../geometryMotion/geometryMotions.hpp | 3 + .../geometryMotionsInstantiate.cpp | 3 + .../sphereInteraction/sphereInteraction.cpp | 8 +- .../sphereInteraction/sphereInteractions.cpp | 66 +++++- src/MotionModel/CMakeLists.txt | 3 + .../entities/rotatingAxis/rotatingAxis.cpp | 14 +- .../entities/rotatingAxis/rotatingAxis.hpp | 2 + .../entities/rotatingAxis/rotatingAxisI.hpp | 9 +- .../entities/timeInterval/timeInterval.cpp | 84 +++++++ .../entities/timeInterval/timeInterval.hpp | 116 ++++++++++ .../entities/vibrating/vibrating.cpp | 102 +++++++++ .../entities/vibrating/vibrating.hpp | 137 +++++++++++ src/MotionModel/fixedWall/fixedWall.hpp | 2 +- .../rotatingAxisMotion/rotatingAxisMotion.hpp | 17 +- .../vibratingMotion/vibratingMotion.cpp | 167 ++++++++++++++ .../vibratingMotion/vibratingMotion.hpp | 216 ++++++++++++++++++ src/demComponent/demComponent.hpp | 7 + 19 files changed, 941 insertions(+), 22 deletions(-) create mode 100644 src/MotionModel/entities/timeInterval/timeInterval.cpp create mode 100644 src/MotionModel/entities/timeInterval/timeInterval.hpp create mode 100644 src/MotionModel/entities/vibrating/vibrating.cpp create mode 100644 src/MotionModel/entities/vibrating/vibrating.hpp create mode 100644 src/MotionModel/vibratingMotion/vibratingMotion.cpp create mode 100644 src/MotionModel/vibratingMotion/vibratingMotion.hpp diff --git a/src/Geometry/geometryMotion/geometryMotion.cpp b/src/Geometry/geometryMotion/geometryMotion.cpp index 20fd0cd7..b3c00ed0 100644 --- a/src/Geometry/geometryMotion/geometryMotion.cpp +++ b/src/Geometry/geometryMotion/geometryMotion.cpp @@ -23,9 +23,10 @@ bool pFlow::geometryMotion::moveGeometry() { real dt = this->dt(); + real t = this->currentTime(); auto pointMIndex= pointMotionIndex_.deviceVector(); - auto mModel = motionModel_.getModel(); + auto mModel = motionModel_.getModel(t); realx3* points = triSurface_.pointsData_D(); auto numPoints = triSurface_.numPoints(); diff --git a/src/Geometry/geometryMotion/geometryMotion.hpp b/src/Geometry/geometryMotion/geometryMotion.hpp index d162e78e..2175fca8 100644 --- a/src/Geometry/geometryMotion/geometryMotion.hpp +++ b/src/Geometry/geometryMotion/geometryMotion.hpp @@ -104,9 +104,9 @@ public: //// - Methods - auto getModel()const + auto getModel(real t)const { - return motionModel_.getModel(); + return motionModel_.getModel(t); } word motionModelTypeName()const override diff --git a/src/Geometry/geometryMotion/geometryMotions.hpp b/src/Geometry/geometryMotion/geometryMotions.hpp index 496e2dd0..b701ef5e 100644 --- a/src/Geometry/geometryMotion/geometryMotions.hpp +++ b/src/Geometry/geometryMotion/geometryMotions.hpp @@ -24,11 +24,14 @@ Licence: #include "geometryMotion.hpp" #include "fixedWall.hpp" #include "rotatingAxisMotion.hpp" +#include "vibratingMotion.hpp" namespace pFlow { +typedef geometryMotion vibratingMotionGeometry; + typedef geometryMotion rotationAxisMotionGeometry; typedef geometryMotion fixedGeometry; diff --git a/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp b/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp index 9d980f69..2dc9bbe7 100644 --- a/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp +++ b/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp @@ -20,9 +20,12 @@ Licence: #include "fixedWall.hpp" #include "rotatingAxisMotion.hpp" +#include "vibratingMotion.hpp" template class pFlow::geometryMotion; template class pFlow::geometryMotion; +template class pFlow::geometryMotion; + diff --git a/src/Interaction/sphereInteraction/sphereInteraction.cpp b/src/Interaction/sphereInteraction/sphereInteraction.cpp index 9426041b..0dacee74 100644 --- a/src/Interaction/sphereInteraction/sphereInteraction.cpp +++ b/src/Interaction/sphereInteraction/sphereInteraction.cpp @@ -55,7 +55,8 @@ template< bool pFlow::sphereInteraction:: sphereSphereInteraction() { - + + auto lastItem = ppContactList_().loopCount(); @@ -95,14 +96,15 @@ bool pFlow::sphereInteractioncurrentTime(); + pFlow::sphereInteractionKernels::pwInteractionFunctor pwInteraction( this->dt(), this->forceModel_(), pwContactList_(), geometryMotion_.getTriangleAccessor(), - geometryMotion_.getModel() , + geometryMotion_.getModel(t) , sphParticles_.diameter().deviceVectorAll() , sphParticles_.propertyId().deviceVectorAll(), sphParticles_.pointPosition().deviceVectorAll(), diff --git a/src/Interaction/sphereInteraction/sphereInteractions.cpp b/src/Interaction/sphereInteraction/sphereInteractions.cpp index d8fbbebd..df9c2e2c 100644 --- a/src/Interaction/sphereInteraction/sphereInteractions.cpp +++ b/src/Interaction/sphereInteraction/sphereInteractions.cpp @@ -67,6 +67,27 @@ template class pFlow::sphereInteraction< pFlow::sortedContactList>; +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedLinearNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedLinearNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::sortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedLinearNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedLinearNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::sortedContactList>; + + /// non-linear models @@ -111,8 +132,30 @@ template class pFlow::sphereInteraction< pFlow::sortedContactList>; +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedNonLinearNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedNonLinearNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::sortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedNonLinearNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedNonLinearNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::sortedContactList>; + + + // - nonLinearMod models - template class pFlow::sphereInteraction< +template class pFlow::sphereInteraction< pFlow::cfModels::limitedNonLinearModNormalRolling, pFlow::fixedGeometry, pFlow::unsortedContactList>; @@ -153,5 +196,26 @@ template class pFlow::sphereInteraction< pFlow::sortedContactList>; +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedNonLinearModNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::limitedNonLinearModNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::sortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedNonLinearModNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::unsortedContactList>; + +template class pFlow::sphereInteraction< + pFlow::cfModels::nonLimitedNonLinearModNormalRolling, + pFlow::vibratingMotionGeometry, + pFlow::sortedContactList>; + + diff --git a/src/MotionModel/CMakeLists.txt b/src/MotionModel/CMakeLists.txt index 83eb1415..bebc1f7a 100644 --- a/src/MotionModel/CMakeLists.txt +++ b/src/MotionModel/CMakeLists.txt @@ -1,8 +1,11 @@ list(APPEND SourceFiles entities/rotatingAxis/rotatingAxis.cpp +entities/timeInterval/timeInterval.cpp +entities/vibrating/vibrating.cpp fixedWall/fixedWall.cpp rotatingAxisMotion/rotatingAxisMotion.cpp +vibratingMotion/vibratingMotion.cpp ) set(link_libs Kokkos::kokkos phasicFlow) diff --git a/src/MotionModel/entities/rotatingAxis/rotatingAxis.cpp b/src/MotionModel/entities/rotatingAxis/rotatingAxis.cpp index 34fc5f6b..dbb9206e 100644 --- a/src/MotionModel/entities/rotatingAxis/rotatingAxis.cpp +++ b/src/MotionModel/entities/rotatingAxis/rotatingAxis.cpp @@ -21,13 +21,6 @@ Licence: #include "rotatingAxis.hpp" #include "dictionary.hpp" -/*FUNCTION_HD -pFlow::rotatingAxis::rotatingAxis() -: - line(), - omega_(0.0), - rotating_(false) -{}*/ FUNCTION_H pFlow::rotatingAxis::rotatingAxis @@ -52,6 +45,7 @@ pFlow::rotatingAxis::rotatingAxis real omega ) : + timeInterval(), line(p1, p2), omega_(omega), rotating_(!equal(omega,0.0)) @@ -60,7 +54,6 @@ pFlow::rotatingAxis::rotatingAxis } -//rotatingAxis(const dictionary& dict); FUNCTION_HD pFlow::real pFlow::rotatingAxis::setOmega(real omega) { @@ -76,6 +69,8 @@ bool pFlow::rotatingAxis::read const dictionary& dict ) { + + if(!timeInterval::read(dict))return false; if(!line::read(dict)) return false; real omega = dict.getValOrSet("omega", static_cast(0.0)); @@ -90,6 +85,7 @@ bool pFlow::rotatingAxis::write dictionary& dict ) const { + if( !timeInterval::write(dict) ) return false; if( !line::write(dict) ) return false; if( !dict.add("omega", omega_) ) @@ -107,6 +103,7 @@ bool pFlow::rotatingAxis::read iIstream& is ) { + if( !rotatingAxis::timeInterval::read(is)) return false; if( !rotatingAxis::line::read(is)) return false; word omegaw; @@ -137,6 +134,7 @@ bool pFlow::rotatingAxis::write iOstream& os )const { + if( !rotatingAxis::timeInterval::write(os)) return false; if( !rotatingAxis::line::write(os) ) return false; os.writeWordEntry("omega", omega()); diff --git a/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp b/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp index 833fcff7..c506146f 100644 --- a/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp +++ b/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp @@ -21,6 +21,7 @@ Licence: #ifndef __rotatingAxis_hpp__ #define __rotatingAxis_hpp__ +#include "timeInterval.hpp" #include "line.hpp" namespace pFlow @@ -33,6 +34,7 @@ class rotatingAxis; class rotatingAxis : + public timeInterval, public line { protected: diff --git a/src/MotionModel/entities/rotatingAxis/rotatingAxisI.hpp b/src/MotionModel/entities/rotatingAxis/rotatingAxisI.hpp index a46a634a..c7563020 100755 --- a/src/MotionModel/entities/rotatingAxis/rotatingAxisI.hpp +++ b/src/MotionModel/entities/rotatingAxis/rotatingAxisI.hpp @@ -21,6 +21,9 @@ Licence: INLINE_FUNCTION_HD pFlow::realx3 pFlow::rotatingAxis::linTangentialVelocityPoint(const realx3 &p)const { + + if(!inTimeRange()) return {0,0,0}; + realx3 L = p - projectPoint(p); return cross(omega_*unitVector(),L); } @@ -28,6 +31,9 @@ pFlow::realx3 pFlow::rotatingAxis::linTangentialVelocityPoint(const realx3 &p)co INLINE_FUNCTION_HD pFlow::realx3 pFlow::rotate(const realx3& p, const rotatingAxis& ax, real dt) { + + if(!ax.inTimeRange()) return p; + realx3 nv = ax.unitVector(); real cos_tet = cos(ax.omega()*dt); real sin_tet = sin(ax.omega()*dt); @@ -61,7 +67,6 @@ INLINE_FUNCTION_HD pFlow::realx3 pFlow::rotate(const realx3 &p, const line& ln, real theta) { - realx3 nv = ln.unitVector(); real cos_tet = cos(theta); real sin_tet = sin(theta); @@ -130,6 +135,8 @@ void pFlow::rotate(realx3* p, size_t n, const line& ln, real theta) INLINE_FUNCTION_HD void pFlow::rotate(realx3* p, size_t n, const rotatingAxis& ax, real dt) { + if(!ax.inTimeRange()) return; + realx3 nv = ax.unitVector(); real cos_tet = cos(ax.omega()*dt); real sin_tet = sin(ax.omega()*dt); diff --git a/src/MotionModel/entities/timeInterval/timeInterval.cpp b/src/MotionModel/entities/timeInterval/timeInterval.cpp new file mode 100644 index 00000000..6f40d9bd --- /dev/null +++ b/src/MotionModel/entities/timeInterval/timeInterval.cpp @@ -0,0 +1,84 @@ + + +#include "timeInterval.hpp" +#include "dictionary.hpp" + +FUNCTION_H +pFlow::timeInterval::timeInterval(const dictionary& dict) +{ + if(!read(dict)) + { + fatalExit; + } +} + + +FUNCTION_H +bool pFlow::timeInterval::read(const dictionary& dict) +{ + startTime_ = dict.getValOrSet("startTime", 0); + endTime_ = dict.getValOrSet("endTime", largeValue); + + return true; +} + +FUNCTION_H +bool pFlow::timeInterval::write(dictionary& dict) const +{ + if( !dict.add("startTime", startTime_) ) + { + fatalErrorInFunction<< + " error in writing startTime to dictionary "<< dict.globalName()<> key >> val; + if(key != "startTime") + { + ioErrorInFile(is.name(), is.lineNumber())<< + " expected startTime but found "<< key <> key >> val; + if(key != "endTime") + { + ioErrorInFile(is.name(), is.lineNumber())<< + " expected endTime but found "<< key <= startTime_ && t<= endTime_; + } + + INLINE_FUNCTION_HD + bool inTimeRange()const + { + return isInInterval_; + } + + // - IO operation + FUNCTION_H + bool read(const dictionary& dict); + + FUNCTION_H + bool write(dictionary& dict) const; + + FUNCTION_H + bool read(iIstream& is); + + FUNCTION_H + bool write(iOstream& os)const; +}; + + +inline iOstream& operator <<(iOstream& os, const timeInterval& obj) +{ + if(!obj.write(os)) + { + fatalExit; + } + return os; +} + +inline iIstream& operator >>(iIstream& is, timeInterval& obj) +{ + if( !obj.read(is) ) + { + fatalExit; + } + return is; +} + +} + +#endif diff --git a/src/MotionModel/entities/vibrating/vibrating.cpp b/src/MotionModel/entities/vibrating/vibrating.cpp new file mode 100644 index 00000000..008ef0a2 --- /dev/null +++ b/src/MotionModel/entities/vibrating/vibrating.cpp @@ -0,0 +1,102 @@ +/*------------------------------- 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 "vibrating.hpp" +#include "dictionary.hpp" + + +FUNCTION_H +pFlow::vibrating::vibrating(const dictionary& dict) +{ + + if(!read(dict)) + { + fatalErrorInFunction<< + " error in reading vibrating from dictionary "<< dict.globalName()<("angularFreq"); + + phaseAngle_ = dict.getValOrSet("phaseAngle", realx3(0)); + + amplitude_ = dict.getVal("amplitude"); + + return true; +} + +FUNCTION_H +bool pFlow::vibrating::write(dictionary& dict) const +{ + + if(!timeInterval::write(dict)) return false; + + if( !dict.add("angularFreq", angularFreq_) ) + { + fatalErrorInFunction<< + " error in writing angularFreq to dictionary "<< dict.globalName()<>(iIstream& is, vibrating& obj) +{ + if( !obj.read(is) ) + { + fatalExit; + } + return is; +} + +} + + +#endif diff --git a/src/MotionModel/fixedWall/fixedWall.hpp b/src/MotionModel/fixedWall/fixedWall.hpp index fddeb95d..4ddcc47b 100644 --- a/src/MotionModel/fixedWall/fixedWall.hpp +++ b/src/MotionModel/fixedWall/fixedWall.hpp @@ -107,7 +107,7 @@ public: ~fixedWall() = default; - Model getModel()const + Model getModel(real t)const { return Model(); } diff --git a/src/MotionModel/rotatingAxisMotion/rotatingAxisMotion.hpp b/src/MotionModel/rotatingAxisMotion/rotatingAxisMotion.hpp index cb478614..a8ef65d8 100644 --- a/src/MotionModel/rotatingAxisMotion/rotatingAxisMotion.hpp +++ b/src/MotionModel/rotatingAxisMotion/rotatingAxisMotion.hpp @@ -129,8 +129,15 @@ public: ~rotatingAxisMotion() = default; - Model getModel()const + Model getModel(real t) { + for(int32 i= 0; i("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; + + axisVector_HD components_; + + wordList componentName_; + + label numComponents_= 0; + + bool readDictionary(const dictionary& dict); + + bool writeDictionary(dictionary& dict)const; + +public: + + TypeInfoNV("vibratingMotion"); + + // empty + FUNCTION_H + vibratingMotion(); + + // construct with dictionary + FUNCTION_H + vibratingMotion(const dictionary& dict); + + // copy + 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