From 9105a503ce8c8be16cac3e51af93cf1bf29f0b63 Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Sun, 2 Apr 2023 09:17:16 -0700 Subject: [PATCH] motion model docs are added --- doc/Doxyfile | 2 +- .../multiRotatingAxis/multiRotatingAxis.hpp | 266 ++++++++++-------- .../entities/rotatingAxis/rotatingAxis.hpp | 8 +- .../entities/vibrating/vibrating.hpp | 31 +- src/MotionModel/fixedWall/fixedWall.hpp | 148 ++++++---- .../multiRotatingAxisMotion.hpp | 215 ++++++++------ .../rotatingAxisMotion/rotatingAxisMotion.hpp | 208 ++++++++------ .../vibratingMotion/vibratingMotion.hpp | 65 ++++- 8 files changed, 579 insertions(+), 364 deletions(-) diff --git a/doc/Doxyfile b/doc/Doxyfile index 92592451..b3f44e72 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1554,7 +1554,7 @@ FORMULA_MACROFILE = # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -USE_MATHJAX = NO +USE_MATHJAX = YES # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: diff --git a/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.hpp b/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.hpp index ded4f975..2f2d81de 100644 --- a/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.hpp +++ b/src/MotionModel/entities/multiRotatingAxis/multiRotatingAxis.hpp @@ -32,147 +32,183 @@ namespace pFlow class dictionary; class multiRotatingAxisMotion; +/** + * Defines an axis of rotation that rotates around itself and rotates around + * another axis. + * + * This axis rotates around itself and can have one axis of rotation, and that + * axis of rotation can have another axis of rotatoin and so on. + * + * + \verbatim + // This creates an axis around x-axis. This axis rotates round itself at + // 1.57 rad/s and at the same time rotates around rotating axis axisName. + // axisName is separatly defined in the same dictionray. + axis1 + { + p1 (0 0 0); + p2 (1 0 0); + omega 1.57; + rotationAxis axisName; + startTime 1; + endTime 5; + } + axisName + { + p1 (0 0 0); + p2 (0 1 1); + omega 3.14; + } \endverbatim + * + * + * | Parameter | Type | Description | Optional [default value] | + * |----| :---: | ---- | :---: | + * | p1 | realx3 | begin point of axis | No | + * | p2 | realx3 | end point of axis | No | + * | omega | real | rotation speed (rad/s) | No | + * | rotationAxis | word | the axis rotates around this axis | Yes [none] | + * | startTime | real | start time of rotation (s) | Yes [0] | + * | endTime | real | end time of rotation (s) | Yes [infinity] | + * + */ class multiRotatingAxis : public rotatingAxis { protected: - // this is either host/device pointer - multiRotatingAxis* axisList_; + /// This is either host/device pointer to all axes + multiRotatingAxis* axisList_; - int32 parentAxisIndex_ = -1; + /// Index of parent axis + int32 parentAxisIndex_ = -1; public: - INLINE_FUNCTION_HD - multiRotatingAxis(){} + // - Constructors - FUNCTION_H - multiRotatingAxis(multiRotatingAxisMotion* axisMotion); + /// Empty Constructor + INLINE_FUNCTION_HD + multiRotatingAxis(){} - 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; + /// Empty with list of axes + FUNCTION_H + multiRotatingAxis(multiRotatingAxisMotion* axisMotion); - 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) - { + /// Construct from dictionary and list of axes + FUNCTION_H + multiRotatingAxis(multiRotatingAxisMotion* axisMotion, const dictionary& dict); - if( !hasParrent() ) return; - - auto lp1 = point1(); - auto lp2 = point2(); + /// Copy constructor + FUNCTION_HD + multiRotatingAxis(const multiRotatingAxis&) = default; - lp1 = axisList_[parentAxisIndex()].transferPoint(lp1, dt); - lp2 = axisList_[parentAxisIndex()].transferPoint(lp2, dt); + /// Copy assignment + FUNCTION_HD + multiRotatingAxis& operator=(const multiRotatingAxis&) = default; - set(lp1, lp2); - } + /// Destructor + ~multiRotatingAxis() = default; + /// - Methods + + /// Tangential velocity at point p + 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); + } + + /// Translate point p for dt seconds based on the axis information + 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; + } + + /// Does this axis have a parent + INLINE_FUNCTION_HD + bool hasParent()const + { + return parentAxisIndex_ > -1; + } + + /// Return the index of parent axis + INLINE_FUNCTION_HD + int32 parentAxisIndex()const + { + return parentAxisIndex_; + } + + /// Set the pointer to the list of all axes. + /// This pointer is device pointer + INLINE_FUNCTION_H + void setAxisList(multiRotatingAxis* axisList) + { + axisList_ = axisList; + } + + /** + * Move the end points of the axis + * + * This function moves the end points of this axis, if it has any parrents. + * 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( !hasParent() ) 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; + /// Read from dictionary + FUNCTION_H + bool read(multiRotatingAxisMotion* axisMotion, const dictionary& dict); - /*FUNCTION_H - bool read(iIstream& is); - - FUNCTION_H - bool write(iOstream& os)const;*/ + /// Write to dictionary + FUNCTION_H + bool write(const multiRotatingAxisMotion* axisMotion, dictionary& dict) 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; -}*/ } diff --git a/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp b/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp index 0fa38bc7..ee37eba9 100644 --- a/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp +++ b/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp @@ -50,13 +50,13 @@ class rotatingAxis; endTime 5; } \endverbatim * - * | parameter | value type | discription | optional (default) | - * |----| ---- | ---- | ---- | + * | Parameter | Type | Description | Optional [default value] | + * |----| :---: | ---- | ---- | * | p1 | realx3 | begin point of axis | No | * | p2 | realx3 | end point of axis | No | * | omega | real | rotation speed (rad/s) | No | - * | startTime | real | start time of rotation (s) | Yes (0) | - * | endTime | real | end time of rotation (s) | Yes (infinity) | + * | startTime | real | start time of rotation (s) | Yes [0] | + * | endTime | real | end time of rotation (s) | Yes [infinity] | * */ class rotatingAxis diff --git a/src/MotionModel/entities/vibrating/vibrating.hpp b/src/MotionModel/entities/vibrating/vibrating.hpp index 5e41e195..4ece54a2 100644 --- a/src/MotionModel/entities/vibrating/vibrating.hpp +++ b/src/MotionModel/entities/vibrating/vibrating.hpp @@ -29,10 +29,39 @@ Licence: namespace pFlow { +// forward class dictionary; -class vibrating; +/** + * Vibrating model for a wall + * + * Creates a sinoidal virating model for a wall. The viration is defined by + * frequency, amplitude and phase angle. + * \f[ + \vec{v}(t) = \vec{A} sin(\vec{\omega}(t-startTime)+\vec{\phi}) + \f] + \verbatim + // This creates sinoidal vibration on the wall in x-direction. The viration + // starts at t = 0 s and ends at t = 10 s. + { + angularFreq (10 0 0); + amplitude ( 1 0 0); + phaseAngle ( 0 0 0); + startTime 0; + endTime 10; + } \endverbatim + * + * * + * | Parameter | Type | Description | Optional [default value] | + * |----| :---: | ---- | :---: | + * | angularFreq | realx3 | angular frequency of vibration (rad/s) | No | + * | amplitude | realx3 | rotation speed (m/s) | No | + * | phaseAngle | realx3 | phase angle (rad) | Yes [(0 0 0)] | + * | startTime | real | start time of rotation (s) | Yes [0] | + * | endTime | real | end time of rotation (s) | Yes [infinity] | + * + */ class vibrating : public timeInterval diff --git a/src/MotionModel/fixedWall/fixedWall.hpp b/src/MotionModel/fixedWall/fixedWall.hpp index 68c246e5..5c8b4760 100644 --- a/src/MotionModel/fixedWall/fixedWall.hpp +++ b/src/MotionModel/fixedWall/fixedWall.hpp @@ -34,12 +34,26 @@ namespace pFlow class dictionary; +/** + * Fixed wall motion model for walls + * + * This class is used for geometries that are fixed during simulation. + * + * +\verbatim +// In geometryDict file, this will defines fixed walls during simulation +... +motionModel fixedWall; +... +\endverbatim + */ class fixedWall { public: - // - this class shuold be decleared in every motion model with - // exact methods + /** Motion model class to be passed to computational units/kernels for + * transfing points and returning velocities at various positions + */ class Model { @@ -80,89 +94,111 @@ public: }; protected: - + + /// Name const word name_ = "none"; + + /// Read from a dictionary bool readDictionary(const dictionary& dict); + /// write to a dictionary bool writeDictionary(dictionary& dict)const; public: + /// Type info TypeInfoNV("fixedWall"); - // empty - fixedWall(); + // - Constructors - // construct with dictionary - fixedWall(const dictionary& dict); + /// Empty + fixedWall(); - fixedWall(const fixedWall&) = default; + /// Constructor with dictionary + fixedWall(const dictionary& dict); - fixedWall(fixedWall&&) = default; + /// Copy constructor + fixedWall(const fixedWall&) = default; - fixedWall& operator=(const fixedWall&) = default; + /// Move constructor + fixedWall(fixedWall&&) = default; - fixedWall& operator=(fixedWall&&) = default; + /// Copy assignment + fixedWall& operator=(const fixedWall&) = default; - ~fixedWall() = default; + /// Move assignment + fixedWall& operator=(fixedWall&&) = default; - Model getModel(real t)const - { - return Model(); - } + /// Destructor + ~fixedWall() = default; - int32 nameToIndex(const word& name)const - { - return 0; - } + // - Methods - word indexToName(label i)const - { - return name_; - } + /// Return motion model + /// t is the current simulation time + Model getModel(real t)const + { + return Model(); + } - - INLINE_FUNCTION_HD - realx3 pointVelocity(label n, const realx3& p)const - { - return zero3; - } + /// Name of the motion component to index + int32 nameToIndex(const word& name)const + { + return 0; + } - + /// Index of motion component to name + word indexToName(label i)const + { + return name_; + } - INLINE_FUNCTION_HD - realx3 transferPoint(label n, const realx3 p, real dt)const - { - return p; - } + /// Velocity at point p + INLINE_FUNCTION_HD + realx3 pointVelocity(label n, const realx3& p)const + { + return zero3; + } - + + /// Transfer point p for dt seconds according to motion component n + INLINE_FUNCTION_HD + realx3 transferPoint(label n, const realx3 p, real dt)const + { + return p; + } - INLINE_FUNCTION_HD - bool transferPoint(label n, realx3* pVec, size_t numP, real dt) - { - return true; - } + /// Transfer a vector of point pVec for dt seconds according to motion + /// component n + INLINE_FUNCTION_HD + bool transferPoint(label n, realx3* pVec, size_t numP, real dt) + { + return true; + } - INLINE_FUNCTION_HD - bool isMoving()const - { - return false; - } + /// Are walls moving + INLINE_FUNCTION_HD + bool isMoving()const + { + return false; + } - bool move(real t, real dt) - { - return true; - } + /// Move points + bool move(real t, real dt) + { + return true; + } - FUNCTION_H - bool read(iIstream& is); + // - IO operations - FUNCTION_H - bool write(iOstream& os)const; + /// Read from input stream is + FUNCTION_H + bool read(iIstream& is); - + /// Write to output stream os + FUNCTION_H + bool write(iOstream& os)const; }; } // pFlow diff --git a/src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.hpp b/src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.hpp index 4f79e2d2..246430af 100644 --- a/src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.hpp +++ b/src/MotionModel/multiRotatingAxisMotion/multiRotatingAxisMotion.hpp @@ -32,14 +32,43 @@ Licence: namespace pFlow { +// forward class dictionary; +/** + * 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: - // - this class shuold be decleared in every motion model with - // exact methods + /** Motion model class to be passed to computational units/kernels for + * transfing points and returning velocities at various positions + */ class Model { protected: @@ -91,121 +120,141 @@ protected: using axisVector_HD = VectorDual; + /// Vector of multiRotaingAxis axes axisVector_HD axis_; + /// Sorted index based on number of parrents each axis ha VectorDual sortedIndex_; + /// List of axes names wordList axisName_; + /// Number of axes label numAxis_= 0; - - + /// Read from a dictionary bool readDictionary(const dictionary& dict); + /// Write to a dictionary bool writeDictionary(dictionary& dict)const; public: + /// Type info TypeInfoNV("multiRotatingAxisMotion"); - // empty - FUNCTION_H - multiRotatingAxisMotion(); + // - Constructor - // construct with dictionary - FUNCTION_H - multiRotatingAxisMotion(const dictionary& dict); + /// Empty constructor + FUNCTION_H + multiRotatingAxisMotion(); - // copy - FUNCTION_H - multiRotatingAxisMotion(const multiRotatingAxisMotion&) = default; + /// Construct with dictionary + FUNCTION_H + multiRotatingAxisMotion(const dictionary& dict); - multiRotatingAxisMotion(multiRotatingAxisMotion&&) = delete; + /// Copy constructor + FUNCTION_H + multiRotatingAxisMotion(const multiRotatingAxisMotion&) = default; - FUNCTION_H - multiRotatingAxisMotion& operator=(const multiRotatingAxisMotion&) = default; + /// No Move + multiRotatingAxisMotion(multiRotatingAxisMotion&&) = delete; - multiRotatingAxisMotion& operator=(multiRotatingAxisMotion&&) = delete; + /// Copy assignment + FUNCTION_H + multiRotatingAxisMotion& operator=(const multiRotatingAxisMotion&) = default; - FUNCTION_H - ~multiRotatingAxisMotion() = default; + /// No move assignment + multiRotatingAxisMotion& operator=(multiRotatingAxisMotion&&) = delete; + /// Destructor + FUNCTION_H + ~multiRotatingAxisMotion() = default; - Model getModel(real t) - { - for(int32 i= 0; i; + /// 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"); - // empty - FUNCTION_H - rotatingAxisMotion(); + // - Constructors + + /// Empty + FUNCTION_H + rotatingAxisMotion(); - // construct with dictionary - FUNCTION_H - rotatingAxisMotion(const dictionary& dict); + /// Construct with dictionary + FUNCTION_H + rotatingAxisMotion(const dictionary& dict); - // copy - FUNCTION_H - rotatingAxisMotion(const rotatingAxisMotion&) = default; + /// Copy constructor + FUNCTION_H + rotatingAxisMotion(const rotatingAxisMotion&) = default; - rotatingAxisMotion(rotatingAxisMotion&&) = delete; + /// No move constructor + rotatingAxisMotion(rotatingAxisMotion&&) = delete; - FUNCTION_H - rotatingAxisMotion& operator=(const rotatingAxisMotion&) = default; + /// Copy assignment + FUNCTION_H + rotatingAxisMotion& operator=(const rotatingAxisMotion&) = default; - rotatingAxisMotion& operator=(rotatingAxisMotion&&) = delete; + /// No move assignment + rotatingAxisMotion& operator=(rotatingAxisMotion&&) = delete; - FUNCTION_H - ~rotatingAxisMotion() = default; + /// Destructor + FUNCTION_H + ~rotatingAxisMotion() = default; - - Model getModel(real t) - { - for(int32 i= 0; i=numAxis_)return false; - - rotate( pVec, numP, axis_.deviceVectorAll()[n], dt); - - return true; - }*/ - - 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 diff --git a/src/MotionModel/vibratingMotion/vibratingMotion.hpp b/src/MotionModel/vibratingMotion/vibratingMotion.hpp index 3880075e..4392ed09 100644 --- a/src/MotionModel/vibratingMotion/vibratingMotion.hpp +++ b/src/MotionModel/vibratingMotion/vibratingMotion.hpp @@ -34,14 +34,44 @@ Licence: namespace pFlow { +// forward class dictionary; +/** + * Vibrating motion model for walls + * + * This class is used for simulaiton that at least one wall components + * are moving according to a sinoidal viration defined in class vibrating. + * One or more than one motion components can be defined in + * vibratingMotionInfo dictionary + * +\verbatim +// In geometryDict file, this will defines vibrating walls during simulation +... +motionModel vibratingMotion; + +vibratingMotionInfo +{ + vibComponent1 + { + // the definition based on class vibrating + } + vibComponent2 + { + // the definition based on calss vibrating + } +} +... +\endverbatim + * + */ class vibratingMotion { public: - // - this class shuold be decleared in every motion model with - // exact methods + /** Motion model class to be passed to computational units/kernels for + * transfing points and returning velocities at various positions + */ class Model { protected: @@ -93,43 +123,53 @@ 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 + /// Empty FUNCTION_H vibratingMotion(); - // construct with dictionary + /// Construct with dictionary FUNCTION_H vibratingMotion(const dictionary& dict); - // copy + /// 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