diff --git a/.gitignore b/.gitignore index 54081c4f..d18b66f0 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,6 @@ bin/** lib/** test*/** **/**notnow -**/MPIParallel*/** doc/code-documentation/ doc/DTAGS # all possible time folders diff --git a/CMakeLists.txt b/CMakeLists.txt index 233e18aa..8cd85bfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,7 @@ add_subdirectory(src) #add_subdirectory(solvers) -#add_subdirectory(utilities) +add_subdirectory(utilities) #add_subdirectory(DEMSystems) add_subdirectory(testIO) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 31049334..235f17a2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,11 @@ add_subdirectory(phasicFlow) -#add_subdirectory(Integration) +add_subdirectory(Integration) -#add_subdirectory(Property) +add_subdirectory(Property) -#add_subdirectory(Particles) +add_subdirectory(Particles) #add_subdirectory(Interaction) diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp b/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp index 09a4eaa0..4c6a05cc 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp @@ -19,36 +19,107 @@ Licence: -----------------------------------------------------------------------------*/ #include "AdamsBashforth2.hpp" +#include "pointStructure.hpp" +#include "Time.hpp" +#include "vocabs.hpp" + +namespace pFlow +{ + +/// Range policy for integration kernel (alias) +using rpIntegration = Kokkos::RangePolicy< + DefaultExecutionSpace, + Kokkos::Schedule, + Kokkos::IndexType + >; + +bool intAllActive( + real dt, + realx3PointField_D& y, + realx3PointField_D& dy, + realx3PointField_D& dy1) +{ + + auto d_dy = dy.fieldDevice(); + auto d_y = y.fieldDevice(); + auto d_dy1= dy1.fieldDevice(); + auto activeRng = dy1.activeRange(); + + Kokkos::parallel_for( + "AdamsBashforth2::correct", + rpIntegration (activeRng.start(), activeRng.end()), + LAMBDA_HD(int32 i){ + d_y[i] += dt*(static_cast(1.5) * d_dy[i] - static_cast(0.5) * d_dy1[i]); + d_dy1[i] = d_dy[i]; + }); + Kokkos::fence(); + + return true; +} + +bool intScattered +( + real dt, + realx3PointField_D& y, + realx3PointField_D& dy, + realx3PointField_D& dy1 +) +{ + + auto d_dy = dy.fieldDevice(); + auto d_y = y.fieldDevice(); + auto d_dy1 = dy1.fieldDevice(); + auto activeRng = dy1.activeRange(); + const auto& activeP = dy1.activePointsMaskDevice(); + + Kokkos::parallel_for( + "AdamsBashforth2::correct", + rpIntegration (activeRng.start(), activeRng.end()), + LAMBDA_HD(int32 i){ + if( activeP(i)) + { + d_y[i] += dt*(static_cast(1.5) * d_dy[i] - static_cast(0.5) * d_dy1[i]); + d_dy1[i] = d_dy[i]; + } + }); + Kokkos::fence(); + + + return true; +} + +} + -//const real AB2_coef[] = { 3.0 / 2.0, 1.0 / 2.0}; pFlow::AdamsBashforth2::AdamsBashforth2 ( const word& baseName, - repository& owner, - const pointStructure& pStruct, - const word& method + pointStructure& pStruct, + const word& method, + const realx3Field_D& initialValField ) : - integration(baseName, owner, pStruct, method), - dy1_( - owner.emplaceObject( - objectFile( - groupNames(baseName,"dy1"), - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS), - pStruct, - zero3)) -{ - -} + integration(baseName, pStruct, method, initialValField), + realx3PointField_D + ( + objectFile + ( + groupNames(baseName,"dy1"), + pStruct.time().integrationFolder(), + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS + ), + pStruct, + zero3 + ) +{} bool pFlow::AdamsBashforth2::predict ( real UNUSED(dt), - realx3Vector_D& UNUSED(y), - realx3Vector_D& UNUSED(dy) + realx3PointField_D& UNUSED(y), + realx3PointField_D& UNUSED(dy) ) { @@ -58,17 +129,19 @@ bool pFlow::AdamsBashforth2::predict bool pFlow::AdamsBashforth2::correct ( real dt, - realx3Vector_D& y, - realx3Vector_D& dy + realx3PointField_D& y, + realx3PointField_D& dy ) { - if(this->pStruct().allActive()) + auto& dy1l = dy1(); + + if(dy1l.isAllActive()) { - return intAll(dt, y, dy, this->pStruct().activeRange()); + return intAllActive(dt, y, dy, dy1l); } else { - return intRange(dt, y, dy, this->pStruct().activePointsMaskD()); + return intScattered(dt, y, dy, dy1l); } return true; @@ -81,25 +154,3 @@ bool pFlow::AdamsBashforth2::setInitialVals( return true; } -bool pFlow::AdamsBashforth2::intAll( - real dt, - realx3Vector_D& y, - realx3Vector_D& dy, - range activeRng) -{ - - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_dy1= dy1_.deviceVectorAll(); - - Kokkos::parallel_for( - "AdamsBashforth2::correct", - rpIntegration (activeRng.first, activeRng.second), - LAMBDA_HD(int32 i){ - d_y[i] += dt*(static_cast(3.0 / 2.0) * d_dy[i] - static_cast(1.0 / 2.0) * d_dy1[i]); - d_dy1[i] = d_dy[i]; - }); - Kokkos::fence(); - - return true; -} \ No newline at end of file diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp b/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp index 6e2a8892..54e1c421 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp @@ -36,20 +36,16 @@ namespace pFlow */ class AdamsBashforth2 : - public integration + public integration, + public realx3PointField_D { -protected: +private: - /// dy at t-dt - realx3PointField_D& dy1_; - - /// Range policy for integration kernel (alias) - using rpIntegration = Kokkos::RangePolicy< - DefaultExecutionSpace, - Kokkos::Schedule, - Kokkos::IndexType - >; + auto& dy1() + { + return static_cast(*this); + } public: /// Type info @@ -60,17 +56,12 @@ public: /// Construct from components AdamsBashforth2( const word& baseName, - repository& owner, - const pointStructure& pStruct, - const word& method); - - uniquePtr clone()const override - { - return makeUnique(*this); - } + pointStructure& pStruct, + const word& method, + const realx3Field_D& initialValField); /// Destructor - virtual ~AdamsBashforth2()=default; + ~AdamsBashforth2()final = default; /// Add this to the virtual constructor table add_vCtor( @@ -80,71 +71,33 @@ public: // - Methods + /// return integration method + word method()const override + { + return "AdamsBashforth2"; + } bool predict( real UNUSED(dt), - realx3Vector_D& UNUSED(y), - realx3Vector_D& UNUSED(dy)) override; + realx3PointField_D& UNUSED(y), + realx3PointField_D& UNUSED(dy)) final; bool correct( real dt, - realx3Vector_D& y, - realx3Vector_D& dy) override; + realx3PointField_D& y, + realx3PointField_D& dy) final; bool setInitialVals( const int32IndexContainer& newIndices, - const realx3Vector& y) override; + const realx3Vector& y) final; - bool needSetInitialVals()const override + bool needSetInitialVals()const final { return false; } - - /// 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 ); }; -template -bool pFlow::AdamsBashforth2::intRange( - real dt, - realx3Vector_D& y, - realx3Vector_D& dy, - activeFunctor activeP ) -{ - - auto d_dy = dy.deviceVectorAll(); - auto d_y = y.deviceVectorAll(); - auto d_dy1= dy1_.deviceVectorAll(); - auto activeRng = activeP.activeRange(); - - Kokkos::parallel_for( - "AdamsBashforth2::correct", - rpIntegration (activeRng.first, activeRng.second), - LAMBDA_HD(int32 i){ - if( activeP(i)) - { - d_y[i] += dt*(static_cast(3.0 / 2.0) * d_dy[i] - static_cast(1.0 / 2.0) * d_dy1[i]); - d_dy1[i] = d_dy[i]; - } - }); - Kokkos::fence(); - - - return true; -} } // pFlow diff --git a/src/Integration/CMakeLists.txt b/src/Integration/CMakeLists.txt index f3a03112..fca650cd 100644 --- a/src/Integration/CMakeLists.txt +++ b/src/Integration/CMakeLists.txt @@ -1,13 +1,13 @@ list(APPEND SourceFiles integration/integration.cpp -AdamsBashforth5/AdamsBashforth5.cpp -AdamsBashforth4/AdamsBashforth4.cpp -AdamsBashforth3/AdamsBashforth3.cpp AdamsBashforth2/AdamsBashforth2.cpp -AdamsMoulton3/AdamsMoulton3.cpp -AdamsMoulton4/AdamsMoulton4.cpp -AdamsMoulton5/AdamsMoulton5.cpp +#AdamsBashforth5/AdamsBashforth5.cpp +#AdamsBashforth4/AdamsBashforth4.cpp +#AdamsBashforth3/AdamsBashforth3.cpp +#AdamsMoulton3/AdamsMoulton3.cpp +#AdamsMoulton4/AdamsMoulton4.cpp +#AdamsMoulton5/AdamsMoulton5.cpp ) set(link_libs Kokkos::kokkos phasicFlow) diff --git a/src/Integration/integration/integration.cpp b/src/Integration/integration/integration.cpp index 6e48ddaf..f3126e1e 100644 --- a/src/Integration/integration/integration.cpp +++ b/src/Integration/integration/integration.cpp @@ -19,33 +19,35 @@ Licence: -----------------------------------------------------------------------------*/ #include "integration.hpp" +#include "pointStructure.hpp" +#include "repository.hpp" pFlow::integration::integration ( const word& baseName, - repository& owner, - const pointStructure& pStruct, - const word& method + pointStructure& pStruct, + const word&, + const realx3Field_D& ) : - owner_(owner), - baseName_(baseName), - pStruct_(pStruct) -{ - CONSUME_PARAM(method); -} + owner_(*pStruct.owner()), + pStruct_(pStruct), + baseName_(baseName) +{} pFlow::uniquePtr - pFlow::integration::create( + pFlow::integration::create +( const word& baseName, - repository& owner, - const pointStructure& pStruct, - const word& method) + pointStructure& pStruct, + const word& method, + const realx3Field_D& initialValField +) { if( wordvCtorSelector_.search(method) ) { - return wordvCtorSelector_[method] (baseName, owner, pStruct, method); + return wordvCtorSelector_[method] (baseName, pStruct, method, initialValField); } else { diff --git a/src/Integration/integration/integration.hpp b/src/Integration/integration/integration.hpp index 3cca58c2..334e328e 100644 --- a/src/Integration/integration/integration.hpp +++ b/src/Integration/integration/integration.hpp @@ -23,14 +23,16 @@ Licence: #include "virtualConstructor.hpp" -#include "Vectors.hpp" -#include "pointStructure.hpp" -#include "repository.hpp" +#include "pointFields.hpp" namespace pFlow { +// - Forward +class repository; +class pointStructure; + /** * Base class for integrating the first order ODE (IVP) * @@ -48,19 +50,19 @@ namespace pFlow */ class integration { -protected: +private: // - Protected data members /// The owner repository that all fields are storred in repository& owner_; - /// The base name for integration - const word baseName_; - /// A reference to pointStructure const pointStructure& pStruct_; + /// The base name for integration + const word baseName_; + public: /// Type info @@ -72,9 +74,9 @@ public: /// Construct from components integration( const word& baseName, - repository& owner, - const pointStructure& pStruct, - const word& method); + pointStructure& pStruct, + const word& method, + const realx3Field_D& initialValField); /// Copy constructor integration(const integration&) = default; @@ -88,22 +90,22 @@ public: /// Move assignment integration& operator = (integration&&) = default; - /// Polymorphic copy/cloning - virtual - uniquePtr clone()const=0; - /// Destructor virtual ~integration()=default; /// Add a virtual constructor - create_vCtor( + create_vCtor + ( integration, word, - (const word& baseName, - repository& owner, - const pointStructure& pStruct, - const word& method), - (baseName, owner, pStruct, method) ); + ( + const word& baseName, + pointStructure& pStruct, + const word& method, + const realx3Field_D& initialValField + ), + (baseName, pStruct, method, initialValField) + ); // - Methods @@ -129,13 +131,17 @@ public: return owner_; } + /// return integration method + virtual + word method()const = 0 ; + /// Prediction step in integration virtual - bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0; + bool predict(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0; /// Correction/main integration step virtual - bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0; + bool correct(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0; /// Set the initial values for new indices virtual @@ -152,9 +158,9 @@ public: static uniquePtr create( const word& baseName, - repository& owner, - const pointStructure& pStruct, - const word& method); + pointStructure& pStruct, + const word& method, + const realx3Field_D& initialValField); }; // integration diff --git a/src/Particles/CMakeLists.txt b/src/Particles/CMakeLists.txt index 9c23631f..42ac0ea8 100644 --- a/src/Particles/CMakeLists.txt +++ b/src/Particles/CMakeLists.txt @@ -2,14 +2,14 @@ set(SourceFiles dynamicPointStructure/dynamicPointStructure.cpp particles/particles.cpp -particles/particleIdHandler.cpp -SphereParticles/sphereShape/sphereShape.cpp -SphereParticles/sphereParticles/sphereParticles.cpp -Insertion/shapeMixture/shapeMixture.cpp -Insertion/insertion/insertion.cpp -Insertion/Insertion/Insertions.cpp -Insertion/insertionRegion/insertionRegion.cpp -Insertion/insertionRegion/timeFlowControl.cpp +#particles/particleIdHandler.cpp +#SphereParticles/sphereShape/sphereShape.cpp +#SphereParticles/sphereParticles/sphereParticles.cpp +#Insertion/shapeMixture/shapeMixture.cpp +#Insertion/insertion/insertion.cpp +#Insertion/Insertion/Insertions.cpp +#Insertion/insertionRegion/insertionRegion.cpp +#Insertion/insertionRegion/timeFlowControl.cpp ) set(link_libs Kokkos::kokkos phasicFlow Integration Property) diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp b/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp index 16e5b849..d99766e2 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp @@ -19,57 +19,40 @@ Licence: -----------------------------------------------------------------------------*/ #include "dynamicPointStructure.hpp" - +#include "systemControl.hpp" pFlow::dynamicPointStructure::dynamicPointStructure ( - Time& time, - const word& integrationMethod + systemControl& control ) : - time_(time), - integrationMethod_(integrationMethod), - pStruct_( - time_.emplaceObject( - objectFile( - pointStructureFile__, - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ) - ) - ), - velocity_( - time_.emplaceObject( - objectFile( - "velocity", - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ), - pStruct(), - zero3 - ) - ) - + pointStructure(control), + velocity_ + ( + objectFile( + "velocity", + "", + objectFile::READ_ALWAYS, + objectFile::WRITE_ALWAYS + ), + *this, + zero3 + ), + integrationMethod_ + ( + control.settingsDict().getVal("integrationMethod") + ) { - - this->subscribe(pStruct()); - REPORT(1)<< "Creating integration method "<< - greenText(integrationMethod_)<<" for dynamicPointStructure."<needSetInitialVals()) return; + /*if(!integrationPos_->needSetInitialVals()) return; @@ -107,14 +100,13 @@ pFlow::dynamicPointStructure::dynamicPointStructure vel.push_back( hVel[index(i)]); } - //output<< "pos "<< pos<setInitialVals(indexHD, pos); REPORT(2)<< "Initializing the required vectors for velocity integratoin\n "<setInitialVals(indexHD, vel); + integrationVel_->setInitialVals(indexHD, vel);*/ + } bool pFlow::dynamicPointStructure::predict @@ -123,10 +115,10 @@ bool pFlow::dynamicPointStructure::predict realx3PointField_D& acceleration ) { - auto& pos = pStruct().pointPosition(); + //auto& pos = pStruct().pointPosition(); - if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false; - if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false; + //if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false; + //if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false; return true; } @@ -137,11 +129,11 @@ bool pFlow::dynamicPointStructure::correct realx3PointField_D& acceleration ) { - auto& pos = pStruct().pointPosition(); + //auto& pos = pStruct().pointPosition(); - if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false; + //if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false; - if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false; + //if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false; return true; } @@ -178,7 +170,7 @@ pFlow::uniquePtr pFlow::dynamicPointStructure::inser }*/ -bool pFlow::dynamicPointStructure::update( +/*bool pFlow::dynamicPointStructure::update( const eventMessage& msg) { if( msg.isInsert()) @@ -215,4 +207,4 @@ bool pFlow::dynamicPointStructure::update( } return true; -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp b/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp index 843a3c46..d2e72659 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp @@ -30,98 +30,65 @@ Licence: namespace pFlow { +class systemControl; + class dynamicPointStructure : - //public pointStructure -public eventObserver + public pointStructure { -protected: +private: - Time& time_; + realx3PointField_D velocity_; - word integrationMethod_; + uniquePtr integrationPos_ = nullptr; - pointStructure& pStruct_; + uniquePtr integrationVel_ = nullptr; - realx3PointField_D& velocity_; - - uniquePtr integrationPos_; - - uniquePtr integrationVel_; + /// @brief integration method for velocity and position + word integrationMethod_; public: TypeInfo("dynamicPointStructure"); - dynamicPointStructure(Time& time, const word& integrationMethod); - - dynamicPointStructure(const dynamicPointStructure& ps) = default; + dynamicPointStructure(systemControl& control); + dynamicPointStructure(const dynamicPointStructure& ps) = delete; - // - no move construct + // - no move construct dynamicPointStructure(dynamicPointStructure&&) = delete; - // - copy assignment - // - // should be changed, may causs undefined behavior - ////////////////////////////////////////////////////////////// - dynamicPointStructure& operator=(const dynamicPointStructure&) = default; + /// + dynamicPointStructure& operator=(const dynamicPointStructure&) = delete; // - no move assignment dynamicPointStructure& operator=(dynamicPointStructure&&) = delete; // - destructor - virtual ~dynamicPointStructure() = default; + ~dynamicPointStructure() override = default; - inline pointStructure& pStruct() - { - return pStruct_; - } - - inline const pointStructure& pStruct() const - { - return pStruct_; - } - - inline const realx3PointField_D& velocity()const + inline + const realx3PointField_D& velocity()const { return velocity_; } - inline auto velocityHostAll() + inline + realx3PointField_D& velocity() + { + return velocity_; + } + + /*inline auto velocityHostAll() { return velocity_.hostVectorAll(); - } - - inline auto pointPositionHostAll() - { - return pStruct_.pointPositionHostAll(); - } - - auto markDeleteOutOfBox(const box& domain) - { - return pStruct_.markDeleteOutOfBox(domain); - } + }*/ bool predict(real dt, realx3PointField_D& acceleration); bool correct(real dt, realx3PointField_D& acceleration); - - // - update data structure by inserting/setting new points - // Notifies all the fields in the registered list of data structure - // and exclude the fields that re in the exclusionList - // retrun nullptr if it fails - /*FUNCTION_H - virtual uniquePtr insertPoints( - const realx3Vector& pos, - const List& exclusionList={nullptr} - )override;*/ - - bool update(const eventMessage& msg) override; - - }; } diff --git a/src/Particles/particles/particles.cpp b/src/Particles/particles/particles.cpp index d5c3bb45..23250718 100644 --- a/src/Particles/particles/particles.cpp +++ b/src/Particles/particles/particles.cpp @@ -24,135 +24,107 @@ Licence: pFlow::particles::particles ( - systemControl& control, - const word& integrationMethod + systemControl& control ) : - demParticles(control), - time_(control.time()), - integrationMethod_(integrationMethod), - /*dynPointStruct_( - time_.emplaceObject( - objectFile( - pointStructureFile__, - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ), - control.time(), - integrationMethod - ) - ),*/ - dynPointStruct_( - control.time(), - integrationMethod), - shapeName_( - control.time().emplaceObject( - objectFile( - "shapeName", - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS, - false - ), - pStruct(), - word("NO_NAME_SHAPE") - ) + observer(), + demComponent("particles", control), + dynPointStruct_(control), + id_ + ( + objectFile + ( + "id", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS ), - id_( - control.time().emplaceObject( - objectFile( - "id", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS - ), - pStruct(), - static_cast(-1) - ) + dynPointStruct_, + static_cast(-1) + ), + propertyId_ + ( + objectFile + ( + "propertyId", + "", + objectFile::READ_NEVER, + objectFile::WRITE_NEVER ), - propertyId_( - control.time().emplaceObject( - objectFile( - "propertyId", - "", - objectFile::READ_NEVER, - objectFile::WRITE_NEVER - ), - pStruct(), - static_cast(0) - ) + dynPointStruct_, + static_cast(0) + ), + diameter_ + ( + objectFile + ( + "diameter", + "", + objectFile::READ_NEVER, + objectFile::WRITE_ALWAYS ), - diameter_( - control.time().emplaceObject( - objectFile( - "diameter", - "", - objectFile::READ_NEVER, - objectFile::WRITE_ALWAYS - ), - pStruct(), - static_cast(0.00000000001) - ) + dynPointStruct_, + 0.00000000001 + ), + mass_ + ( + objectFile + ( + "mass", + "", + objectFile::READ_NEVER, + objectFile::WRITE_ALWAYS ), - mass_( - control.time().emplaceObject( - objectFile( - "mass", - "", - objectFile::READ_NEVER, - objectFile::WRITE_ALWAYS - ), - pStruct(), - static_cast(0.0000000001) - ) + dynPointStruct_, + 0.0000000001 + ), + accelertion_ + ( + objectFile + ( + "accelertion", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS + ), + dynPointStruct_, + zero3 + ), + contactForce_ + ( + objectFile + ( + "contactForce", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS ), - accelertion_( - control.time().emplaceObject( - objectFile( - "accelertion", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS - ), - pStruct(), - zero3 - ) + dynPointStruct_, + zero3 + ), + contactTorque_ + ( + + objectFile + ( + "contactTorque", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS ), - contactForce_( - control.time().emplaceObject( - objectFile( - "contactForce", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS - ), - pStruct(), - zero3 - ) - ), - contactTorque_( - control.time().emplaceObject( - objectFile( - "contactTorque", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS - ), - pStruct(), - zero3 - ) - ), - idHandler_(id_) + dynPointStruct_, + zero3 + ) { - this->subscribe(pStruct()); + WARNING<<"Subscribe particles"<subscribe(pStruct()); } bool pFlow::particles::beforeIteration() { - auto domain = this->control().domain(); + /*auto domain = this->control().domain(); auto numMarked = dynPointStruct_.markDeleteOutOfBox(domain); @@ -174,12 +146,12 @@ bool pFlow::particles::beforeIteration() } this->zeroForce(); - this->zeroTorque(); + this->zeroTorque();*/ return true; } -pFlow::uniquePtr> +/*pFlow::uniquePtr> pFlow::particles::getFieldObjectList()const { auto objListPtr = makeUnique>(); @@ -199,4 +171,4 @@ pFlow::particles::getFieldObjectList()const static_cast(&shapeName_) ); return objListPtr; -} +}*/ diff --git a/src/Particles/particles/particles.hpp b/src/Particles/particles/particles.hpp index 7b207c50..554c9a85 100644 --- a/src/Particles/particles/particles.hpp +++ b/src/Particles/particles/particles.hpp @@ -23,66 +23,75 @@ Licence: #define __particles_hpp__ #include "dynamicPointStructure.hpp" -#include "particleIdHandler.hpp" -#include "demParticles.hpp" +#include "demComponent.hpp" + namespace pFlow { -class setFieldList; class particles : - public eventObserver, - public demParticles + public observer, + public demComponent { -protected: +private: - // owner repository - Time& time_; - - const word integrationMethod_; - - // dynamic point structure for particles + /// dynamic point structure for particles center mass dynamicPointStructure dynPointStruct_; // - name of shapes - this is managed by particles - wordPointField& shapeName_; + //wordPointField& shapeName_; // id of particles on host - int32PointField_HD& id_; + int32PointField_D id_; // property id on device - int8PointField_D& propertyId_; + int8PointField_D propertyId_; // diameter / boundig sphere size of particles on device - realPointField_D& diameter_; + realPointField_D diameter_; - // mass on device - realPointField_D& mass_; + // mass of particles field + realPointField_D mass_; // - acceleration on device - realx3PointField_D& accelertion_; + realx3PointField_D accelertion_; + /// contact force field + realx3PointField_D contactForce_; - realx3PointField_D& contactForce_; - - - realx3PointField_D& contactTorque_; + /// contact torque field + realx3PointField_D contactTorque_; - // - object handling particle id - particleIdHandler idHandler_; - - virtual uniquePtr> getFieldObjectList()const; - + void zeroForce() { - contactForce_.fill(zero3); + WARNING<<"fill contactTorque"<("materials"); + materials_ = getVal("materials"); - densities_ = dict.getVal("densities"); + densities_ = getVal("densities"); if(materials_.size() != densities_.size() ) { fatalErrorInFunction<< " number of elements in material ("<(materials_.size()); return true; } pFlow::property::property ( + const word& name, const wordVector& materials, - const realVector& densities + const realVector& densities, + repository* owner ) : + fileDictionary + ( + objectFile + ( + name, + "", + objectFile::READ_NEVER, + objectFile::WRITE_NEVER + ), + owner + ), materials_(materials), densities_(densities) { + + if(!writeDictionary()) + { + fatalExit; + } + if(!makeNameIndex()) { fatalErrorInFunction<< - " error in the input parameters of constructor. \n"; + "error in the input parameters of constructor. \n"; fatalExit; } } pFlow::property::property ( -const fileSystem& file + const word& fileName, + repository* owner ) : - dict_ + fileDictionary ( - makeUnique - ("property", true) - ) -{ - iFstream dictStream(file); - - if(!dict_().read(dictStream)) - { - ioErrorInFile(dictStream.name(), dictStream.lineNumber()); - fatalExit; - } - - if(!readDictionary(dict_())) - { - fatalExit; - } - -} - -pFlow::property::property -( - const dictionary& dict -) -: - dict_ - ( - makeUnique(dict) + objectFile + ( + fileName, + "", + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + ), + owner ) { - if(!readDictionary(dict_())) + if(!readDictionary()) { fatalExit; } + + if(!makeNameIndex()) + { + fatalErrorInFunction<< + "error in dictionary "<< globalName()< dict_ = nullptr; - /// list of name of materials wordVector materials_; @@ -62,10 +61,10 @@ protected: // - protected member functions /// read from dict - bool readDictionary(const dictionary& dict); + bool readDictionary(); /// write to dict - bool writeDictionary(dictionary& dict)const; + bool writeDictionary(); /// creates a mapp bool makeNameIndex(); @@ -73,22 +72,19 @@ protected: public: /// Type info - TypeInfoNV("property"); + TypeInfo("property"); - // - Constructors - /// Emptry constructor, used for reading from a file - property(){} - - /// Constructe from materials and densities - property(const wordVector& materials, const realVector& densities); - - /// Construct from file - property(const fileSystem& file); - - /// Construct from dictionary dict - property(const dictionary& dict); + explicit + property( + const word& fileName, + repository* owner=nullptr); + + property(const word& name, + const wordVector& materials, + const realVector& densities, + repository* owner=nullptr); /// Default copy property(const property& ) = default; @@ -103,17 +99,11 @@ public: property& operator= (property&&) = default; /// Default destructor - ~property() = default; + ~property() override = default; // - Methods - /// Return dictionary - inline const auto& dict()const - { - return dict_(); - } - /// Return number of materials inline auto numMaterials()const { @@ -190,20 +180,6 @@ public: } } - //// - IO operatoins - - /// Read from dictionary - bool read(const dictionary& dict) - { - return readDictionary(dict); - } - - /// Write to dictionary - bool write(dictionary& dict)const - { - return writeDictionary(dict); - } - }; } diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index 805a55d0..23ee3e13 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -34,18 +34,6 @@ dictionary/entry/iEntry.cpp dictionary/entry/dataEntry.cpp dictionary/twoPartEntry/twoPartEntry.cpp -containers/Vector/Vectors.cpp -containers/VectorHD/VectorSingles.cpp -containers/Field/Fields.cpp -containers/List/anyList/anyList.cpp -containers/pointField/pointFields.cpp - -#setFieldList/setFieldList.cpp -#setFieldList/setFieldEntry.cpp - -Timer/Timer.cpp -Timer/Timers.cpp - repository/IOobject/objectFile.cpp repository/IOobject/IOfileHeader.cpp repository/IOobject/IOobject.cpp @@ -62,6 +50,24 @@ eventManagement/observer.cpp demComponent/demComponent.cpp +containers/Vector/Vectors.cpp +containers/VectorHD/VectorSingles.cpp +containers/Field/Fields.cpp +containers/List/anyList/anyList.cpp +containers/pointField/pointFields.cpp + +#setFieldList/setFieldList.cpp +#setFieldList/setFieldEntry.cpp + +Timer/Timer.cpp +Timer/Timers.cpp + + + + + + + structuredData/box/box.cpp structuredData/line/line.cpp structuredData/infinitePlane/infinitePlane.cpp @@ -73,6 +79,7 @@ structuredData/pointStructure/internalPoints.cpp structuredData/pointStructure/pointStructure.cpp structuredData/boundaries/boundaryBase/boundaryBase.cpp structuredData/boundaries/boundaryExit/boundaryExit.cpp +structuredData/boundaries/boundaryNone/boundaryNone.cpp structuredData/pointStructure/boundaryList.cpp commandLine/commandLine.cpp diff --git a/src/phasicFlow/containers/Vector/Vector.hpp b/src/phasicFlow/containers/Vector/Vector.hpp index 32d2f115..f2511fd5 100644 --- a/src/phasicFlow/containers/Vector/Vector.hpp +++ b/src/phasicFlow/containers/Vector/Vector.hpp @@ -322,7 +322,7 @@ public: { return readStdVector(is, vectorField()); } - bool write(iOstream& os) + bool write(iOstream& os)const { return writeStdVector(os, vectorField()); } diff --git a/src/phasicFlow/containers/pointField/internalField.hpp b/src/phasicFlow/containers/pointField/internalField.hpp index 9783fdbc..30e08bc4 100644 --- a/src/phasicFlow/containers/pointField/internalField.hpp +++ b/src/phasicFlow/containers/pointField/internalField.hpp @@ -86,6 +86,21 @@ public: return field_.hostVector(); } + const FieldType& field()const + { + return field_; + } + + const pFlagTypeDevice& activePointsMaskDevice()const + { + return internalPoints_.activePointsMaskDevice(); + } + + const pFlagTypeHost& activePointsMaskHost()const + { + return internalPoints_.activePointsMaskHost(); + } + FieldTypeHost activeValuesHost()const; inline diff --git a/src/phasicFlow/containers/pointField/pointField.cpp b/src/phasicFlow/containers/pointField/pointField.cpp index 28bc8c73..edc42ce1 100644 --- a/src/phasicFlow/containers/pointField/pointField.cpp +++ b/src/phasicFlow/containers/pointField/pointField.cpp @@ -41,9 +41,32 @@ pFlow::pointField::pointField boundaryFieldList_(pStruct.boundaries(), *this), pStruct_(pStruct), defaultValue_(defVal) -{ - -} +{} + +template +pFlow::pointField::pointField +( + const objectFile& objf, + repository* owner, + pointStructure& pStruct, + const T& defVal +) +: + IOobject + ( + objf, + pStruct.ioPattern(), + owner + ), + InternalFieldType + ( + objf.name(), + pStruct + ), + boundaryFieldList_(pStruct.boundaries(), *this), + pStruct_(pStruct), + defaultValue_(defVal) +{} template pFlow::pointField::pointField diff --git a/src/phasicFlow/containers/pointField/pointField.hpp b/src/phasicFlow/containers/pointField/pointField.hpp index 5ebb015d..ffc315c5 100644 --- a/src/phasicFlow/containers/pointField/pointField.hpp +++ b/src/phasicFlow/containers/pointField/pointField.hpp @@ -81,6 +81,12 @@ public: pointStructure& pStruct, const T& defVal); + pointField( + const objectFile& objf, + repository* owner, + pointStructure& pStruct, + const T& defVal); + pointField( const objectFile& objf, pointStructure& pStruct, diff --git a/src/phasicFlow/containers/pointField/pointFields.hpp b/src/phasicFlow/containers/pointField/pointFields.hpp index 2dc5242a..d3435812 100644 --- a/src/phasicFlow/containers/pointField/pointFields.hpp +++ b/src/phasicFlow/containers/pointField/pointFields.hpp @@ -36,57 +36,39 @@ template using pointField_D = pointField; -using int8PointField_D = pointField; +using int8PointField_D = pointField_D; +using int8PointField_H = pointField_H; -using int8PointField_H = pointField; +using uint8PointField_D = pointField_D; +using uint8PointField_H = pointField_H; -using realPointField_D = pointField; +using int32PointField_D = pointField_D; +using int32PointField_H = pointField_H; -using realPointField_H = pointField; +using uint32PointField_D = pointField_D; +using uint32PointField_H = pointField_H; -//using int32PointField_D = pointField; +using int64PointField_D = pointField_D; +using int63PointField_H = pointField_H; -/*using int32PointField_H = pointField; +using uint64PointField_D = pointField_D; +using uint64PointField_H = pointField_H; -using int64PointField_D = pointField; +using int32PointField_D = pointField_D; +using int32PointField_H = pointField_H; -using int64PointField_H = pointField; +using realPointField_D = pointField_D; +using realPointField_H = pointField_H; -using uint32PointField_D = pointField; +using realx3PointField_D = pointField_D; +using realx3PointField_H = pointField_H; -using uint32PointField_H = pointField; +using realx4PointField_D = pointField_D; +using realx4PointField_H = pointField_H; -using labelPointField_D = pointField; -using labelPointField_H = pointField; -using realPointField_D = pointField; -using realPointField_H = pointField; - -using realx3PointField_D = pointField ; - -using realx3PointField_H = pointField; - -using wordPointField_H = pointField; - -using int8PointField_HD = pointField; - -using int16PointField_HD = pointField; - -using int32PointField_HD = pointField; - -using int64PointField_HD = pointField; - -using uint32PointField_HD = pointField; - -using labelPointField_HD = pointField; - -using realPointField_HD = pointField; - -using realx3PointField_HD = pointField; - -using wordPointField = pointField>;*/ } diff --git a/src/phasicFlow/dictionary/fileDictionary.cpp b/src/phasicFlow/dictionary/fileDictionary.cpp index 14012165..62bd3b2d 100644 --- a/src/phasicFlow/dictionary/fileDictionary.cpp +++ b/src/phasicFlow/dictionary/fileDictionary.cpp @@ -10,7 +10,7 @@ pFlow::fileDictionary::fileDictionary IOobject ( of, - IOPattern::IOPattern::AllProcessorsSimilar, + IOPattern::AllProcessorsSimilar, owner ), dictionary diff --git a/src/phasicFlow/repository/IOobject/IOPattern.hpp b/src/phasicFlow/repository/IOobject/IOPattern.hpp index 9f8f3124..9bd46e09 100644 --- a/src/phasicFlow/repository/IOobject/IOPattern.hpp +++ b/src/phasicFlow/repository/IOobject/IOPattern.hpp @@ -58,7 +58,7 @@ public: // standard input and output streams }; -protected: +private: IOType ioType_; @@ -72,12 +72,16 @@ protected: public: - IOPattern( IOType iotype); + IOPattern( IOPattern::IOType iotype); IOPattern(const IOPattern&)=default; + IOPattern(IOPattern&&) = default; + IOPattern& operator=(const IOPattern&)=default; + IOPattern& operator=(IOPattern&&)=default; + ~IOPattern() = default; inline @@ -123,6 +127,13 @@ public: return true; } + inline + bool thisCallWrite()const + { + if(isMasterProcessorOnly()&& !isMaster())return false; + return true; + } + inline bool thisProcReadData()const { diff --git a/src/phasicFlow/repository/IOobject/IOfileHeader.cpp b/src/phasicFlow/repository/IOobject/IOfileHeader.cpp index 15fda4fb..440a1ab6 100644 --- a/src/phasicFlow/repository/IOobject/IOfileHeader.cpp +++ b/src/phasicFlow/repository/IOobject/IOfileHeader.cpp @@ -36,7 +36,7 @@ pFlow::uniquePtr pFlow::IOfileHeader::outStream()const if(osPtr && owner()) { auto outPrecision = owner()->outFilePrecision(); - osPtr->precision(outPrecision); + osPtr->precision(static_cast(outPrecision)); } return osPtr; @@ -62,7 +62,7 @@ pFlow::fileSystem pFlow::IOfileHeader::path() const { f = localPath(); } - f += name_; + f += name(); return f; } @@ -146,11 +146,8 @@ bool pFlow::IOfileHeader::writeHeader ) const { - if(!forceWrite) - { - if(!writeHeader()) return true; - } - + if(!forceWrite && !writeHeader()) return true; + writeBanner(os); os.writeWordEntry("objectType", typeName ); diff --git a/src/phasicFlow/repository/IOobject/IOobject.cpp b/src/phasicFlow/repository/IOobject/IOobject.cpp index 39e3090c..2cd77a9f 100644 --- a/src/phasicFlow/repository/IOobject/IOobject.cpp +++ b/src/phasicFlow/repository/IOobject/IOobject.cpp @@ -64,60 +64,56 @@ pFlow::repository* pFlow::IOobject::releaseOwner bool pFlow::IOobject::readObject(bool rdHdr) { - - if( implyRead() ) - { - if( rdHdr & ioPattern().thisCallRead()) - { - if( auto ptrIS = inStream(); ptrIS ) - { - if(!readHeader(ptrIS()))return false; - } - else - { - warningInFunction<< - "could not open file " << path() <writeHeader() && ioPattern().thisProcWriteHeader()) writeHeader(os, typeName()); - if(ioPattern().thisProcWriteData()) - { //return (object_->write_object_t(os, ioPattern_) && writeSeparator(os)); - notImplementedFunction; - //return object_->read_object_t(is, ioPattern_); - return false; + if(ioPattern().thisCallWrite()) + { + return write(os, ioPattern() ); } else return true; diff --git a/src/phasicFlow/repository/IOobject/IOobject.hpp b/src/phasicFlow/repository/IOobject/IOobject.hpp index 952498c5..f2eaaba7 100644 --- a/src/phasicFlow/repository/IOobject/IOobject.hpp +++ b/src/phasicFlow/repository/IOobject/IOobject.hpp @@ -36,7 +36,7 @@ class IOobject : public IOfileHeader { -protected: +private: IOPattern ioPattern_; @@ -57,7 +57,7 @@ public: const IOPattern& iop, repository* owner); - ~IOobject(); + ~IOobject() override; // - copy construct IOobject(const IOobject& src)=delete; diff --git a/src/phasicFlow/repository/IOobject/objectFile.hpp b/src/phasicFlow/repository/IOobject/objectFile.hpp index 8bb5cb5f..dfe93fd2 100644 --- a/src/phasicFlow/repository/IOobject/objectFile.hpp +++ b/src/phasicFlow/repository/IOobject/objectFile.hpp @@ -45,16 +45,16 @@ public: }; -protected: +private: /// Name of the entity word name_; /// Read flag - readFlag rFlag_ = READ_NEVER; + readFlag rFlag_ = readFlag::READ_NEVER; /// Write flag - writeFlag wFlag_ = WRITE_NEVER; + writeFlag wFlag_ = writeFlag::WRITE_NEVER; /// Local path of entity fileSystem localPath_ = ""; @@ -70,7 +70,7 @@ public: // constructors - objectFile + explicit objectFile ( const word& name ); @@ -80,8 +80,8 @@ public: ( const word& name, const fileSystem& localPath, - const readFlag& rf = READ_NEVER, - const writeFlag& wf = WRITE_NEVER, + const readFlag& rf = readFlag::READ_NEVER, + const writeFlag& wf = writeFlag::WRITE_NEVER, bool rwHeader = true ); @@ -122,31 +122,31 @@ public: inline bool isReadAlways()const { - return rFlag_ == READ_ALWAYS; + return rFlag_ == readFlag::READ_ALWAYS; } inline bool isReadNever()const { - return rFlag_ == READ_NEVER; + return rFlag_ == readFlag::READ_NEVER; } inline bool isReadIfPresent()const { - return rFlag_ == READ_IF_PRESENT; + return rFlag_ == readFlag::READ_IF_PRESENT; } inline bool isWriteAlways()const { - return wFlag_ == WRITE_ALWAYS; + return wFlag_ == writeFlag::WRITE_ALWAYS; } inline bool isWriteNever()const { - return wFlag_ == WRITE_NEVER; + return wFlag_ == writeFlag::WRITE_NEVER; } inline diff --git a/src/phasicFlow/repository/Time/Time.cpp b/src/phasicFlow/repository/Time/Time.cpp index 693dcd85..234dcfd0 100644 --- a/src/phasicFlow/repository/Time/Time.cpp +++ b/src/phasicFlow/repository/Time/Time.cpp @@ -55,12 +55,6 @@ pFlow::Time::Time geometryRepository_, geometryFolder__, this - ), - integration_ - ( - integrationRepository__, - integrationFolder__, - this ) { @@ -90,12 +84,6 @@ pFlow::Time::Time( geometryRepository_, geometryFolder__, this - ), - integration_ - ( - integrationRepository__, - integrationFolder__, - this ) { if(!readDictionary(setiingsDict)) @@ -109,6 +97,11 @@ pFlow::fileSystem pFlow::Time::localPath()const return fileSystem(timeName()); } +pFlow::fileSystem pFlow::Time::integrationFolder() const +{ + return integrationFolder__; +} + bool pFlow::Time::write ( bool verbose diff --git a/src/phasicFlow/repository/Time/Time.hpp b/src/phasicFlow/repository/Time/Time.hpp index 7bdf7091..6cafa87b 100644 --- a/src/phasicFlow/repository/Time/Time.hpp +++ b/src/phasicFlow/repository/Time/Time.hpp @@ -28,7 +28,7 @@ Licence: #include "timeControl.hpp" #include "repository.hpp" - +#include "fileSystem.hpp" namespace pFlow @@ -49,10 +49,6 @@ protected: // - geometry folder/repository repository geometry_; - // - integration folder/repository - repository integration_; - - bool readDictionary(const dictionary& dict); public: @@ -84,15 +80,7 @@ public: return geometry_; } - const repository& integration()const - { - return integration_; - } - - repository& integration() - { - return integration_; - } + fileSystem integrationFolder()const; /// Write to the file with binary format? bool outFileBinary()const override diff --git a/src/phasicFlow/smartPointers/uniquePtr.hpp b/src/phasicFlow/smartPointers/uniquePtr.hpp index 373a043b..c1363cde 100644 --- a/src/phasicFlow/smartPointers/uniquePtr.hpp +++ b/src/phasicFlow/smartPointers/uniquePtr.hpp @@ -18,7 +18,6 @@ Licence: -----------------------------------------------------------------------------*/ - #ifndef __uniquePtr_hpp__ #define __uniquePtr_hpp__ @@ -47,7 +46,7 @@ class uniquePtr { public: - typedef std::unique_ptr uniquePtrType; + using uniquePtrType = std::unique_ptr; // using base constructors using uniquePtrType::unique_ptr; diff --git a/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.cpp b/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.cpp new file mode 100644 index 00000000..e3362956 --- /dev/null +++ b/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.cpp @@ -0,0 +1,58 @@ +/*------------------------------- 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 "boundaryNone.hpp" + +pFlow::boundaryNone::boundaryNone +( + const dictionary& dict, + const plane& bplane, + internalPoints& internal +) +: + boundaryBase(dict, bplane, internal) +{} + +bool pFlow::boundaryNone::beforeIteratoin +( + uint32 iterNum, + real t +) +{ + return true; +} + +bool pFlow::boundaryNone::iterate +( + uint32 iterNum, + real t +) +{ + return true; +} + +bool pFlow::boundaryNone::afterIteration +( + uint32 iterNum, + real t +) +{ + return true; +} \ No newline at end of file diff --git a/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.hpp b/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.hpp new file mode 100644 index 00000000..da93977e --- /dev/null +++ b/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.hpp @@ -0,0 +1,64 @@ +/*------------------------------- 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 __boundaryNone_hpp__ +#define __boundaryNone_hpp__ + + +#include "boundaryBase.hpp" + +namespace pFlow +{ + +class boundaryNone +: + public boundaryBase +{ + +public: + + TypeInfo("boundary"); + + boundaryNone( + const dictionary& dict, + const plane& bplane, + internalPoints& internal); + + ~boundaryNone() override= default; + + add_vCtor + ( + boundaryBase, + boundaryNone, + dictionary + ); + + bool beforeIteratoin(uint32 iterNum, real t) override; + + bool iterate(uint32 iterNum, real t) override; + + bool afterIteration(uint32 iterNum, real t) override; + + +}; + +} + +#endif \ No newline at end of file diff --git a/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp b/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp index 86fdf02e..7eeb888a 100644 --- a/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp +++ b/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp @@ -39,6 +39,11 @@ public: uint32 initialNumberInThis()const override; + bool initialThisDomainActive()const override + { + return true; + } + /*bool updateDomains( span pointPos, pFlagTypeHost flags) override;*/ diff --git a/src/phasicFlow/structuredData/domain/simulationDomain.hpp b/src/phasicFlow/structuredData/domain/simulationDomain.hpp index 205f1c75..35718798 100644 --- a/src/phasicFlow/structuredData/domain/simulationDomain.hpp +++ b/src/phasicFlow/structuredData/domain/simulationDomain.hpp @@ -97,6 +97,9 @@ public: virtual uint32 initialNumberInThis()const = 0; + virtual + bool initialThisDomainActive()const = 0; + virtual bool initialTransferBlockData( span src, diff --git a/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp b/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp index cbf1f539..83dbcec9 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp +++ b/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp @@ -172,7 +172,7 @@ public: INLINE_FUNCTION_HD - bool operator()(uint32 i) + bool operator()(uint32 i)const { return isActive(i); } diff --git a/utilities/Utilities/readFromTimeFolder.hpp b/utilities/Utilities/readFromTimeFolder.hpp index 75559780..a0d3b93d 100644 --- a/utilities/Utilities/readFromTimeFolder.hpp +++ b/utilities/Utilities/readFromTimeFolder.hpp @@ -42,7 +42,7 @@ protected: public: - readFromTimeFolder(repository& rep); + explicit readFromTimeFolder(repository& rep); auto path()const { @@ -65,9 +65,9 @@ public: bool pointFieldGetType(word& typeName)const { word fieldTYPENAME = pointField_H::TYPENAME(); - word fldType{}, space{}; + word fldType{}; - if( !pFlow::utilities::pointFieldGetType( + if(word space{}; !pFlow::utilities::pointFieldGetType( fieldTYPENAME, fldType, space) ) { fatalErrorInFunction<< @@ -81,18 +81,19 @@ public: } template - bool pointFieldGetCheckType(word fieldName, word& typeName) const + bool pointFieldGetCheckType(word const& fieldName, word& typeName) const { word fieldTYPENAME = pointField_H::TYPENAME(); - word flType{},fldType{}; - + + word flType{}; if(!pointFieldFileGetType( fieldName, flType)) { fatalExit; return false; } - + + word fldType{}; if( !pointFieldGetType(fldType) ) { fatalExit; @@ -112,7 +113,7 @@ public: } template - pointField_H& createUniformPointField_H(word name, T value) + uniquePtr> createUniformPointField_H(word const& name, T value) { if( !checkForPointStructure() ) { @@ -120,29 +121,28 @@ public: "cannot find " << pointStructureFile__ << " in repository "<< repository_.name()<(pointStructureFile__); - word fType; - pointFieldGetType(fType); - word newName = name + fType; - auto& field = repository_.emplaceReplaceObject>( - objectFile( + auto Ptr = makeUnique> + ( + objectFile + ( name, "", objectFile::READ_NEVER, objectFile::WRITE_NEVER - ), + ), pStruct, + T{}, value - ); - - return field; - + ); + return Ptr; } template - pointField_H& readPointField_H(word name) + uniquePtr> readPointField_H(word const& name) { if( !checkForPointStructure() ) { @@ -152,23 +152,25 @@ public: } auto& pStruct = repository_.lookupObject(pointStructureFile__); - auto& field = repository_.emplaceObjectOrGet>( - objectFile( + auto Ptr = makeUnique> + ( + objectFile + ( name, "", objectFile::READ_IF_PRESENT, objectFile::WRITE_ALWAYS - ), + ), pStruct, T{} - ); + ); - return field; + return Ptr; } template - pointField_D& readPointField_D(word name) + uniquePtr> readPointField_D(word const& name) { if( !checkForPointStructure() ) { @@ -178,18 +180,20 @@ public: } auto& pStruct = repository_.lookupObject(pointStructureFile__); - auto& field = repository_.emplaceObjectOrGet>( - objectFile( + auto Ptr = makeUnique> + ( + objectFile + ( name, "", objectFile::READ_IF_PRESENT, objectFile::WRITE_ALWAYS - ), + ), pStruct, T{} - ); + ); - return field; + return Ptr; } }; diff --git a/utilities/particlesPhasicFlow/particlesPhasicFlow.cpp b/utilities/particlesPhasicFlow/particlesPhasicFlow.cpp index 8d568a52..1e3351b5 100755 --- a/utilities/particlesPhasicFlow/particlesPhasicFlow.cpp +++ b/utilities/particlesPhasicFlow/particlesPhasicFlow.cpp @@ -72,21 +72,10 @@ int main( int argc, char* argv[] ) // this should be palced in each main #include "initialize_Control.hpp" - auto objCPDict = IOobject::make - ( - objectFile - ( - "particlesDict", - Control.settings().path(), - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ), - "particlesDict" - ); + fileDictionary cpDict("particlesDict", Control.settings().path()); + - auto& cpDict = objCPDict().getObject(); - - pointStructure* pStructPtr = nullptr; + uniquePtr pStructPtr = nullptr; if(!setOnly) @@ -100,24 +89,11 @@ int main( int argc, char* argv[] ) auto finalPos = pointPosition().getFinalPosition(); - - auto& pStruct = Control.time().emplaceObject - ( - objectFile - ( - pointStructureFile__, - Control.time().path(), - objectFile::READ_NEVER, - objectFile::WRITE_ALWAYS - ), - Control, - finalPos - ); + pStructPtr = makeUnique(Control, finalPos); - pStructPtr = &pStruct; - REPORT(1)<< "Created pStruct with "<< pStruct.size() << " points and capacity "<< - pStruct.capacity()<<" . . ."<< END_REPORT; + REPORT(1)<< "Created pStruct with "<< pStructPtr().size() << " points and capacity "<< + pStructPtr().capacity()<<" . . ."<< END_REPORT; //REPORT(1)<< "Writing pStruct to " << Control.time().path()+ pointStructureFile__<< END_REPORT< - ( - objectFile - ( - pointStructureFile__, - Control.time().path(), - objectFile::READ_NEVER, - objectFile::WRITE_ALWAYS - ), - Control - ); - - pStructPtr = &pStruct; + // read the content of pStruct from 0/pStructure + pStructPtr = makeUnique(Control); } diff --git a/utilities/particlesPhasicFlow/positionParticles/positionParticles.cpp b/utilities/particlesPhasicFlow/positionParticles/positionParticles.cpp index 7ad046f6..a7d3879a 100755 --- a/utilities/particlesPhasicFlow/positionParticles/positionParticles.cpp +++ b/utilities/particlesPhasicFlow/positionParticles/positionParticles.cpp @@ -19,6 +19,7 @@ Licence: -----------------------------------------------------------------------------*/ #include "positionParticles.hpp" +#include "vocabs.hpp" #include "box.hpp" #include "cylinder.hpp" #include "sphere.hpp" @@ -101,7 +102,18 @@ pFlow::positionParticles::positionParticles } else { - region_ = makeUnique>( control.domainDict().subDict("globalBox")); + fileDictionary domainDict + ( + objectFile + { + domainFile__, + "", + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + }, + &control.settings() + ); + region_ = makeUnique>( domainDict.subDict("globalBox")); } }