boundaryListPtr is created and other classes were changed accordingly

This commit is contained in:
HRN 2025-02-01 22:14:41 +03:30
parent af2572331d
commit 64c041a753
37 changed files with 468 additions and 161 deletions

View File

@ -77,6 +77,11 @@ public:
return true; return true;
} }
bool isActive()const override
{
return false;
}
static static
uniquePtr<boundaryIntegration> create( uniquePtr<boundaryIntegration> create(
const boundaryBase& boundary, const boundaryBase& boundary,

View File

@ -7,11 +7,11 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList(
integration &intgrtn integration &intgrtn
) )
: :
ListPtr<boundaryIntegration>(6), boundaryListPtr<boundaryIntegration>(),
boundaries_(pStruct.boundaries()) boundaries_(pStruct.boundaries())
{ {
for(uint32 i=0; i<6; i++) ForAllBoundariesPtr(i, this)
{ {
this->set( this->set(
i, i,
@ -19,25 +19,23 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList(
boundaries_[i], boundaries_[i],
pStruct, pStruct,
method, method,
intgrtn intgrtn
) )
); );
} }
} }
bool pFlow::boundaryIntegrationList::correct(real dt, realx3PointField_D &y, realx3PointField_D &dy) bool pFlow::boundaryIntegrationList::correct(real dt, realx3PointField_D &y, realx3PointField_D &dy)
{ {
for(auto& bndry:*this) ForAllActiveBoundariesPtr(i,this)
{ {
if(!bndry->correct(dt, y, dy)) if(!boundaryPtr(i)->correct(dt, y, dy))
{ {
fatalErrorInFunction<<"Error in correcting boundary "<< fatalErrorInFunction<<"Error in correcting boundary "<<
bndry->boundaryName()<<endl; boundaryPtr(i)->boundaryName()<<endl;
return false; return false;
} }
}
}
return true; return true;
} }
@ -46,14 +44,15 @@ bool pFlow::boundaryIntegrationList::correctPStruct(
pointStructure &pStruct, pointStructure &pStruct,
const realx3PointField_D &vel) const realx3PointField_D &vel)
{ {
for(auto& bndry:*this) ForAllActiveBoundariesPtr(i,this)
{ {
if(!bndry->correctPStruct(dt, vel)) if(!boundaryPtr(i)->correctPStruct(dt, vel))
{ {
fatalErrorInFunction<<"Error in correcting boundary "<< fatalErrorInFunction<<"Error in correcting boundary "<<
bndry->boundaryName()<<" in pointStructure."<<endl; boundaryPtr(i)->boundaryName()<<" in pointStructure."<<endl;
return false; return false;
} }
} }
return true; return true;
} }

View File

@ -4,7 +4,7 @@
#include "boundaryList.hpp" #include "boundaryList.hpp"
#include "ListPtr.hpp" #include "boundaryListPtr.hpp"
#include "boundaryIntegration.hpp" #include "boundaryIntegration.hpp"
@ -15,7 +15,7 @@ class integration;
class boundaryIntegrationList class boundaryIntegrationList
: :
public ListPtr<boundaryIntegration> public boundaryListPtr<boundaryIntegration>
{ {
private: private:

View File

@ -98,6 +98,11 @@ public:
return true; return true;
} }
bool isActive()const override
{
return false;
}
static uniquePtr<boundaryContactSearch> create( static uniquePtr<boundaryContactSearch> create(
const dictionary &dict, const dictionary &dict,
const boundaryBase &boundary, const boundaryBase &boundary,

View File

@ -1,3 +1,23 @@
/*------------------------------- 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 "boundaryContactSearchList.hpp" #include "boundaryContactSearchList.hpp"
#include "boundaryList.hpp" #include "boundaryList.hpp"
@ -5,7 +25,7 @@ void pFlow::boundaryContactSearchList::setList(
const dictionary &dict, const dictionary &dict,
const contactSearch &cSearch) const contactSearch &cSearch)
{ {
for(auto i=0; i<boundaries_.size(); i++) ForAllBoundariesPtr(i, this)
{ {
this->set this->set
( (
@ -20,7 +40,7 @@ pFlow::boundaryContactSearchList::boundaryContactSearchList(
const boundaryList& bndrs, const boundaryList& bndrs,
const contactSearch &cSearch) const contactSearch &cSearch)
: :
ListPtr(bndrs.size()), boundaryListPtr(),
boundaries_(bndrs) boundaries_(bndrs)
{ {
setList(dict, cSearch); setList(dict, cSearch);

View File

@ -1,4 +1,24 @@
#include "ListPtr.hpp" /*------------------------------- 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 "boundaryListPtr.hpp"
#include "boundaryContactSearch.hpp" #include "boundaryContactSearch.hpp"
namespace pFlow namespace pFlow
@ -9,7 +29,7 @@ class contactSearch;
class boundaryContactSearchList class boundaryContactSearchList
: :
public ListPtr<boundaryContactSearch> public boundaryListPtr<boundaryContactSearch>
{ {
private: private:

View File

@ -74,6 +74,11 @@ public:
csPairContainerType &ppPairs, csPairContainerType &ppPairs,
csPairContainerType &pwPairs, csPairContainerType &pwPairs,
bool force = false) override; bool force = false) override;
bool isActive()const override
{
return true;
}
}; };
} }

View File

@ -152,8 +152,6 @@ public:
return false; return false;
} }
bool hearChanges bool hearChanges
( (
real t, real t,
@ -170,6 +168,11 @@ public:
return true; return true;
} }
bool isActive()const override
{
return false;
}
static static
uniquePtr<BoundaryGrainInteractionType> create( uniquePtr<BoundaryGrainInteractionType> create(
const boundaryBase& boundary, const boundaryBase& boundary,

View File

@ -7,11 +7,11 @@ pFlow::boundaryGrainInteractionList<CFModel, gMModel>::boundaryGrainInteractionL
const gMModel &geomMotion const gMModel &geomMotion
) )
: :
ListPtr<boundaryGrainInteraction<CFModel,gMModel>>(6), boundaryListPtr<boundaryGrainInteraction<CFModel,gMModel>>(),
boundaries_(grnPrtcls.pStruct().boundaries()) boundaries_(grnPrtcls.pStruct().boundaries())
{ {
//gSettings::sleepMiliSeconds(1000*pFlowProcessors().localRank()); //gSettings::sleepMiliSeconds(1000*pFlowProcessors().localRank());
for(uint32 i=0; i<6; i++) ForAllBoundariesPtr(i, this)
{ {
this->set( this->set(
i, i,

View File

@ -3,7 +3,7 @@
#include "boundaryList.hpp" #include "boundaryList.hpp"
#include "ListPtr.hpp" #include "boundaryListPtr.hpp"
#include "boundaryGrainInteraction.hpp" #include "boundaryGrainInteraction.hpp"
@ -14,7 +14,7 @@ namespace pFlow
template<typename contactForceModel,typename geometryMotionModel> template<typename contactForceModel,typename geometryMotionModel>
class boundaryGrainInteractionList class boundaryGrainInteractionList
: :
public ListPtr<boundaryGrainInteraction<contactForceModel,geometryMotionModel>> public boundaryListPtr<boundaryGrainInteraction<contactForceModel,geometryMotionModel>>
{ {
private: private:

View File

@ -78,13 +78,15 @@ public:
~periodicBoundaryGrainInteraction()override = default; ~periodicBoundaryGrainInteraction()override = default;
bool grainGrainInteraction( bool grainGrainInteraction(
real dt, real dt,
const ContactForceModel& cfModel, const ContactForceModel& cfModel,
uint32 step)override; uint32 step)override;
bool isActive()const override
{
return true;
}
}; };

View File

@ -110,7 +110,7 @@ public:
return geometryMotion_; return geometryMotion_;
} }
ContactListType& ppPairs() ContactListType& ppPairs()
{ {
return ppPairs_(); return ppPairs_();
} }
@ -170,6 +170,11 @@ public:
return true; return true;
} }
bool isActive()const override
{
return false;
}
static static
uniquePtr<BoundarySphereInteractionType> create( uniquePtr<BoundarySphereInteractionType> create(
const boundaryBase& boundary, const boundaryBase& boundary,

View File

@ -7,11 +7,11 @@ pFlow::boundarySphereInteractionList<CFModel, gMModel>::boundarySphereInteractio
const gMModel &geomMotion const gMModel &geomMotion
) )
: :
ListPtr<boundarySphereInteraction<CFModel,gMModel>>(6), boundaryListPtr<boundarySphereInteraction<CFModel,gMModel>>(),
boundaries_(sphPrtcls.pStruct().boundaries()) boundaries_(sphPrtcls.pStruct().boundaries())
{ {
//gSettings::sleepMiliSeconds(1000*pFlowProcessors().localRank());
for(uint32 i=0; i<6; i++) ForAllActiveBoundariesPtr(i, this)
{ {
this->set( this->set(
i, i,

View File

@ -3,7 +3,7 @@
#include "boundaryList.hpp" #include "boundaryList.hpp"
#include "ListPtr.hpp" #include "boundaryListPtr.hpp"
#include "boundarySphereInteraction.hpp" #include "boundarySphereInteraction.hpp"
@ -14,7 +14,7 @@ namespace pFlow
template<typename contactForceModel,typename geometryMotionModel> template<typename contactForceModel,typename geometryMotionModel>
class boundarySphereInteractionList class boundarySphereInteractionList
: :
public ListPtr<boundarySphereInteraction<contactForceModel,geometryMotionModel>> public boundaryListPtr<boundarySphereInteraction<contactForceModel,geometryMotionModel>>
{ {
private: private:

View File

@ -76,15 +76,17 @@ public:
boundaryBase boundaryBase
); );
~periodicBoundarySphereInteraction()override = default; ~periodicBoundarySphereInteraction()override = default;
bool sphereSphereInteraction( bool sphereSphereInteraction(
real dt, real dt,
const ContactForceModel& cfModel, const ContactForceModel& cfModel,
uint32 step)override; uint32 step)override;
bool isActive()const override
{
return true;
}
}; };

View File

@ -145,11 +145,6 @@ pFlow::sphereInteraction<cFM,gMM, cLT>::sphereInteraction
{ {
fatalExit; fatalExit;
} }
for(uint32 i=0; i<6; i++)
{
activeBoundaries_[i] = boundaryInteraction_[i].ppPairsAllocated();
}
} }
template<typename cFM,typename gMM,template <class, class, class> class cLT> template<typename cFM,typename gMM,template <class, class, class> class cLT>
@ -193,15 +188,14 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
{ {
contactListMangementBoundaryTimer_.start(); contactListMangementBoundaryTimer_.start();
ComputationTimer().start(); ComputationTimer().start();
for(uint32 i=0; i<6u; i++)
ForAllActiveBoundaries(i, boundaryInteraction_)
{ {
if(activeBoundaries_[i]) auto& BI = boundaryInteraction_[i];
{ BI.ppPairs().beforeBroadSearch();
auto& BI = boundaryInteraction_[i]; BI.pwPairs().beforeBroadSearch();
BI.ppPairs().beforeBroadSearch();
BI.pwPairs().beforeBroadSearch();
}
} }
ComputationTimer().end(); ComputationTimer().end();
contactListMangementBoundaryTimer_.pause(); contactListMangementBoundaryTimer_.pause();
} }
@ -219,22 +213,19 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
fatalExit; fatalExit;
} }
for(uint32 i=0; i<6u; i++) ForAllActiveBoundaries(i, boundaryInteraction_)
{ {
if(activeBoundaries_[i]) auto& BI = boundaryInteraction_[i];
if(!contactSearchRef.boundaryBroadSearch(
i,
ti,
BI.ppPairs(),
BI.pwPairs())
)
{ {
auto& BI = boundaryInteraction_[i]; fatalErrorInFunction<<
if(!contactSearchRef.boundaryBroadSearch( "failed to perform broadSearch for boundary index "<<i<<endl;
i, return false;
ti,
BI.ppPairs(),
BI.pwPairs())
)
{
fatalErrorInFunction<<
"failed to perform broadSearch for boundary index "<<i<<endl;
return false;
}
} }
} }
ComputationTimer().end(); ComputationTimer().end();
@ -253,15 +244,14 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
{ {
contactListMangementBoundaryTimer_.resume(); contactListMangementBoundaryTimer_.resume();
ComputationTimer().start(); ComputationTimer().start();
for(uint32 i=0; i<6u; i++)
ForAllActiveBoundaries(i, boundaryInteraction_ )
{ {
if(activeBoundaries_[i]) auto& BI = boundaryInteraction_[i];
{ BI.ppPairs().afterBroadSearch();
auto& BI = boundaryInteraction_[i]; BI.pwPairs().afterBroadSearch();
BI.ppPairs().afterBroadSearch();
BI.pwPairs().afterBroadSearch();
}
} }
ComputationTimer().end(); ComputationTimer().end();
contactListMangementBoundaryTimer_.end(); contactListMangementBoundaryTimer_.end();
} }
@ -274,7 +264,7 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
ComputationTimer().start(); ComputationTimer().start();
while(requireStep.anyElement(true) && step <= 10) while(requireStep.anyElement(true) && step <= 10)
{ {
for(uint32 i=0; i<6u; i++) ForAllBoundaries(i, boundaryInteraction_)
{ {
if(requireStep[i] ) if(requireStep[i] )
{ {
@ -313,7 +303,7 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
const auto& cfModel = this->forceModel_(); const auto& cfModel = this->forceModel_();
while( requireStep.anyElement(true) && step < 20 ) while( requireStep.anyElement(true) && step < 20 )
{ {
for(uint32 i=0; i<6u; i++) ForAllBoundaries(i, boundaryInteraction_)
{ {
if(requireStep[i]) if(requireStep[i])
{ {

View File

@ -65,6 +65,11 @@ public:
return true; return true;
} }
bool isActive()const override
{
return false;
}
static static
uniquePtr<boundaryGrainParticles> create( uniquePtr<boundaryGrainParticles> create(
const boundaryBase &boundary, const boundaryBase &boundary,

View File

@ -5,10 +5,10 @@ pFlow::boundaryGrainParticlesList::boundaryGrainParticlesList(
grainParticles &prtcls grainParticles &prtcls
) )
: :
ListPtr(bndrs.size()), boundaryListPtr(),
boundaries_(bndrs) boundaries_(bndrs)
{ {
for(auto i=0; i<boundaries_.size(); i++) ForAllBoundariesPtr(i, this)
{ {
this->set this->set
( (
@ -16,4 +16,5 @@ pFlow::boundaryGrainParticlesList::boundaryGrainParticlesList(
boundaryGrainParticles::create(boundaries_[i], prtcls) boundaryGrainParticles::create(boundaries_[i], prtcls)
); );
} }
} }

View File

@ -3,7 +3,7 @@
#ifndef __boundaryGrainParticlesList_hpp__ #ifndef __boundaryGrainParticlesList_hpp__
#define __boundaryGrainParticlesList_hpp__ #define __boundaryGrainParticlesList_hpp__
#include "ListPtr.hpp" #include "boundaryListPtr.hpp"
#include "boundaryList.hpp" #include "boundaryList.hpp"
#include "boundaryGrainParticles.hpp" #include "boundaryGrainParticles.hpp"
@ -12,7 +12,7 @@ namespace pFlow
class boundaryGrainParticlesList class boundaryGrainParticlesList
: :
public ListPtr<boundaryGrainParticles> public boundaryListPtr<boundaryGrainParticles>
{ {
private: private:

View File

@ -316,9 +316,10 @@ bool pFlow::grainParticles::iterate()
accelertion().deviceViewAll(), accelertion().deviceViewAll(),
rAcceleration().deviceViewAll() rAcceleration().deviceViewAll()
); );
for(auto& bndry:boundaryGrainParticles_)
ForAllActiveBoundaries(i,boundaryGrainParticles_)
{ {
bndry->acceleration(ti, g); boundaryGrainParticles_[i].acceleration(ti, g);
} }
accelerationTimer_.end(); accelerationTimer_.end();

View File

@ -65,6 +65,11 @@ public:
return true; return true;
} }
bool isActive()const override
{
return false;
}
static static
uniquePtr<boundarySphereParticles> create( uniquePtr<boundarySphereParticles> create(
const boundaryBase &boundary, const boundaryBase &boundary,

View File

@ -5,10 +5,10 @@ pFlow::boundarySphereParticlesList::boundarySphereParticlesList(
sphereParticles &prtcls sphereParticles &prtcls
) )
: :
ListPtr(bndrs.size()), boundaryListPtr(),
boundaries_(bndrs) boundaries_(bndrs)
{ {
for(auto i=0; i<boundaries_.size(); i++) ForAllBoundariesPtr(i, this)
{ {
this->set this->set
( (

View File

@ -3,7 +3,7 @@
#ifndef __boundarySphereParticlesList_hpp__ #ifndef __boundarySphereParticlesList_hpp__
#define __boundarySphereParticlesList_hpp__ #define __boundarySphereParticlesList_hpp__
#include "ListPtr.hpp" #include "boundaryListPtr.hpp"
#include "boundaryList.hpp" #include "boundaryList.hpp"
#include "boundarySphereParticles.hpp" #include "boundarySphereParticles.hpp"
@ -12,7 +12,7 @@ namespace pFlow
class boundarySphereParticlesList class boundarySphereParticlesList
: :
public ListPtr<boundarySphereParticles> public boundaryListPtr<boundarySphereParticles>
{ {
private: private:

View File

@ -552,10 +552,11 @@ bool pFlow::sphereParticles::iterate()
accelertion().deviceViewAll(), accelertion().deviceViewAll(),
rAcceleration().deviceViewAll() rAcceleration().deviceViewAll()
); );
for(auto& bndry:boundarySphereParticles_) ForAllActiveBoundaries(i,boundarySphereParticles_)
{ {
bndry->acceleration(ti, g); boundarySphereParticles_[i].acceleration(ti, g);
} }
accelerationTimer_.end(); accelerationTimer_.end();
intCorrectTimer_.start(); intCorrectTimer_.start();

View File

@ -184,6 +184,12 @@ public:
return; return;
} }
bool isActive()const override
{
return false;
}
static static
uniquePtr<boundaryField> create( uniquePtr<boundaryField> create(
const boundaryBase& boundary, const boundaryBase& boundary,

View File

@ -22,7 +22,7 @@ Licence:
#include "boundaryField.hpp" #include "boundaryField.hpp"
#include "boundaryList.hpp" #include "boundaryList.hpp"
#include "ListPtr.hpp" #include "boundaryListPtr.hpp"
namespace pFlow namespace pFlow
@ -31,7 +31,7 @@ namespace pFlow
template< class T, class MemorySpace = void > template< class T, class MemorySpace = void >
class boundaryFieldList class boundaryFieldList
: :
public ListPtr< boundaryField<T, MemorySpace> > public boundaryListPtr< boundaryField<T, MemorySpace> >
{ {
public: public:
@ -50,10 +50,10 @@ public:
boundaryFieldList(const boundaryList& boundaries, InternalFieldType& internal) boundaryFieldList(const boundaryList& boundaries, InternalFieldType& internal)
: :
ListPtr<BoundaryFieldType>(boundaries.size()), boundaryListPtr<BoundaryFieldType>(),
boundaries_(boundaries) boundaries_(boundaries)
{ {
for(auto i=0; i<boundaries.size(); i++) ForAllBoundaries(i, *this)
{ {
this->set this->set
( (
@ -68,26 +68,18 @@ public:
if( direction == DataDirection::SlaveToMaster if( direction == DataDirection::SlaveToMaster
&& slaveToMasterUpdateIter_ == iter) return; && slaveToMasterUpdateIter_ == iter) return;
// first step // first step
uint32 i=0; ForAllBoundaries(i,*this)
for(auto b:*this)
{ {
if(i==0 ) this->boundaryPtr(i)->updateBoundary(1, direction);
{
//pOutput<<"request for update boundaries for field "<< b->name()<<endl;
i++;
}
b->updateBoundary(1, direction);
} }
// second step // second step
for(auto b:*this) ForAllBoundaries(i,*this)
{ {
b->updateBoundary(2, direction); this->boundaryPtr(i)->updateBoundary(1, direction);
} }
if(direction == DataDirection::SlaveToMaster) if(direction == DataDirection::SlaveToMaster)
{ {
slaveToMasterUpdateIter_ = iter; slaveToMasterUpdateIter_ = iter;
@ -96,9 +88,9 @@ public:
void fill(const T& val) void fill(const T& val)
{ {
for(auto& bf: *this) ForAllBoundaries(i, *this)
{ {
bf->fill(val); this->boundaryPtr(i)->fill(val);
} }
} }

View File

@ -81,6 +81,11 @@ public:
return true; return true;
} }
bool isActive()const override
{
return false;
}
}; };
} }

View File

@ -147,6 +147,9 @@ public:
} }
const Time& time()const; const Time& time()const;
virtual
bool isActive()const = 0;
}; };

View File

@ -81,6 +81,10 @@ public:
return true; return true;
} }
bool isActive()const override
{
return false;
}
}; };
} }

View File

@ -25,15 +25,12 @@ Licence:
#include "message.hpp" #include "message.hpp"
pFlow::subscriber::subscriber(const subscriber & src) pFlow::subscriber::subscriber(const subscriber & src)
:
subName_(src.subName_)
{ {
} }
pFlow::subscriber::subscriber(subscriber && src) pFlow::subscriber::subscriber(subscriber && src)
: :
observerList_(std::move(src.observerList_)), observerList_(std::move(src.observerList_))
subName_(std::move(src.subName_))
{ {
for(size_t i=0; i<observerList_.size(); i++) for(size_t i=0; i<observerList_.size(); i++)
@ -47,13 +44,13 @@ pFlow::subscriber::subscriber(subscriber && src)
pFlow::subscriber &pFlow::subscriber::operator=(const subscriber & rhs) pFlow::subscriber &pFlow::subscriber::operator=(const subscriber & rhs)
{ {
this->subName_ = rhs.subName_; //this->subName_ = rhs.subName_;
return *this; return *this;
} }
pFlow::subscriber &pFlow::subscriber::operator=(subscriber && rhs) pFlow::subscriber &pFlow::subscriber::operator=(subscriber && rhs)
{ {
this->subName_ = std::move(rhs.subName_); //this->subName_ = std::move(rhs.subName_);
this->observerList_ = std::move(rhs.observerList_); this->observerList_ = std::move(rhs.observerList_);
for(size_t i=0; i<observerList_.size(); i++) for(size_t i=0; i<observerList_.size(); i++)

View File

@ -39,15 +39,13 @@ class subscriber
private: private:
// - list of subsribed objectd that recieve updage messages // - list of subsribed objectd that recieve updage messages
mutable std::array<List<observer*>,message::numEvents()> observerList_; mutable std::vector<List<observer*>> observerList_{message::numEvents()};
word subName_; //word subName_;
public: public:
subscriber(const word& name) subscriber(const word& name)
:
subName_(name)
{} {}
/// Copy constructor, only copies the name, not the list /// Copy constructor, only copies the name, not the list
@ -82,9 +80,9 @@ public:
const message msg, const message msg,
const anyList& varList); const anyList& varList);
const word& subscriberName()const word subscriberName()const
{ {
return subName_; return "subscriber"; //subName_;
} }
}; };

View File

@ -1,4 +1,3 @@
#ifndef __boundariesMask_hpp__ #ifndef __boundariesMask_hpp__
#define __boundariesMask_hpp__ #define __boundariesMask_hpp__

View File

@ -119,7 +119,7 @@ bool pFlow::boundaryBase::removeIndices
if( !this->notify(iter, t, dt, msgBndry, aList) ) if( !this->notify(iter, t, dt, msgBndry, aList) )
{ {
fatalErrorInFunction<<"Error in notify operation in boundary "<< fatalErrorInFunction<<"Error in notify operation in boundary "<<
name_ <<endl; name() <<endl;
return false; return false;
} }
@ -233,16 +233,16 @@ pFlow::boundaryBase::boundaryBase(
indexList_(groupNames("indexList", dict.name())), indexList_(groupNames("indexList", dict.name())),
indexListHost_(groupNames("hostIndexList", dict.name())), indexListHost_(groupNames("hostIndexList", dict.name())),
neighborLength_(dict.getVal<real>("neighborLength")), neighborLength_(dict.getVal<real>("neighborLength")),
// updateInetrval_(dict.getVal<uint32>("updateInterval")),
boundaryExtntionLengthRatio_(dict.getVal<real>("boundaryExtntionLengthRatio")), boundaryExtntionLengthRatio_(dict.getVal<real>("boundaryExtntionLengthRatio")),
internal_(internal), internal_(internal),
boundaries_(bndrs), boundaries_(bndrs),
thisBoundaryIndex_(thisIndex), thisBoundaryIndex_(thisIndex),
neighborProcessorNo_(dict.getVal<int32>("neighborProcessorNo")), neighborProcessorNo_(dict.getVal<int32>("neighborProcessorNo")),
isBoundaryMaster_(thisProcessorNo() >= neighborProcessorNo()), type_(makeUnique<word>(dict.getVal<word>("type")))
name_(dict.name()),
type_(dict.getVal<word>("type"))
{ {
isBoundaryMaster_ = thisProcessorNo() >= neighborProcessorNo();
unSyncLists(); unSyncLists();
} }

View File

@ -31,6 +31,14 @@ Licence:
namespace pFlow namespace pFlow
{ {
static
inline const std::array<word,6> boundaryNames_ =
{
"left", "right",
"bottom", "top",
"rear", "front"
};
// forward // forward
class internalPoints; class internalPoints;
@ -61,16 +69,18 @@ private:
/// 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
mutable bool listsSync_ = false;
/// The length defined for creating neighbor list /// The length defined for creating neighbor list
real neighborLength_; real neighborLength_;
/// device and host list are sync
mutable bool listsSync_ = false;
bool updateTime_ = false; bool updateTime_ = false;
bool iterBeforeUpdate_ = false; bool iterBeforeUpdate_ = false;
bool isBoundaryMaster_;
/// the extra boundary extension beyound actual limits of boundary /// the extra boundary extension beyound actual limits of boundary
real boundaryExtntionLengthRatio_; real boundaryExtntionLengthRatio_;
@ -85,11 +95,7 @@ private:
int neighborProcessorNo_; int neighborProcessorNo_;
bool isBoundaryMaster_; uniquePtr<word> type_;
word name_;
word type_;
protected: protected:
@ -251,13 +257,13 @@ public:
inline inline
const word& type()const const word& type()const
{ {
return type_; return type_();
} }
inline inline
const word& name()const const word& name()const
{ {
return name_; return boundaryNames_[thisBoundaryIndex_];
} }
inline inline
@ -406,6 +412,12 @@ public:
return 0u; return 0u;
} }
inline
bool isActive()const
{
return true;
}
/// - static create /// - static create
static static
uniquePtr<boundaryBase> create uniquePtr<boundaryBase> create

View File

@ -39,7 +39,8 @@ pFlow::boundaryList::setExtendedDomain()
boundary(3).boundaryExtensionLength() + boundary(3).boundaryExtensionLength() +
boundary(5).boundaryExtensionLength(); boundary(5).boundaryExtensionLength();
extendedDomain_ = pStruct_.simDomain().extendThisDomain(lowerExt, upperExt); extendedDomain_ = makeUnique<domain>(
pStruct_.simDomain().extendThisDomain(lowerExt, upperExt));
} }
bool bool
@ -66,7 +67,7 @@ pFlow::boundaryList::updateNeighborLists()
dist[4] = boundary(4).neighborLength(); dist[4] = boundary(4).neighborLength();
dist[5] = boundary(5).neighborLength(); dist[5] = boundary(5).neighborLength();
pStruct_.updateFlag(extendedDomain_, dist); pStruct_.updateFlag(extendedDomain_(), dist);
const auto& maskD = pStruct_.activePointsMaskDevice(); const auto& maskD = pStruct_.activePointsMaskDevice();
boundary(0).setSize(maskD.leftSize()); boundary(0).setSize(maskD.leftSize());
@ -88,8 +89,8 @@ pFlow::boundaryList::updateNeighborLists()
return true; return true;
} }
pFlow::boundaryList::boundaryList(pointStructure& pStruct) pFlow::boundaryList::boundaryList(pointStructure& pStruct):
: ListPtr<boundaryBase>(pStruct.simDomain().sizeOfBoundaries()), boundaryListPtr<boundaryBase>(),
pStruct_(pStruct) pStruct_(pStruct)
{ {
const dictionary& dict= pStruct_.simDomain().thisBoundariesDict(); const dictionary& dict= pStruct_.simDomain().thisBoundariesDict();
@ -143,7 +144,7 @@ pFlow::boundaryList::createBoundaries()
if (listSet_) if (listSet_)
return true; return true;
for (auto i = 0; i < pStruct_.simDomain().sizeOfBoundaries(); i++) ForAllBoundaries(i, *this)
{ {
this->set( this->set(
i, i,
@ -155,7 +156,9 @@ pFlow::boundaryList::createBoundaries()
i i
) )
); );
} }
listSet_ = true; listSet_ = true;
setExtendedDomain(); setExtendedDomain();
return true; return true;
@ -197,7 +200,24 @@ pFlow::boundaryList::beforeIteration(const timeInfo& ti, bool force)
while(callAgain.anyElement(true) && step <= 10u) while(callAgain.anyElement(true) && step <= 10u)
{ {
for(size_t i=0; i<6ul; i++) ForAllBoundaries(i,*this)
{
if(callAgain[i])
{
if(! boundary(i).beforeIteration(
step,
ti,
boundaryUpdate_,
iterBeforeBoundaryUpdate_,
callAgain[i]))
{
fatalErrorInFunction<<"error in performing beforeIteration for boundary"<<
boundary(i).name()<<" at step "<< step<<endl;
return false;
}
}
}
/*for(size_t i=0; i<6ul; i++)
{ {
if(callAgain[i]) if(callAgain[i])
@ -214,21 +234,28 @@ pFlow::boundaryList::beforeIteration(const timeInfo& ti, bool force)
return false; return false;
} }
} }
} }*/
step++; step++;
} }
ForAllBoundaries(i,*this)
for (auto bdry : *this) {
boundary(i).updataBoundaryData(1);
}
/*for (auto bdry : *this)
{ {
bdry->updataBoundaryData(1); bdry->updataBoundaryData(1);
} }*/
for (auto bdry : *this) ForAllBoundaries(i,*this)
{
boundary(i).updataBoundaryData(2);
}
/*for (auto bdry : *this)
{ {
bdry->updataBoundaryData(2); bdry->updataBoundaryData(2);
} }*/
return true; return true;
} }
@ -236,7 +263,16 @@ pFlow::boundaryList::beforeIteration(const timeInfo& ti, bool force)
bool bool
pFlow::boundaryList::iterate(const timeInfo& ti, bool force) pFlow::boundaryList::iterate(const timeInfo& ti, bool force)
{ {
for (auto& bdry : *this) ForAllBoundaries(i, *this)
{
if (!boundary(i).iterate(ti))
{
fatalErrorInFunction << "Error in iterate in boundary "
<< boundary(i).name() << endl;
return false;
}
}
/*for (auto& bdry : *this)
{ {
if (!bdry->iterate(ti)) if (!bdry->iterate(ti))
{ {
@ -244,7 +280,7 @@ pFlow::boundaryList::iterate(const timeInfo& ti, bool force)
<< bdry->name() << endl; << bdry->name() << endl;
return false; return false;
} }
} }*/
return true; return true;
} }
@ -257,7 +293,7 @@ pFlow::boundaryList::afterIteration(const timeInfo& ti, bool force)
int step = 1; int step = 1;
while(callAgain.anyElement(true)&& step <=10) while(callAgain.anyElement(true)&& step <=10)
{ {
for(size_t i=0; i<6; i++) ForAllBoundaries(i,*this)
{ {
if(callAgain[i]) if(callAgain[i])
{ {

View File

@ -22,7 +22,7 @@ Licence:
#include "domain.hpp" #include "domain.hpp"
#include "boundaryBase.hpp" #include "boundaryBase.hpp"
#include "ListPtr.hpp" #include "boundaryListPtr.hpp"
#include "timeInfo.hpp" #include "timeInfo.hpp"
#include "boundariesMask.hpp" #include "boundariesMask.hpp"
@ -34,13 +34,11 @@ class pointStructure;
class boundaryList class boundaryList
: :
public ListPtr<boundaryBase> public boundaryListPtr<boundaryBase>
{ {
private: private:
//// - data members //// - data members
pointStructure& pStruct_;
uint32 neighborListUpdateInterval_; uint32 neighborListUpdateInterval_;
uint32 updateInterval_; uint32 updateInterval_;
@ -53,12 +51,14 @@ private:
bool iterBeforeBoundaryUpdate_; bool iterBeforeBoundaryUpdate_;
domain extendedDomain_;
box internalDomainBox_;
bool listSet_ = false; bool listSet_ = false;
pointStructure& pStruct_;
uniquePtr<domain> extendedDomain_;
box internalDomainBox_;
void setExtendedDomain(); void setExtendedDomain();
bool resetLists(); bool resetLists();
@ -94,13 +94,13 @@ public:
inline inline
auto& boundary(size_t i) auto& boundary(size_t i)
{ {
return ListPtr<boundaryBase>::operator[](i); return boundaryListPtr<boundaryBase>::operator[](i);
} }
inline inline
const auto& boundary(size_t i)const const auto& boundary(size_t i)const
{ {
return ListPtr<boundaryBase>::operator[](i); return boundaryListPtr<boundaryBase>::operator[](i);
} }
inline inline
@ -112,13 +112,13 @@ public:
inline inline
const auto& extendedDomain()const const auto& extendedDomain()const
{ {
return extendedDomain_; return extendedDomain_();
} }
inline inline
const auto& extendedDomainBox()const const auto& extendedDomainBox()const
{ {
return extendedDomain_.domainBox(); return extendedDomain_->domainBox();
} }
box internalDomainBox()const; box internalDomainBox()const;

View File

@ -0,0 +1,186 @@
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __boundaryListPtr_hpp__
#define __boundaryListPtr_hpp__
#include <bitset>
#include <array>
#include "uniquePtr.hpp"
#include "error.h"
#include "iOstream.hpp"
namespace pFlow
{
template<typename BoundaryType>
class boundaryListPtr
{
private:
std::array<BoundaryType*,6> boundaries_;
std::bitset<6> activeBoundaries_=0B000000;
public:
boundaryListPtr():
boundaries_({nullptr, nullptr, nullptr, nullptr, nullptr, nullptr})
{}
void set(size_t i, uniquePtr<BoundaryType>&& ptr )
{
if( i > boundaries_.size() )
{
fatalErrorInFunction<<
"Out of range access of boundaryListPtr members. List size is "<<
size() << "and you are accessing "<< i << "\n";
fatalExit;
}
if(boundaries_[i]) delete boundaries_[i];
boundaries_[i] = ptr.release();
if(boundaries_[i])
{
// query if this boundary active or not
activeBoundaries_.set(i,boundaries_[i]->isActive());
}
}
~boundaryListPtr()
{
clear();
}
void clear()
{
for(auto& bndry:boundaries_)
{
if(bndry != nullptr)
{
delete bndry;
bndry = nullptr;
}
}
activeBoundaries_.reset();
}
// - access to ith element
inline
BoundaryType& operator[](size_t i)
{
if(boundaries_[i]== nullptr)
{
fatalErrorInFunction<<"Accessing nullptr element"<<endl;
fatalExit;
}
return *boundaries_[i];
}
// - const access to ith element
// fatalexit if out of range or nullptr
inline
const BoundaryType& operator[](size_t i) const
{
if(boundaries_[i]== nullptr)
{
fatalErrorInFunction<<"Accessing nullptr element"<<endl;
fatalExit;
}
return *boundaries_[i];
}
inline
BoundaryType* boundaryPtr(size_t i)
{
if(boundaries_[i]== nullptr)
{
fatalErrorInFunction<<"Accessing nullptr element"<<endl;
fatalExit;
}
return boundaries_[i];
}
inline
const BoundaryType* boundaryPtr(size_t i)const
{
if(boundaries_[i]== nullptr)
{
fatalErrorInFunction<<"Accessing nullptr element"<<endl;
fatalExit;
}
return boundaries_[i];
}
inline constexpr
size_t size()const
{
return 6ul;
}
inline
size_t firstActive()const
{
if(activeBoundaries_[0]) return 0ul;
if(activeBoundaries_[1]) return 1ul;
if(activeBoundaries_[2]) return 2ul;
if(activeBoundaries_[3]) return 3ul;
if(activeBoundaries_[4]) return 4ul;
if(activeBoundaries_[5]) return 5ul;
return 6ul;
}
inline
size_t nextActive(size_t i)const
{
if(i>=5ul) return 6ul;
if(activeBoundaries_[i+1])
return i+1;
else
return nextActive(i+1);
}
inline
bool allActive()const
{
return activeBoundaries_.all();
}
inline
bool anyActive()const
{
return activeBoundaries_.any();
}
inline
bool noneActive()const
{
return activeBoundaries_.none();
}
};
}
#define ForAllBoundaries(i,bndryList) for(size_t i = 0ul; i<(bndryList).size(); i++)
#define ForAllBoundariesPtr(i,bndryList) for(size_t i = 0ul; i<bndryList->size(); i++)
#define ForAllActiveBoundaries(i,bndryList) for(size_t i = bndryList.firstActive(); i<bndryList.size(); i=bndryList.nextActive(i))
#define ForAllActiveBoundariesPtr(i,bndryList) for(size_t i = bndryList->firstActive(); i<bndryList->size(); i=bndryList->nextActive(i))
#endif //__boundaryListPtr_hpp__