diff --git a/src/Interaction/CMakeLists.txt b/src/Interaction/CMakeLists.txt index 1427433f..c0265808 100644 --- a/src/Interaction/CMakeLists.txt +++ b/src/Interaction/CMakeLists.txt @@ -7,6 +7,8 @@ contactSearch/methods/cellBased/NBS/NBS.cpp contactSearch/methods/cellBased/NBS/cellsWallLevel0.cpp contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.cpp +contactSearch/boundaries/twoPartContactSearch/twoPartContactSearchKernels.cpp +contactSearch/boundaries/twoPartContactSearch/twoPartContactSearch.cpp contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearchKernels.cpp contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.cpp contactSearch/boundaries/periodicBoundaryContactSearch/wallBoundaryContactSearch.cpp @@ -22,6 +24,13 @@ sphereInteraction/sphereInteractionsNonLinearModels.cpp sphereInteraction/sphereInteractionsNonLinearModModels.cpp ) +if(pFlow_Build_MPI) + list(APPEND SourceFiles + contactSearch/boundaries/processorBoundaryContactSearch/processorBoundaryContactSearch.cpp + sphereInteraction/boundaries/processorBoundarySphereInteraction/processorBoundarySphereInteractions.cpp + ) +endif() + set(link_libs Kokkos::kokkos phasicFlow Property Particles Geometry) pFlow_add_library_install(Interaction SourceFiles link_libs) diff --git a/src/Interaction/contactSearch/ContactSearch/ContactSearch.hpp b/src/Interaction/contactSearch/ContactSearch/ContactSearch.hpp index 531ecad9..bb72657d 100644 --- a/src/Interaction/contactSearch/ContactSearch/ContactSearch.hpp +++ b/src/Interaction/contactSearch/ContactSearch/ContactSearch.hpp @@ -130,9 +130,10 @@ public: csPairContainerType& pwPairs, bool force = false) override { - ppTimer().start(); + Particles().boundingSphere().updateBoundaries(DataDirection::SlaveToMaster); + const auto& position = Particles().pointPosition().deviceViewAll(); const auto& flags = Particles().dynPointStruct().activePointsMaskDevice(); const auto& diam = Particles().boundingSphere().deviceViewAll(); diff --git a/src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.hpp b/src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.hpp index 15f5dc6a..0eda8983 100644 --- a/src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.hpp +++ b/src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.hpp @@ -36,15 +36,16 @@ public: using NextType = deviceViewType1D; private: - cells searchCells_; - HeadType head_{"periodic::head", 1, 1, 1}; + cells searchCells_; - NextType next_{"periodic::next", 1}; + HeadType head_{ "periodic::head", 1, 1, 1 }; - real sizeRatio_ = 1.0; + NextType next_{ "periodic::next", 1 }; - uint32 nextCapacity_ = 0; + real sizeRatio_ = 1.0; + + uint32 nextCapacity_ = 0; void checkAllocateNext(uint32 n); diff --git a/src/Interaction/sphereInteraction/boundaries/boundarySphereInteraction/boundarySphereInteraction.hpp b/src/Interaction/sphereInteraction/boundaries/boundarySphereInteraction/boundarySphereInteraction.hpp index b511ac6c..56058b6d 100644 --- a/src/Interaction/sphereInteraction/boundaries/boundarySphereInteraction/boundarySphereInteraction.hpp +++ b/src/Interaction/sphereInteraction/boundaries/boundarySphereInteraction/boundarySphereInteraction.hpp @@ -143,7 +143,9 @@ public: ) override { - notImplementedFunction; + pOutput<<"Function (hearChanges in boundarySphereInteractions)is not implmented Message "<< + msg <name() <<" type "<< this->type()< +inline void sphereSphereInteraction ( real dt, @@ -46,14 +47,6 @@ void sphereSphereInteraction if( ovrlp >0.0 ) { - - /*auto Vi = thisVel[i]; - auto Vj = mirrorVel[j]; - auto wi = thisRVel[i]; - auto wj = mirrorRVel[j]; - auto Nij = (xj-xi)/dist; - auto Vr = Vi - Vj + cross((Ri*wi+Rj*wj), Nij);*/ - auto Nij = (xj-xi)/dist; auto wi = rVel[ind_i]; auto wj = rVel[ind_j]; diff --git a/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp b/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp index cb298cd7..29451289 100644 --- a/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp +++ b/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp @@ -163,9 +163,16 @@ bool pFlow::sphereInteraction::iterate() auto t = this->currentTime(); auto dt = this->dt(); - //output<<"iter, t, dt "<< iter<<" "<< t << " "< getIdRange(uint32 nNewParticles)=0; virtual - bool initialIdCheck()=0; + uint32 maxId()const = 0; + + // heat change for possible insertion of particles // overrdie from internalField diff --git a/src/Particles/particles/particles.cpp b/src/Particles/particles/particles.cpp index b6a389ab..187f45da 100644 --- a/src/Particles/particles/particles.cpp +++ b/src/Particles/particles/particles.cpp @@ -78,7 +78,7 @@ pFlow::particles::particles(systemControl& control) { this->addToSubscriber(dynPointStruct_); - idHandler_().initialIdCheck(); + //idHandler_().initialIdCheck(); } bool @@ -87,7 +87,16 @@ pFlow::particles::beforeIteration() zeroForce(); zeroTorque(); - return dynPointStruct_.beforeIteration(); + if( !dynPointStruct_.beforeIteration()) + { + return false; + } + + shapeIndex_.updateBoundariesSlaveToMasterIfRequested(); + accelertion_.updateBoundariesSlaveToMasterIfRequested(); + idHandler_().updateBoundariesSlaveToMasterIfRequested(); + + return true; } bool diff --git a/src/Particles/particles/particles.hpp b/src/Particles/particles/particles.hpp index a06c5c3c..1f3c7ab1 100644 --- a/src/Particles/particles/particles.hpp +++ b/src/Particles/particles/particles.hpp @@ -181,6 +181,12 @@ public: return contactTorque_; } + inline + uint maxId()const + { + return idHandler_().maxId(); + } + bool beforeIteration() override; bool iterate() override; diff --git a/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.cpp b/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.cpp index 401bc281..1916f430 100644 --- a/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.cpp +++ b/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.cpp @@ -9,6 +9,7 @@ pFlow::regularParticleIdHandler::regularParticleIdHandler : particleIdHandler(pStruct) { + initialIdCheck(); } pFlow::Pair diff --git a/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.hpp b/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.hpp index 4d40261f..a237e0da 100644 --- a/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.hpp +++ b/src/Particles/particles/regularParticleIdHandler/regularParticleIdHandler.hpp @@ -33,6 +33,7 @@ private: uint32 maxId_ = -1; + bool initialIdCheck()override; public: ClassInfo("particleIdHandler"); @@ -50,7 +51,10 @@ public: Pair getIdRange(uint32 nNewParticles)override; - bool initialIdCheck()override; + uint32 maxId()const override + { + return maxId_; + } }; diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index 58117785..de526e20 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -25,6 +25,7 @@ streams/TStream/oTstream.cpp streams/Fstream/iFstream.cpp streams/Fstream/oFstream.cpp streams/Fstream/fileStream.cpp +streams/dataIO/dataIORegulars.cpp streams/streams.cpp fileSystem/fileSystem.cpp @@ -132,14 +133,14 @@ if(pFlow_Build_MPI) message(STATUS "Zoltan lib path: ${ZOLTAN_LIBRARY}") list(APPEND SourceFiles - MPIParallelization/partitioning.cpp - MPIParallelization/rcb1DPartitioning.cpp + MPIParallelization/domain/partitioning/partitioning.cpp + MPIParallelization/domain/partitioning/rcb1DPartitioning.cpp MPIParallelization/domain/MPISimulationDomain.cpp - #MPIParallelization/dataIOMPI.cpp - MPIParallelization/procCommunication.cpp - MPIParallelization/boundaryProcessor.cpp - MPIParallelization/scatteredMasterDistributeChar.cpp - MPIParallelization/processorBoundaryFields.cpp + MPIParallelization/dataIOMPI/dataIOMPIs.cpp + MPIParallelization/MPI/procCommunication.cpp + MPIParallelization/MPI/scatteredMasterDistributeChar.cpp + MPIParallelization/pointStructure/boundaries/boundaryProcessor.cpp + MPIParallelization/pointField/processorBoundaryFields.cpp ) list(APPEND link_libs MPI::MPI_CXX ${ZOLTAN_LIBRARY} -lm ) diff --git a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.cpp b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.cpp index 2d2cc3bf..b2674920 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.cpp +++ b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.cpp @@ -36,6 +36,25 @@ pFlow::boundaryField::boundaryField internal_(internal) {} +template +typename pFlow::boundaryField::ProcVectorType& +pFlow::boundaryField::neighborProcField() +{ + static ProcVectorType dummyVector{"dummyVector"}; + notImplementedFunction; + fatalExit; + return dummyVector; +} + +template +const typename pFlow::boundaryField::ProcVectorType& +pFlow::boundaryField::neighborProcField() const +{ + static ProcVectorType dummyVector{"dummyVector"}; + notImplementedFunction; + fatalExit; + return dummyVector; +} template pFlow::uniquePtr> diff --git a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp index 7e1935a5..d30b3f18 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp @@ -26,6 +26,18 @@ Licence: namespace pFlow { + +// forward +template< class T, class MemorySpace> + class boundaryFieldList; + +enum class DataDirection +{ + MasterToSlave, + SlaveToMaster, + TwoWay +}; + template< class T, class MemorySpace = void> class boundaryField : @@ -43,12 +55,22 @@ public: using FieldAccessType = scatteredFieldAccess; -protected: + using ProcVectorType = VectorSingle; +private: + + /// friend et al. + friend class boundaryFieldList; + /// @brief a ref to the internal field InternalFieldType& internal_; - + virtual + bool updateBoundary(int step, DataDirection direction) + { + return true; + } + public: TypeInfoTemplate211("boundaryField","none" ,T, memory_space::name()); @@ -78,7 +100,6 @@ public: boundaryBase ); - bool hearChanges ( real t, @@ -116,6 +137,12 @@ public: this->mirrorBoundary().indexList().deviceViewAll(), internal_.deviceViewAll()); } + + virtual + ProcVectorType& neighborProcField(); + + virtual + const ProcVectorType& neighborProcField()const; void fill(const std::any& val)override { diff --git a/src/phasicFlow/containers/pointField/boundaryField/boundaryFieldList.hpp b/src/phasicFlow/containers/pointField/boundaryField/boundaryFieldList.hpp index e4179bc2..31a13661 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/boundaryFieldList.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/boundaryFieldList.hpp @@ -43,6 +43,8 @@ protected: const boundaryList& boundaries_; + uint32 slaveToMasterUpdateIter_ = -1; + public: boundaryFieldList(const boundaryList& boundaries, InternalFieldType& internal) @@ -60,6 +62,29 @@ public: } } + void updateBoundaries(uint32 iter, DataDirection direction) + { + if( direction == DataDirection::SlaveToMaster + && slaveToMasterUpdateIter_ == iter) return; + + // first step + for(auto b:*this) + { + b->updateBoundary(1, direction); + } + + // second step + for(auto b:*this) + { + b->updateBoundary(2, direction); + } + + if(direction == DataDirection::SlaveToMaster) + { + slaveToMasterUpdateIter_ = iter; + } + } + void fill(const T& val) { for(auto& bf: *this) @@ -68,6 +93,12 @@ public: } } + bool slaveToMasterUpdateRequested()const + { + return slaveToMasterUpdateIter_ != -1; + } + + }; } diff --git a/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.cpp b/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.cpp index 3e2f0141..c8e3c2c1 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.cpp +++ b/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.cpp @@ -31,7 +31,8 @@ pFlow::generalBoundary::generalBoundary : observer(&boundary, defaultMessage_), boundary_(boundary), - pStruct_(pStruct) + pStruct_(pStruct), + isBoundaryMaster_(boundary.isBoundaryMaster()) {} diff --git a/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.hpp b/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.hpp index 18105542..c55a7f71 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.hpp @@ -45,16 +45,10 @@ private: const pointStructure& pStruct_; + const bool isBoundaryMaster_; static inline const message defaultMessage_{message::BNDR_RESET}; - - template - inline - bool checkForType()const - { - return typeName() == BoundaryFieldType::TYPENAME(); - } public: @@ -68,7 +62,6 @@ public: ~generalBoundary()override = default; - inline uint32 thisBoundaryIndex()const { @@ -93,6 +86,24 @@ public: return boundary_.capacity(); } + inline + auto neighborProcSize()const + { + return boundary_.neighborProcSize(); + } + + inline + int neighborProcessorNo()const + { + return boundary_.neighborProcessorNo(); + } + + inline + int thisProcessorNo()const + { + return boundary_.thisProcessorNo(); + } + inline const auto& boundary()const { @@ -129,22 +140,17 @@ public: return pStruct_; } + inline + bool isBoundaryMaster()const + { + return isBoundaryMaster_; + } + const Time& time()const; virtual void fill(const std::any& val)=0; - /*template - BoundaryFieldType& thisField() - { - return static_cast(*this); - } - - template - const BoundaryFieldType& thisField()const - { - return static_cast(*this); - }*/ }; diff --git a/src/phasicFlow/containers/pointField/internalField/internalField.hpp b/src/phasicFlow/containers/pointField/internalField/internalField.hpp index 779b0c61..423f1ef7 100644 --- a/src/phasicFlow/containers/pointField/internalField/internalField.hpp +++ b/src/phasicFlow/containers/pointField/internalField/internalField.hpp @@ -181,6 +181,11 @@ public: return field_.insertSetElement(indices, val); } + inline const Time& time()const + { + return internalPoints_.time(); + } + bool hearChanges ( real t, diff --git a/src/phasicFlow/containers/pointField/pointField/pointField.hpp b/src/phasicFlow/containers/pointField/pointField/pointField.hpp index d42870d5..345dfdcc 100644 --- a/src/phasicFlow/containers/pointField/pointField/pointField.hpp +++ b/src/phasicFlow/containers/pointField/pointField/pointField.hpp @@ -24,7 +24,7 @@ Licence: #include "pointStructure.hpp" #include "internalField.hpp" #include "boundaryFieldList.hpp" - +#include "Time.hpp" namespace pFlow { @@ -103,6 +103,23 @@ public: return static_cast(*this); } + void updateBoundaries(DataDirection direction)const + { + uint32 iter = this->time().currentIter(); + auto& bList = const_cast(boundaryFieldList_); + bList.updateBoundaries(iter, direction); + } + + /// @brief update boundaries if it is requested previousely (slave to master). + /// It only checks for SlaveToMaster direction. + void updateBoundariesSlaveToMasterIfRequested() + { + if(boundaryFieldList_.slaveToMasterUpdateRequested()) + { + updateBoundaries(DataDirection::SlaveToMaster); + } + } + const auto& boundaryFields()const { return boundaryFieldList_; diff --git a/src/phasicFlow/processors/localProcessors.cpp b/src/phasicFlow/processors/localProcessors.cpp index 0dc7e658..7b1067c4 100644 --- a/src/phasicFlow/processors/localProcessors.cpp +++ b/src/phasicFlow/processors/localProcessors.cpp @@ -1,3 +1,22 @@ +/*------------------------------- 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 "localProcessors.hpp" pFlow::localProcessors::localProcessors(const word &name) @@ -8,8 +27,8 @@ pFlow::localProcessors::localProcessors(const word &name) name_(name) { #ifdef pFlow_Build_MPI - parrentCommunicator_ = pFlow::MPI::CommWorld; - localCommunicator_ = pFlow::MPI::CommWorld; + parrentCommunicator_ = MPI_COMM_WORLD; + localCommunicator_ = MPI_COMM_WORLD; #endif } @@ -24,7 +43,7 @@ pFlow::localProcessors::localProcessors name_(name) { #ifdef pFlow_Build_MPI - parrentCommunicator_ = pFlow::MPI::CommWorld; + parrentCommunicator_ = MPI_COMM_WORLD; if(ranks.size()> this->globalSize() ) { @@ -33,17 +52,17 @@ pFlow::localProcessors::localProcessors fatalExit; } - pFlow::MPI::Group globalGroup; + MPI_Group globalGroup; MPI_Comm_group(parrentCommunicator_, &globalGroup); - pFlow::MPI::Group localGroup; + MPI_Group localGroup; MPI_Group_incl(globalGroup, ranks.size(), ranks.data(), &localGroup); // Create the new communicator from that group of processes. CheckMPI( MPI_Comm_create(parrentCommunicator_, localGroup, &localCommunicator_), true); - isPartOfLocal_ = localCommunicator_ != MPI::CommNull; + isPartOfLocal_ = localCommunicator_ != MPI_COMM_NULL; if(isPartOfLocal_) { @@ -71,7 +90,7 @@ pFlow::localProcessors::localProcessors pFlow::localProcessors::localProcessors ( - pFlow::MPI::Comm parrentComm, + MPI_Comm parrentComm, const word &name, const std::vector &ranks ) @@ -92,17 +111,17 @@ pFlow::localProcessors::localProcessors fatalExit; } - pFlow::MPI::Group parGroup; + MPI_Group parGroup; MPI_Comm_group(parrentCommunicator_, &parGroup); - pFlow::MPI::Group localGroup; + MPI_Group localGroup; MPI_Group_incl(parGroup, ranks.size(), ranks.data(), &localGroup); // Create the new communicator from that group of processes. CheckMPI( MPI_Comm_create(parrentCommunicator_, localGroup, &localCommunicator_), true); - isPartOfLocal_ = localCommunicator_ != MPI::CommNull; + isPartOfLocal_ = localCommunicator_ != MPI_COMM_NULL; if(isPartOfLocal_) { diff --git a/src/phasicFlow/processors/localProcessors.hpp b/src/phasicFlow/processors/localProcessors.hpp index 41e07f9e..eab18c08 100644 --- a/src/phasicFlow/processors/localProcessors.hpp +++ b/src/phasicFlow/processors/localProcessors.hpp @@ -25,7 +25,7 @@ Licence: #include "types.hpp" #ifdef pFlow_Build_MPI - #include "mpiTypes.hpp" + #include "mpi.h" #endif @@ -39,9 +39,9 @@ class localProcessors private: #ifdef pFlow_Build_MPI - pFlow::MPI::Comm parrentCommunicator_; + MPI_Comm parrentCommunicator_; - pFlow::MPI::Comm localCommunicator_; + MPI_Comm localCommunicator_; #endif int localSize_ = 1 ; @@ -70,7 +70,7 @@ public: #ifdef pFlow_Build_MPI localProcessors( - pFlow::MPI::Comm parrentComm, + MPI_Comm parrentComm, const word& name, const std::vector& ranks); #endif diff --git a/src/phasicFlow/processors/processors.cpp b/src/phasicFlow/processors/processors.cpp index 67f71bb2..f5eb066a 100644 --- a/src/phasicFlow/processors/processors.cpp +++ b/src/phasicFlow/processors/processors.cpp @@ -58,11 +58,13 @@ void pFlow::processors::initProcessors(int argc, char *argv[]) if(processors::globalParallel()) { pFlow::pOutput.activatePrefix(); - pFlow::pOutput.setPrefixNum(processors::globalRank_); + pFlow::pOutput.setPrefixNum(processors::globalRank_); + pFlow::errReport.activatePrefix(); + pFlow::errReport.setPrefixNum(processors::globalRank_); } pFlow::mOutput.setMasterSlave(processors::globalMaster()); - pFlow::errReport.setMasterSlave(processors::globalMaster()); + MPI_Type_contiguous(3, pFlow::MPI::Type(), &pFlow::MPI::realx3Type__); MPI_Type_commit(&pFlow::MPI::realx3Type__); diff --git a/src/phasicFlow/repository/IOobject/IOPattern.hpp b/src/phasicFlow/repository/IOobject/IOPattern.hpp index 9bd46e09..9c1e3a13 100644 --- a/src/phasicFlow/repository/IOobject/IOPattern.hpp +++ b/src/phasicFlow/repository/IOobject/IOPattern.hpp @@ -41,7 +41,7 @@ public: * * MasterProcessorDistribute: Read is done on master processor, but * the data should be distributed between processors based on an externally - * specified pattern. Write is done on master processors and the data is + * specified pattern. Write is done on master processor and the data is * collected from all processors (collection is done based on the externally * specified pattern). * @@ -146,7 +146,6 @@ public: bool thisProcWriteData()const { if(isAllProcessorsDifferent()) return true; - if(isMasterProcessorDistribute())return true; return isMaster(); } diff --git a/src/phasicFlow/repository/IOobject/IOobject.cpp b/src/phasicFlow/repository/IOobject/IOobject.cpp index c3956d1e..b5857ea1 100644 --- a/src/phasicFlow/repository/IOobject/IOobject.cpp +++ b/src/phasicFlow/repository/IOobject/IOobject.cpp @@ -118,8 +118,9 @@ bool pFlow::IOobject::readObject(bool rdHdr) bool pFlow::IOobject::writeObject() const { - - if(implyWrite()&& ioPattern().thisCallWrite()) + if(!implyWrite()) return true; + + if(ioPattern().thisCallWrite()) { if(auto ptrOS = outStream(); ptrOS ) @@ -160,7 +161,9 @@ bool pFlow::IOobject::readObject(iIstream& is, bool rdHdr) bool pFlow::IOobject::writeObject(iOstream& os) const { if(this->writeHeader() && ioPattern().thisProcWriteHeader()) - writeHeader(os, typeName()); + { + writeHeader(os, typeName()); + } if(ioPattern().thisCallWrite()) { diff --git a/src/phasicFlow/repository/systemControl/systemControl.cpp b/src/phasicFlow/repository/systemControl/systemControl.cpp index eef9fea3..ab9a52b8 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.cpp +++ b/src/phasicFlow/repository/systemControl/systemControl.cpp @@ -199,7 +199,7 @@ bool pFlow::systemControl::operator++(int) if (time().timersReportTime() && timersReport()) { - timers_.write(output, true); + timers_.write(mOutput, true); } } else if (time().finalTime()) @@ -212,7 +212,7 @@ bool pFlow::systemControl::operator++(int) } writeToFileTimer_.end(); - timers_.write(output, true); + timers_.write(mOutput, true); } return toContinue; diff --git a/src/phasicFlow/streams/dataIO/dataIO.cpp b/src/phasicFlow/streams/dataIO/dataIO.cpp index f1b0974d..39fbd9e0 100644 --- a/src/phasicFlow/streams/dataIO/dataIO.cpp +++ b/src/phasicFlow/streams/dataIO/dataIO.cpp @@ -202,7 +202,7 @@ bool pFlow::dataIO::writeData(iOstream& os, span data) if( ioPattern_.thisProcWriteData()) { - return writeDataAsciiBinary(os, data); + return writeDataAsciiBinary(os, bufferSpan_); } else { @@ -215,7 +215,7 @@ inline bool pFlow::dataIO::writeData(iOstream& os, span data) { - if( ioPattern_.isParallel() ) + if( ioPattern_.isParallel() && ioPattern_.isMasterProcessorDistribute()) { notImplementedFunction<< "data transfer for type word is not supported in parallel mode!"<::writeData(iOstream& os, span data) if( ioPattern_.thisProcWriteData()) { - return writeDataASCII(os, data); + return writeDataASCII(os, bufferSpan_); } else { diff --git a/src/phasicFlow/streams/dataIO/dataIO.hpp b/src/phasicFlow/streams/dataIO/dataIO.hpp index 04f28c79..281fe832 100644 --- a/src/phasicFlow/streams/dataIO/dataIO.hpp +++ b/src/phasicFlow/streams/dataIO/dataIO.hpp @@ -31,8 +31,6 @@ Licence: #include "virtualConstructor.hpp" #include "pFlowProcessors.hpp" - - namespace pFlow { diff --git a/src/phasicFlow/streams/dataIO/dataIOMPI.hpp b/src/phasicFlow/streams/dataIO/dataIOMPI.hpp deleted file mode 100644 index 850cf69b..00000000 --- a/src/phasicFlow/streams/dataIO/dataIOMPI.hpp +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef __datIOMPI_hpp__ -#define __datIOMPI_hpp__ - -#include "dataIO.hpp" -#include "pFlowProcessors.hpp" - -#ifdef pFlow_Build_MPI - #include "gatherMaster.hpp" -#endif - -namespace pFlow -{ - -template -class dataIOMPI -: - public dataIO -{ -protected: - - bool gatherData(span data ) override - { - - if(this->ioPattern_.isAllProcessorsDifferent()) - { - this->bufferSpan_ = data; - return true; - } - - if( this->ioPattern_.isMasterProcessorDistribute()) - { - -#ifdef pFlow_Build_MPI - - auto gatherT = pFlow::MPI::gatherMaster(pFlowProcessors()); - - if(!gatherT.gatherData(data)) - { - fatalErrorInFunction<<"Error in gathering data to master"<buffer_ = gatherT.moveData(); - - this->bufferSpan_ = makeSpan(this->buffer_); - - return true; -#else - notImplementedFunction; - fatalExit; - return false; -#endif //pFlow_Build_MPI - - } - - if( this->ioPattern_.isMasterProcessorOnly() || this->ioPattern_.isAllProcessorSimilar() ) - { - if( this->ioPattern_.isMaster() ) - { - this->bufferSpan_ = data; - } - else - { - this->bufferSpan_ = span(nullptr, 0); - return true; - } - } - - return false; - } -public: - - TypeInfo("dataIO"); - - dataIOMPI(const IOPattern& iop) - : - dataIO(iop) - {} - - dataIOMPI(const dataIOMPI&) = default; - - dataIOMPI(dataIOMPI&&) = default; - - - dataIOMPI& operator=(const dataIOMPI&) = default; - - dataIOMPI& operator=(dataIOMPI&&) = default; - - ~dataIOMPI() = default; - -}; - - -} - - -#endif \ No newline at end of file diff --git a/src/phasicFlow/streams/dataIO/dataIORegulars.cpp b/src/phasicFlow/streams/dataIO/dataIORegulars.cpp index 740c0401..d1067504 100644 --- a/src/phasicFlow/streams/dataIO/dataIORegulars.cpp +++ b/src/phasicFlow/streams/dataIO/dataIORegulars.cpp @@ -19,9 +19,15 @@ template class pFlow::dataIORegular; template class pFlow::dataIO; template class pFlow::dataIORegular; +template class pFlow::dataIO; +template class pFlow::dataIORegular; + template class pFlow::dataIO; template class pFlow::dataIORegular; +template class pFlow::dataIO; +template class pFlow::dataIORegular; + template class pFlow::dataIO; template class pFlow::dataIORegular; diff --git a/src/phasicFlow/streams/iStream/iIstream.hpp b/src/phasicFlow/streams/iStream/iIstream.hpp index 2dbf0fa9..817d42e3 100755 --- a/src/phasicFlow/streams/iStream/iIstream.hpp +++ b/src/phasicFlow/streams/iStream/iIstream.hpp @@ -260,6 +260,8 @@ inline iIstream& operator>>( iIstream& is, float& val); inline iIstream& operator>>( iIstream& is, double& val); +inline iIstream& operator>>( iIstream& is, size_t& val); + } // pFlow diff --git a/src/phasicFlow/streams/iStream/iIstreamI.hpp b/src/phasicFlow/streams/iStream/iIstreamI.hpp index 9ddb739a..1c73f87b 100755 --- a/src/phasicFlow/streams/iStream/iIstreamI.hpp +++ b/src/phasicFlow/streams/iStream/iIstreamI.hpp @@ -295,3 +295,35 @@ inline pFlow::iIstream& pFlow::operator>>( iIstream& is, double& val) return is; } +inline pFlow::iIstream& pFlow::operator>>( iIstream& is, size_t& val) +{ + token t(is); + if (!t.good()) + { + ioErrorInFile(is.name(), is.lineNumber()) + << "Bad token - could not get double value"; + fatalExit; + is.setBad(); + return is; + } + + if (t.isNumber()) + { + val = static_cast(t.number()); + } + else + { + ioErrorInFile(is.name(), is.lineNumber()) + << "Wrong token type - expected double value, found " + << t; + fatalExit; + is.setBad(); + return is; + } + + is.check(FUNCTION_NAME); + return is; +} + + + diff --git a/src/phasicFlow/streams/streams.cpp b/src/phasicFlow/streams/streams.cpp index 12ad3690..9b49dbf8 100755 --- a/src/phasicFlow/streams/streams.cpp +++ b/src/phasicFlow/streams/streams.cpp @@ -9,5 +9,5 @@ pFlow::processorOstream pFlow::pOutput(cout, "pFlow processorOstream"); pFlow::Istream pFlow::input( std::cin, "sFlow Istream"); -pFlow::masterOstream pFlow::errReport( std::cerr, "pFlow error report stream"); +pFlow::processorOstream pFlow::errReport( std::cerr, "pFlow error report stream"); diff --git a/src/phasicFlow/streams/streams.hpp b/src/phasicFlow/streams/streams.hpp index 683bba58..56e2f2b6 100755 --- a/src/phasicFlow/streams/streams.hpp +++ b/src/phasicFlow/streams/streams.hpp @@ -28,12 +28,12 @@ namespace pFlow extern Istream input; - extern masterOstream errReport; + extern processorOstream errReport; } -#define INFORMATION pFlow::mOutput< INFO: "< INFO: "<("mirrorProcessorNo")), + neighborProcessorNo_(dict.getVal("neighborProcessorNo")), + isBoundaryMaster_(thisProcessorNo()>=neighborProcessorNo()), name_(dict.name()), type_(dict.getVal("type")) { @@ -231,13 +232,22 @@ pFlow::boundaryBase::thisPoints()const } -typename pFlow::boundaryBase::pointFieldAccessType - pFlow::boundaryBase::neighborPoints()const +pFlow::realx3Vector_D& pFlow::boundaryBase::neighborProcPoints() { - notImplementedFunction; - return pointFieldAccessType(); + static realx3Vector_D dummyVector{"dummyVector"}; + notImplementedFunction; + fatalExit; + return dummyVector; } +const pFlow::realx3Vector_D& +pFlow::boundaryBase::neighborProcPoints()const +{ + static realx3Vector_D dummyVector{"dummyVector"}; + notImplementedFunction; + fatalExit; + return dummyVector; +} pFlow::realx3 pFlow::boundaryBase::displacementVectroToMirror() const { diff --git a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp index 15b8284f..54fb94d0 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp @@ -51,42 +51,48 @@ public: private: - // friend et al. + // friend et al. friend boundaryList; - const plane& boundaryPlane_; + const plane& boundaryPlane_; - /// list of particles indices on device - uint32Vector_D indexList_; + /// list of particles indices on device + uint32Vector_D indexList_; /// list of particles indieces on host - mutable uint32Vector_H indexListHost_; + mutable uint32Vector_H indexListHost_; /// device and host list are sync - mutable bool listsSync_ = false; + mutable bool listsSync_ = false; - /// The length defined for creating neighbor list - real neighborLength_; + /// The length defined for creating neighbor list + real neighborLength_; - /// a reference to internal points - internalPoints& internal_; + /// a reference to internal points + internalPoints& internal_; - /// a reference to the list of boundaries + /// a reference to the list of boundaries /// (never use this in the constructor). - boundaryList& boundaries_; + boundaryList& boundaries_; - uint32 thisBoundaryIndex_; + uint32 thisBoundaryIndex_; - uint32 mirrorProcessoNo_; + int neighborProcessorNo_; - word name_; + bool isBoundaryMaster_; - word type_; + word name_; + + word type_; protected: - /// @brief set the size of indexList - void setSize(uint32 newSize); + /// @brief Set the size of indexList. + /// It is virtual to let derived classed to be aware of + /// the fact that the size of boundary points has been changed. + /// So, any drived class that override this method should call + /// boundaryBase::setSize(newSize) too. + virtual void setSize(uint32 newSize); void setNewIndices(const uint32Vector_D& newIndices); @@ -116,6 +122,17 @@ protected: } } + /// Update this boundary data in two steps (1 and 2). + /// This is called after calling beforeIteration for + /// all boundaries, so any particle addition, deletion, + /// and transfer has been finished up to this point. + /// This two-step update help to have a flexible mechanism + /// for data transfer, mostly for MPI related jobs. + virtual + bool updataBoundary(int step) + { + return true; + } public: @@ -213,6 +230,24 @@ public: return indexList_.capacity(); } + inline + int neighborProcessorNo()const + { + return neighborProcessorNo_; + } + + inline + int thisProcessorNo()const + { + return pFlowProcessors().localRank(); + } + + inline + bool isBoundaryMaster()const + { + return isBoundaryMaster_; + } + inline uint32 thisBoundaryIndex()const { @@ -283,8 +318,22 @@ public: pointFieldAccessType thisPoints()const; + /// @brief Return number of points in the neighbor processor boundary + virtual + uint32 neighborProcSize()const + { + return 0; + } + + /// @brief Return a reference to point positions in the neighbor + /// processor boundary. virtual - pointFieldAccessType neighborPoints()const; + realx3Vector_D& neighborProcPoints(); + + /// @brief Return a const reference to point positions in the + /// neighbor processor boundary. + virtual + const realx3Vector_D& neighborProcPoints()const; /// - static create static diff --git a/src/phasicFlow/structuredData/boundaries/boundaryList.cpp b/src/phasicFlow/structuredData/boundaries/boundaryList.cpp index 9073d9e7..a00476d6 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryList.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryList.cpp @@ -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,49 +21,44 @@ Licence: #include "boundaryList.hpp" #include "pointStructure.hpp" -void pFlow::boundaryList::setExtendedDomain() +void +pFlow::boundaryList::setExtendedDomain() { - if(!listSet_) + if (!listSet_) { - fatalErrorInFunction<< - "boundary list is not set yet and you used the objects."< dist; + std::array dist; dist[0] = boundary(0).neighborLength(); dist[1] = boundary(1).neighborLength(); dist[2] = boundary(2).neighborLength(); @@ -71,71 +66,66 @@ bool pFlow::boundaryList::updateLists() dist[4] = boundary(4).neighborLength(); dist[5] = boundary(5).neighborLength(); - pStruct_.updateFlag( - extendedDomain_, - dist); + pStruct_.updateFlag(extendedDomain_, dist); const auto& maskD = pStruct_.activePointsMaskDevice(); - boundary(0).setSize( maskD.leftSize() ); - boundary(1).setSize( maskD.rightSize() ); - boundary(2).setSize( maskD.bottomSize() ); - boundary(3).setSize( maskD.topSize() ); - boundary(4).setSize( maskD.rearSize() ); - boundary(5).setSize( maskD.frontSize() ); + boundary(0).setSize(maskD.leftSize()); + boundary(1).setSize(maskD.rightSize()); + boundary(2).setSize(maskD.bottomSize()); + boundary(3).setSize(maskD.topSize()); + boundary(4).setSize(maskD.rearSize()); + boundary(5).setSize(maskD.frontSize()); pStruct_.fillNeighborsLists( - boundary(0).indexList().deviceViewAll(), - boundary(1).indexList().deviceViewAll(), - boundary(2).indexList().deviceViewAll(), - boundary(3).indexList().deviceViewAll(), - boundary(4).indexList().deviceViewAll(), - boundary(5).indexList().deviceViewAll()); - - - return true; + boundary(0).indexList().deviceViewAll(), + boundary(1).indexList().deviceViewAll(), + boundary(2).indexList().deviceViewAll(), + boundary(3).indexList().deviceViewAll(), + boundary(4).indexList().deviceViewAll(), + boundary(5).indexList().deviceViewAll() + ); + + return true; } -pFlow::boundaryList::boundaryList -( - pointStructure& pStruct -) -: - ListPtr(pStruct.simDomain().sizeOfBoundaries()), - pStruct_(pStruct), - timeControl_ - ( - pStruct.simDomain().subDict("boundaries"), - "update", - pStruct.currentTime() - ) -{} - -bool pFlow::boundaryList::updateLists(uint32 iter, real t, real dt) +pFlow::boundaryList::boundaryList(pointStructure& pStruct) + : ListPtr(pStruct.simDomain().sizeOfBoundaries()), + pStruct_(pStruct), + timeControl_( + pStruct.simDomain().subDict("boundaries"), + "update", + pStruct.currentTime() + ) { - if( timeControl_.timeEvent(iter, t, dt)) +} + +bool +pFlow::boundaryList::updateNeighborLists(uint32 iter, real t, real dt) +{ + if (timeControl_.timeEvent(iter, t, dt)) { - return updateLists(); + return updateNeighborLists(); } return true; } -bool pFlow::boundaryList::setLists() +bool +pFlow::boundaryList::createBoundaries() { - if(listSet_)return true; + if (listSet_) + return true; - for(auto i=0; iset - ( - i, - boundaryBase::create - ( - pStruct_.simDomain().boundaryDict(i), - pStruct_.simDomain().boundaryPlane(i), - pStruct_, - *this, - i - ) + this->set( + i, + boundaryBase::create( + pStruct_.simDomain().boundaryDict(i), + pStruct_.simDomain().boundaryPlane(i), + pStruct_, + *this, + i + ) ); } listSet_ = true; @@ -146,81 +136,81 @@ bool pFlow::boundaryList::setLists() pFlow::box pFlow::boundaryList::internalDomainBox() const { - const auto& thisBox = pStruct_.thisDomain().domainBox(); - + const auto& thisBox = pStruct_.thisDomain().domainBox(); + const realx3 lowerPointDisplacement = { - boundary(0).neighborLengthIntoInternal(), - boundary(2).neighborLengthIntoInternal(), - boundary(4).neighborLengthIntoInternal()}; + boundary(0).neighborLengthIntoInternal(), + boundary(2).neighborLengthIntoInternal(), + boundary(4).neighborLengthIntoInternal() + }; const realx3 upperPointDisplacement = { - boundary(1).neighborLengthIntoInternal(), - boundary(3).neighborLengthIntoInternal(), - boundary(5).neighborLengthIntoInternal()}; - - return {thisBox.minPoint() + lowerPointDisplacement, - thisBox.maxPoint() - upperPointDisplacement}; + boundary(1).neighborLengthIntoInternal(), + boundary(3).neighborLengthIntoInternal(), + boundary(5).neighborLengthIntoInternal() + }; + + return { thisBox.minPoint() + lowerPointDisplacement, + thisBox.maxPoint() - upperPointDisplacement }; } bool pFlow::boundaryList::beforeIteration(uint32 iter, real t, real dt) { - // it is time to update lists - if(timeControl_.timeEvent(iter, t, dt)) + // it is time to update lists + if (timeControl_.timeEvent(iter, t, dt) && !updateNeighborLists()) { - if(!updateLists()) + fatalErrorInFunction; + return false; + } + + for (auto bdry : *this) + { + if (!bdry->beforeIteration(iter, t, dt)) { - fatalErrorInFunction; + fatalErrorInFunction << "Error in beforeIteration in boundary " + << bdry->name() << endl; return false; } } - for(auto& bdry:*this) + for (auto bdry : *this) { - if( !bdry->beforeIteration(iter, t, dt)) - { - fatalErrorInFunction<< - "Error in beforeIteration in boundary "<name()<updataBoundary(1); } - return true; + for (auto bdry : *this) + { + bdry->updataBoundary(2); + } + + return true; } -bool pFlow::boundaryList::iterate -( - uint32 iter, - real t, - real dt -) +bool +pFlow::boundaryList::iterate(uint32 iter, real t, real dt) { - for(auto& bdry:*this) + for (auto& bdry : *this) { - if( !bdry->iterate(iter, t, dt)) + if (!bdry->iterate(iter, t, dt)) { - fatalErrorInFunction<< - "Error in iterate in boundary "<name()<afterIteration(iter, t, dt)) - { - fatalErrorInFunction<< - "Error in afterIteration in boundary "<name()<name() << endl; + return false; + } + } + return true; +} + +bool +pFlow::boundaryList::afterIteration(uint32 iter, real t, real dt) +{ + for (auto& bdry : *this) + { + if (!bdry->afterIteration(iter, t, dt)) + { + fatalErrorInFunction << "Error in afterIteration in boundary " + << bdry->name() << endl; return false; } } diff --git a/src/phasicFlow/structuredData/boundaries/boundaryList.hpp b/src/phasicFlow/structuredData/boundaries/boundaryList.hpp index c5e3b25e..5eba6399 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryList.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryList.hpp @@ -40,24 +40,23 @@ class boundaryList private: //// - data members - pointStructure& pStruct_; + pointStructure& pStruct_; - baseTimeControl timeControl_; + baseTimeControl timeControl_; - domain extendedDomain_; + domain extendedDomain_; - box internalDomainBox_; + box internalDomainBox_; - bool listSet_ = false; + bool listSet_ = false; - void setExtendedDomain(); + void setExtendedDomain(); - bool resetLists(); - - /// @brief update neighbor list of boundaries regardless - /// of the time intervals - bool updateLists(); + bool resetLists(); + /// @brief update neighbor list of boundaries regardless + /// of the time intervals + bool updateNeighborLists(); public: @@ -66,16 +65,16 @@ public: //// - Constructors - boundaryList(pointStructure& pStruct); + explicit boundaryList(pointStructure& pStruct); - ~boundaryList() = default; + virtual ~boundaryList() = default; /// @brief update neighbor list of boundaries based on /// the time intervals - bool updateLists(uint32 iter, real t, real dt); + bool updateNeighborLists(uint32 iter, real t, real dt); - bool setLists(); + bool createBoundaries(); inline const pointStructure& pStruct()const @@ -115,8 +114,6 @@ public: box internalDomainBox()const; - - bool beforeIteration(uint32 iter, real t, real dt); bool iterate(uint32 iter, real t, real dt); diff --git a/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp b/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp index 7f999541..e94d111e 100644 --- a/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp +++ b/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp @@ -51,9 +51,9 @@ bool pFlow::regularSimulationDomain::createBoundaryDicts() return false; } - if(!bDict.add("mirrorProcessorNo",(uint32) processors::globalRank())) + if(!bDict.add("neighborProcessorNo",(uint32) processors::globalRank())) { - fatalErrorInFunction<<"error in adding mirrorProcessorNo to "<< bName << + fatalErrorInFunction<<"error in adding neighborProcessorNo to "<< bName << " in dictionary "<< boundaries.globalName()< src, - span dst, - size_t sizeOfElement +bool +pFlow::regularSimulationDomain::domainActive() const +{ + return true; +} + +const pFlow::domain& +pFlow::regularSimulationDomain::thisDomain() const +{ + return thisDomain_; +} + +bool +pFlow::regularSimulationDomain::initialTransferBlockData( + span src, + span dst, + size_t sizeOfElement ) const { size_t requiredSize = sizeOfElement*initialNumberInThis(); @@ -209,7 +221,3 @@ const pFlow::dictionary &pFlow::regularSimulationDomain::thisBoundaryDict() cons return this->subDict("regularBoundaries"); } -bool pFlow::regularSimulationDomain::requiresDataTransfer()const -{ - return false; -} diff --git a/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp b/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp index 39491387..74bea6bc 100644 --- a/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp +++ b/src/phasicFlow/structuredData/domain/regularSimulationDomain.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. @@ -26,81 +26,70 @@ Licence: namespace pFlow { -class regularSimulationDomain -: +class regularSimulationDomain +: public simulationDomain { -protected: +private: - uint32 initialNumPoints_=0; + domain thisDomain_; - bool createBoundaryDicts() override; + uint32 initialNumPoints_ = 0; - bool setThisDomain()override; + bool createBoundaryDicts() final; + + bool setThisDomain() final; public: TypeInfo("simulationDomain"); - regularSimulationDomain(systemControl& control); + explicit regularSimulationDomain(systemControl& control); - virtual - ~regularSimulationDomain()=default; - - add_vCtor - ( - simulationDomain, - regularSimulationDomain, - systemControl - ); + ~regularSimulationDomain() final = default; - bool initialUpdateDomains(span pointPos) override; + add_vCtor(simulationDomain, regularSimulationDomain, systemControl); - uint32 initialNumberInThis()const override; + bool initialUpdateDomains(span pointPos) final; - bool initialThisDomainActive()const override - { - return true; - } + uint32 initialNumberInThis() const final; - /*bool updateDomains( - span pointPos, - pFlagTypeHost flags) override;*/ - - uint32 numberToBeImported()const override; + uint32 numberToBeImported() const final; - uint32 numberToBeExported()const override; + uint32 numberToBeExported() const final; + + /// @brief Is this domain active? + /// Active mean, there is particle in it and + /// boundaries and other entities of simulation domains are valid + bool domainActive() const final; + + /// @brief return the simulation domain of this processor + const domain& thisDomain() const final; bool initialTransferBlockData( - span src, - span dst, - size_t sizeOfElement) const override; + span src, + span dst, + size_t sizeOfElement + ) const final; + /// @brief + /// @param src + /// @param dst + /// @return + bool initialTransferBlockData(span src, span dst) + const final; - /// @brief - /// @param src - /// @param dst - /// @return - bool initialTransferBlockData( - span src, - span dst) const override; + bool initialTransferBlockData(span src, span dst) + const final; - bool initialTransferBlockData( - span src, - span dst) const override; + bool initialTransferBlockData(span src, span dst) + const final; - bool initialTransferBlockData( - span src, - span dst) const override; + bool initialTransferBlockData(span src, span dst) + const final; - bool initialTransferBlockData( - span src, - span dst) const override; - - - const dictionary& thisBoundaryDict()const override; + const dictionary& thisBoundaryDict() const final; - bool requiresDataTransfer() const override; }; } diff --git a/src/phasicFlow/structuredData/domain/simulationDomain.cpp b/src/phasicFlow/structuredData/domain/simulationDomain.cpp index dde24ae9..07a3a479 100644 --- a/src/phasicFlow/structuredData/domain/simulationDomain.cpp +++ b/src/phasicFlow/structuredData/domain/simulationDomain.cpp @@ -52,8 +52,14 @@ pFlow::domain pFlow::simulationDomain::extendThisDomain return domain({minP, maxP}); } +const pFlow::plane& +pFlow::simulationDomain::boundaryPlane(uint32 i) const +{ + return thisDomain().boundaryPlane(i); +} + pFlow::uniquePtr - pFlow::simulationDomain::create(systemControl &control) +pFlow::simulationDomain::create(systemControl& control) { word sType = angleBracketsNames( "simulationDomain", diff --git a/src/phasicFlow/structuredData/domain/simulationDomain.hpp b/src/phasicFlow/structuredData/domain/simulationDomain.hpp index af49ee21..071e1326 100644 --- a/src/phasicFlow/structuredData/domain/simulationDomain.hpp +++ b/src/phasicFlow/structuredData/domain/simulationDomain.hpp @@ -39,33 +39,27 @@ class simulationDomain : public fileDictionary { -private: +private: -static inline constexpr uint32 sizeOfBoundaries_ = 6; - -static -inline const std::array boundaryNames_ = -{ - "left", "right", - "bottom", "top", - "rear", "front" -}; - -protected: - - //fileDictionary globalDomainDict_ ; - - /// @brief acutal limits of the simulation domain + /// @brief acutal limits of the global box of simulation box globalBox_; - /// @brief the actual limits of this processor domain - domain thisDomain_; - bool boundariesSet_ = false; + static constexpr uint32 sizeOfBoundaries_ = 6; + + static + inline const std::array boundaryNames_ = + { + "left", "right", + "bottom", "top", + "rear", "front" + }; - virtual bool createBoundaryDicts() = 0; + virtual + bool createBoundaryDicts() = 0; - virtual bool setThisDomain() = 0; + virtual + bool setThisDomain() = 0; public: @@ -73,11 +67,10 @@ public: TypeInfo("simulationDomain"); /// Constrcut from components - simulationDomain(systemControl& control); + explicit simulationDomain(systemControl& control); /// Destructor - virtual - ~simulationDomain() = default; + ~simulationDomain() override = default; create_vCtor @@ -88,6 +81,11 @@ public: (control) ); + const auto& globalBox()const + { + return globalBox_; + } + virtual const dictionary& thisBoundaryDict()const = 0; @@ -97,9 +95,6 @@ public: virtual uint32 initialNumberInThis()const = 0; - virtual - bool initialThisDomainActive()const = 0; - virtual bool initialTransferBlockData( span src, @@ -139,9 +134,7 @@ public: charSpan(dst), el ); - } - - + } /// @brief Number of points to be imported after updating domains /// @return number of points @@ -151,40 +144,46 @@ public: virtual uint32 numberToBeExported()const = 0; - - + /// @brief Is this domain active? + /// Active mean, there is particle in it and + /// boundaries and other entities of simulation domains are valid virtual - bool requiresDataTransfer() const = 0; - - inline - const auto& thisDomain()const - { - return thisDomain_; - } + bool domainActive()const = 0; + /// @brief return the simulation domain of this processor + virtual + const domain& thisDomain()const = 0; + + domain extendThisDomain( const realx3& lowerPointExtension, const realx3& upperPointExtension)const; + /// @brief The original dictionary supplied by the user as input inline const auto& globalBoundaryDict()const { return static_cast(*this); } + /// @brief return a const ref to dicrionary of boundary i of this processor inline const dictionary& boundaryDict(uint32 i)const { return thisBoundaryDict().subDict(bundaryName(i)); } - inline - const auto& boundaryPlane(uint32 i)const - { - return thisDomain_.boundaryPlane(i); - } + /// @brief return a const ref to the plane of boundary i of this processor + const plane& boundaryPlane(uint32 i)const; + + static + uniquePtr create(systemControl& control); + + /// @brief Boundary name based on boundary index + /// @param i boundary index (range from 0 to 5) + /// @return const reference to name of the boundary static inline const word& bundaryName(uint32 i) { @@ -197,9 +196,6 @@ public: return boundaryNames_.size(); } - static - uniquePtr create(systemControl& control); - }; // simulationDomain diff --git a/src/phasicFlow/structuredData/pointStructure/pointStructure/pointStructure.cpp b/src/phasicFlow/structuredData/pointStructure/pointStructure/pointStructure.cpp index 30b81c10..9a20395c 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointStructure/pointStructure.cpp +++ b/src/phasicFlow/structuredData/pointStructure/pointStructure/pointStructure.cpp @@ -55,7 +55,7 @@ bool pFlow::pointStructure::setupPointStructure(const PointsTypeHost &points) thisN, RESERVE() ); - + auto pSpan = points.getSpan(); if(auto iSpan = internal.getSpan(); @@ -72,7 +72,7 @@ bool pFlow::pointStructure::setupPointStructure(const PointsTypeHost &points) return false; } - boundaries_.setLists(); + boundaries_.createBoundaries(); return true; }