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;
}
bool isActive()const override
{
return false;
}
static
uniquePtr<boundaryIntegration> create(
const boundaryBase& boundary,

View File

@ -7,11 +7,11 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList(
integration &intgrtn
)
:
ListPtr<boundaryIntegration>(6),
boundaryListPtr<boundaryIntegration>(),
boundaries_(pStruct.boundaries())
{
for(uint32 i=0; i<6; i++)
ForAllBoundariesPtr(i, this)
{
this->set(
i,
@ -19,25 +19,23 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList(
boundaries_[i],
pStruct,
method,
intgrtn
)
);
intgrtn
)
);
}
}
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 "<<
bndry->boundaryName()<<endl;
boundaryPtr(i)->boundaryName()<<endl;
return false;
}
}
}
return true;
}
@ -46,14 +44,15 @@ bool pFlow::boundaryIntegrationList::correctPStruct(
pointStructure &pStruct,
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 "<<
bndry->boundaryName()<<" in pointStructure."<<endl;
boundaryPtr(i)->boundaryName()<<" in pointStructure."<<endl;
return false;
}
}
return true;
}

View File

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

View File

@ -98,6 +98,11 @@ public:
return true;
}
bool isActive()const override
{
return false;
}
static uniquePtr<boundaryContactSearch> create(
const dictionary &dict,
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 "boundaryList.hpp"
@ -5,7 +25,7 @@ void pFlow::boundaryContactSearchList::setList(
const dictionary &dict,
const contactSearch &cSearch)
{
for(auto i=0; i<boundaries_.size(); i++)
ForAllBoundariesPtr(i, this)
{
this->set
(
@ -20,7 +40,7 @@ pFlow::boundaryContactSearchList::boundaryContactSearchList(
const boundaryList& bndrs,
const contactSearch &cSearch)
:
ListPtr(bndrs.size()),
boundaryListPtr(),
boundaries_(bndrs)
{
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"
namespace pFlow
@ -9,7 +29,7 @@ class contactSearch;
class boundaryContactSearchList
:
public ListPtr<boundaryContactSearch>
public boundaryListPtr<boundaryContactSearch>
{
private:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,15 +39,13 @@ class subscriber
private:
// - 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:
subscriber(const word& name)
:
subName_(name)
{}
/// Copy constructor, only copies the name, not the list
@ -82,9 +80,9 @@ public:
const message msg,
const anyList& varList);
const word& subscriberName()const
word subscriberName()const
{
return subName_;
return "subscriber"; //subName_;
}
};

View File

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

View File

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

View File

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

View File

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

View File

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