diff --git a/doc/header.html b/doc/header.html index 776a3e13..8642c69a 100644 --- a/doc/header.html +++ b/doc/header.html @@ -4,7 +4,7 @@ - + $projectname: $title diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp b/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp index 43fb9500..6e2a8892 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp @@ -28,45 +28,68 @@ Licence: namespace pFlow { - +/** + * Second order Adams-Bashforth integration method for solving ODE + * + * This is a one-step integration method and does not have prediction step. + * + */ class AdamsBashforth2 : public integration { protected: + /// dy at t-dt realx3PointField_D& dy1_; + /// Range policy for integration kernel (alias) using rpIntegration = Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule, Kokkos::IndexType >; + public: - // type info + /// Type info TypeInfo("AdamsBashforth2"); - //// - Constructors + // - Constructors + + /// Construct from components AdamsBashforth2( const word& baseName, repository& owner, const pointStructure& pStruct, const word& method); + uniquePtr clone()const override + { + return makeUnique(*this); + } + + /// Destructor virtual ~AdamsBashforth2()=default; - // - add a virtual constructor + /// Add this to the virtual constructor table add_vCtor( integration, AdamsBashforth2, word); - //// - Methods - bool predict(real UNUSED(dt), realx3Vector_D& UNUSED(y), realx3Vector_D& UNUSED(dy)) override; + // - Methods - bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + bool predict( + real UNUSED(dt), + realx3Vector_D& UNUSED(y), + realx3Vector_D& UNUSED(dy)) override; + + bool correct( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy) override; bool setInitialVals( const int32IndexContainer& newIndices, @@ -76,16 +99,21 @@ public: { return false; } + + /// Integrate on all points in the active range + bool intAll( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + range activeRng); - uniquePtr clone()const override - { - return makeUnique(*this); - } - - bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); - + /// Integrate on active points in the active range template - bool intRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP ); + bool intRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP ); }; diff --git a/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp b/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp index e120941a..040a9e40 100644 --- a/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp +++ b/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp @@ -31,26 +31,8 @@ pFlow::AdamsBashforth3::AdamsBashforth3 ) : integration(baseName, owner, pStruct, method), - /*dy1_( - owner.emplaceObject( - objectFile( - groupNames(baseName,"dy1"), - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS), - pStruct, - zero3)), - dy2_( - owner.emplaceObject( - objectFile( - groupNames(baseName,"dy2"), - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS), - pStruct, - zero3))*/ history_( - owner.emplaceObject( + owner.emplaceObject>( objectFile( groupNames(baseName,"AB3History"), "", diff --git a/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp b/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp index 11c93d5c..6bd47b11 100644 --- a/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp +++ b/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp @@ -30,10 +30,10 @@ namespace pFlow struct AB3History { + TypeInfoNV("AB3History"); + realx3 dy1_={0,0,0}; realx3 dy2_={0,0,0}; - - TypeInfoNV("AB3History"); }; @@ -65,21 +65,21 @@ iOstream& operator<<(iOstream& str, const AB3History& ab3) return str; } - +/** + * Third order Adams-Bashforth integration method for solving ODE + * + * This is a one-step integration method and does not have prediction step. + */ class AdamsBashforth3 : public integration { protected: + + /// Integration history + pointField& history_; - using HistoryFieldType = pointField; - //realx3PointField_D& dy1_; - - //realx3PointField_D& dy2_; - - // this is a device - HistoryFieldType& history_; - + /// Range policy for integration kernel using rpIntegration = Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule, @@ -91,23 +91,32 @@ public: // type info TypeInfo("AdamsBashforth3"); - //// - Constructors + // - Constructors + + /// Construct from components AdamsBashforth3( const word& baseName, repository& owner, const pointStructure& pStruct, const word& method); + + uniquePtr clone()const override + { + return makeUnique(*this); + } + /// Destructor virtual ~AdamsBashforth3()=default; - // - add a virtual constructor + /// Add this to the virtual constructor table add_vCtor( integration, AdamsBashforth3, word); - //// - Methods + // - Methods + bool predict( real UNUSED(dt), realx3Vector_D & UNUSED(y), @@ -126,18 +135,17 @@ public: return false; } - uniquePtr clone()const override - { - return makeUnique(*this); - } - - bool intAll(real dt, + /// Integrate on all points in the active range + bool intAll( + real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Integrate on active points in the active range template - bool intRange(real dt, + bool intRange( + real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP ); diff --git a/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp b/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp index 0a713ffb..547de93f 100644 --- a/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp +++ b/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp @@ -32,7 +32,7 @@ pFlow::AdamsBashforth4::AdamsBashforth4 : integration(baseName, owner, pStruct, method), history_( - owner.emplaceObject( + owner.emplaceObject>( objectFile( groupNames(baseName,"AB4History"), "", diff --git a/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp b/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp index 909d93ba..4f4a2914 100644 --- a/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp +++ b/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp @@ -30,11 +30,12 @@ namespace pFlow struct AB4History { + TypeInfoNV("AB4History"); + realx3 dy1_={0,0,0}; realx3 dy2_={0,0,0}; realx3 dy3_={0,0,0}; - - TypeInfoNV("AB4History"); + }; @@ -68,23 +69,21 @@ iOstream& operator<<(iOstream& str, const AB4History& ab4) return str; } - +/** + * Fourth order Adams-Bashforth integration method for solving ODE + * + * This is a one-step integration method and does not have prediction step. + */ class AdamsBashforth4 : public integration { protected: - using HistoryFieldType = pointField; - //realx3PointField_D& dy1_; - - //realx3PointField_D& dy2_; - - - - // this is a device - HistoryFieldType& history_; + /// Integration history + pointField& history_; + /// Range policy for integration kernel using rpIntegration = Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule, @@ -93,32 +92,42 @@ protected: public: - // type info + /// Type info TypeInfo("AdamsBashforth4"); - //// - Constructors + // - Constructors + + /// Construct from components AdamsBashforth4( const word& baseName, repository& owner, const pointStructure& pStruct, const word& method); + + uniquePtr clone()const override + { + return makeUnique(*this); + } + /// Destructor virtual ~AdamsBashforth4()=default; - // - add a virtual constructor + /// Add a this to the virtual constructor table add_vCtor( integration, AdamsBashforth4, word); - //// - Methods + // - Methods + bool predict( real UNUSED(dt), realx3Vector_D & UNUSED(y), realx3Vector_D& UNUSED(dy)) override; - bool correct(real dt, + bool correct( + real dt, realx3Vector_D & y, realx3Vector_D& dy) override; @@ -131,18 +140,17 @@ public: return false; } - uniquePtr clone()const override - { - return makeUnique(*this); - } - - bool intAll(real dt, + /// Integrate on all points in the active range + bool intAll( + real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Integrate on active points in the active range template - bool intRange(real dt, + bool intRange( + real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP ); diff --git a/src/Integration/AdamsBashforth5/AdamsBashforth5.cpp b/src/Integration/AdamsBashforth5/AdamsBashforth5.cpp index 327b5f2b..580f0c06 100644 --- a/src/Integration/AdamsBashforth5/AdamsBashforth5.cpp +++ b/src/Integration/AdamsBashforth5/AdamsBashforth5.cpp @@ -32,7 +32,7 @@ pFlow::AdamsBashforth5::AdamsBashforth5 : integration(baseName, owner, pStruct, method), history_( - owner.emplaceObject( + owner.emplaceObject>( objectFile( groupNames(baseName,"AB5History"), "", diff --git a/src/Integration/AdamsBashforth5/AdamsBashforth5.hpp b/src/Integration/AdamsBashforth5/AdamsBashforth5.hpp index ce8a5d19..99261588 100644 --- a/src/Integration/AdamsBashforth5/AdamsBashforth5.hpp +++ b/src/Integration/AdamsBashforth5/AdamsBashforth5.hpp @@ -30,12 +30,12 @@ namespace pFlow struct AB5History { + TypeInfoNV("AB5History"); + realx3 dy1_={0,0,0}; realx3 dy2_={0,0,0}; realx3 dy3_={0,0,0}; realx3 dy4_={0,0,0}; - - TypeInfoNV("AB5History"); }; @@ -71,18 +71,21 @@ iOstream& operator<<(iOstream& str, const AB5History& ab5) return str; } - +/** + * Fifth order Adams-Bashforth integration method for solving ODE + * + * This is a one-step integration method and does not have prediction step. + */ class AdamsBashforth5 : public integration { protected: - using HistoryFieldType = pointField; - - // this is a device - HistoryFieldType& history_; + /// Integration history + pointField& history_; + /// Range policy for integration kernel using rpIntegration = Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule, @@ -91,32 +94,40 @@ protected: public: - // type info + /// Type info TypeInfo("AdamsBashforth5"); - //// - Constructors + // - Constructors + AdamsBashforth5( const word& baseName, repository& owner, const pointStructure& pStruct, const word& method); + uniquePtr clone()const override + { + return makeUnique(*this); + } + virtual ~AdamsBashforth5()=default; - // - add a virtual constructor + /// Add this to the virtual constructor table add_vCtor( integration, AdamsBashforth5, word); - //// - Methods + // - Methods + bool predict( real UNUSED(dt), realx3Vector_D & UNUSED(y), realx3Vector_D& UNUSED(dy)) override; - bool correct(real dt, + bool correct( + real dt, realx3Vector_D & y, realx3Vector_D& dy) override; @@ -129,18 +140,17 @@ public: return false; } - uniquePtr clone()const override - { - return makeUnique(*this); - } - - bool intAll(real dt, + /// Integrate on all points in the active range + bool intAll( + real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Integrate on active points in the active range template - bool intRange(real dt, + bool intRange( + real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP ); @@ -184,4 +194,4 @@ bool pFlow::AdamsBashforth5::intRange( } // pFlow -#endif //__integration_hpp__ +#endif // diff --git a/src/Integration/AdamsMoulton3/AdamsMoulton3.hpp b/src/Integration/AdamsMoulton3/AdamsMoulton3.hpp index 2e33ae11..349d62b2 100644 --- a/src/Integration/AdamsMoulton3/AdamsMoulton3.hpp +++ b/src/Integration/AdamsMoulton3/AdamsMoulton3.hpp @@ -28,19 +28,27 @@ Licence: namespace pFlow { - +/** + * Third order Adams-Moulton integration method for solving ODE + * + * This is a predictor-corrector integration method. + */ class AdamsMoulton3 : public integration { protected: + /// y at time t realx3PointField_D& y0_; + /// dy at time t realx3PointField_D& dy0_; + /// dy at time t-dt realx3PointField_D& dy1_; + /// Range policy for integration kernel using rpIntegration = Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule, @@ -48,29 +56,44 @@ protected: >; public: - // type info + /// Type info TypeInfo("AdamsMoulton3"); - //// - Constructors + // - Constructors + + /// Construct from components AdamsMoulton3( const word& baseName, repository& owner, const pointStructure& pStruct, const word& method); + uniquePtr clone()const override + { + return makeUnique(*this); + } + + /// Destructor virtual ~AdamsMoulton3()=default; - // - add a virtual constructor + /// Add this to the virtual constructor table add_vCtor( integration, AdamsMoulton3, word); - //// - Methods - bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + // - Methods - bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + bool predict( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy) override; + + bool correct( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy) override; bool setInitialVals( const int32IndexContainer& newIndices, @@ -81,20 +104,35 @@ public: return true; } - uniquePtr clone()const override - { - return makeUnique(*this); - } - - bool predictAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Prediction step on all points in the active range + bool predictAll( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + range activeRng); + /// Prediction step on active points in the active range template - bool predictRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP); + bool predictRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP); - bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Integrate on all points in the active range + bool intAll( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + range activeRng); + /// Integrate on active points in the active range template - bool intRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP ); + bool intRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP); }; @@ -104,7 +142,7 @@ bool AdamsMoulton3::predictRange( real dt, realx3Vector_D& y, realx3Vector_D& dy, - activeFunctor activeP ) + activeFunctor activeP) { auto d_dy = dy.deviceVectorAll(); auto d_y = y.deviceVectorAll(); @@ -141,7 +179,7 @@ bool pFlow::AdamsMoulton3::intRange( real dt, realx3Vector_D& y, realx3Vector_D& dy, - activeFunctor activeP ) + activeFunctor activeP) { auto d_dy = dy.deviceVectorAll(); @@ -176,4 +214,4 @@ bool pFlow::AdamsMoulton3::intRange( } // pFlow -#endif //__integration_hpp__ +#endif // diff --git a/src/Integration/AdamsMoulton4/AdamsMoulton4.hpp b/src/Integration/AdamsMoulton4/AdamsMoulton4.hpp index 1e3863a7..c0da0f62 100644 --- a/src/Integration/AdamsMoulton4/AdamsMoulton4.hpp +++ b/src/Integration/AdamsMoulton4/AdamsMoulton4.hpp @@ -28,21 +28,30 @@ Licence: namespace pFlow { - +/** + * Fourth order Adams-Moulton integration method for solving ODE + * + * This is a predictor-corrector integration method. + */ class AdamsMoulton4 : public integration { protected: + /// y at time t realx3PointField_D& y0_; + /// dy at time t realx3PointField_D& dy0_; + /// dy at time t-dt realx3PointField_D& dy1_; + /// dy at time t-2*dt realx3PointField_D& dy2_; + /// Range policy for integration kernel using rpIntegration = Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule, @@ -50,29 +59,44 @@ protected: >; public: - // type info + /// Type info TypeInfo("AdamsMoulton4"); - //// - Constructors + // - Constructors + + /// Construct from components AdamsMoulton4( const word& baseName, repository& owner, const pointStructure& pStruct, const word& method); + uniquePtr clone()const override + { + return makeUnique(*this); + } + + /// Destructor virtual ~AdamsMoulton4()=default; - // - add a virtual constructor + // Add this to the virtual constructor table add_vCtor( integration, AdamsMoulton4, word); - //// - Methods - bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + // - Methods - bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + bool predict( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy) override; + + bool correct( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy) override; bool setInitialVals( const int32IndexContainer& newIndices, @@ -83,20 +107,35 @@ public: return true; } - uniquePtr clone()const override - { - return makeUnique(*this); - } - - bool predictAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Prediction step on all points in the active range + bool predictAll( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + range activeRng); + /// Prediction step on active points in the active range template - bool predictRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP); + bool predictRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP); - bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Integrate on all points in the active range + bool intAll( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + range activeRng); + /// Integrate on active points in the active range template - bool intRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP ); + bool intRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP ); }; @@ -182,4 +221,4 @@ bool pFlow::AdamsMoulton4::intRange( } // pFlow -#endif //__integration_hpp__ +#endif // diff --git a/src/Integration/AdamsMoulton5/AdamsMoulton5.hpp b/src/Integration/AdamsMoulton5/AdamsMoulton5.hpp index bcfe9035..2e381d4a 100644 --- a/src/Integration/AdamsMoulton5/AdamsMoulton5.hpp +++ b/src/Integration/AdamsMoulton5/AdamsMoulton5.hpp @@ -28,23 +28,33 @@ Licence: namespace pFlow { - +/** + * Fifth order Adams-Moulton integration method for solving ODE + * + * This is a predictor-corrector integration method. + */ class AdamsMoulton5 : public integration { protected: + /// y at time t realx3PointField_D& y0_; + /// dy at time t realx3PointField_D& dy0_; + /// dy at time t-dt realx3PointField_D& dy1_; + /// dy at time t-2*dt realx3PointField_D& dy2_; + /// dy at time t-3*dt realx3PointField_D& dy3_; + /// Range policy for integration kernel using rpIntegration = Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule, @@ -52,16 +62,24 @@ protected: >; public: - // type info + /// Type info TypeInfo("AdamsMoulton5"); - //// - Constructors + // - Constructors + + /// Construct from components AdamsMoulton5( const word& baseName, repository& owner, const pointStructure& pStruct, const word& method); + + uniquePtr clone()const override + { + return makeUnique(*this); + } + /// Destructor virtual ~AdamsMoulton5()=default; // - add a virtual constructor @@ -71,10 +89,17 @@ public: word); - //// - Methods - bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + // - Methods + + bool predict( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy) override; - bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + bool correct( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy) override; bool setInitialVals( const int32IndexContainer& newIndices, @@ -85,20 +110,35 @@ public: return true; } - uniquePtr clone()const override - { - return makeUnique(*this); - } - - bool predictAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Prediction step on all points in the active range + bool predictAll( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + range activeRng); + /// Prediction step on active points in the active range template - bool predictRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP); + bool predictRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP); - bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + /// Integrate on all points in the active range + bool intAll( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + range activeRng); + /// Integrate on active points in the active range template - bool intRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP ); + bool intRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP ); }; diff --git a/src/Integration/integration/integration.hpp b/src/Integration/integration/integration.hpp index a076039b..3cca58c2 100644 --- a/src/Integration/integration/integration.hpp +++ b/src/Integration/integration/integration.hpp @@ -31,32 +31,71 @@ Licence: namespace pFlow { - +/** + * Base class for integrating the first order ODE (IVP) + * + * The ODE should be in the following form: + *\f[ + \frac{dy}{dt} = f(y,t) + \f] + * for example the equation of motion is in the following form: + *\f[ + m\frac{d\vec{v}}{dt} = m\vec{g} + \sum \vec{f_c}(\vec{v},t) + \f] + * + * The integration method can be either one-step or predictor-corrector type. + * + */ class integration { protected: - repository& owner_; + // - Protected data members - const word baseName_; + /// The owner repository that all fields are storred in + repository& owner_; - const pointStructure& pStruct_; + /// The base name for integration + const word baseName_; + + /// A reference to pointStructure + const pointStructure& pStruct_; public: - // type info + /// Type info TypeInfo("integration"); - //// - Constructors + + // - Constructors + + /// Construct from components integration( const word& baseName, repository& owner, const pointStructure& pStruct, const word& method); + /// Copy constructor + integration(const integration&) = default; + + /// Move constructor + integration(integration&&) = default; + + /// Copy assignment + integration& operator = (const integration&) = default; + + /// Move assignment + integration& operator = (integration&&) = default; + + /// Polymorphic copy/cloning + virtual + uniquePtr clone()const=0; + + /// Destructor virtual ~integration()=default; - // - add a virtual constructor + /// Add a virtual constructor create_vCtor( integration, word, @@ -67,35 +106,49 @@ public: (baseName, owner, pStruct, method) ); - //// - Methods + // - Methods + /// Const ref to pointStructure + inline const auto& pStruct()const { return pStruct_; } - virtual bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0; - - virtual bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0; - - virtual bool setInitialVals( - const int32IndexContainer& newIndices, - const realx3Vector& y) = 0; - - virtual bool needSetInitialVals()const = 0; - - virtual uniquePtr clone()const=0; - + /// Base name + inline const word& baseName()const { return baseName_; } + /// Ref to the owner repository + inline repository& owner() { return owner_; } + /// Prediction step in integration + virtual + bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0; + + /// Correction/main integration step + virtual + bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0; + + /// Set the initial values for new indices + virtual + bool setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) = 0; + + /// Check if the method requires any set initial vals + virtual + bool needSetInitialVals()const = 0; + + + /// Create the polymorphic object based on inputs static uniquePtr create( const word& baseName, @@ -103,7 +156,7 @@ public: const pointStructure& pStruct, const word& method); -}; +}; // integration } // pFlow diff --git a/src/Integration/integration/integrations.hpp b/src/Integration/integration/integrations.hpp deleted file mode 100644 index 428656c2..00000000 --- a/src/Integration/integration/integrations.hpp +++ /dev/null @@ -1,28 +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. - ------------------------------------------------------------------------------*/ - -#ifndef __integrations_hpp__ -#define __integrations_hpp__ - -#include "integration.hpp" -#include "AdamsBashforth2.hpp" -#include "AdamsBashforth3.hpp" - -#endif \ No newline at end of file diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp b/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp index 7e101b31..843a3c46 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp @@ -24,7 +24,7 @@ Licence: #include "Time.hpp" #include "pointFields.hpp" -#include "integrations.hpp" +#include "integration.hpp" #include "uniquePtr.hpp" namespace pFlow @@ -57,17 +57,6 @@ public: dynamicPointStructure(const dynamicPointStructure& ps) = default; - /*dynamicPointStructure(const dynamicPointStructure& ps): - pointStructure(ps), - time_(ps.time_), - integrationMethod_(ps.integrationMethod_), - velocity_(ps.velocity_), - integrationPos_(ps.integrationPos_->clone()), - integrationVel_(ps.integrationVel_->clone()) - { - - }*/ - // - no move construct dynamicPointStructure(dynamicPointStructure&&) = delete; diff --git a/src/demComponent/demComponent.hpp b/src/demComponent/demComponent.hpp index 14041057..d5ad1635 100644 --- a/src/demComponent/demComponent.hpp +++ b/src/demComponent/demComponent.hpp @@ -28,70 +28,132 @@ Licence: namespace pFlow { +/** + * A base class for every main component of DEM system. + * + * This class provides abstraction at a very high level for any solver/utility + * that forces the derived component (i.e. particles, geometry, and etc) to + * advance over time when iterate is called in time a loop. + * + */ class demComponent { protected: - word componentName_; + // - Protected data members + /// Name of the DEM component + word componentName_; - systemControl& control_; + /// Reference to systemControl + systemControl& control_; - - Timers timers_; + /// All timers (if any) of this component + Timers timers_; public: + /// Type info TypeInfo("demComponent"); - demComponent(const word& name, systemControl& control) - : - componentName_(name), - control_(control), - timers_(name, &control.timers()) - {} + // - Constructors + + /// construct from components + demComponent(const word& name, systemControl& control) + : + componentName_(name), + control_(control), + timers_(name, &control.timers()) + {} - virtual ~demComponent() = default; + /// No copy constructor + demComponent(const demComponent&) = delete; + /// No move constructor + demComponent(demComponent&&) = delete; - const auto& control()const - { - return control_; - } + /// No copy assignment + demComponent& operator = (const demComponent&) = delete; - auto& control() - { - return control_; - } + /// No move assignment + demComponent& operator =(demComponent&&) = delete; - inline - real dt()const - { - return control_.time().dt(); - } + /// destructor + virtual ~demComponent() = default; - inline - real currentTime()const - { - return control_.time().currentTime(); - } + + // - Member functions - auto& timers(){ - return timers_; - } + /// Const ref to systemControl + inline + const auto& control()const + { + return control_; + } - const auto& timers() const{ - return timers_; - } + /// Ref to systemControl + inline + auto& control() + { + return control_; + } + /// Time step of integration + inline + real dt()const + { + return control_.time().dt(); + } - virtual bool beforeIteration() = 0; + /// Current simulation time + inline + real currentTime()const + { + return control_.time().currentTime(); + } + /// Const ref to timers + inline + const auto& timers() const + { + return timers_; + } - virtual bool iterate() = 0; + /// Ref to timers + inline + auto& timers() + { + return timers_; + } + /// This is called before the start of time loop + virtual + bool beforeTimeLoop() + { + notImplementedFunction; + return false; + } - virtual bool afterIteration() = 0; + /// This is called in time loop, before iterate + virtual + bool beforeIteration() = 0; + + /// This is called in time loop. Perform the main calculations + /// when the component should evolve along time. + virtual + bool iterate() = 0; + + /// This is called in time loop, after iterate. + virtual + bool afterIteration() = 0; + + /// This is called after the time loop + virtual + bool afterTimeLoop() + { + notImplementedFunction; + return false; + } };