diff --git a/solvers/iterateSphereParticles/iterateSphereParticles.cpp b/solvers/iterateSphereParticles/iterateSphereParticles.cpp index fee9c6a5..30c181ba 100755 --- a/solvers/iterateSphereParticles/iterateSphereParticles.cpp +++ b/solvers/iterateSphereParticles/iterateSphereParticles.cpp @@ -57,7 +57,7 @@ bool isCoupling = false; if(!cmds.parse(argc, argv)) return 0; // this should be palced in each main -processors::initProcessors(argc, argv); +processors::initProcessors(argc, argv); initialize_pFlowProcessors(); #include "initialize_Control.hpp" diff --git a/solvers/sphereGranFlow/createDEMComponents.hpp b/solvers/sphereGranFlow/createDEMComponents.hpp index 6fcbde29..57c5866d 100755 --- a/solvers/sphereGranFlow/createDEMComponents.hpp +++ b/solvers/sphereGranFlow/createDEMComponents.hpp @@ -36,10 +36,9 @@ REPORT(0)<<"\nCreating particle insertion object . . ."< +/*template bool pFlow::Insertion::readInsertionDict ( const dictionary& dict @@ -65,6 +65,33 @@ bool pFlow::Insertion::writeInsertionDict } return true; +}*/ + +template +bool +pFlow::Insertion::setInsertionRegions() +{ + regions_.clear(); + + if( !this->isActive() ) + { + return true; + } + + wordList regionDicNames = this->dictionaryKeywords(); + + for(const auto& name:regionDicNames) + { + REPORT(2)<<"reading insertion region "<< Green_Text(name)<>( + name, + *this, + shapes_)); + } + + return true; + } template @@ -75,11 +102,14 @@ pFlow::Insertion::Insertion( insertion(prtcl), shapes_(shapes) { - - + if(!setInsertionRegions()) + { + fatalErrorInFunction; + fatalExit; + } } -template +/*template pFlow::Insertion::Insertion( fileSystem file, particles& prtcl, @@ -95,13 +125,14 @@ pFlow::Insertion::Insertion( file< bool pFlow::Insertion::insertParticles ( - real currentTime, + uint32 iter, + real t, real dt ) { @@ -112,21 +143,21 @@ bool pFlow::Insertion::insertParticles { bool insertionOccured = false; auto& rgn = regions_[i]; - if( rgn.insertionTime(currentTime, dt) ) + if( rgn.insertionTime(iter, t, dt) ) { realx3Vector pos; wordVector shapes; - if( rgn.insertParticles(currentTime, dt, shapes, pos, insertionOccured) ) + if( rgn.insertParticles(iter, t, dt, shapes, pos, insertionOccured) ) { if(insertionOccured) { - REPORT(0)<<"\nParticle insertion from "<< greenText(rgn.name())<::insertParticles return false; } REPORT(1)<<"Total number of particles inserted from this region is "<< - cyanText(rgn.totalInserted())<<'\n'<::insertParticles { if(insertionOccured) { - yWARNING<< "\n fewer number of particles are inserted from region "<< rgn.name() << - " than expected. You may stop the simulation to change settings."<::insertParticles } -template +/*template bool pFlow::Insertion::read ( iIstream& is @@ -217,4 +254,4 @@ bool pFlow::Insertion::write } return true; -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/src/Particles/Insertion/Insertion/Insertion.hpp b/src/Particles/Insertion/Insertion/Insertion.hpp index 09841253..1e55bdb2 100644 --- a/src/Particles/Insertion/Insertion/Insertion.hpp +++ b/src/Particles/Insertion/Insertion/Insertion.hpp @@ -2,30 +2,28 @@ O C enter of O O E ngineering and O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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 __Insertion_hpp__ #define __Insertion_hpp__ - -#include "insertion.hpp" -#include "ListPtr.hpp" #include "InsertionRegion.hpp" +#include "ListPtr.hpp" +#include "insertion.hpp" #include "particles.hpp" namespace pFlow @@ -34,57 +32,56 @@ namespace pFlow /** * This class manages all the insertion regions for particles insertion * in the simulation. - * + * * Any number of insertion regions can be defined in a simulation. The - * data for particle insertion is provided in particleInsertion file, which - * looks like this. A list of insertion regions (class insertionRegion) can be defined in this file. - * For more information see file insertionRegion.hpp. + * data for particle insertion is provided in particleInsertion file, which + * looks like this. A list of insertion regions (class insertionRegion) can be +defined in this file. + * For more information see file insertionRegion.hpp. * \verbatim active yes; region1 { - // the data for insertionRegion + // the data for insertionRegion } region2 { - // Data for insertionRegion + // Data for insertionRegion } \endverbatim */ template -class Insertion -: - public insertion +class Insertion : public insertion { -protected: +private: - const ShapeType& shapes_; + const ShapeType& shapes_; - // - insertion regions - ListPtr> regions_; + // - insertion regions + ListPtr> regions_; - bool readInsertionDict(const dictionary& dict); + bool setInsertionRegions(); - bool writeInsertionDict(dictionary& dict)const; + // bool readInsertionDict(const dictionary& dict); + + // bool writeInsertionDict(dictionary& dict)const; public: - TypeInfoTemplateNV("Insertion",ShapeType); + TypeInfoTemplateNV11("Insertion", ShapeType); Insertion(particles& prtcl, const ShapeType& shapes); - Insertion(fileSystem file, particles& prtcl, const ShapeType& shapes); + // Insertion(fileSystem file, particles& prtcl, const ShapeType& shapes); + bool insertParticles(uint32 iter, real t, real dt); - bool insertParticles(real currentTime, real dt); - - virtual bool read(iIstream& is) override; - - virtual bool write(iOstream& os)const override; + /*virtual bool read(iIstream& is) override; + virtual bool write(iOstream& os)const override;*/ }; } diff --git a/src/Particles/Insertion/InsertionRegion/InsertionRegion.cpp b/src/Particles/Insertion/InsertionRegion/InsertionRegion.cpp index 57404bf7..dda67f80 100644 --- a/src/Particles/Insertion/InsertionRegion/InsertionRegion.cpp +++ b/src/Particles/Insertion/InsertionRegion/InsertionRegion.cpp @@ -39,21 +39,21 @@ bool pFlow::InsertionRegion::checkForContact template pFlow::InsertionRegion::InsertionRegion ( - const dictionary& dict, + const word& name, + const insertion& instn, const ShapeType& shapes ) : - insertionRegion(dict), + insertionRegion(name, instn), shapes_(shapes) -{ - -} +{} template bool pFlow::InsertionRegion::insertParticles ( - real currentTime, + uint32 iter, + real t, real dt, wordVector& names, realx3Vector& pos, @@ -62,9 +62,9 @@ bool pFlow::InsertionRegion::insertParticles { insertionOccured = false; - if(!insertionTime( currentTime, dt)) return true; + if(!insertionTime(iter, t, dt)) return true; - size_t newNum = numberToBeInserted(currentTime); + uint32 newNum = numberToBeInserted(iter, t, dt); if(newNum == 0) return true; @@ -73,43 +73,49 @@ bool pFlow::InsertionRegion::insertParticles names.clear(); pos.clear(); - realVector diams(newNum, RESERVE()); + realVector diams("diams", newNum, 0, RESERVE()); - mixture_->getNextShapeNameN(newNum, names); - - if(!shapes_.shapeToDiameter(names,diams)) + for(uint32 i=0; i -class InsertionRegion -: - public insertionRegion +class InsertionRegion + : public insertionRegion { -protected: +private: /// Ref to Shapes - const ShapeType& shapes_; + const ShapeType& shapes_; - static bool checkForContact( - const realx3Vector& pos, - const realVector& diams, - const realx3& p, - const real& d); + static bool checkForContact( + const realx3Vector& pos, + const realVector& diams, + const realx3& p, + const real& d + ); public: /// Type info - TypeInfoTemplateNV("insertionRegion", ShapeType); + TypeInfoTemplateNV11("insertionRegion", ShapeType); // - Constructors - /// Construct from dictionary - InsertionRegion(const dictionary& dict, const ShapeType& shapes); + /// Construct from dictionary + InsertionRegion( + const word& name, + const insertion& instn, + const ShapeType& shapes + ); - /// Copy - InsertionRegion(const InsertionRegion& ) = default; - - /// Move - InsertionRegion(InsertionRegion&&) = default; - - /// Copy assignment - InsertionRegion& operator=(const InsertionRegion& ) = default; - - /// Copy assignment - InsertionRegion& operator=(InsertionRegion&&) = default; - - /// Clone - auto clone()const - { - return makeUnique>(*this); - } - - /// Clone ptr - auto clonePtr()const - { - return new InsertionRegion(*this); - } + ~InsertionRegion() = default; // - Methods - - /// Insert particles at currentTime - /// Check if currentTime is the right moment for - /// particle insertion. Fill the vectors name, pos and signal - /// if particle insertion occured or not. - bool insertParticles - ( - real currentTime, - real dt, - wordVector& names, - realx3Vector& pos, - bool& insertionOccured - ); - //bool read(const dictionary& dict); + /// Insert particles at current time t + /// Check if currentTime is the right moment for + /// particle insertion. Fill the vectors name, pos and signal + /// if particle insertion occured or not. + bool insertParticles( + uint32 iter, + real t, + real dt, + wordVector& names, + realx3Vector& pos, + bool& insertionOccured + ); - //bool write(dictionary& dict)const; + // bool read(const dictionary& dict); + // bool write(dictionary& dict)const; }; - - } // pFlow - #include "InsertionRegion.cpp" #endif diff --git a/src/Particles/Insertion/insertion/insertion.cpp b/src/Particles/Insertion/insertion/insertion.cpp index 18b53d2c..e2f909c4 100644 --- a/src/Particles/Insertion/insertion/insertion.cpp +++ b/src/Particles/Insertion/insertion/insertion.cpp @@ -2,73 +2,96 @@ O C enter of O O E ngineering and O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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 "particles.hpp" -#include "dictionary.hpp" #include "insertion.hpp" +#include "particles.hpp" #include "streams.hpp" +#include "systemControl.hpp" +#include "vocabs.hpp" -bool pFlow::insertion::readInsertionDict -( - const dictionary& dict -) +pFlow::insertion::insertion(particles& prtcl) + : fileDictionary( + objectFile( + insertionFile__, + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_NEVER + ), + &prtcl.control().caseSetup() + ), + particles_(prtcl) { + readInsertionDict(*this); +} +bool +pFlow::insertion::read(iIstream& is, const IOPattern& iop) +{ + if (fileDictionary::read(is, iop)) + { + readFromFile_ = true; + return true; + } + else + { + return false; + } +} + +bool +pFlow::insertion::readInsertionDict(const dictionary& dict) +{ active_ = dict.getVal("active"); - if(active_) - REPORT(1)<< "Particle insertion mechanism is "<< - yellowText("active")<<" in the simulation."< +bool +setOneEntry(const twoPartEntry& tpEntry, anyList& varList) +{ + if (getTypeName() != tpEntry.firstPart()) + return false; - name_ = dict.name(); - type_ = dict.getVal("type"); - - pRegion_ = peakableRegion::create(type_, dict.subDict(type_+"Info")); - - mixture_ = makeUnique(dict.subDict("mixture")); + T val = tpEntry.secondPartVal(); + varList.emplaceBack(tpEntry.keyword(), val); - addToNumInserted(mixture_().totalInserted()); + return true; +} - if( !dict.containsDictionay("setFields")) +bool +readOneEtrty(const dataEntry& entry, anyList& varList) +{ + twoPartEntry stField(entry); + + if (!(setOneEntry(stField, varList) || + setOneEntry(stField, varList) || + setOneEntry(stField, varList) || + setOneEntry(stField, varList) || + setOneEntry(stField, varList) || + setOneEntry(stField, varList) || + setOneEntry(stField, varList) || + setOneEntry(stField, varList) || + setOneEntry(stField, varList))) { - output<<"\n insertion region "<< name_ << " does not contain setFields dictionary." - " An empty dictoiinary is created for it. \n"; - setFields_ = makeUnique( dictionary("setFields") ); + fatalErrorInFunction << "un-supported data type " << stField.firstPart() + << endl; + return false; } - else + return true; +} +} + +bool +pFlow::insertionRegion::readInsertionRegion(const dictionary& dict) +{ + type_ = dict.getVal("regionType"); + + rate_ = dict.getVal("rate"); + + pRegion_ = peakableRegion::create(type_, dict.subDict(type_ + "Info")); + + mixture_ = makeUnique( + dict.subDict("mixture"), + insertion_.Particles().getShapes().shapeNameList() + ); + + numInserted_ = mixture_().totalInserted(); + + if (dict.containsDictionay("setFields")) { - setFields_ = makeUnique( dict.subDict("setFields") ); + setFieldDict_ = + makeUnique("setFields", dict, dict.subDict("setFields")); } - for(auto& sfEntry:setFields_()) + if (setFieldDict_) { - if(!sfEntry.checkForTypeAndValueAll()) + if (!readSetFieldDict()) { - fatalErrorInFunction<< - " error in setFields dictionary "<< dict.globalName()<clone(): nullptr), - mixture_( src.mixture_? src.mixture_->clone(): nullptr), - setFields_( src.setFields_? src.setFields_->clone(): nullptr) -{} - -pFlow::insertionRegion& pFlow::insertionRegion::operator= -( - const insertionRegion& src -) +pFlow::uint32 +pFlow::insertionRegion::numberToBeInserted(uint32 iter, real t, real dt) { + if (!tControl_.isInRange(iter, t, dt)) + return 0u; - if(&src == this)return *this; - timeFlowControl::operator=(src); - - name_ = src.name_; - type_ = src.type_; - pRegion_ = (src.pRegion_? src.pRegion_->clone(): nullptr); - mixture_ = (src.mixture_? src.mixture_->clone(): nullptr); - setFields_ = (src.setFields_? src.setFields_->clone(): nullptr); - - return *this; + if (tControl_.isTimeStep()) + { + return static_cast( + (iter - tControl_.startIter() + tControl_.iInterval()) * dt * rate_ - + numInserted_ + ); + } + else + { + return static_cast( + (t - tControl_.startTime() + tControl_.rInterval()) * rate_ - + numInserted_ + ); + } } - - diff --git a/src/Particles/Insertion/insertionRegion/insertionRegion.hpp b/src/Particles/Insertion/insertionRegion/insertionRegion.hpp index d0f6ea5d..2e9c3eb1 100644 --- a/src/Particles/Insertion/insertionRegion/insertionRegion.hpp +++ b/src/Particles/Insertion/insertionRegion/insertionRegion.hpp @@ -2,17 +2,17 @@ O C enter of O O E ngineering and O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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. @@ -21,52 +21,54 @@ Licence: #ifndef __insertionRegion_hpp__ #define __insertionRegion_hpp__ -#include "timeFlowControl.hpp" +#include "anyList.hpp" +#include "baseTimeControl.hpp" +#include "peakableRegion.hpp" #include "shapeMixture.hpp" -#include "peakableRegions.hpp" -#include "setFieldList.hpp" namespace pFlow { class dictionary; +class insertion; /** * This class defines all the necessary enteties for defining an insertion - * region. - * - * Insertion region information are supplied through a dictionary in a file. + * region. + * + * Insertion region information are supplied through a dictionary in a file. * For example: \verbatim { - type cylinderRegion; // type of insertion region - rate 15000; // insertion rate (particles/s) - startTime 0; // (s) - endTime 0.5; // (s) - interval 0.025; // (s) + type cylinderRegion; // type of insertion region + rate 15000; // insertion rate (particles/s) + startTime 0; // (s) + endTime 0.5; // (s) + interval 0.025; // (s) - cylinderRegionInfo - { - radius 0.09; // radius of cylinder (m) - p1 (0.0 0.0 0.10); // (m,m,m) - p2 (0.0 0.0 0.11); // (m,m,m) - } - - setFields - { - velocity realx3 (0.0 0.0 -0.6); // initial velocity of inserted particles - } - - mixture - { - lightSphere 1; // mixture composition of inserted particles - } + cylinderRegionInfo + { + radius 0.09; // radius of cylinder (m) + p1 (0.0 0.0 0.10); // (m,m,m) + p2 (0.0 0.0 0.11); // (m,m,m) + } + + setFields + { + velocity realx3 (0.0 0.0 -0.6); // initial velocity of inserted +particles + } + + mixture + { + lightSphere 1; // mixture composition of inserted particles + } } \endverbatim - * + * * More information on the above dictionary entries can be found in * the table below. - * - * + * + * * | Parameter | Type | Description | Optional [default value] | * |----| :---: | ---- | ---- | * | type | word | type of the insertion region with name ### | No | @@ -75,31 +77,51 @@ class dictionary; * | endTime | real | end of insertion (s) | No | * | interval | real | time interval between successive insertions (s) | No | * | ###Info | dictionary | data for insertion region | No | - * | setFields | dictionary | set field for inserted particles (s) | Yes [empty dictionray] | + * | setFields | dictionary | set field for inserted particles (s) | Yes [empty +dictionray] | * | mixture | dictionary | mixture of particles to be inserted (s) | No | - * + * */ class insertionRegion -: - public timeFlowControl { -protected: +private: - /// name of the region - word name_; + /// name of this region + const word name_; + + /// insertion region dictionary + const dictionary& dict_; + + /// ref to pointStructure + const insertion& insertion_; + + /// @brief time control for insertion events + baseTimeControl tControl_; + + /// rate of insertion + real rate_; + + /// number of inserted particles + uint32 numInserted_ = 0; /// type of insertion region - word type_; + word type_; /// peakable region of points - uniquePtr pRegion_ = nullptr; + uniquePtr pRegion_ = nullptr; - /// mixture of shapes - uniquePtr mixture_ = nullptr; + /// mixture of shapes + uniquePtr mixture_ = nullptr; - /// setFields for insertion region - uniquePtr setFields_ = nullptr; + /// @brief dictionary for set field + uniquePtr setFieldDict_ = nullptr; + /// list of (filedName type value) for the fields + anyList setFieldList_; + +private: + + // - private methods /// read from dictionary bool readInsertionRegion(const dictionary& dict); @@ -107,6 +129,7 @@ protected: /// write to dictionary bool writeInsertionRegion(dictionary& dict) const; + bool readSetFieldDict(); public: @@ -115,58 +138,83 @@ public: // - Constructors - /// Construct from a dictionary - insertionRegion(const dictionary& dict); + /// Construct from a dictionary + insertionRegion(const word& name, const insertion& instn); - /// Copy - insertionRegion(const insertionRegion& src); + /// Destructor + ~insertionRegion() = default; - /// Move - insertionRegion(insertionRegion&&) = default; + // - Methods - /// Copy assignment - insertionRegion& operator=(const insertionRegion&); + /// Const ref to name of the region + const auto& name() const + { + return name_; + } - /// Move assignment - insertionRegion& operator=(insertionRegion&&) = default; + /// return type of insertion region + const auto& type() const + { + return type_; + } - /// Destructor - ~insertionRegion() = default; + const auto& Insertion() const + { + return insertion_; + } + inline bool insertionTime(uint32 iter, real t, real dt) const + { + return tControl_.timeEvent(iter, t, dt); + } - // - Methods + uint32 numberToBeInserted(uint32 iter, real t, real dt); - /// Const ref to setFields - const auto& setFields()const - { - return setFields_(); - } + inline uint32 addToNumInserted(uint32 newInserted) + { + return numInserted_ += newInserted; + } - /// Const ref to name of the region - const auto& name()const - { - return name_; - } + inline uint32 totalInserted() const + { + return numInserted_; + } + auto& mixture() + { + return mixture_(); + } + + auto& pRegion() + { + return pRegion_(); + } + + const auto& setFieldList() const + { + return setFieldList_; + } // - IO operation - /// read from dictionary - bool read(const dictionary& dict) - { - if(!timeFlowControl::read(dict))return false; + /// read from dictionary + /*bool read(const dictionary& dict) + { + if (!timeFlowControl::read(dict)) + return false; - return readInsertionRegion(dict); - } + return readInsertionRegion(dict); + } - /// write to dictionary - bool write(dictionary& dict)const - { - if(!timeFlowControl::write(dict)) return false; + /// write to dictionary + bool write(dictionary& dict) const + { + if (!timeFlowControl::write(dict)) + return false; - return writeInsertionRegion(dict); - } + return writeInsertionRegion(dict); + }*/ }; -} //pFlow +} // pFlow #endif //__insertionRegion_hpp__ diff --git a/src/Particles/Insertion/insertionRegion/timeFlowControl.cpp b/src/Particles/Insertion/insertionRegion/timeFlowControl.cpp deleted file mode 100644 index d92241aa..00000000 --- a/src/Particles/Insertion/insertionRegion/timeFlowControl.cpp +++ /dev/null @@ -1,83 +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. - ------------------------------------------------------------------------------*/ - -#include "timeFlowControl.hpp" -#include "dictionary.hpp" - -size_t pFlow::timeFlowControl::numberToBeInserted(real currentTime) -{ - if(currentTimeendTime_) return 0; - - return static_cast - ( - (currentTime - startTime_ + interval_)*rate_ - numInserted_ - ); -} - -bool pFlow::timeFlowControl::readTimeFlowControl -( - const dictionary& dict -) -{ - rate_ = dict.getVal("rate"); - startTime_ = dict.getVal("startTime"); - endTime_ = dict.getVal("endTime"); - interval_ = dict.getVal("interval"); - numInserted_=0; - return true; -} - -bool pFlow::timeFlowControl::writeTimeFlowControl -( - dictionary& dict -) const -{ - if(!dict.add("rate", rate_)) return false; - if(!dict.add("startTime", startTime_)) return false; - if(!dict.add("endTime", endTime_)) return false; - if(!dict.add("interval", interval_)) return false; - - return true; -} - - -pFlow::timeFlowControl::timeFlowControl -( - const dictionary& dict -) -{ - - if(!readTimeFlowControl(dict)) - { - fatalExit; - } - -} - -bool pFlow::timeFlowControl::insertionTime( real currentTime, real dt) -{ - if(currentTime < startTime_) return false; - - if(currentTime > endTime_) return false; - if( mod(abs(currentTime-startTime_),interval_)/dt < 1 ) return true; - - return false; -} \ No newline at end of file diff --git a/src/Particles/Insertion/insertionRegion/timeFlowControl.hpp b/src/Particles/Insertion/insertionRegion/timeFlowControl.hpp deleted file mode 100644 index 5ac963dd..00000000 --- a/src/Particles/Insertion/insertionRegion/timeFlowControl.hpp +++ /dev/null @@ -1,101 +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 __timeFlowControl_hpp__ -#define __timeFlowControl_hpp__ - -#include "types.hpp" -#include "streams.hpp" - -namespace pFlow -{ - -class dictionary; - -/** - * Time control for particle insertion - */ -class timeFlowControl -{ -protected: - - /// start time of insertion - real startTime_; - - /// end time of insertion - real endTime_; - - /// time interval between each insertion - real interval_; - - /// rate of insertion - real rate_; - - /// number of inserted particles - size_t numInserted_ = 0; - - - /// Read dictionary - bool readTimeFlowControl(const dictionary& dict); - - /// Write to dictionary - bool writeTimeFlowControl(dictionary& dict) const; - - /// Return number of particles to be inserted at time currentTime - size_t numberToBeInserted(real currentTime); - - /// Add to numInserted - inline - size_t addToNumInserted(size_t newInserted) - { - return numInserted_ += newInserted; - } - -public: - - /// Construct from dictionary - timeFlowControl(const dictionary& dict); - - /// Is currentTime the insertion moment? - bool insertionTime( real currentTime, real dt); - - /// Total number inserted so far - size_t totalInserted()const - { - return numInserted_; - } - - /// Read from dictionary - bool read(const dictionary& dict) - { - return readTimeFlowControl(dict); - } - - /// Write to dictionary - bool write(dictionary& dict)const - { - return writeTimeFlowControl(dict); - } - -}; - -} - -#endif //__timeFlowControl_hpp__ diff --git a/src/Particles/Insertion/shapeMixture/shapeMixture.cpp b/src/Particles/Insertion/shapeMixture/shapeMixture.cpp index 041f71dc..1038af15 100755 --- a/src/Particles/Insertion/shapeMixture/shapeMixture.cpp +++ b/src/Particles/Insertion/shapeMixture/shapeMixture.cpp @@ -2,150 +2,167 @@ O C enter of O O E ngineering and O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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 "shapeMixture.hpp" #include "dictionary.hpp" - -pFlow::shapeMixture::shapeMixture -( - const dictionary & dict +pFlow::shapeMixture::shapeMixture( + const dictionary& dict, + const wordList& validNames ) { - if( !read(dict)) + if (!read(dict)) { fatalExit; } + + for (const auto& rN : names_) + { + bool found = false; + for (const auto& vN : validNames) + { + if (rN == vN) + { + found = true; + break; + } + } + + if (!found) + { + fatalErrorInFunction + << "Shape name " << rN << " provided in mixture dictionary " + << dict.globalName() << " is invalid. \n Valid names are " + << validNames << endl; + } + } } -pFlow::word pFlow::shapeMixture::getNextShapeName() +pFlow::word +pFlow::shapeMixture::getNextShapeName() { - ForAll(i, names_) { - if(current_[i]< number_[i]) + if (current_[i] < number_[i]) { current_[i]++; numberInserted_[i]++; return names_[i]; } } - + fill(current_, static_cast(0)); return getNextShapeName(); } -void pFlow::shapeMixture::getNextShapeNameN -( - size_t n, - wordVector& names -) +void +pFlow::shapeMixture::getNextShapeNameN(size_t n, wordVector& names) { names.clear(); - - for(label i=0; i(nm); - if( num <= 0 ) - { - fatalErrorInFunction<< - " number inserte in front of "<< nm << " is invalid: "<< num<(nm); + if (num <= 0) + { + fatalErrorInFunction << " number inserte in front of " << nm + << " is invalid: " << num << endl + << " in dictionary " << dict.globalName() + << endl; + return false; + } + number_.push_back(num); + } - if(containNumberIneserted) - { - numberInserted_ = dict.getVal("numberInserted"); - } - else - { - numberInserted_ = uint32Vector(size(), static_cast(0)); - } + if (containNumberIneserted) + { + numberInserted_ = dict.getVal("numberInserted"); + } + else + { + numberInserted_ = + uint32Vector(numberInserted_.name(), size(), static_cast(0)); + } - if(numberInserted_.size() != names_.size() ) - { - fatalErrorInFunction<< - " number of elements in numberInserted ("<(*this); } - /// Polymorphic copy - shapeMixture* clonePtr()const - { - return new shapeMixture(*this); - } - - /// Destructor ~shapeMixture() = default; diff --git a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp index 01579677..55eb3660 100644 --- a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp +++ b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp @@ -198,7 +198,7 @@ bool pFlow::sphereParticles::initializeParticles() }*/ -bool pFlow::sphereParticles::initInertia() +bool pFlow::sphereParticles::initializeParticles() { using exeSpace = typename realPointField_D::execution_space; @@ -255,6 +255,55 @@ bool pFlow::sphereParticles::initInertia() return true; } +bool +pFlow::sphereParticles::getParticlesInfoFromShape( + const wordVector& shapeNames, + uint32Vector& propIds, + realVector& diams, + realVector& m, + realVector& Is, + uint32Vector& shIndex +) +{ + auto numNew = static_cast(shapeNames.size()); + + propIds.clear(); + propIds.reserve(numNew); + + diams.clear(); + diams.reserve(numNew); + + m.clear(); + m.reserve(numNew); + + Is.clear(); + Is.reserve(numNew); + + shIndex.clear(); + shIndex.reserve(numNew); + + + for(const auto& name:shapeNames) + { + uint32 indx; + if(spheres_.shapeNameToIndex(name,indx)) + { + shIndex.push_back(indx); + Is.push_back( spheres_.Inertia(indx)); + m.push_back(spheres_.mass(indx)); + diams.push_back(spheres_.boundingDiameter(indx)); + propIds.push_back( spheres_.propertyId(indx)); + } + else + { + fatalErrorInFunction<<"Shape name "<< name << + "does not exist. The list is "< rVelIntegration_ = nullptr; + /// rotational velocity integrator + uniquePtr rVelIntegration_ = nullptr; - /// timer for acceleration computations - Timer accelerationTimer_; + /// timer for acceleration computations + Timer accelerationTimer_; /// timer for integration computations (prediction step) - Timer intPredictTimer_; + Timer intPredictTimer_; /// timer for integration computations (correction step) - Timer intCorrectTimer_; + Timer intCorrectTimer_; - bool initInertia(); + +private: + bool initializeParticles(); + + bool getParticlesInfoFromShape( + const wordVector& shapeNames, + uint32Vector& propIds, + realVector& diams, + realVector& m, + realVector& Is, + uint32Vector& shIndex + ); /*bool initializeParticles(); bool insertSphereParticles( - const wordVector& names, - const int32IndexContainer& indices, - bool setId = true); + const wordVector& names, + const int32IndexContainer& indices, + bool setId = true); virtual uniquePtr> getFieldObjectList()const override; */ public: - /// construct from systemControl and property - sphereParticles( - systemControl &control, - const property& prop); + /// construct from systemControl and property + sphereParticles(systemControl& control, const property& prop); - - ~sphereParticles()override=default; + ~sphereParticles() override = default; /** * Insert new particles in position with specified shapes - * - * This function is involked by inserted object to insert new set of particles - * into the simulation. - * \param position position of new particles + * + * This function is involked by inserted object to insert new set of + * particles into the simulation. \param position position of new particles * \param shape shape of new particles * \param setField initial value of the selected fields for new particles */ /*bool insertParticles ( - const realx3Vector& position, - const wordVector& shapes, - const setFieldList& setField + const realx3Vector& position, + const wordVector& shapes, + const setFieldList& setField ) override ;*/ - /// const reference to shapes object - const auto& spheres()const + /// const reference to shapes object + const auto& spheres() const { return spheres_; } /// const reference to inertia pointField - const auto& I()const + const auto& I() const { return I_; } - /// reference to inertia pointField + /// reference to inertia pointField auto& I() { return I_; } - - const auto& rVelocity()const - { + + const auto& rVelocity() const + { return rVelocity_; } auto& rVelocity() - { + { return rVelocity_; } - bool hearChanges - ( - real t, - real dt, - uint32 iter, - const message& msg, - const anyList& varList + bool hearChanges( + real t, + real dt, + uint32 iter, + const message& msg, + const anyList& varList ) override { notImplementedFunction; return false; } - - const uint32PointField_D& propertyId()const override + const uint32PointField_D& propertyId() const override { return propertyId_; } - - - const realPointField_D& diameter()const override + + const realPointField_D& diameter() const override { return diameter_; } - - const realPointField_D& mass()const override + const realPointField_D& mass() const override { return mass_; } - - /// before iteration step + + /// before iteration step bool beforeIteration() override; - /// iterate particles - bool iterate() override; + /// iterate particles + bool iterate() override; + + bool insertParticles( + const realx3Vector& position, + const wordVector& shapesNames, + const anyList& setVarList + ) override; - realx3PointField_D& rAcceleration() override { return rAcceleration_; @@ -194,20 +200,19 @@ public: { return rAcceleration_; } - - const realPointField_D& boundingSphere()const override + + const realPointField_D& boundingSphere() const override { return diameter(); } - word shapeTypeName()const override; - - const shape& getShapes()const override; + word shapeTypeName() const override; - - void boundingSphereMinMax(real & minDiam, real& maxDiam)const override; - -}; //sphereParticles + const shape& getShapes() const override; + + void boundingSphereMinMax(real& minDiam, real& maxDiam) const override; + +}; // sphereParticles } // pFlow diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp b/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp index 593ca168..c57475ec 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp @@ -78,20 +78,6 @@ pFlow::dynamicPointStructure::dynamicPointStructure } -/*bool pFlow::dynamicPointStructure::beforeIteration() -{ - pointStructure::beforeIteration(); - auto& acc = time().lookupObject("acceleration"); - return predict(dt(), acc); -}*/ - -/*bool pFlow::dynamicPointStructure::iterate() -{ - pointStructure::iterate(); - auto& acc = time().lookupObject("acceleration"); - return correct(dt(), acc); - -}*/ bool pFlow::dynamicPointStructure::beforeIteration() { @@ -137,74 +123,3 @@ bool pFlow::dynamicPointStructure::correct return true; } - -/*FUNCTION_H -pFlow::uniquePtr pFlow::dynamicPointStructure::insertPoints -( - const realx3Vector& pos, - const List& exclusionList -) -{ - auto newIndicesPtr = pointStructure::insertPoints(pos, exclusionList); - - // no new point is inserted - if( !newIndicesPtr ) return newIndicesPtr; - - if(!integrationPos_().needSetInitialVals()) return newIndicesPtr; - - auto hVel = velocity_.hostView(); - auto n = newIndicesPtr().size(); - auto index = newIndicesPtr().indicesHost(); - - realx3Vector velVec(n, RESERVE()); - for(auto i=0; isetInitialVals(newIndicesPtr(), pos ); - integrationVel_->setInitialVals(newIndicesPtr(), velVec ); - - return newIndicesPtr; - -}*/ - - -/*bool pFlow::dynamicPointStructure::update( - const eventMessage& msg) -{ - if( msg.isInsert()) - { - - if(!integrationPos_->needSetInitialVals())return true; - - const auto indexHD = pStruct().insertedPointIndex(); - - - auto n = indexHD.size(); - - if(n==0) return true; - - auto index = indexHD.indicesHost(); - - realx3Vector pos(n,RESERVE()); - realx3Vector vel(n,RESERVE()); - const auto hVel = velocity().hostView(); - const auto hPos = pStruct().pointPosition().hostView(); - - for(auto i=0; isetInitialVals(indexHD, pos); - - integrationVel_->setInitialVals(indexHD, vel); - - } - - return true; -}*/ \ No newline at end of file diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp b/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp index 1195f389..0e6a9fcd 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp @@ -87,11 +87,10 @@ public: /// when the component should evolve along time. bool iterate() override; - - - + /// prediction step (if any), is called in beforeIteration bool predict(real dt, realx3PointField_D& acceleration); + /// correction step, is called in iterate bool correct(real dt, realx3PointField_D& acceleration); }; diff --git a/src/Particles/particles/particleIdHandler.cpp b/src/Particles/particles/particleIdHandler/particleIdHandler.cpp similarity index 53% rename from src/Particles/particles/particleIdHandler.cpp rename to src/Particles/particles/particleIdHandler/particleIdHandler.cpp index c5bae004..66eeb228 100644 --- a/src/Particles/particles/particleIdHandler.cpp +++ b/src/Particles/particles/particleIdHandler/particleIdHandler.cpp @@ -20,25 +20,69 @@ Licence: #include "particleIdHandler.hpp" -pFlow::particleIdHandler::particleIdHandler(uint32PointField_D &id) +pFlow::particleIdHandler::particleIdHandler(pointStructure& pStruct) : - id_(id) + uint32PointField_D + ( + objectFile + ( + "id", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS + ), + pStruct, + static_cast(-1), + static_cast(-1) + ) { + } -pFlow::uniquePtr - pFlow::particleIdHandler::create(uint32PointField_D &id) +bool +pFlow::particleIdHandler::hearChanges( + real t, + real dt, + uint32 iter, + const message& msg, + const anyList& varList +) +{ + if(msg.equivalentTo(message::ITEM_INSERT)) + { + const word eventName = message::eventName(message::ITEM_INSERT); + + const auto& indices = varList.getObject( + eventName); + + uint32 numNew = indices.size(); + if(numNew == 0u)return true; + + auto idRange = getIdRange(numNew); + uint32Vector newId("newId",numNew,numNew,RESERVE()); + fillSequence(newId, idRange.first); + output<< "id "<< idRange<field().insertSetElement(indices, newId); + } + else + { + return uint32PointField_D::hearChanges(t,dt,iter, msg,varList); + } +} + +pFlow::uniquePtr +pFlow::particleIdHandler::create(pointStructure& pStruct) { word idHType = angleBracketsNames( "particleIdHandler", pFlowProcessors().localRunTypeName()); - if( pointFieldvCtorSelector_.search(idHType) ) + if( pointStructurevCtorSelector_.search(idHType) ) { REPORT(1)<<"Creating particle id handler "<< Green_Text(idHType)< fatalError << "Ctor Selector "<< idHType << " dose not exist. \n" <<"Avaiable ones are: \n\n" , - pointFieldvCtorSelector_ + pointStructurevCtorSelector_ ); fatalExit; } diff --git a/src/Particles/particles/particleIdHandler.hpp b/src/Particles/particles/particleIdHandler/particleIdHandler.hpp similarity index 74% rename from src/Particles/particles/particleIdHandler.hpp rename to src/Particles/particles/particleIdHandler/particleIdHandler.hpp index 9ec528de..11344336 100644 --- a/src/Particles/particles/particleIdHandler.hpp +++ b/src/Particles/particles/particleIdHandler/particleIdHandler.hpp @@ -28,34 +28,26 @@ namespace pFlow { class particleIdHandler +: + public uint32PointField_D { -private: - - uint32PointField_D& id_; - -protected: - - auto& id() - { - return id_; - } - + public: - TypeInfo("particleIdHandler"); + /// class info + ClassInfo("particleIdHandler"); - explicit particleIdHandler(uint32PointField_D & id); + explicit particleIdHandler(pointStructure& pStruct); create_vCtor ( particleIdHandler, - pointField, - (uint32PointField_D & id), - (id) + pointStructure, + (pointStructure& pStruct), + (pStruct) ); - virtual - ~particleIdHandler()=default; + ~particleIdHandler()override=default; virtual Pair getIdRange(uint32 nNewParticles)=0; @@ -63,9 +55,20 @@ public: virtual bool initialIdCheck()=0; + // heat change for possible insertion of particles + // overrdie from internalField + bool hearChanges + ( + real t, + real dt, + uint32 iter, + const message& msg, + const anyList& varList + ) override; + static uniquePtr create( - uint32PointField_D & id); + pointStructure& pStruct); }; diff --git a/src/Particles/particles/particles.cpp b/src/Particles/particles/particles.cpp index 7b3a41d6..b6a389ab 100644 --- a/src/Particles/particles/particles.cpp +++ b/src/Particles/particles/particles.cpp @@ -2,119 +2,111 @@ O C enter of O O E ngineering and O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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 "particles.hpp" - -pFlow::particles::particles -( - systemControl &control -) -: - observer(defaultMessage_), - demComponent("particles", control), - dynPointStruct_(control), - id_ - ( - objectFile - ( - "id", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS - ), - dynPointStruct_, - static_cast(-1), - static_cast(-1) - ), - shapeIndex_ - ( - objectFile - ( - "shapeIndex", - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ), - dynPointStruct_, - 0 - ), - accelertion_ - ( - objectFile( - "accelertion", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS), - dynPointStruct_, - zero3 - ), - contactForce_( - objectFile( - "contactForce", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS), - dynPointStruct_, - zero3), - contactTorque_( - objectFile( - "contactTorque", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS), - dynPointStruct_, - zero3), - idHandler_(particleIdHandler::create(id_)) +pFlow::particles::particles(systemControl& control) + : observer(defaultMessage_), + demComponent("particles", control), + dynPointStruct_(control), + /*id_( + objectFile( + "id", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS + ), + dynPointStruct_, + static_cast(-1), + static_cast(-1) + ),*/ + shapeIndex_( + objectFile( + "shapeIndex", + "", + objectFile::READ_ALWAYS, + objectFile::WRITE_ALWAYS + ), + dynPointStruct_, + 0 + ), + accelertion_( + objectFile( + "accelertion", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS + ), + dynPointStruct_, + zero3 + ), + contactForce_( + objectFile( + "contactForce", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS + ), + dynPointStruct_, + zero3 + ), + contactTorque_( + objectFile( + "contactTorque", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS + ), + dynPointStruct_, + zero3 + ), + idHandler_(particleIdHandler::create(dynPointStruct_)) { this->addToSubscriber(dynPointStruct_); idHandler_().initialIdCheck(); - } -bool pFlow::particles::beforeIteration() +bool +pFlow::particles::beforeIteration() { - zeroForce(); zeroTorque(); return dynPointStruct_.beforeIteration(); } -bool pFlow::particles::iterate() +bool +pFlow::particles::iterate() { return dynPointStruct_.iterate(); } -bool pFlow::particles::afterIteration() +bool +pFlow::particles::afterIteration() { return dynPointStruct_.afterIteration(); } -void pFlow::particles::boundingSphereMinMax -( - real &minDiam, - real &maxDiam -) const +void +pFlow::particles::boundingSphereMinMax(real& minDiam, real& maxDiam) const { auto& shp = getShapes(); + minDiam = shp.minBoundingSphere(); maxDiam = shp.maxBoundingSphere(); -} \ No newline at end of file +} diff --git a/src/Particles/particles/particles.hpp b/src/Particles/particles/particles.hpp index 3ca77237..a06c5c3c 100644 --- a/src/Particles/particles/particles.hpp +++ b/src/Particles/particles/particles.hpp @@ -1,66 +1,63 @@ -/*------------------------------- phasicFlow --------------------------------- - O C enter of - O O E ngineering and - O O M ultiscale modeling of - OOOOOOO F luid flow +/*------------------------------- 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. + 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 __particles_hpp__ #define __particles_hpp__ -#include "dynamicPointStructure.hpp" #include "demComponent.hpp" -#include "shape.hpp" +#include "dynamicPointStructure.hpp" #include "particleIdHandler.hpp" +#include "shape.hpp" namespace pFlow { class particles -: - public observer, - public demComponent + : public observer + , public demComponent { private: - + /// dynamic point structure for particles center mass - dynamicPointStructure dynPointStruct_; + dynamicPointStructure dynPointStruct_; - /// id of particles on host - uint32PointField_D id_; - - - uint32PointField_D shapeIndex_; + /// shape index of each particle + uint32PointField_D shapeIndex_; /// acceleration on device - realx3PointField_D accelertion_; + realx3PointField_D accelertion_; /// contact force field - realx3PointField_D contactForce_; + realx3PointField_D contactForce_; /// contact torque field - realx3PointField_D contactTorque_; + realx3PointField_D contactTorque_; + /// handling new ids for new particles uniquePtr idHandler_ = nullptr; - static inline - const message defaultMessage_{message::DEFAULT}; - - + /// messages for this objects + static inline const message defaultMessage_{ message::DEFAULT }; + +protected: void zeroForce() { @@ -72,8 +69,6 @@ private: contactTorque_.fill(zero3); } -protected: - inline auto& dynPointStruct() { return dynPointStruct_; @@ -81,17 +76,15 @@ protected: inline auto& pointPosition() { - return dynPointStruct_.pointPosition(); + return dynPointStruct_.pointPosition(); } - /*inline - auto& velocity() + inline auto& idHandler() { - return dynPointStruct_.velocity(); - }*/ - - inline - auto& shapeIndex() + return idHandler_(); + } + + inline auto& shapeIndex() { return shapeIndex_; } @@ -103,148 +96,123 @@ public: explicit particles(systemControl& control); - - inline - const auto& dynPointStruct()const + inline const auto& dynPointStruct() const { return dynPointStruct_; } - inline - const pointStructure& pStruct()const + inline const pointStructure& pStruct() const { return dynPointStruct_; } - inline - const auto& simDomain()const + inline const auto& simDomain() const { return dynPointStruct_.simDomain(); } - inline - const auto& thisDomain()const + inline const auto& thisDomain() const { return dynPointStruct_.thisDomain(); } - inline - const auto& extendedDomain()const + inline const auto& extendedDomain() const { return dynPointStruct_.extendedDomain(); } - inline auto size()const{ + inline auto size() const + { return dynPointStruct_.size(); } - inline auto capacity() const{ + inline auto capacity() const + { return dynPointStruct_.capacity(); } - - inline auto numActive()const + + inline auto numActive() const { return dynPointStruct_.numActive(); } - - inline bool isAllActive()const + + inline bool isAllActive() const { return dynPointStruct_.isAllActive(); } - inline - const auto& pointPosition()const + inline const auto& pointPosition() const { return dynPointStruct_.pointPosition(); } - inline - const auto& velocity()const + inline const auto& velocity() const { return dynPointStruct_.velocity(); } - inline - const auto& accelertion()const + inline const auto& accelertion() const { return accelertion_; } - inline - auto& accelertion() + inline auto& accelertion() { return accelertion_; } - inline - auto& contactForce() + inline auto& contactForce() { return contactForce_; } - inline - const auto& contactForce() const + inline const auto& contactForce() const { return contactForce_; } - inline - auto& contactTorque() + inline auto& contactTorque() { return contactTorque_; } - inline - const auto& contactTorque() const + inline const auto& contactTorque() const { return contactTorque_; } - bool beforeIteration() override; + bool beforeIteration() override; - bool iterate()override; + bool iterate() override; - bool afterIteration() override; + bool afterIteration() override; - /*virtual - bool insertParticles - ( - const realx3Vector& position, - const wordVector& shapes, - const setFieldList& setField - ) = 0;*/ + virtual bool insertParticles( + const realx3Vector& position, + const wordVector& shapesNames, + const anyList& setVarList + ) = 0; - virtual - const uint32PointField_D& propertyId()const = 0; - - virtual - const realPointField_D& diameter()const = 0; + virtual const uint32PointField_D& propertyId() const = 0; - virtual - const realPointField_D& mass()const = 0; + virtual const realPointField_D& diameter() const = 0; - virtual - realx3PointField_D& rAcceleration() = 0; + virtual const realPointField_D& mass() const = 0; - virtual - const realx3PointField_D& rAcceleration() const = 0; + virtual realx3PointField_D& rAcceleration() = 0; - virtual - const realPointField_D& boundingSphere()const = 0; + virtual const realx3PointField_D& rAcceleration() const = 0; - virtual - word shapeTypeName()const = 0; + virtual const realPointField_D& boundingSphere() const = 0; - virtual - const shape& getShapes()const = 0; + virtual word shapeTypeName() const = 0; - virtual - void boundingSphereMinMax(real & minDiam, real& maxDiam)const = 0; + virtual const shape& getShapes() const = 0; - + virtual void boundingSphereMinMax(real& minDiam, real& maxDiam) const = 0; }; // particles -} // pFlow +} // namespace pFlow #endif //__particles_hpp__ diff --git a/src/Particles/particles/regularParticleHandler.cpp b/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.cpp similarity index 54% rename from src/Particles/particles/regularParticleHandler.cpp rename to src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.cpp index 429ac0b2..401bc281 100644 --- a/src/Particles/particles/regularParticleHandler.cpp +++ b/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.cpp @@ -1,18 +1,18 @@ -#include "regularParticleHandler.hpp" +#include "regularParticleIdHandler.hpp" -pFlow::regularParticleHandler::regularParticleHandler +pFlow::regularParticleIdHandler::regularParticleIdHandler ( - uint32PointField_D & id + pointStructure& pStruct ) : - particleIdHandler(id) + particleIdHandler(pStruct) { } pFlow::Pair - pFlow::regularParticleHandler::getIdRange(uint32 nNewParticles) + pFlow::regularParticleIdHandler::getIdRange(uint32 nNewParticles) { uint32 startId; if(maxId_==-1) @@ -28,18 +28,18 @@ pFlow::Pair return {startId, endId}; } -bool pFlow::regularParticleHandler::initialIdCheck() +bool pFlow::regularParticleIdHandler::initialIdCheck() { /// empty point structure / no particles in simulation - if( id().pStruct().empty() ) return true; + if( pStruct().empty() ) return true; - uint32 maxId = max(id()); + uint32 maxId = max( *this ); /// particles should get ids from 0 to size-1 if(maxId == -1) { - fillSequence(id(),0u); - maxId_ = id().size()-1; + fillSequence(*this,0u); + maxId_ = size()-1; } else { diff --git a/src/Particles/particles/regularParticleHandler.hpp b/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.hpp similarity index 77% rename from src/Particles/particles/regularParticleHandler.hpp rename to src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.hpp index 9c4ee1dd..4d40261f 100644 --- a/src/Particles/particles/regularParticleHandler.hpp +++ b/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.hpp @@ -17,15 +17,15 @@ Licence: implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -----------------------------------------------------------------------------*/ -#ifndef __regularParticleHandler_hpp__ -#define __regularParticleHandler_hpp__ +#ifndef __regularParticleIdHandler_hpp__ +#define __regularParticleIdHandler_hpp__ #include "particleIdHandler.hpp" namespace pFlow { -class regularParticleHandler +class regularParticleIdHandler : public particleIdHandler { @@ -35,17 +35,17 @@ private: public: - TypeInfo("particleIdHandler"); + ClassInfo("particleIdHandler"); + + explicit regularParticleIdHandler(pointStructure& pStruct); - explicit regularParticleHandler(uint32PointField_D & id); - - ~regularParticleHandler()override = default; + ~regularParticleIdHandler()override = default; add_vCtor ( particleIdHandler, - regularParticleHandler, - pointField + regularParticleIdHandler, + pointStructure ); Pair getIdRange(uint32 nNewParticles)override; @@ -57,4 +57,4 @@ public: } -#endif //__regularParticleHandler_hpp__ \ No newline at end of file +#endif //__regularParticleIdHandler_hpp__ \ No newline at end of file diff --git a/src/Particles/particles/baseShapeNames.cpp b/src/Particles/particles/shape/baseShapeNames.cpp similarity index 100% rename from src/Particles/particles/baseShapeNames.cpp rename to src/Particles/particles/shape/baseShapeNames.cpp diff --git a/src/Particles/particles/baseShapeNames.hpp b/src/Particles/particles/shape/baseShapeNames.hpp similarity index 100% rename from src/Particles/particles/baseShapeNames.hpp rename to src/Particles/particles/shape/baseShapeNames.hpp diff --git a/src/Particles/particles/shape.cpp b/src/Particles/particles/shape/shape.cpp similarity index 100% rename from src/Particles/particles/shape.cpp rename to src/Particles/particles/shape/shape.cpp diff --git a/src/Particles/particles/shape.hpp b/src/Particles/particles/shape/shape.hpp similarity index 96% rename from src/Particles/particles/shape.hpp rename to src/Particles/particles/shape/shape.hpp index 1ce5d8ce..6a0f44b8 100644 --- a/src/Particles/particles/shape.hpp +++ b/src/Particles/particles/shape/shape.hpp @@ -122,6 +122,17 @@ public: return 0.0; } + inline + uint32 propertyId(uint32 index)const + { + if(indexValid(index)) + { + return shapePropertyIds_[index]; + } + fatalExit; + return 0.0; + } + virtual real maxBoundingSphere()const = 0; diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index 49772f57..6bf9c3ee 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -5,6 +5,7 @@ types/basicTypes/Logical.cpp types/types.cpp globals/error.cpp +globals/globalSettings.cpp processors/processors.cpp processors/localProcessors.cpp @@ -62,11 +63,18 @@ containers/Field/Fields.cpp containers/symArrayHD/symArrays.cpp containers/List/anyList/anyList.cpp +structuredData/box/box.cpp +structuredData/sphere/sphere.cpp +structuredData/cylinder/cylinder.cpp +structuredData/peakableRegion/geometricRegion/geometricRegions.cpp +structuredData/peakableRegion/PeakableRegion/PeakableRegions.cpp +structuredData/peakableRegion/peakableRegion/peakableRegion.cpp + structuredData/pointStructure/internalPoints/internalPointsKernels.cpp structuredData/pointStructure/internalPoints/internalPoints.cpp structuredData/zAxis/zAxis.cpp -structuredData/box/box.cpp + structuredData/line/line.cpp structuredData/infinitePlane/infinitePlane.cpp structuredData/plane/plane.cpp @@ -82,10 +90,9 @@ structuredData/boundaries/boundaryReflective/boundaryReflective.cpp structuredData/boundaries/boundaryList.cpp structuredData/pointStructure/pointStructure/pointStructure.cpp structuredData/pointStructure/selectors/pStructSelector/pStructSelector.cpp -structuredData/pointStructure/selectors/selectBox/selectBox.cpp structuredData/pointStructure/selectors/selectRange/selectRange.cpp structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp - +structuredData/pointStructure/selectors/selectBox/selectBox.cpp triSurface/subSurface.cpp triSurface/triSurface.cpp diff --git a/src/phasicFlow/Kokkos/Range.hpp b/src/phasicFlow/Kokkos/Range.hpp index 64f211c3..cbdd385d 100644 --- a/src/phasicFlow/Kokkos/Range.hpp +++ b/src/phasicFlow/Kokkos/Range.hpp @@ -44,13 +44,11 @@ struct Range : public Kokkos::pair //// - Constructors /// Default - INLINE_FUNCTION_HD Range() - { - } + INLINE_FUNCTION_HD Range() = default; /// From end, set start to 0 INLINE_FUNCTION_HD - Range(const T& e) + explicit Range(const T& e) : Range(0, e) { } diff --git a/src/phasicFlow/Kokkos/ViewAlgorithms.hpp b/src/phasicFlow/Kokkos/ViewAlgorithms.hpp index 025534c9..db071f0b 100644 --- a/src/phasicFlow/Kokkos/ViewAlgorithms.hpp +++ b/src/phasicFlow/Kokkos/ViewAlgorithms.hpp @@ -253,11 +253,14 @@ copy( uint32 sEnd ) { - range32 sSpan(sStart, sEnd); - range32 dSpan(dStart, dStart + (sEnd - sStart)); + + auto srcSub = Kokkos::subview( + src, + Kokkos::make_pair(sStart, sEnd)); - auto srcSub = Kokkos::subview(src, sSpan); - auto dstSub = Kokkos::subview(dst, dSpan); + auto dstSub = Kokkos::subview( + dst, + Kokkos::make_pair(dStart, dStart + (sEnd - sStart))); Kokkos::deep_copy(dstSub, srcSub); } diff --git a/src/phasicFlow/containers/List/anyList/anyList.hpp b/src/phasicFlow/containers/List/anyList/anyList.hpp index b0d39405..c8abef63 100644 --- a/src/phasicFlow/containers/List/anyList/anyList.hpp +++ b/src/phasicFlow/containers/List/anyList/anyList.hpp @@ -23,6 +23,7 @@ Licence: #include +#include "typeInfo.hpp" #include "types.hpp" #include "List.hpp" @@ -44,8 +45,7 @@ public: using const_iterator= typename anyListType::const_iterator; - -protected: +private: /// Contains a list of variables with any type anyListType anyList_; @@ -109,7 +109,7 @@ public: fatalExit; } names_.push_back(name); - types_.push_back(getTypeName()); + types_.push_back(getTypeName(other)); return anyList_.emplace_back(std::in_place_type, other); } @@ -125,14 +125,23 @@ public: fatalExit; } names_.push_back(name); - types_.push_back(getTypeName()); - return anyList_.emplace_back(std::in_place_type, std::move(other)); + types_.push_back(getTypeName(other)); + return anyList_.emplace_back(std::in_place_type, std::forward(other)); } /// Get the reference to variable by index template T& getObject(size_t i) { + if(getTypeName() != types_[i]) + { + fatalErrorInFunction<< + "requested object type is "<()<< + " while strored type is "<has_value()) { @@ -156,15 +165,7 @@ public: "list of variables is "<has_value()) - { - fatalErrorInFunction<< - "any does not have a value for dereferencing. "<< - "index in anyList is "<(a); + return getObject(static_cast(i)); } /// Get the const reference to variable by name @@ -179,21 +180,22 @@ public: "list of variables is "<has_value()) - { - fatalErrorInFunction<< - "any does not have a value for dereferencing. "<< - "index in anyList is "<(a); + return getObject(static_cast(i)); } /// Get the const reference to object by index template const T& getObject(size_t i)const { + if(getTypeName() != types_[i]) + { + fatalErrorInFunction<< + "requested object type is "<()<< + " while strored type is "<has_value()) { @@ -211,6 +213,15 @@ public: { if(i>= size())return nullptr; + if(getTypeName() != types_[i]) + { + warningInFunction<< + "requested object type is "<()<< + " while strored type is "<has_value()) { @@ -227,6 +238,15 @@ public: const T* getObjectPtr(size_t i)const { if(i>=size())return nullptr; + if(getTypeName() != types_[i]) + { + warningInFunction<< + "requested object type is "<()<< + " while strored type is "<has_value()) { diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp index 558cf711..24248594 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp @@ -1,4 +1,3 @@ -#include "VectorSingle.hpp" /*------------------------------- phasicFlow --------------------------------- O C enter of O O E ngineering and @@ -75,9 +74,7 @@ void pFlow::VectorSingle::changeCapacity { newView(i) = view_(i); } - view_ = newView; - } else { @@ -661,7 +658,7 @@ auto pFlow::VectorSingle::getSpan()const template INLINE_FUNCTION_H -bool pFlow::VectorSingle::insertSetElement(uint32IndexContainer indices, const T& val) +bool pFlow::VectorSingle::insertSetElement(const uint32IndexContainer& indices, const T& val) { if(indices.empty()) return true; @@ -713,7 +710,7 @@ template INLINE_FUNCTION_H bool pFlow::VectorSingle::insertSetElement ( - const uint32IndexContainer indices, + const uint32IndexContainer& indices, const std::vector& vals ) { @@ -766,7 +763,7 @@ template INLINE_FUNCTION_H bool pFlow::VectorSingle::insertSetElement ( - uint32IndexContainer indices, + const uint32IndexContainer& indices, const ViewType1D vals ) { diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp index 7adcd04c..256ccb6c 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp @@ -88,11 +88,7 @@ private: /// view of the vector viewType view_; - // - protected members and methods - - /// growth factor for vector - static const inline - real growthFactor_ = vectorGrowthFactor__; + // - protected members and methods /// Is the memory of this vector accessible from Host static constexpr @@ -108,7 +104,7 @@ private: /// Evaluate capacity based on the input size static INLINE_FUNCTION_H uint32 evalCapacity(uint32 n) { - return static_cast(n*growthFactor_+1); + return static_cast(n*pFlow::gSettings::vectorGrowthFactor__+1); } /// @brief Change size to n and preserve the conetent if realloc @@ -289,11 +285,6 @@ public: INLINE_FUNCTION_H void assign(const VectorType& src, bool srcCapacity = true); - - /*template::memory_space, memory_space>, - bool> = true>*/ template INLINE_FUNCTION_H void assignFromDevice(const VectorSingle& src, bool srcCapacity = true) @@ -329,14 +320,14 @@ public: auto getSpan()const; INLINE_FUNCTION_H - bool insertSetElement(uint32IndexContainer indices, const T& val); + bool insertSetElement(const uint32IndexContainer& indices, const T& val); INLINE_FUNCTION_H - bool insertSetElement(uint32IndexContainer indices, const std::vector& vals); + bool insertSetElement(const uint32IndexContainer& indices, const std::vector& vals); INLINE_FUNCTION_H bool insertSetElement( - uint32IndexContainer indices, + const uint32IndexContainer& indices, const ViewType1D vals); INLINE_FUNCTION_H diff --git a/src/phasicFlow/containers/indexContainer/indexContainer.hpp b/src/phasicFlow/containers/indexContainer/indexContainer.hpp index 10fce100..72118609 100644 --- a/src/phasicFlow/containers/indexContainer/indexContainer.hpp +++ b/src/phasicFlow/containers/indexContainer/indexContainer.hpp @@ -24,7 +24,7 @@ Licence: #include #include "phasicFlowKokkos.hpp" - +#include "typeInfo.hpp" namespace pFlow { @@ -94,6 +94,8 @@ protected: public: + TypeInfoTemplateNV11("indexContainer", IndexType); + //// - Constructors /// Default diff --git a/src/phasicFlow/containers/pointField/internalField/internalField.cpp b/src/phasicFlow/containers/pointField/internalField/internalField.cpp index df0f0756..c1c69bd5 100644 --- a/src/phasicFlow/containers/pointField/internalField/internalField.cpp +++ b/src/phasicFlow/containers/pointField/internalField/internalField.cpp @@ -17,11 +17,51 @@ Licence: implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -----------------------------------------------------------------------------*/ + +template +bool pFlow::internalField::insert(const anyList& varList) +{ + const word eventName = message::eventName(message::ITEM_INSERT); + + const auto& indices = varList.getObject( + eventName); + bool success = false; + output<<"insert for field "<< name()<(name()); + success = field_.insertSetElement(indices, val); + + } + else if(varList.contains(name()+"Vector")) + { + // a vector of values is going to be assigned + const auto& valVec = varList.getObject>(name()+"Vector"); + success = field_.insertSetElement(indices,valVec); + } + else + { + success = field_.insertSetElement(indices, defaultValue_); + } + + if(!success) + { + fatalErrorInFunction; + return false; + } + + return true; + +} + template pFlow::internalField::internalField ( const word& name, - const internalPoints& internal + const internalPoints& internal, + const T& defVal ) : observer @@ -37,6 +77,7 @@ pFlow::internalField::internalField internal.size(), RESERVE() ), + defaultValue_(defVal), internalPoints_(internal) {} @@ -45,6 +86,7 @@ pFlow::internalField::internalField ( const word &name, const internalPoints &internal, + const T& defVal, const T &val ) : @@ -61,6 +103,7 @@ pFlow::internalField::internalField internal.size(), RESERVE() ), + defaultValue_(defVal), internalPoints_(internal) { fillInternal(val); @@ -131,8 +174,7 @@ bool pFlow::internalField:: hearChanges } if(msg.equivalentTo(message::ITEM_INSERT)) { - notImplementedFunction; - return false; + return insert(varList); } return true; } diff --git a/src/phasicFlow/containers/pointField/internalField/internalField.hpp b/src/phasicFlow/containers/pointField/internalField/internalField.hpp index 07ad006a..779b0c61 100644 --- a/src/phasicFlow/containers/pointField/internalField/internalField.hpp +++ b/src/phasicFlow/containers/pointField/internalField/internalField.hpp @@ -52,8 +52,13 @@ public: protected: + /// Field FieldType field_; + /// @brief value when a new item is added to field + T defaultValue_; + + /// const ref to internal points const internalPoints& internalPoints_; static inline @@ -66,15 +71,19 @@ protected: message::ITEM_DELETE ); + bool insert(const anyList& varList); + public: internalField( const word& name, - const internalPoints& internal); + const internalPoints& internal, + const T& defVal); internalField( const word& name, const internalPoints& internal, + const T& defVal, const T& val); inline @@ -142,6 +151,12 @@ public: return field_.fieldKey(); } + inline + const T& defaultValue()const + { + return defaultValue_; + } + inline auto activeRange()const { diff --git a/src/phasicFlow/containers/pointField/pointField/pointField.cpp b/src/phasicFlow/containers/pointField/pointField/pointField.cpp index 0c1c44fd..5e969445 100644 --- a/src/phasicFlow/containers/pointField/pointField/pointField.cpp +++ b/src/phasicFlow/containers/pointField/pointField/pointField.cpp @@ -34,11 +34,11 @@ pFlow::pointField::pointField InternalFieldType ( objf.name(), - pStruct + pStruct, + defVal ), boundaryFieldList_(pStruct.boundaries(), *this), - pStruct_(pStruct), - defaultValue_(defVal) + pStruct_(pStruct) { if(IOobject::implyRead()) @@ -77,11 +77,11 @@ pFlow::pointField::pointField InternalFieldType ( objf.name(), - pStruct + pStruct, + defVal ), boundaryFieldList_(pStruct.boundaries(), *this), - pStruct_(pStruct), - defaultValue_(defVal) + pStruct_(pStruct) { if(IOobject::implyRead()) { @@ -125,11 +125,11 @@ pFlow::pointField::pointField ( objf.name(), pStruct, + defVal, val ), boundaryFieldList_(pStruct.boundaries(), *this), - pStruct_(pStruct), - defaultValue_(defVal) + pStruct_(pStruct) { } diff --git a/src/phasicFlow/containers/pointField/pointField/pointField.hpp b/src/phasicFlow/containers/pointField/pointField/pointField.hpp index 6977563e..d42870d5 100644 --- a/src/phasicFlow/containers/pointField/pointField/pointField.hpp +++ b/src/phasicFlow/containers/pointField/pointField/pointField.hpp @@ -61,9 +61,6 @@ private: /// @brief refrence to point structure const pointStructure& pStruct_; - /// @brief value when a new item is added to field - T defaultValue_; - public: @@ -95,6 +92,11 @@ public: //// - Methods + + const word& name() const final + { + return IOobject::name(); + } const auto& internal()const { diff --git a/src/phasicFlow/eventManagement/message.hpp b/src/phasicFlow/eventManagement/message.hpp index 7d811fc5..e5e1bfb0 100644 --- a/src/phasicFlow/eventManagement/message.hpp +++ b/src/phasicFlow/eventManagement/message.hpp @@ -108,6 +108,12 @@ public: return *this; } + inline const word& addAndName(EVENT evnt) + { + add(evnt); + return eventName(static_cast(evnt)); + } + inline message& remove(EVENT evnt) { events_.set(static_cast(evnt), false); diff --git a/src/phasicFlow/eventManagement/subscriber.hpp b/src/phasicFlow/eventManagement/subscriber.hpp index 6507de01..1cf419f3 100644 --- a/src/phasicFlow/eventManagement/subscriber.hpp +++ b/src/phasicFlow/eventManagement/subscriber.hpp @@ -76,6 +76,10 @@ public: const message msg, const anyList& varList); + const word& subscriberName()const + { + return subName_; + } }; diff --git a/src/phasicFlow/globals/globalSettings.cpp b/src/phasicFlow/globals/globalSettings.cpp new file mode 100644 index 00000000..36115c8c --- /dev/null +++ b/src/phasicFlow/globals/globalSettings.cpp @@ -0,0 +1,6 @@ + + +#include "globalSettings.hpp" + + +const double pFlow::gSettings::vectorGrowthFactor__ = 1.1; \ No newline at end of file diff --git a/src/phasicFlow/globals/globalSettings.hpp b/src/phasicFlow/globals/globalSettings.hpp index cb9e19ea..734db3c3 100755 --- a/src/phasicFlow/globals/globalSettings.hpp +++ b/src/phasicFlow/globals/globalSettings.hpp @@ -23,9 +23,11 @@ Licence: -namespace pFlow +namespace pFlow::gSettings { -const inline double vectorGrowthFactor__ = 1.2; + +extern const double vectorGrowthFactor__; + } diff --git a/src/phasicFlow/globals/vocabs.hpp b/src/phasicFlow/globals/vocabs.hpp index e578e50e..9cb2c5bd 100755 --- a/src/phasicFlow/globals/vocabs.hpp +++ b/src/phasicFlow/globals/vocabs.hpp @@ -25,31 +25,31 @@ namespace pFlow { // folders / repositories -const inline char* settingsFolder__ = "settings"; -const inline char* settingsRepository__ = "settings"; -const inline char* caseSetupFolder__ = "caseSetup"; -const inline char* caseSetupRepository__ = "caseSetup"; -const inline char* geometryFolder__ = "geometry"; -const inline char* geometryRepository_ = "geometry"; -const inline char* integrationRepository__ = "integration"; -const inline char* integrationFolder__ = "integration"; +const inline char* const settingsFolder__ = "settings"; +const inline char* const settingsRepository__ = "settings"; +const inline char* const caseSetupFolder__ = "caseSetup"; +const inline char* const caseSetupRepository__ = "caseSetup"; +const inline char* const geometryFolder__ = "geometry"; +const inline char* const geometryRepository_ = "geometry"; +const inline char* const integrationRepository__ = "integration"; +const inline char* const integrationFolder__ = "integration"; // file names -const inline char* settingsFile__ = "settingsDict"; -const inline char* domainFile__ = "domainDict"; -const inline char* insertionFile__ = "particleInsertion"; -const inline char* shapeFile__ = "shapes"; -const inline char* pointStructureFile__ = "pStructure"; -const inline char* triSurfaceFile__ = "triSurface"; -const inline char* createParticles__ = "createParticles"; -const inline char* motionModelFile__ = "motionModel"; -const inline char* contactSearchFile__ = "contactSearch"; -const inline char* propertyFile__ = "interaction"; -const inline char* interactionFile__ = "interaction"; -const inline char* postprocessFile__ = "postprocessDict"; +const inline char* const settingsFile__ = "settingsDict"; +const inline char* const domainFile__ = "domainDict"; +const inline char* const insertionFile__ = "particleInsertion"; +const inline char* const shapeFile__ = "shapes"; +const inline char* const pointStructureFile__ = "pStructure"; +const inline char* const triSurfaceFile__ = "triSurface"; +const inline char* const createParticles__ = "createParticles"; +const inline char* const motionModelFile__ = "motionModel"; +const inline char* const contactSearchFile__ = "contactSearch"; +const inline char* const propertyFile__ = "interaction"; +const inline char* const interactionFile__ = "interaction"; +const inline char* const postprocessFile__ = "postprocessDict"; -const inline char* uniform__ = "uniform"; -const inline char* nonUniform__ = "nonUniform"; +const inline char* const uniform__ = "uniform"; +const inline char* const nonUniform__ = "nonUniform"; } diff --git a/src/phasicFlow/repository/Time/Time.hpp b/src/phasicFlow/repository/Time/Time.hpp index 93a990e0..4da092f6 100644 --- a/src/phasicFlow/repository/Time/Time.hpp +++ b/src/phasicFlow/repository/Time/Time.hpp @@ -28,6 +28,7 @@ Licence: #include "repository.hpp" #include "timeControl.hpp" + namespace pFlow { diff --git a/src/phasicFlow/repository/Time/timeControl.hpp b/src/phasicFlow/repository/Time/timeControl.hpp index 64129ab0..dc533bd7 100644 --- a/src/phasicFlow/repository/Time/timeControl.hpp +++ b/src/phasicFlow/repository/Time/timeControl.hpp @@ -25,7 +25,7 @@ Licence: #include "types.hpp" #include "ranges.hpp" #include "streams.hpp" - +#include "timeInfo.hpp" namespace pFlow { @@ -36,7 +36,7 @@ class dictionary; class timeControl { -protected: +private: //// - Data members @@ -90,7 +90,7 @@ protected: public: - timeControl(const dictionary& dict); + explicit timeControl(const dictionary& dict); timeControl( dictionary& dict, @@ -99,10 +99,8 @@ public: real saveInterval, word startTimeName); - virtual ~timeControl() - {} - - + virtual ~timeControl() = default; + real dt()const { return dt_; @@ -186,7 +184,11 @@ public: return timePrecision_; } - + inline + timeInfo TimeInfo()const + { + return {static_cast(currentIter_), currentTime_, dt_}; + } }; diff --git a/src/phasicFlow/structuredData/peakableRegion/peakableRegions.hpp b/src/phasicFlow/repository/Time/timeInfo.hpp similarity index 55% rename from src/phasicFlow/structuredData/peakableRegion/peakableRegions.hpp rename to src/phasicFlow/repository/Time/timeInfo.hpp index a7c6784f..34e30d90 100644 --- a/src/phasicFlow/structuredData/peakableRegion/peakableRegions.hpp +++ b/src/phasicFlow/repository/Time/timeInfo.hpp @@ -1,45 +1,63 @@ /*------------------------------- phasicFlow --------------------------------- - O C enter of - O O E ngineering and - O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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 __timeInfo__hpp_ +#define __timeInfo__hpp_ -#ifndef __peakableRegions_hpp__ -#define __peakableRegions_hpp__ - -#include "PeakableRegion.hpp" -#include "boxRegion.hpp" -#include "sphereRegion.hpp" +#include "types.hpp" namespace pFlow { +class timeInfo +{ +private: -typedef PeakableRegion boxPeakableRegion; + uint32 currentIter_; -typedef PeakableRegion spherePeakableRegion; + real currentTime_; -} // pFlow + real dt_; -#ifndef BUILD_SHARED_LIBS - #include "peakableRegionInstantiate.cpp" -#endif +public: + timeInfo(uint32 cIter, real cTime, real dt) + : currentIter_(cIter), + currentTime_(cTime), + dt_(dt) + { + } + inline const real& t() const + { + return currentTime_; + } + inline const real& dt() const + { + return dt_; + } + inline const uint32& iter() const + { + return currentIter_; + } +}; -#endif +} // namespace pFlow + +#endif //__timeInfo__hpp_ \ No newline at end of file diff --git a/src/phasicFlow/setFieldList/setFieldEntryTemplates.cpp b/src/phasicFlow/setFieldList/setFieldEntryTemplates.cpp index ac30c06c..45489eca 100644 --- a/src/phasicFlow/setFieldList/setFieldEntryTemplates.cpp +++ b/src/phasicFlow/setFieldList/setFieldEntryTemplates.cpp @@ -69,40 +69,7 @@ pFlow::uniquePtr> return Ptr; } -/*template -void* pFlow::setFieldEntry::setPointFieldDefaultValueStdNew -( - repository& owner, - pointStructure& pStruct, - bool verbose -) -{ - if( !checkForType() ) return nullptr; - - Type defValue = entry_.secondPartVal(); - - if(verbose) - REPORT(2)<<"Creating pointField " << Green_Text(fieldName())<< " with default value " << cyanText(defValue)<< - " in repository "<< owner.name() <>> - ( - objectFile - ( - fieldName(), - "", - objectFile::READ_NEVER, - objectFile::WRITE_ALWAYS - ), - pStruct, - defValue - ); - - return &field; -}*/ template bool pFlow::setFieldEntry::setPointFieldSelected @@ -148,45 +115,3 @@ bool pFlow::setFieldEntry::setPointFieldSelected return false; } -/*template -void* pFlow::setFieldEntry::setPointFieldSelectedStd -( - repository& owner, - int32IndexContainer& selected, - bool verbose -) -{ - - if( !checkForType() ) return nullptr; - - - auto fName = fieldName(); - - if( !owner.lookupObjectName(fName) ) - { - fatalErrorInFunction<< - " Cannot find "<< fName << " in repository " << owner.name() << ". \n"; - return nullptr; - } - - - Type value = entry_.secondPartVal(); - - if(verbose) - REPORT(2)<< "Setting selected points of " << Green_Text(fName) - << " to value " << cyanText(value) <>::TYPENAME() == fieldTypeName ) - { - auto& field = owner.lookupObject>>(fName); - if(field.insertSetElement(selected, value)) - return &field; - else - return nullptr; - } - - return nullptr; -}*/ \ No newline at end of file diff --git a/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegion.cpp b/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegion.cpp index f178026b..05b3aa43 100644 --- a/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegion.cpp +++ b/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegion.cpp @@ -19,8 +19,8 @@ Licence: -----------------------------------------------------------------------------*/ -template -pFlow::PeakableRegion::PeakableRegion +template +pFlow::PeakableRegion::PeakableRegion ( const word& type, const dictionary& dict @@ -32,8 +32,8 @@ pFlow::PeakableRegion::PeakableRegion } -template -bool pFlow::PeakableRegion::isInside +template +bool pFlow::PeakableRegion::isInside ( const realx3& point )const @@ -42,20 +42,20 @@ bool pFlow::PeakableRegion::isInside } -template -pFlow::realx3 pFlow::PeakableRegion::peek()const +template +pFlow::realx3 pFlow::PeakableRegion::peek()const { return region_.peek(); } -template -bool pFlow::PeakableRegion::read(const dictionary& dict) +template +bool pFlow::PeakableRegion::read(const dictionary& dict) { return region_.read(dict); } -template -bool pFlow::PeakableRegion::write(dictionary& dict)const +template +bool pFlow::PeakableRegion::write(dictionary& dict)const { return region_.write(dict); } diff --git a/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegion.hpp b/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegion.hpp index eefecc19..90251e6c 100644 --- a/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegion.hpp +++ b/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegion.hpp @@ -2,85 +2,78 @@ O C enter of O O E ngineering and O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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 __PeakableRegion_hpp__ #define __PeakableRegion_hpp__ - -#include "peakableRegion.hpp" #include "dictionary.hpp" +#include "geometricRegion.hpp" +#include "peakableRegion.hpp" namespace pFlow { - - - -template -class PeakableRegion -: - public peakableRegion +template +class PeakableRegion : public peakableRegion { -protected: +public: - RegionType region_; + using RegionType = geometricRegion; + + using GeometryType = typename RegionType::GeometryType; + +private: + + RegionType region_; public: // type info - TypeInfoTemplate("peakableRegion", RegionType); + TypeInfoTemplate11("peakable", GeometryType); - //// - Constructors - PeakableRegion(const word& type, const dictionary& dict); + //// - Constructors + PeakableRegion(const word& type, const dictionary& dict); - add_vCtor( - peakableRegion, - PeakableRegion, - word - ); + add_vCtor(peakableRegion, PeakableRegion, word); - virtual uniquePtr clone()const override - { - return makeUnique>(*this); - } - - virtual peakableRegion* clonePtr()const override - { - return new PeakableRegion(*this); - } + virtual uniquePtr clone() const override + { + return makeUnique>(*this); + } + virtual peakableRegion* clonePtr() const override + { + return new PeakableRegion(*this); + } - virtual ~PeakableRegion() = default; + virtual ~PeakableRegion() = default; //// - Methods - virtual bool isInside(const realx3& point)const override; + virtual bool isInside(const realx3& point) const override; - virtual realx3 peek()const override; + virtual realx3 peek() const override; + //// - IO operatoins - //// - IO operatoins - - virtual bool read(const dictionary& dict) override; - - virtual bool write(dictionary& dict)const override; + virtual bool read(const dictionary& dict) override; + virtual bool write(dictionary& dict) const override; }; } // pFlow diff --git a/src/phasicFlow/structuredData/peakableRegion/peakableRegions.cpp b/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegions.cpp similarity index 81% rename from src/phasicFlow/structuredData/peakableRegion/peakableRegions.cpp rename to src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegions.cpp index 32476038..c27850d5 100644 --- a/src/phasicFlow/structuredData/peakableRegion/peakableRegions.cpp +++ b/src/phasicFlow/structuredData/peakableRegion/PeakableRegion/PeakableRegions.cpp @@ -19,9 +19,11 @@ Licence: -----------------------------------------------------------------------------*/ -#include "peakableRegions.hpp" +#include "PeakableRegion.hpp" +#include "geometricRegions.hpp" - -#ifdef BUILD_SHARED_LIBS - #include "peakableRegionInstantiate.cpp" -#endif +template class pFlow::PeakableRegion; + +template class pFlow::PeakableRegion; + +template class pFlow::PeakableRegion; \ No newline at end of file diff --git a/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegion.cpp b/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegion.cpp new file mode 100644 index 00000000..baf09653 --- /dev/null +++ b/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegion.cpp @@ -0,0 +1,67 @@ +/*------------------------------- 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. + +-----------------------------------------------------------------------------*/ + +template +pFlow::geometricRegion::geometricRegion(const dictionary& dict) + : geom_(dict) + , random_() +{ + minPoint_ = geom_.minPoint(); + maxPoint_ = geom_.maxPoint(); +} + +template +inline bool +pFlow::geometricRegion::isInside(const realx3& p) const +{ + return geom_.isInside(p); +} + +template +inline pFlow::realx3 +pFlow::geometricRegion::peek() const +{ + for (uint32 i = 0u; i < maxTries_; i++) + { + realx3 p = random_.randomNumber(minPoint_, maxPoint_); + + if (isInside(p)) + return p; + } + + fatalErrorInFunction << "cannot peek a random point from geometricRegion " + << typeName() << endl; + fatalExit; + return 0; +} + +template +bool +pFlow::geometricRegion::read(const dictionary& dict) +{ + return geom_.read(dict); +} + +template +bool +pFlow::geometricRegion::write(dictionary& dict) const +{ + return geom_.write(dict); +} \ No newline at end of file diff --git a/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegion.hpp b/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegion.hpp new file mode 100644 index 00000000..f6dbc7f7 --- /dev/null +++ b/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegion.hpp @@ -0,0 +1,75 @@ +/*------------------------------- 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 __geometricRegion_hpp__ +#define __geometricRegion_hpp__ + + +#include "dictionary.hpp" +#include "uniformRandomReal.hpp" +#include "typeInfo.hpp" + +namespace pFlow +{ + +template +class geometricRegion +{ +public: + + using GeometryType = GeomType; + +private: + + GeomType geom_; + + realx3 minPoint_; + + realx3 maxPoint_; + + mutable uniformRandomReal random_; + + static constexpr uint32 maxTries_ = 100; + +public: + + // - type info + TypeInfoTemplateNV11("geometricRegion", GeomType); + + explicit geometricRegion(const dictionary& dict); + + ~geometricRegion() = default; + + //// - methods + bool isInside(const realx3& p) const; + + realx3 peek() const; + + //// IO operation + bool read(const dictionary& dict); + + bool write(dictionary& dict) const; +}; + +} // namespace pFlow + +#include "geometricRegion.cpp" + +#endif diff --git a/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegions.cpp b/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegions.cpp new file mode 100644 index 00000000..91077be9 --- /dev/null +++ b/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegions.cpp @@ -0,0 +1,9 @@ + + + +#include "geometricRegions.hpp" + + +template class pFlow::geometricRegion; + +template class pFlow::geometricRegion; \ No newline at end of file diff --git a/src/Particles/particles/demParticles.hpp b/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegions.hpp similarity index 69% rename from src/Particles/particles/demParticles.hpp rename to src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegions.hpp index 9afd2f62..0ff5fc61 100644 --- a/src/Particles/particles/demParticles.hpp +++ b/src/phasicFlow/structuredData/peakableRegion/geometricRegion/geometricRegions.hpp @@ -2,46 +2,39 @@ O C enter of O O E ngineering and O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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 __geometricRegions_hpp__ +#define __geometricRegions_hpp__ -#ifndef __demParticles_hpp__ -#define __demParticles_hpp__ - -#include "demComponent.hpp" +#include "geometricRegion.hpp" +#include "box.hpp" +#include "sphere.hpp" +#include "cylinder.hpp" namespace pFlow { +using boxRegion = geometricRegion; -class demParticles -: - public demComponent -{ +using sphereRegion = geometricRegion; -public: - - demParticles(systemControl& control): - demComponent("particles", control) - {} - - -}; +using cylinderRegion = geometricRegion; } -#endif +#endif //__geometricRegions_hpp__ \ No newline at end of file diff --git a/src/phasicFlow/structuredData/peakableRegion/boxRegion/boxRegion.cpp b/src/phasicFlow/structuredData/peakableRegion/old/boxRegion/boxRegion.cpp similarity index 100% rename from src/phasicFlow/structuredData/peakableRegion/boxRegion/boxRegion.cpp rename to src/phasicFlow/structuredData/peakableRegion/old/boxRegion/boxRegion.cpp diff --git a/src/phasicFlow/structuredData/peakableRegion/boxRegion/boxRegion.hpp b/src/phasicFlow/structuredData/peakableRegion/old/boxRegion/boxRegion.hpp similarity index 100% rename from src/phasicFlow/structuredData/peakableRegion/boxRegion/boxRegion.hpp rename to src/phasicFlow/structuredData/peakableRegion/old/boxRegion/boxRegion.hpp diff --git a/src/phasicFlow/structuredData/peakableRegion/cylinderRegion/cylinderRegion.cpp b/src/phasicFlow/structuredData/peakableRegion/old/cylinderRegion/cylinderRegion.cpp similarity index 100% rename from src/phasicFlow/structuredData/peakableRegion/cylinderRegion/cylinderRegion.cpp rename to src/phasicFlow/structuredData/peakableRegion/old/cylinderRegion/cylinderRegion.cpp diff --git a/src/phasicFlow/structuredData/peakableRegion/cylinderRegion/cylinderRegion.hpp b/src/phasicFlow/structuredData/peakableRegion/old/cylinderRegion/cylinderRegion.hpp similarity index 100% rename from src/phasicFlow/structuredData/peakableRegion/cylinderRegion/cylinderRegion.hpp rename to src/phasicFlow/structuredData/peakableRegion/old/cylinderRegion/cylinderRegion.hpp diff --git a/src/phasicFlow/structuredData/peakableRegion/sphereRegion/sphereRegion.cpp b/src/phasicFlow/structuredData/peakableRegion/old/sphereRegion/sphereRegion.cpp similarity index 100% rename from src/phasicFlow/structuredData/peakableRegion/sphereRegion/sphereRegion.cpp rename to src/phasicFlow/structuredData/peakableRegion/old/sphereRegion/sphereRegion.cpp diff --git a/src/phasicFlow/structuredData/peakableRegion/sphereRegion/sphereRegion.hpp b/src/phasicFlow/structuredData/peakableRegion/old/sphereRegion/sphereRegion.hpp similarity index 100% rename from src/phasicFlow/structuredData/peakableRegion/sphereRegion/sphereRegion.hpp rename to src/phasicFlow/structuredData/peakableRegion/old/sphereRegion/sphereRegion.hpp diff --git a/src/phasicFlow/structuredData/peakableRegion/peakableRegion/peakableRegion.cpp b/src/phasicFlow/structuredData/peakableRegion/peakableRegion/peakableRegion.cpp index fb36b661..0693431a 100644 --- a/src/phasicFlow/structuredData/peakableRegion/peakableRegion/peakableRegion.cpp +++ b/src/phasicFlow/structuredData/peakableRegion/peakableRegion/peakableRegion.cpp @@ -18,13 +18,13 @@ Licence: -----------------------------------------------------------------------------*/ - #include "peakableRegion.hpp" #include "dictionary.hpp" pFlow::peakableRegion::peakableRegion ( - const word& type, const dictionary& dict + const word& type, + const dictionary& dict ) { CONSUME_PARAM(type); @@ -37,8 +37,8 @@ pFlow::uniquePtr pFlow::peakableRegion::create const word& type, const dictionary& dict ) -{ - word regionType = angleBracketsNames("peakableRegion", type); +{ + word regionType = angleBracketsNames("peakable", type); if( wordvCtorSelector_.search(regionType) ) { @@ -48,7 +48,7 @@ pFlow::uniquePtr pFlow::peakableRegion::create { printKeys ( - fatalError << "Ctor Selector "<< regionType << " dose not exist. \n" + fatalError << "Ctor Selector "<< regionType << " does not exist. \n" <<"Avaiable ones are: \n\n" , wordvCtorSelector_ diff --git a/src/phasicFlow/structuredData/peakableRegion/peakableRegion/peakableRegion.hpp b/src/phasicFlow/structuredData/peakableRegion/peakableRegion/peakableRegion.hpp index 7f573572..e1449902 100644 --- a/src/phasicFlow/structuredData/peakableRegion/peakableRegion/peakableRegion.hpp +++ b/src/phasicFlow/structuredData/peakableRegion/peakableRegion/peakableRegion.hpp @@ -2,81 +2,72 @@ O C enter of O O E ngineering and O O M ultiscale modeling of - OOOOOOO F luid flow + 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 + 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 + 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 __peakableRegion_hpp__ #define __peakableRegion_hpp__ #include "types.hpp" #include "virtualConstructor.hpp" - namespace pFlow { - class dictionary; class peakableRegion { -protected: - - public: // type info TypeInfo("peakableRegion"); - peakableRegion(const word& type, const dictionary& dict); + peakableRegion(const word& type, const dictionary& dict); - create_vCtor( - peakableRegion, - word, - (const word& type, const dictionary& dict), - (type, dict) - ); + create_vCtor( + peakableRegion, + word, + (const word& type, const dictionary& dict), + (type, dict) + ); - virtual uniquePtr clone()const = 0; - - virtual peakableRegion* clonePtr()const = 0; + virtual uniquePtr clone() const = 0; - virtual ~peakableRegion() = default; + virtual peakableRegion* clonePtr() const = 0; + + virtual ~peakableRegion() = default; //// - Methods - virtual bool isInside(const realx3& point)const = 0; + virtual bool isInside(const realx3& point) const = 0; - virtual realx3 peek()const = 0; + virtual realx3 peek() const = 0; + //// - IO operatoins - //// - IO operatoins + virtual bool read(const dictionary& dict) = 0; - virtual bool read(const dictionary& dict) = 0; - - virtual bool write(dictionary& dict)const = 0; - - // - static create - static uniquePtr - create(const word& type, const dictionary& dict); + virtual bool write(dictionary& dict) const = 0; + // - static create + static uniquePtr + create(const word& type, const dictionary& dict); }; -} // pFlow - +} // namespace pFlow #endif diff --git a/src/phasicFlow/structuredData/peakableRegion/peakableRegionInstantiate.cpp b/src/phasicFlow/structuredData/peakableRegion/peakableRegionInstantiate.cpp deleted file mode 100644 index 7a669618..00000000 --- a/src/phasicFlow/structuredData/peakableRegion/peakableRegionInstantiate.cpp +++ /dev/null @@ -1,30 +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. - ------------------------------------------------------------------------------*/ - -#include "boxRegion.hpp" -#include "sphereRegion.hpp" -#include "cylinderRegion.hpp" - - -template class pFlow::PeakableRegion; - -template class pFlow::PeakableRegion; - -template class pFlow::PeakableRegion; \ No newline at end of file diff --git a/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp b/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp index 26c477c1..3bc1fa66 100644 --- a/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp +++ b/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp @@ -193,14 +193,14 @@ const pFlow::pFlagTypeHost& return pFlagsH_; } -FUNCTION_H + const typename pFlow::internalPoints::PointsType& pFlow::internalPoints::pointPosition()const { return pointPosition_; } -FUNCTION_H + typename pFlow::internalPoints::PointsType& pFlow::internalPoints::pointPosition() { @@ -255,7 +255,7 @@ bool pFlow::internalPoints::deletePoints return true; } -FUNCTION_H + pFlow::uint32 pFlow::internalPoints::updateFlag ( const domain& dm, @@ -296,7 +296,108 @@ void pFlow::internalPoints::fillNeighborsLists } -FUNCTION_H +bool +pFlow::internalPoints::insertPoints( + const realx3Vector& points, + anyList& varList +) +{ + uint32 numNew = static_cast(points.size()); + + auto aRange = pFlagsD_.activeRange(); + uint32 emptySpots = pFlagsD_.capacity() - pFlagsD_.numActive(); + message msg; + + if( numNew > emptySpots ) + { + // increase the capacity to hold new points + aRange = pFlagsD_.activeRange(); + uint32 newCap = pFlagsD_.changeCapacity(numNew); + unSyncFlag(); + varList.emplaceBack( + msg.addAndName(message::CAP_CHANGED), + newCap); + } + + + // first check if it is possible to add to the beggining of list + if(numNew <= aRange.start()) + { + varList.emplaceBack( + msg.addAndName(message::ITEM_INSERT), + 0u, numNew); + } + // check if it is possible to add to the end of the list + else if( numNew <= pFlagsD_.capacity() - aRange.end() ) + { + varList.emplaceBack( + msg.addAndName(message::ITEM_INSERT), + aRange.end(), aRange.end()+numNew); + } + // we should fill the scattered empty spots + else + { + notImplementedFunction; + return false; + } + + const auto& indices = varList.getObject( + message::eventName(message::ITEM_INSERT) + ); + + auto nAdded = pFlagsD_.addInternalPoints(indices.deviceView()); + unSyncFlag(); + + if(nAdded != numNew ) + { + fatalErrorInFunction; + return false; + } + + pointPosition_.reserve( pFlagsD_.capacity() ); + if(!pointPosition_.insertSetElement(indices, points)) + { + fatalErrorInFunction<< + "Error in inserting new positions into pointPosition"<< + " internalPoints field"< delPoints); - FUNCTION_H + uint32 updateFlag( const domain& dm, const std::array& dist); - FUNCTION_H + void fillNeighborsLists( ViewType1D leftList, ViewType1D rightList, @@ -234,27 +233,24 @@ public: ViewType1D rearList, ViewType1D frontList); - + + bool insertPoints(const realx3Vector& points, anyList& varList); //// - IO operations /// Read - FUNCTION_H bool read(iIstream& is); /// Write - FUNCTION_H bool write(iOstream& os)const; /// Read - FUNCTION_H bool read(iIstream& is, const IOPattern& iop); /// Write - FUNCTION_H bool write(iOstream& os, const IOPattern& iop)const; }; diff --git a/src/phasicFlow/structuredData/pointStructure/internalPoints/pointFlag.hpp b/src/phasicFlow/structuredData/pointStructure/internalPoints/pointFlag.hpp index ebdeb1ae..28509010 100644 --- a/src/phasicFlow/structuredData/pointStructure/internalPoints/pointFlag.hpp +++ b/src/phasicFlow/structuredData/pointStructure/internalPoints/pointFlag.hpp @@ -20,10 +20,10 @@ Licence: #ifndef __pointFlag_hpp__ #define __pointFlag_hpp__ - #include "phasicFlowKokkos.hpp" #include "domain.hpp" #include "scatteredFieldAccess.hpp" +#include "globalSettings.hpp" namespace pFlow { @@ -112,8 +112,7 @@ public: friend class internalPoints; - pointFlag() - {} + pointFlag() = default; pointFlag(uint32 capacity, uint32 start, uint32 end ) : @@ -122,7 +121,7 @@ public: activeRange_(start, end), isAllActive_(true) { - fill(flags_, 0, capacity, static_cast(Flag::DELETED)); + fill(flags_, end, capacity, static_cast(Flag::DELETED)); fill(flags_, activeRange_, static_cast(Flag::INTERNAL)); } @@ -160,6 +159,12 @@ public: return activeRange_; } + INLINE_FUNCTION_HD + uint32 capacity()const + { + return flags_.extent(0); + } + INLINE_FUNCTION_HD auto numActive()const { @@ -289,6 +294,9 @@ public: const box& validBox, ViewType1D points); + uint32 addInternalPoints( + const ViewType1D& points); + bool deletePoints( scatteredFieldAccess points); @@ -345,6 +353,8 @@ public: ViewType1D indices, ViewType1D onOff); + uint32 changeCapacity( uint32 reqEmptySpots ); + }; diff --git a/src/phasicFlow/structuredData/pointStructure/internalPoints/pointFlagKernels.hpp b/src/phasicFlow/structuredData/pointStructure/internalPoints/pointFlagKernels.hpp index ff43112f..3c5c1540 100644 --- a/src/phasicFlow/structuredData/pointStructure/internalPoints/pointFlagKernels.hpp +++ b/src/phasicFlow/structuredData/pointStructure/internalPoints/pointFlagKernels.hpp @@ -122,62 +122,52 @@ pFlow::uint32 pFlow::pointFlag::markOutOfBoxDelete return numDeleted; } -/*template -pFlow::uint32 pFlow::pointFlag::scanPointFlag() +template +pFlow::uint32 +pFlow::pointFlag::addInternalPoints +( + const ViewType1D& points +) { - - using rpScanFlag = Kokkos::RangePolicy>; + if(points.extent(0)==0u)return 0; - uint32 numActive = 0; + uint32 minRange; + uint32 maxRange; + uint32 numAdded = 0; - uint32 start = activeRange().start(); - uint32 end = activeRange().end(); + Kokkos::parallel_reduce( + "pointFlagKernels::addInternalPoints", + deviceRPolicyStatic(0, points.extent(0)), + LAMBDA_HD( + uint32 i, + uint32& minUpdate, + uint32& maxUpdate, + uint32& addToUpdate) + { + uint32 idx = points(i); + if( flags_[idx] <= DELETED) addToUpdate ++; + minUpdate = min(minUpdate,idx); + maxUpdate = max(maxUpdate,idx); + flags_[idx] = INTERNAL; + }, + Kokkos::Min(minRange), + Kokkos::Max(maxRange), + numAdded); - uint32 minRange = end; - uint32 maxRange = start; - - if(startisActive(i)) - { - sumToUpdate++; - minUpdate = min(minUpdate,i); - maxUpdate = max(maxUpdate,i); - } - }, - Kokkos::Min(minRange), - Kokkos::Max(maxRange), - numActive); - } + // add one to max range to make range it half open + maxRange++; - if(numActive==0) - { - minRange = 0; - maxRange = 0; - } - else - { - // add one to maxRange to make it half-open - maxRange ++; - } + minRange = min(activeRange_.start(), minRange); + maxRange = max(activeRange_.end(), maxRange); activeRange_ = {minRange, maxRange}; - numActive_ = numActive; + numActive_ = numActive_ + numAdded; + isAllActive_ = activeRange_.numElements() == numActive_; - - return numActive; -}*/ + + return numAdded; +} template bool pFlow::pointFlag::deletePoints @@ -187,13 +177,7 @@ bool pFlow::pointFlag::deletePoints { if(points.empty())return true; - //uint32 minIndex = points.getFirstCopy(); - //uint32 maxIndex = points.getLastCopy(); - //if(maxIndexactiveRange_.end())return false; - //if(minIndex>; @@ -237,10 +221,6 @@ bool pFlow::pointFlag::deletePoints uint32 s = points.size(); if(s==0u)return true; - //if(maxIndexactiveRange_.end())return false; - //if(minIndex>; @@ -549,4 +529,92 @@ pFlow::uint32 pFlow::pointFlag::markDelete return numMarked; } +template +pFlow::uint32 pFlow::pointFlag::changeCapacity +( + uint32 reqEmptySpots +) +{ + + uint32 oldCap = capacity(); + uint32 newCap = oldCap* pFlow::gSettings::vectorGrowthFactor__+1; + uint32 emptySpots = newCap - numActive_; + + while( emptySpots < reqEmptySpots ) + { + newCap = newCap*pFlow::gSettings::vectorGrowthFactor__+1; + uint32 emptySpots = newCap - numActive_; + } + + viewType newFlags(flags_.label(), newCap); + // copy contnent + copy(newFlags, 0u, flags_, 0u, oldCap); + fill(newFlags, oldCap, newCap, static_cast(DELETED)); + + // reference replacement + flags_ = newFlags; + + return newCap; +} + #endif // __pointFlagKernels_hpp__ + + + + +/*template +pFlow::uint32 pFlow::pointFlag::scanPointFlag() +{ + + using rpScanFlag = Kokkos::RangePolicy>; + + uint32 numActive = 0; + + + uint32 start = activeRange().start(); + uint32 end = activeRange().end(); + + uint32 minRange = end; + uint32 maxRange = start; + + if(startisActive(i)) + { + sumToUpdate++; + minUpdate = min(minUpdate,i); + maxUpdate = max(maxUpdate,i); + } + }, + Kokkos::Min(minRange), + Kokkos::Max(maxRange), + numActive); + } + + if(numActive==0) + { + minRange = 0; + maxRange = 0; + } + else + { + // add one to maxRange to make it half-open + maxRange ++; + } + + activeRange_ = {minRange, maxRange}; + numActive_ = numActive; + isAllActive_ = activeRange_.numElements() == numActive_; + + return numActive; +}*/ \ No newline at end of file