Merge pull request #106 from PhasicFlow/develop

modification to the base code for MPI-developement up to processor bo…
This commit is contained in:
Hamidreza Norouzi 2024-04-30 00:25:19 +03:30 committed by GitHub
commit 9a69f510a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
44 changed files with 646 additions and 477 deletions

View File

@ -7,6 +7,8 @@ contactSearch/methods/cellBased/NBS/NBS.cpp
contactSearch/methods/cellBased/NBS/cellsWallLevel0.cpp contactSearch/methods/cellBased/NBS/cellsWallLevel0.cpp
contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.cpp contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.cpp
contactSearch/boundaries/twoPartContactSearch/twoPartContactSearchKernels.cpp
contactSearch/boundaries/twoPartContactSearch/twoPartContactSearch.cpp
contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearchKernels.cpp contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearchKernels.cpp
contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.cpp contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.cpp
contactSearch/boundaries/periodicBoundaryContactSearch/wallBoundaryContactSearch.cpp contactSearch/boundaries/periodicBoundaryContactSearch/wallBoundaryContactSearch.cpp
@ -22,6 +24,13 @@ sphereInteraction/sphereInteractionsNonLinearModels.cpp
sphereInteraction/sphereInteractionsNonLinearModModels.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) set(link_libs Kokkos::kokkos phasicFlow Property Particles Geometry)
pFlow_add_library_install(Interaction SourceFiles link_libs) pFlow_add_library_install(Interaction SourceFiles link_libs)

View File

@ -130,9 +130,10 @@ public:
csPairContainerType& pwPairs, csPairContainerType& pwPairs,
bool force = false) override bool force = false) override
{ {
ppTimer().start(); ppTimer().start();
Particles().boundingSphere().updateBoundaries(DataDirection::SlaveToMaster);
const auto& position = Particles().pointPosition().deviceViewAll(); const auto& position = Particles().pointPosition().deviceViewAll();
const auto& flags = Particles().dynPointStruct().activePointsMaskDevice(); const auto& flags = Particles().dynPointStruct().activePointsMaskDevice();
const auto& diam = Particles().boundingSphere().deviceViewAll(); const auto& diam = Particles().boundingSphere().deviceViewAll();

View File

@ -36,15 +36,16 @@ public:
using NextType = deviceViewType1D<uint32>; using NextType = deviceViewType1D<uint32>;
private: 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); void checkAllocateNext(uint32 n);

View File

@ -143,7 +143,9 @@ public:
) override ) override
{ {
notImplementedFunction; pOutput<<"Function (hearChanges in boundarySphereInteractions)is not implmented Message "<<
msg <<endl<<" name "<< this->name() <<" type "<< this->type()<<endl;;
//notImplementedFunction;
return true; return true;
} }

View File

@ -3,6 +3,7 @@ namespace pFlow::periodicBoundarySIKernels
{ {
template<typename ContactListType, typename ContactForceModel> template<typename ContactListType, typename ContactForceModel>
inline
void sphereSphereInteraction void sphereSphereInteraction
( (
real dt, real dt,
@ -46,14 +47,6 @@ void sphereSphereInteraction
if( ovrlp >0.0 ) 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 Nij = (xj-xi)/dist;
auto wi = rVel[ind_i]; auto wi = rVel[ind_i];
auto wj = rVel[ind_j]; auto wj = rVel[ind_j];

View File

@ -163,9 +163,16 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
auto t = this->currentTime(); auto t = this->currentTime();
auto dt = this->dt(); auto dt = this->dt();
//output<<"iter, t, dt "<< iter<<" "<< t << " "<<dt<<endl;
bool broadSearch = contactSearch_().enterBroadSearch(iter, t, dt); bool broadSearch = contactSearch_().enterBroadSearch(iter, t, dt);
/*sphParticles_.diameter().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.velocity().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.rVelocity().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.mass().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.I().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.propertyId().updateBoundaries(DataDirection::SlaveToMaster);*/
if(broadSearch) if(broadSearch)
{ {

View File

@ -16,6 +16,11 @@ Insertion/shapeMixture/shapeMixture.cpp
Insertion/Insertion/Insertions.cpp Insertion/Insertion/Insertions.cpp
) )
if(pFlow_Build_MPI)
list(APPEND SourceFiles
particles/MPIParticleIdHandler/MPIParticleIdHandler.cpp)
endif()
set(link_libs Kokkos::kokkos phasicFlow Integration Property) set(link_libs Kokkos::kokkos phasicFlow Integration Property)
pFlow_add_library_install(Particles SourceFiles link_libs) pFlow_add_library_install(Particles SourceFiles link_libs)

View File

@ -513,6 +513,14 @@ bool pFlow::sphereParticles::beforeIteration()
dynPointStruct().predict(dt, accelertion()); dynPointStruct().predict(dt, accelertion());
rVelIntegration_().predict(dt,rVelocity_, rAcceleration_); rVelIntegration_().predict(dt,rVelocity_, rAcceleration_);
intPredictTimer_.end(); intPredictTimer_.end();
propertyId_.updateBoundariesSlaveToMasterIfRequested();
diameter_.updateBoundariesSlaveToMasterIfRequested();
mass_.updateBoundariesSlaveToMasterIfRequested();
I_.updateBoundariesSlaveToMasterIfRequested();
rVelocity_.updateBoundariesSlaveToMasterIfRequested();
rAcceleration_.updateBoundariesSlaveToMasterIfRequested();
return true; return true;
} }

View File

@ -31,7 +31,12 @@ class particleIdHandler
: :
public uint32PointField_D public uint32PointField_D
{ {
private:
virtual
bool initialIdCheck()=0;
public: public:
/// class info /// class info
@ -53,7 +58,9 @@ public:
Pair<uint32, uint32> getIdRange(uint32 nNewParticles)=0; Pair<uint32, uint32> getIdRange(uint32 nNewParticles)=0;
virtual virtual
bool initialIdCheck()=0; uint32 maxId()const = 0;
// heat change for possible insertion of particles // heat change for possible insertion of particles
// overrdie from internalField // overrdie from internalField

View File

@ -78,7 +78,7 @@ pFlow::particles::particles(systemControl& control)
{ {
this->addToSubscriber(dynPointStruct_); this->addToSubscriber(dynPointStruct_);
idHandler_().initialIdCheck(); //idHandler_().initialIdCheck();
} }
bool bool
@ -87,7 +87,16 @@ pFlow::particles::beforeIteration()
zeroForce(); zeroForce();
zeroTorque(); zeroTorque();
return dynPointStruct_.beforeIteration(); if( !dynPointStruct_.beforeIteration())
{
return false;
}
shapeIndex_.updateBoundariesSlaveToMasterIfRequested();
accelertion_.updateBoundariesSlaveToMasterIfRequested();
idHandler_().updateBoundariesSlaveToMasterIfRequested();
return true;
} }
bool bool

View File

@ -181,6 +181,12 @@ public:
return contactTorque_; return contactTorque_;
} }
inline
uint maxId()const
{
return idHandler_().maxId();
}
bool beforeIteration() override; bool beforeIteration() override;
bool iterate() override; bool iterate() override;

View File

@ -9,6 +9,7 @@ pFlow::regularParticleIdHandler::regularParticleIdHandler
: :
particleIdHandler(pStruct) particleIdHandler(pStruct)
{ {
initialIdCheck();
} }
pFlow::Pair<pFlow::uint32, pFlow::uint32> pFlow::Pair<pFlow::uint32, pFlow::uint32>

View File

@ -33,6 +33,7 @@ private:
uint32 maxId_ = -1; uint32 maxId_ = -1;
bool initialIdCheck()override;
public: public:
ClassInfo("particleIdHandler<regular>"); ClassInfo("particleIdHandler<regular>");
@ -50,7 +51,10 @@ public:
Pair<uint32, uint32> getIdRange(uint32 nNewParticles)override; Pair<uint32, uint32> getIdRange(uint32 nNewParticles)override;
bool initialIdCheck()override; uint32 maxId()const override
{
return maxId_;
}
}; };

View File

@ -25,6 +25,7 @@ streams/TStream/oTstream.cpp
streams/Fstream/iFstream.cpp streams/Fstream/iFstream.cpp
streams/Fstream/oFstream.cpp streams/Fstream/oFstream.cpp
streams/Fstream/fileStream.cpp streams/Fstream/fileStream.cpp
streams/dataIO/dataIORegulars.cpp
streams/streams.cpp streams/streams.cpp
fileSystem/fileSystem.cpp fileSystem/fileSystem.cpp
@ -132,14 +133,14 @@ if(pFlow_Build_MPI)
message(STATUS "Zoltan lib path: ${ZOLTAN_LIBRARY}") message(STATUS "Zoltan lib path: ${ZOLTAN_LIBRARY}")
list(APPEND SourceFiles list(APPEND SourceFiles
MPIParallelization/partitioning.cpp MPIParallelization/domain/partitioning/partitioning.cpp
MPIParallelization/rcb1DPartitioning.cpp MPIParallelization/domain/partitioning/rcb1DPartitioning.cpp
MPIParallelization/domain/MPISimulationDomain.cpp MPIParallelization/domain/MPISimulationDomain.cpp
#MPIParallelization/dataIOMPI.cpp MPIParallelization/dataIOMPI/dataIOMPIs.cpp
MPIParallelization/procCommunication.cpp MPIParallelization/MPI/procCommunication.cpp
MPIParallelization/boundaryProcessor.cpp MPIParallelization/MPI/scatteredMasterDistributeChar.cpp
MPIParallelization/scatteredMasterDistributeChar.cpp MPIParallelization/pointStructure/boundaries/boundaryProcessor.cpp
MPIParallelization/processorBoundaryFields.cpp MPIParallelization/pointField/processorBoundaryFields.cpp
) )
list(APPEND link_libs MPI::MPI_CXX ${ZOLTAN_LIBRARY} -lm ) list(APPEND link_libs MPI::MPI_CXX ${ZOLTAN_LIBRARY} -lm )

View File

@ -36,6 +36,25 @@ pFlow::boundaryField<T, MemorySpace>::boundaryField
internal_(internal) internal_(internal)
{} {}
template<class T, class MemorySpace>
typename pFlow::boundaryField<T, MemorySpace>::ProcVectorType&
pFlow::boundaryField<T, MemorySpace>::neighborProcField()
{
static ProcVectorType dummyVector{"dummyVector"};
notImplementedFunction;
fatalExit;
return dummyVector;
}
template<class T, class MemorySpace>
const typename pFlow::boundaryField<T, MemorySpace>::ProcVectorType&
pFlow::boundaryField<T, MemorySpace>::neighborProcField() const
{
static ProcVectorType dummyVector{"dummyVector"};
notImplementedFunction;
fatalExit;
return dummyVector;
}
template<class T, class MemorySpace> template<class T, class MemorySpace>
pFlow::uniquePtr<pFlow::boundaryField<T, MemorySpace>> pFlow::uniquePtr<pFlow::boundaryField<T, MemorySpace>>

View File

@ -26,6 +26,18 @@ Licence:
namespace pFlow namespace pFlow
{ {
// forward
template< class T, class MemorySpace>
class boundaryFieldList;
enum class DataDirection
{
MasterToSlave,
SlaveToMaster,
TwoWay
};
template< class T, class MemorySpace = void> template< class T, class MemorySpace = void>
class boundaryField class boundaryField
: :
@ -43,12 +55,22 @@ public:
using FieldAccessType = scatteredFieldAccess<T, memory_space>; using FieldAccessType = scatteredFieldAccess<T, memory_space>;
protected: using ProcVectorType = VectorSingle<T,MemorySpace>;
private:
/// friend et al.
friend class boundaryFieldList<T,MemorySpace>;
/// @brief a ref to the internal field /// @brief a ref to the internal field
InternalFieldType& internal_; InternalFieldType& internal_;
virtual
bool updateBoundary(int step, DataDirection direction)
{
return true;
}
public: public:
TypeInfoTemplate211("boundaryField","none" ,T, memory_space::name()); TypeInfoTemplate211("boundaryField","none" ,T, memory_space::name());
@ -78,7 +100,6 @@ public:
boundaryBase boundaryBase
); );
bool hearChanges bool hearChanges
( (
real t, real t,
@ -116,6 +137,12 @@ public:
this->mirrorBoundary().indexList().deviceViewAll(), this->mirrorBoundary().indexList().deviceViewAll(),
internal_.deviceViewAll()); internal_.deviceViewAll());
} }
virtual
ProcVectorType& neighborProcField();
virtual
const ProcVectorType& neighborProcField()const;
void fill(const std::any& val)override void fill(const std::any& val)override
{ {

View File

@ -43,6 +43,8 @@ protected:
const boundaryList& boundaries_; const boundaryList& boundaries_;
uint32 slaveToMasterUpdateIter_ = -1;
public: public:
boundaryFieldList(const boundaryList& boundaries, InternalFieldType& internal) 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) void fill(const T& val)
{ {
for(auto& bf: *this) for(auto& bf: *this)
@ -68,6 +93,12 @@ public:
} }
} }
bool slaveToMasterUpdateRequested()const
{
return slaveToMasterUpdateIter_ != -1;
}
}; };
} }

View File

@ -31,7 +31,8 @@ pFlow::generalBoundary::generalBoundary
: :
observer(&boundary, defaultMessage_), observer(&boundary, defaultMessage_),
boundary_(boundary), boundary_(boundary),
pStruct_(pStruct) pStruct_(pStruct),
isBoundaryMaster_(boundary.isBoundaryMaster())
{} {}

View File

@ -45,16 +45,10 @@ private:
const pointStructure& pStruct_; const pointStructure& pStruct_;
const bool isBoundaryMaster_;
static inline static inline
const message defaultMessage_{message::BNDR_RESET}; const message defaultMessage_{message::BNDR_RESET};
template<typename BoundaryFieldType>
inline
bool checkForType()const
{
return typeName() == BoundaryFieldType::TYPENAME();
}
public: public:
@ -68,7 +62,6 @@ public:
~generalBoundary()override = default; ~generalBoundary()override = default;
inline inline
uint32 thisBoundaryIndex()const uint32 thisBoundaryIndex()const
{ {
@ -93,6 +86,24 @@ public:
return boundary_.capacity(); 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 inline
const auto& boundary()const const auto& boundary()const
{ {
@ -129,22 +140,17 @@ public:
return pStruct_; return pStruct_;
} }
inline
bool isBoundaryMaster()const
{
return isBoundaryMaster_;
}
const Time& time()const; const Time& time()const;
virtual virtual
void fill(const std::any& val)=0; void fill(const std::any& val)=0;
/*template<typename BoundaryFieldType>
BoundaryFieldType& thisField()
{
return static_cast<BoundaryFieldType&>(*this);
}
template<typename BoundaryFieldType>
const BoundaryFieldType& thisField()const
{
return static_cast<const BoundaryFieldType&>(*this);
}*/
}; };

View File

@ -181,6 +181,11 @@ public:
return field_.insertSetElement(indices, val); return field_.insertSetElement(indices, val);
} }
inline const Time& time()const
{
return internalPoints_.time();
}
bool hearChanges bool hearChanges
( (
real t, real t,

View File

@ -24,7 +24,7 @@ Licence:
#include "pointStructure.hpp" #include "pointStructure.hpp"
#include "internalField.hpp" #include "internalField.hpp"
#include "boundaryFieldList.hpp" #include "boundaryFieldList.hpp"
#include "Time.hpp"
namespace pFlow namespace pFlow
{ {
@ -103,6 +103,23 @@ public:
return static_cast<const InternalFieldType&>(*this); return static_cast<const InternalFieldType&>(*this);
} }
void updateBoundaries(DataDirection direction)const
{
uint32 iter = this->time().currentIter();
auto& bList = const_cast<boundaryFieldListType&>(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 const auto& boundaryFields()const
{ {
return boundaryFieldList_; return boundaryFieldList_;

View File

@ -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" #include "localProcessors.hpp"
pFlow::localProcessors::localProcessors(const word &name) pFlow::localProcessors::localProcessors(const word &name)
@ -8,8 +27,8 @@ pFlow::localProcessors::localProcessors(const word &name)
name_(name) name_(name)
{ {
#ifdef pFlow_Build_MPI #ifdef pFlow_Build_MPI
parrentCommunicator_ = pFlow::MPI::CommWorld; parrentCommunicator_ = MPI_COMM_WORLD;
localCommunicator_ = pFlow::MPI::CommWorld; localCommunicator_ = MPI_COMM_WORLD;
#endif #endif
} }
@ -24,7 +43,7 @@ pFlow::localProcessors::localProcessors
name_(name) name_(name)
{ {
#ifdef pFlow_Build_MPI #ifdef pFlow_Build_MPI
parrentCommunicator_ = pFlow::MPI::CommWorld; parrentCommunicator_ = MPI_COMM_WORLD;
if(ranks.size()> this->globalSize() ) if(ranks.size()> this->globalSize() )
{ {
@ -33,17 +52,17 @@ pFlow::localProcessors::localProcessors
fatalExit; fatalExit;
} }
pFlow::MPI::Group globalGroup; MPI_Group globalGroup;
MPI_Comm_group(parrentCommunicator_, &globalGroup); MPI_Comm_group(parrentCommunicator_, &globalGroup);
pFlow::MPI::Group localGroup; MPI_Group localGroup;
MPI_Group_incl(globalGroup, ranks.size(), ranks.data(), &localGroup); MPI_Group_incl(globalGroup, ranks.size(), ranks.data(), &localGroup);
// Create the new communicator from that group of processes. // Create the new communicator from that group of processes.
CheckMPI( MPI_Comm_create(parrentCommunicator_, localGroup, &localCommunicator_), true); CheckMPI( MPI_Comm_create(parrentCommunicator_, localGroup, &localCommunicator_), true);
isPartOfLocal_ = localCommunicator_ != MPI::CommNull; isPartOfLocal_ = localCommunicator_ != MPI_COMM_NULL;
if(isPartOfLocal_) if(isPartOfLocal_)
{ {
@ -71,7 +90,7 @@ pFlow::localProcessors::localProcessors
pFlow::localProcessors::localProcessors pFlow::localProcessors::localProcessors
( (
pFlow::MPI::Comm parrentComm, MPI_Comm parrentComm,
const word &name, const word &name,
const std::vector<int> &ranks const std::vector<int> &ranks
) )
@ -92,17 +111,17 @@ pFlow::localProcessors::localProcessors
fatalExit; fatalExit;
} }
pFlow::MPI::Group parGroup; MPI_Group parGroup;
MPI_Comm_group(parrentCommunicator_, &parGroup); MPI_Comm_group(parrentCommunicator_, &parGroup);
pFlow::MPI::Group localGroup; MPI_Group localGroup;
MPI_Group_incl(parGroup, ranks.size(), ranks.data(), &localGroup); MPI_Group_incl(parGroup, ranks.size(), ranks.data(), &localGroup);
// Create the new communicator from that group of processes. // Create the new communicator from that group of processes.
CheckMPI( MPI_Comm_create(parrentCommunicator_, localGroup, &localCommunicator_), true); CheckMPI( MPI_Comm_create(parrentCommunicator_, localGroup, &localCommunicator_), true);
isPartOfLocal_ = localCommunicator_ != MPI::CommNull; isPartOfLocal_ = localCommunicator_ != MPI_COMM_NULL;
if(isPartOfLocal_) if(isPartOfLocal_)
{ {

View File

@ -25,7 +25,7 @@ Licence:
#include "types.hpp" #include "types.hpp"
#ifdef pFlow_Build_MPI #ifdef pFlow_Build_MPI
#include "mpiTypes.hpp" #include "mpi.h"
#endif #endif
@ -39,9 +39,9 @@ class localProcessors
private: private:
#ifdef pFlow_Build_MPI #ifdef pFlow_Build_MPI
pFlow::MPI::Comm parrentCommunicator_; MPI_Comm parrentCommunicator_;
pFlow::MPI::Comm localCommunicator_; MPI_Comm localCommunicator_;
#endif #endif
int localSize_ = 1 ; int localSize_ = 1 ;
@ -70,7 +70,7 @@ public:
#ifdef pFlow_Build_MPI #ifdef pFlow_Build_MPI
localProcessors( localProcessors(
pFlow::MPI::Comm parrentComm, MPI_Comm parrentComm,
const word& name, const word& name,
const std::vector<int>& ranks); const std::vector<int>& ranks);
#endif #endif

View File

@ -58,11 +58,13 @@ void pFlow::processors::initProcessors(int argc, char *argv[])
if(processors::globalParallel()) if(processors::globalParallel())
{ {
pFlow::pOutput.activatePrefix(); 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::mOutput.setMasterSlave(processors::globalMaster());
pFlow::errReport.setMasterSlave(processors::globalMaster());
MPI_Type_contiguous(3, pFlow::MPI::Type<real>(), &pFlow::MPI::realx3Type__); MPI_Type_contiguous(3, pFlow::MPI::Type<real>(), &pFlow::MPI::realx3Type__);
MPI_Type_commit(&pFlow::MPI::realx3Type__); MPI_Type_commit(&pFlow::MPI::realx3Type__);

View File

@ -41,7 +41,7 @@ public:
* *
* MasterProcessorDistribute: Read is done on master processor, but * MasterProcessorDistribute: Read is done on master processor, but
* the data should be distributed between processors based on an externally * 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 * collected from all processors (collection is done based on the externally
* specified pattern). * specified pattern).
* *
@ -146,7 +146,6 @@ public:
bool thisProcWriteData()const bool thisProcWriteData()const
{ {
if(isAllProcessorsDifferent()) return true; if(isAllProcessorsDifferent()) return true;
if(isMasterProcessorDistribute())return true;
return isMaster(); return isMaster();
} }

View File

@ -118,8 +118,9 @@ bool pFlow::IOobject::readObject(bool rdHdr)
bool pFlow::IOobject::writeObject() const bool pFlow::IOobject::writeObject() const
{ {
if(!implyWrite()) return true;
if(implyWrite()&& ioPattern().thisCallWrite())
if(ioPattern().thisCallWrite())
{ {
if(auto ptrOS = outStream(); ptrOS ) if(auto ptrOS = outStream(); ptrOS )
@ -160,7 +161,9 @@ bool pFlow::IOobject::readObject(iIstream& is, bool rdHdr)
bool pFlow::IOobject::writeObject(iOstream& os) const bool pFlow::IOobject::writeObject(iOstream& os) const
{ {
if(this->writeHeader() && ioPattern().thisProcWriteHeader()) if(this->writeHeader() && ioPattern().thisProcWriteHeader())
writeHeader(os, typeName()); {
writeHeader(os, typeName());
}
if(ioPattern().thisCallWrite()) if(ioPattern().thisCallWrite())
{ {

View File

@ -199,7 +199,7 @@ bool pFlow::systemControl::operator++(int)
if (time().timersReportTime() && timersReport()) if (time().timersReportTime() && timersReport())
{ {
timers_.write(output, true); timers_.write(mOutput, true);
} }
} }
else if (time().finalTime()) else if (time().finalTime())
@ -212,7 +212,7 @@ bool pFlow::systemControl::operator++(int)
} }
writeToFileTimer_.end(); writeToFileTimer_.end();
timers_.write(output, true); timers_.write(mOutput, true);
} }
return toContinue; return toContinue;

View File

@ -202,7 +202,7 @@ bool pFlow::dataIO<T>::writeData(iOstream& os, span<T> data)
if( ioPattern_.thisProcWriteData()) if( ioPattern_.thisProcWriteData())
{ {
return writeDataAsciiBinary(os, data); return writeDataAsciiBinary(os, bufferSpan_);
} }
else else
{ {
@ -215,7 +215,7 @@ inline
bool pFlow::dataIO<pFlow::word>::writeData(iOstream& os, span<word> data) bool pFlow::dataIO<pFlow::word>::writeData(iOstream& os, span<word> data)
{ {
if( ioPattern_.isParallel() ) if( ioPattern_.isParallel() && ioPattern_.isMasterProcessorDistribute())
{ {
notImplementedFunction<< notImplementedFunction<<
"data transfer for type word is not supported in parallel mode!"<<endl; "data transfer for type word is not supported in parallel mode!"<<endl;
@ -232,7 +232,7 @@ bool pFlow::dataIO<pFlow::word>::writeData(iOstream& os, span<word> data)
if( ioPattern_.thisProcWriteData()) if( ioPattern_.thisProcWriteData())
{ {
return writeDataASCII(os, data); return writeDataASCII(os, bufferSpan_);
} }
else else
{ {

View File

@ -31,8 +31,6 @@ Licence:
#include "virtualConstructor.hpp" #include "virtualConstructor.hpp"
#include "pFlowProcessors.hpp" #include "pFlowProcessors.hpp"
namespace pFlow namespace pFlow
{ {

View File

@ -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<typename T>
class dataIOMPI
:
public dataIO<T>
{
protected:
bool gatherData(span<T> data ) override
{
if(this->ioPattern_.isAllProcessorsDifferent())
{
this->bufferSpan_ = data;
return true;
}
if( this->ioPattern_.isMasterProcessorDistribute())
{
#ifdef pFlow_Build_MPI
auto gatherT = pFlow::MPI::gatherMaster<T>(pFlowProcessors());
if(!gatherT.gatherData(data))
{
fatalErrorInFunction<<"Error in gathering data to master"<<endl;
return false;
}
this->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<T>(nullptr, 0);
return true;
}
}
return false;
}
public:
TypeInfo("dataIO<MPI>");
dataIOMPI(const IOPattern& iop)
:
dataIO<T>(iop)
{}
dataIOMPI(const dataIOMPI&) = default;
dataIOMPI(dataIOMPI&&) = default;
dataIOMPI& operator=(const dataIOMPI&) = default;
dataIOMPI& operator=(dataIOMPI&&) = default;
~dataIOMPI() = default;
};
}
#endif

View File

@ -19,9 +19,15 @@ template class pFlow::dataIORegular<pFlow::int64>;
template class pFlow::dataIO<pFlow::uint32>; template class pFlow::dataIO<pFlow::uint32>;
template class pFlow::dataIORegular<pFlow::uint32>; template class pFlow::dataIORegular<pFlow::uint32>;
template class pFlow::dataIO<pFlow::uint32x3>;
template class pFlow::dataIORegular<pFlow::uint32x3>;
template class pFlow::dataIO<pFlow::uint64>; template class pFlow::dataIO<pFlow::uint64>;
template class pFlow::dataIORegular<pFlow::uint64>; template class pFlow::dataIORegular<pFlow::uint64>;
template class pFlow::dataIO<size_t>;
template class pFlow::dataIORegular<size_t>;
template class pFlow::dataIO<pFlow::real>; template class pFlow::dataIO<pFlow::real>;
template class pFlow::dataIORegular<pFlow::real>; template class pFlow::dataIORegular<pFlow::real>;

View File

@ -260,6 +260,8 @@ inline iIstream& operator>>( iIstream& is, float& val);
inline iIstream& operator>>( iIstream& is, double& val); inline iIstream& operator>>( iIstream& is, double& val);
inline iIstream& operator>>( iIstream& is, size_t& val);
} // pFlow } // pFlow

View File

@ -295,3 +295,35 @@ inline pFlow::iIstream& pFlow::operator>>( iIstream& is, double& val)
return is; 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<size_t>(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;
}

View File

@ -9,5 +9,5 @@ pFlow::processorOstream pFlow::pOutput(cout, "pFlow processorOstream");
pFlow::Istream pFlow::input( std::cin, "sFlow Istream"); 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");

View File

@ -28,12 +28,12 @@ namespace pFlow
extern Istream input; extern Istream input;
extern masterOstream errReport; extern processorOstream errReport;
} }
#define INFORMATION pFlow::mOutput<<boldChar<<magentaColor<<"> INFO: "<<defaultColor<<magentaColor #define INFORMATION pFlow::pOutput<<boldChar<<magentaColor<<"> INFO: "<<defaultColor<<magentaColor
#define END_INFO defaultColor<<pFlow::endl #define END_INFO defaultColor<<pFlow::endl
#define REPORT(n) pFlow::mOutput.space(2*n) #define REPORT(n) pFlow::mOutput.space(2*n)

View File

@ -191,7 +191,8 @@ pFlow::boundaryBase::boundaryBase
internal_(internal), internal_(internal),
boundaries_(bndrs), boundaries_(bndrs),
thisBoundaryIndex_(thisIndex), thisBoundaryIndex_(thisIndex),
mirrorProcessoNo_(dict.getVal<uint32>("mirrorProcessorNo")), neighborProcessorNo_(dict.getVal<int32>("neighborProcessorNo")),
isBoundaryMaster_(thisProcessorNo()>=neighborProcessorNo()),
name_(dict.name()), name_(dict.name()),
type_(dict.getVal<word>("type")) type_(dict.getVal<word>("type"))
{ {
@ -231,13 +232,22 @@ pFlow::boundaryBase::thisPoints()const
} }
typename pFlow::boundaryBase::pointFieldAccessType pFlow::realx3Vector_D& pFlow::boundaryBase::neighborProcPoints()
pFlow::boundaryBase::neighborPoints()const
{ {
notImplementedFunction; static realx3Vector_D dummyVector{"dummyVector"};
return pointFieldAccessType(); 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 pFlow::realx3 pFlow::boundaryBase::displacementVectroToMirror() const
{ {

View File

@ -51,42 +51,48 @@ public:
private: private:
// friend et al. // friend et al.
friend boundaryList; friend boundaryList;
const plane& boundaryPlane_; const plane& boundaryPlane_;
/// list of particles indices on device /// list of particles indices on device
uint32Vector_D indexList_; uint32Vector_D indexList_;
/// list of particles indieces on host /// list of particles indieces on host
mutable uint32Vector_H indexListHost_; mutable uint32Vector_H indexListHost_;
/// device and host list are sync /// device and host list are sync
mutable bool listsSync_ = false; mutable bool listsSync_ = false;
/// The length defined for creating neighbor list /// The length defined for creating neighbor list
real neighborLength_; real neighborLength_;
/// a reference to internal points /// a reference to internal points
internalPoints& internal_; internalPoints& internal_;
/// a reference to the list of boundaries /// a reference to the list of boundaries
/// (never use this in the constructor). /// (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: protected:
/// @brief set the size of indexList /// @brief Set the size of indexList.
void setSize(uint32 newSize); /// 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); 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: public:
@ -213,6 +230,24 @@ public:
return indexList_.capacity(); return indexList_.capacity();
} }
inline
int neighborProcessorNo()const
{
return neighborProcessorNo_;
}
inline
int thisProcessorNo()const
{
return pFlowProcessors().localRank();
}
inline
bool isBoundaryMaster()const
{
return isBoundaryMaster_;
}
inline inline
uint32 thisBoundaryIndex()const uint32 thisBoundaryIndex()const
{ {
@ -283,8 +318,22 @@ public:
pointFieldAccessType thisPoints()const; 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 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 create
static static

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: 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 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. 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 phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -21,49 +21,44 @@ Licence:
#include "boundaryList.hpp" #include "boundaryList.hpp"
#include "pointStructure.hpp" #include "pointStructure.hpp"
void pFlow::boundaryList::setExtendedDomain() void
pFlow::boundaryList::setExtendedDomain()
{ {
if(!listSet_) if (!listSet_)
{ {
fatalErrorInFunction<< fatalErrorInFunction
"boundary list is not set yet and you used the objects."<<endl; << "boundary list is not set yet and you used the objects." << endl;
fatalExit; fatalExit;
} }
realx3 lowerExt = realx3 lowerExt = boundary(0).boundaryExtensionLength() +
boundary(0).boundaryExtensionLength() + boundary(2).boundaryExtensionLength() +
boundary(2).boundaryExtensionLength() + boundary(4).boundaryExtensionLength();
boundary(4).boundaryExtensionLength();
realx3 upperExt = boundary(1).boundaryExtensionLength() +
realx3 upperExt = boundary(3).boundaryExtensionLength() +
boundary(1).boundaryExtensionLength()+ boundary(5).boundaryExtensionLength();
boundary(3).boundaryExtensionLength()+
boundary(5).boundaryExtensionLength(); extendedDomain_ = pStruct_.simDomain().extendThisDomain(lowerExt, upperExt);
extendedDomain_ = pStruct_.simDomain().extendThisDomain
(
lowerExt,
upperExt
);
} }
bool pFlow::boundaryList::resetLists() bool
pFlow::boundaryList::resetLists()
{ {
clear(); clear();
listSet_ = false; listSet_ = false;
return true; return true;
} }
bool pFlow::boundaryList::updateLists() bool
pFlow::boundaryList::updateNeighborLists()
{ {
if(!listSet_) if (!listSet_)
{ {
setLists(); createBoundaries();
} }
std::array<real,6> dist; std::array<real, 6> dist;
dist[0] = boundary(0).neighborLength(); dist[0] = boundary(0).neighborLength();
dist[1] = boundary(1).neighborLength(); dist[1] = boundary(1).neighborLength();
dist[2] = boundary(2).neighborLength(); dist[2] = boundary(2).neighborLength();
@ -71,71 +66,66 @@ bool pFlow::boundaryList::updateLists()
dist[4] = boundary(4).neighborLength(); dist[4] = boundary(4).neighborLength();
dist[5] = boundary(5).neighborLength(); dist[5] = boundary(5).neighborLength();
pStruct_.updateFlag( pStruct_.updateFlag(extendedDomain_, dist);
extendedDomain_,
dist);
const auto& maskD = pStruct_.activePointsMaskDevice(); const auto& maskD = pStruct_.activePointsMaskDevice();
boundary(0).setSize( maskD.leftSize() ); boundary(0).setSize(maskD.leftSize());
boundary(1).setSize( maskD.rightSize() ); boundary(1).setSize(maskD.rightSize());
boundary(2).setSize( maskD.bottomSize() ); boundary(2).setSize(maskD.bottomSize());
boundary(3).setSize( maskD.topSize() ); boundary(3).setSize(maskD.topSize());
boundary(4).setSize( maskD.rearSize() ); boundary(4).setSize(maskD.rearSize());
boundary(5).setSize( maskD.frontSize() ); boundary(5).setSize(maskD.frontSize());
pStruct_.fillNeighborsLists( pStruct_.fillNeighborsLists(
boundary(0).indexList().deviceViewAll(), boundary(0).indexList().deviceViewAll(),
boundary(1).indexList().deviceViewAll(), boundary(1).indexList().deviceViewAll(),
boundary(2).indexList().deviceViewAll(), boundary(2).indexList().deviceViewAll(),
boundary(3).indexList().deviceViewAll(), boundary(3).indexList().deviceViewAll(),
boundary(4).indexList().deviceViewAll(), boundary(4).indexList().deviceViewAll(),
boundary(5).indexList().deviceViewAll()); boundary(5).indexList().deviceViewAll()
);
return true; return true;
} }
pFlow::boundaryList::boundaryList pFlow::boundaryList::boundaryList(pointStructure& pStruct)
( : ListPtr<boundaryBase>(pStruct.simDomain().sizeOfBoundaries()),
pointStructure& pStruct pStruct_(pStruct),
) timeControl_(
: pStruct.simDomain().subDict("boundaries"),
ListPtr<boundaryBase>(pStruct.simDomain().sizeOfBoundaries()), "update",
pStruct_(pStruct), pStruct.currentTime()
timeControl_ )
(
pStruct.simDomain().subDict("boundaries"),
"update",
pStruct.currentTime()
)
{}
bool pFlow::boundaryList::updateLists(uint32 iter, real t, real dt)
{ {
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; return true;
} }
bool pFlow::boundaryList::setLists() bool
pFlow::boundaryList::createBoundaries()
{ {
if(listSet_)return true; if (listSet_)
return true;
for(auto i=0; i<pStruct_.simDomain().sizeOfBoundaries();i++) for (auto i = 0; i < pStruct_.simDomain().sizeOfBoundaries(); i++)
{ {
this->set this->set(
( i,
i, boundaryBase::create(
boundaryBase::create pStruct_.simDomain().boundaryDict(i),
( pStruct_.simDomain().boundaryPlane(i),
pStruct_.simDomain().boundaryDict(i), pStruct_,
pStruct_.simDomain().boundaryPlane(i), *this,
pStruct_, i
*this, )
i
)
); );
} }
listSet_ = true; listSet_ = true;
@ -146,81 +136,81 @@ bool pFlow::boundaryList::setLists()
pFlow::box pFlow::box
pFlow::boundaryList::internalDomainBox() const pFlow::boundaryList::internalDomainBox() const
{ {
const auto& thisBox = pStruct_.thisDomain().domainBox(); const auto& thisBox = pStruct_.thisDomain().domainBox();
const realx3 lowerPointDisplacement = { const realx3 lowerPointDisplacement = {
boundary(0).neighborLengthIntoInternal(), boundary(0).neighborLengthIntoInternal(),
boundary(2).neighborLengthIntoInternal(), boundary(2).neighborLengthIntoInternal(),
boundary(4).neighborLengthIntoInternal()}; boundary(4).neighborLengthIntoInternal()
};
const realx3 upperPointDisplacement = { const realx3 upperPointDisplacement = {
boundary(1).neighborLengthIntoInternal(), boundary(1).neighborLengthIntoInternal(),
boundary(3).neighborLengthIntoInternal(), boundary(3).neighborLengthIntoInternal(),
boundary(5).neighborLengthIntoInternal()}; boundary(5).neighborLengthIntoInternal()
};
return {thisBox.minPoint() + lowerPointDisplacement,
thisBox.maxPoint() - upperPointDisplacement}; return { thisBox.minPoint() + lowerPointDisplacement,
thisBox.maxPoint() - upperPointDisplacement };
} }
bool bool
pFlow::boundaryList::beforeIteration(uint32 iter, real t, real dt) pFlow::boundaryList::beforeIteration(uint32 iter, real t, real dt)
{ {
// it is time to update lists // it is time to update lists
if(timeControl_.timeEvent(iter, t, dt)) 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; return false;
} }
} }
for(auto& bdry:*this) for (auto bdry : *this)
{ {
if( !bdry->beforeIteration(iter, t, dt)) bdry->updataBoundary(1);
{
fatalErrorInFunction<<
"Error in beforeIteration in boundary "<<bdry->name()<<endl;
return false;
}
} }
return true; for (auto bdry : *this)
{
bdry->updataBoundary(2);
}
return true;
} }
bool pFlow::boundaryList::iterate bool
( pFlow::boundaryList::iterate(uint32 iter, real t, real dt)
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<< fatalErrorInFunction << "Error in iterate in boundary "
"Error in iterate in boundary "<<bdry->name()<<endl; << bdry->name() << endl;
return false; return false;
} }
} }
return true; return true;
} }
bool pFlow::boundaryList::afterIteration bool
( pFlow::boundaryList::afterIteration(uint32 iter, real t, real dt)
uint32 iter, {
real t, for (auto& bdry : *this)
real dt {
) if (!bdry->afterIteration(iter, t, dt))
{ {
for(auto& bdry:*this) fatalErrorInFunction << "Error in afterIteration in boundary "
{ << bdry->name() << endl;
if( !bdry->afterIteration(iter, t, dt))
{
fatalErrorInFunction<<
"Error in afterIteration in boundary "<<bdry->name()<<endl;
return false; return false;
} }
} }

View File

@ -40,24 +40,23 @@ class boundaryList
private: private:
//// - data members //// - 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(); bool resetLists();
/// @brief update neighbor list of boundaries regardless
/// of the time intervals
bool updateLists();
/// @brief update neighbor list of boundaries regardless
/// of the time intervals
bool updateNeighborLists();
public: public:
@ -66,16 +65,16 @@ public:
//// - Constructors //// - Constructors
boundaryList(pointStructure& pStruct); explicit boundaryList(pointStructure& pStruct);
~boundaryList() = default; virtual ~boundaryList() = default;
/// @brief update neighbor list of boundaries based on /// @brief update neighbor list of boundaries based on
/// the time intervals /// the time intervals
bool updateLists(uint32 iter, real t, real dt); bool updateNeighborLists(uint32 iter, real t, real dt);
bool setLists(); bool createBoundaries();
inline inline
const pointStructure& pStruct()const const pointStructure& pStruct()const
@ -115,8 +114,6 @@ public:
box internalDomainBox()const; box internalDomainBox()const;
bool beforeIteration(uint32 iter, real t, real dt); bool beforeIteration(uint32 iter, real t, real dt);
bool iterate(uint32 iter, real t, real dt); bool iterate(uint32 iter, real t, real dt);

View File

@ -51,9 +51,9 @@ bool pFlow::regularSimulationDomain::createBoundaryDicts()
return false; 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()<<endl; " in dictionary "<< boundaries.globalName()<<endl;
return false; return false;
} }
@ -84,7 +84,7 @@ bool pFlow::regularSimulationDomain::createBoundaryDicts()
bool pFlow::regularSimulationDomain::setThisDomain() bool pFlow::regularSimulationDomain::setThisDomain()
{ {
thisDomain_ = domain(globalBox_); thisDomain_ = domain(globalBox());
return true; return true;
} }
@ -126,11 +126,23 @@ pFlow::uint32 pFlow::regularSimulationDomain::numberToBeExported() const
return 0; return 0;
} }
bool pFlow::regularSimulationDomain::initialTransferBlockData bool
( pFlow::regularSimulationDomain::domainActive() const
span<char> src, {
span<char> dst, return true;
size_t sizeOfElement }
const pFlow::domain&
pFlow::regularSimulationDomain::thisDomain() const
{
return thisDomain_;
}
bool
pFlow::regularSimulationDomain::initialTransferBlockData(
span<char> src,
span<char> dst,
size_t sizeOfElement
) const ) const
{ {
size_t requiredSize = sizeOfElement*initialNumberInThis(); size_t requiredSize = sizeOfElement*initialNumberInThis();
@ -209,7 +221,3 @@ const pFlow::dictionary &pFlow::regularSimulationDomain::thisBoundaryDict() cons
return this->subDict("regularBoundaries"); return this->subDict("regularBoundaries");
} }
bool pFlow::regularSimulationDomain::requiresDataTransfer()const
{
return false;
}

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: 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 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. 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 phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -26,81 +26,70 @@ Licence:
namespace pFlow namespace pFlow
{ {
class regularSimulationDomain class regularSimulationDomain
: :
public simulationDomain 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: public:
TypeInfo("simulationDomain<regular>"); TypeInfo("simulationDomain<regular>");
regularSimulationDomain(systemControl& control); explicit regularSimulationDomain(systemControl& control);
virtual ~regularSimulationDomain() final = default;
~regularSimulationDomain()=default;
add_vCtor
(
simulationDomain,
regularSimulationDomain,
systemControl
);
bool initialUpdateDomains(span<realx3> pointPos) override; add_vCtor(simulationDomain, regularSimulationDomain, systemControl);
uint32 initialNumberInThis()const override; bool initialUpdateDomains(span<realx3> pointPos) final;
bool initialThisDomainActive()const override uint32 initialNumberInThis() const final;
{
return true;
}
/*bool updateDomains( uint32 numberToBeImported() const final;
span<realx3> pointPos,
pFlagTypeHost flags) override;*/
uint32 numberToBeImported()const override;
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( bool initialTransferBlockData(
span<char> src, span<char> src,
span<char> dst, span<char> dst,
size_t sizeOfElement) const override; size_t sizeOfElement
) const final;
/// @brief
/// @param src
/// @param dst
/// @return
bool initialTransferBlockData(span<realx3> src, span<realx3> dst)
const final;
/// @brief bool initialTransferBlockData(span<real> src, span<real> dst)
/// @param src const final;
/// @param dst
/// @return
bool initialTransferBlockData(
span<realx3> src,
span<realx3> dst) const override;
bool initialTransferBlockData( bool initialTransferBlockData(span<uint32> src, span<uint32> dst)
span<real> src, const final;
span<real> dst) const override;
bool initialTransferBlockData( bool initialTransferBlockData(span<int32> src, span<int32> dst)
span<uint32> src, const final;
span<uint32> dst) const override;
bool initialTransferBlockData( const dictionary& thisBoundaryDict() const final;
span<int32> src,
span<int32> dst) const override;
const dictionary& thisBoundaryDict()const override;
bool requiresDataTransfer() const override;
}; };
} }

View File

@ -52,8 +52,14 @@ pFlow::domain pFlow::simulationDomain::extendThisDomain
return domain({minP, maxP}); return domain({minP, maxP});
} }
const pFlow::plane&
pFlow::simulationDomain::boundaryPlane(uint32 i) const
{
return thisDomain().boundaryPlane(i);
}
pFlow::uniquePtr<pFlow::simulationDomain> pFlow::uniquePtr<pFlow::simulationDomain>
pFlow::simulationDomain::create(systemControl &control) pFlow::simulationDomain::create(systemControl& control)
{ {
word sType = angleBracketsNames( word sType = angleBracketsNames(
"simulationDomain", "simulationDomain",

View File

@ -39,33 +39,27 @@ class simulationDomain
: :
public fileDictionary public fileDictionary
{ {
private: private:
static inline constexpr uint32 sizeOfBoundaries_ = 6; /// @brief acutal limits of the global box of simulation
static
inline const std::array<word,6> boundaryNames_ =
{
"left", "right",
"bottom", "top",
"rear", "front"
};
protected:
//fileDictionary globalDomainDict_ ;
/// @brief acutal limits of the simulation domain
box globalBox_; 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<word,6> boundaryNames_ =
{
"left", "right",
"bottom", "top",
"rear", "front"
};
virtual bool createBoundaryDicts() = 0; virtual
bool createBoundaryDicts() = 0;
virtual bool setThisDomain() = 0; virtual
bool setThisDomain() = 0;
public: public:
@ -73,11 +67,10 @@ public:
TypeInfo("simulationDomain"); TypeInfo("simulationDomain");
/// Constrcut from components /// Constrcut from components
simulationDomain(systemControl& control); explicit simulationDomain(systemControl& control);
/// Destructor /// Destructor
virtual ~simulationDomain() override = default;
~simulationDomain() = default;
create_vCtor create_vCtor
@ -88,6 +81,11 @@ public:
(control) (control)
); );
const auto& globalBox()const
{
return globalBox_;
}
virtual virtual
const dictionary& thisBoundaryDict()const = 0; const dictionary& thisBoundaryDict()const = 0;
@ -97,9 +95,6 @@ public:
virtual virtual
uint32 initialNumberInThis()const = 0; uint32 initialNumberInThis()const = 0;
virtual
bool initialThisDomainActive()const = 0;
virtual virtual
bool initialTransferBlockData( bool initialTransferBlockData(
span<char> src, span<char> src,
@ -139,9 +134,7 @@ public:
charSpan(dst), charSpan(dst),
el el
); );
} }
/// @brief Number of points to be imported after updating domains /// @brief Number of points to be imported after updating domains
/// @return number of points /// @return number of points
@ -151,40 +144,46 @@ public:
virtual virtual
uint32 numberToBeExported()const = 0; 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 virtual
bool requiresDataTransfer() const = 0; bool domainActive()const = 0;
inline
const auto& thisDomain()const
{
return thisDomain_;
}
/// @brief return the simulation domain of this processor
virtual
const domain& thisDomain()const = 0;
domain extendThisDomain( domain extendThisDomain(
const realx3& lowerPointExtension, const realx3& lowerPointExtension,
const realx3& upperPointExtension)const; const realx3& upperPointExtension)const;
/// @brief The original dictionary supplied by the user as input
inline inline
const auto& globalBoundaryDict()const const auto& globalBoundaryDict()const
{ {
return static_cast<const fileDictionary&>(*this); return static_cast<const fileDictionary&>(*this);
} }
/// @brief return a const ref to dicrionary of boundary i of this processor
inline inline
const dictionary& boundaryDict(uint32 i)const const dictionary& boundaryDict(uint32 i)const
{ {
return thisBoundaryDict().subDict(bundaryName(i)); return thisBoundaryDict().subDict(bundaryName(i));
} }
inline /// @brief return a const ref to the plane of boundary i of this processor
const auto& boundaryPlane(uint32 i)const const plane& boundaryPlane(uint32 i)const;
{
return thisDomain_.boundaryPlane(i);
}
static
uniquePtr<simulationDomain> 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 static inline
const word& bundaryName(uint32 i) const word& bundaryName(uint32 i)
{ {
@ -197,9 +196,6 @@ public:
return boundaryNames_.size(); return boundaryNames_.size();
} }
static
uniquePtr<simulationDomain> create(systemControl& control);
}; // simulationDomain }; // simulationDomain

View File

@ -55,7 +55,7 @@ bool pFlow::pointStructure::setupPointStructure(const PointsTypeHost &points)
thisN, thisN,
RESERVE() RESERVE()
); );
auto pSpan = points.getSpan(); auto pSpan = points.getSpan();
if(auto iSpan = internal.getSpan(); if(auto iSpan = internal.getSpan();
@ -72,7 +72,7 @@ bool pFlow::pointStructure::setupPointStructure(const PointsTypeHost &points)
return false; return false;
} }
boundaries_.setLists(); boundaries_.createBoundaries();
return true; return true;
} }