# PhasicFlow: src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

boundaryBase.hpp
Go to the documentation of this file.
/*------------------------------- 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 __boundaryBase_hpp__
#define __boundaryBase_hpp__
#include "virtualConstructor.hpp"
#include "subscriber.hpp"
#include "VectorSingles.hpp"
#include "plane.hpp"
#include "scatteredFieldAccess.hpp"
#include "timeInfo.hpp"
namespace pFlow
{
// forward
class internalPoints;
class dictionary;
class boundaryList;
class pointStructure;
class Time;
class boundaryBase
:
public subscriber
{
public:
using pointFieldAccessType =
deviceScatteredFieldAccess<realx3>;
private:
// friend et al.
friend boundaryList;
const plane& boundaryPlane_;
uint32Vector_D indexList_;
mutable uint32Vector_H indexListHost_;
mutable bool listsSync_ = false;
real neighborLength_;
bool updateTime_ = false;
bool iterBeforeUpdate_ = false;
real boundaryExtntionLengthRatio_;
internalPoints& internal_;
boundaryList& boundaries_;
uint32 thisBoundaryIndex_;
int neighborProcessorNo_;
bool isBoundaryMaster_;
word name_;
word type_;
protected:
virtual void setSize(uint32 newSize);
void setUpdateTime(bool val)
{
updateTime_ = val;
}
void setNewIndices(const uint32Vector_D& newIndices);
bool appendNewIndices(const uint32Vector_D& newIndices);
bool removeIndices(
uint32 numRemove,
const uint32Vector_D& removeMask);
bool setRemoveKeepIndices(
const uint32Vector_D& removeIndices,
const uint32Vector_D& keepIndices);
bool transferPointsToMirror(
uint32 numTransfer,
const uint32Vector_D& transferMask,
uint32 transferBoundaryIndex,
realx3 transferVector);
void unSyncLists()
{
listsSync_ = false;
}
void syncLists()const
{
if(!listsSync_)
{
indexListHost_.assignFromDevice(indexList_, true);
listsSync_ = true;
}
}
virtual
bool updataBoundaryData(int step)
{
return true;
}
virtual
bool transferData(uint32 iter, int step, bool& callAgain)
{
callAgain = false;
return true;
}
public:
uint32 markInNegativeSide(const word& name, uint32Vector_D& markedIndices )const;
TypeInfo("boundaryBase");
boundaryBase(
const dictionary &dict,
const plane &bplane,
internalPoints &internal,
boundaryList &bndrs,
uint32 thisIndex);
boundaryBase(const boundaryBase&) = delete;
boundaryBase& operator=(const boundaryBase&) = delete;
boundaryBase(boundaryBase&&) = default;
boundaryBase& operator=(boundaryBase&&) = default;
~boundaryBase() override = default;
create_vCtor
(
boundaryBase,
dictionary,
(
const dictionary &dict,
const plane &bplane,
internalPoints &internal,
boundaryList &bndrs,
uint32 thisIndex
),
(dict, bplane, internal, bndrs, thisIndex)
);
inline
real neighborLengthIntoInternal()const
{
return neighborLength_;
}
virtual
real neighborLength()const
{
return (1+boundaryExtntionLengthRatio_)*neighborLength_;
}
virtual
realx3 boundaryExtensionLength()const
{
return -boundaryExtntionLengthRatio_*neighborLength_ * boundaryPlane_.normal();
}
inline
bool performBoundarytUpdate()const
{
return updateTime_;
}
inline
bool iterBeforeBoundaryUpdate()const
{
return iterBeforeUpdate_;
}
inline
const word& type()const
{
return type_;
}
inline
const word& name()const
{
return name_;
}
inline
bool empty()const
{
return indexList_.size()==0;
}
inline
auto size()const
{
return indexList_.size();
}
inline
auto capacity()const
{
return indexList_.capacity();
}
inline
int neighborProcessorNo()const
{
return neighborProcessorNo_;
}
inline
int thisProcessorNo()const
{
return pFlowProcessors().localRank();
}
inline
bool isBoundaryMaster()const
{
return isBoundaryMaster_;
}
inline
uint32 thisBoundaryIndex()const
{
return thisBoundaryIndex_;
}
inline
uint32 mirrorBoundaryIndex()const
{
return thisBoundaryIndex_%2==0? thisBoundaryIndex_+1:thisBoundaryIndex_-1;
}
inline
const internalPoints& internal()const
{
return internal_;
}
inline
internalPoints& internal()
{
return internal_;
}
const pointStructure& pStruct()const;
const Time& time()const;
inline
const auto& indexList()const
{
return indexList_;
}
inline
const auto& indexListHost()const
{
syncLists();
return indexListHost_;
}
boundaryBase& mirrorBoundary();
const boundaryBase& mirrorBoundary()const;
const plane& boundaryPlane()const
{
return boundaryPlane_;
}
virtual
realx3 displacementVectroToMirror()const;
virtual
bool beforeIteration(
uint32 step,
const timeInfo& ti,
bool updateIter,
bool iterBeforeUpdate ,
bool& callAgain
)
{
updateTime_ = updateIter;
iterBeforeUpdate_ = iterBeforeUpdate;
return true;
}
virtual
bool iterate(const timeInfo& ti) = 0;
virtual
bool afterIteration(const timeInfo& ti) = 0;
pointFieldAccessType thisPoints()const;
virtual
uint32 neighborProcSize()const
{
return 0;
}
virtual
realx3Vector_D& neighborProcPoints();
virtual
const realx3Vector_D& neighborProcPoints()const;
virtual
uint32 numToTransfer()const
{
return 0u;
}
virtual
uint32 numToRecieve()const
{
return 0u;
}
static
uniquePtr<boundaryBase> create
(
const dictionary &dict,
const plane &bplane,
internalPoints &internal,
boundaryList &bndrs,
uint32 thisIndex
);
};
}
#endif //__boundaryBase_hpp__
pFlow::boundaryBase::neighborProcSize
virtual uint32 neighborProcSize() const
Return number of points in the neighbor processor boundary.
Definition: boundaryBase.hpp:382
subscriber.hpp
pFlow::boundaryBase::neighborLengthIntoInternal
real neighborLengthIntoInternal() const
The length from boundary plane into the domain where beyond that distance internal points exist.
Definition: boundaryBase.hpp:211
pFlow::boundaryBase::pStruct
const pointStructure & pStruct() const
Definition: boundaryBase.cpp:249
pFlow::internalPoints
Definition: internalPoints.hpp:38
pFlow::boundaryBase::indexListHost
const auto & indexListHost() const
Definition: boundaryBase.hpp:334
pFlow::boundaryBase::displacementVectroToMirror
virtual realx3 displacementVectroToMirror() const
displacement vector that transfers points to a distance that is equal to the distance between this ...
Definition: boundaryBase.cpp:299
pFlow::boundaryBase::name_
word name_
Definition: boundaryBase.hpp:90
pFlow::infinitePlane::normal
const INLINE_FUNCTION_HD auto & normal() const
Definition: infinitePlane.hpp:155
pFlow::boundaryBase::syncLists
void syncLists() const
Definition: boundaryBase.hpp:132
pFlow::scatteredFieldAccess
Definition: scatteredFieldAccess.hpp:32
pFlow::boundaryBase::TypeInfo
TypeInfo("boundaryBase")
pFlow::real
float real
Definition: builtinTypes.hpp:45
timeInfo.hpp
pFlow::plane
Definition: plane.hpp:30
pFlow::localProcessors::localRank
auto localRank() const
Definition: localProcessors.hpp:88
pFlow::boundaryBase::thisBoundaryIndex
uint32 thisBoundaryIndex() const
Definition: boundaryBase.hpp:300
pFlow::VectorSingle::assignFromDevice
INLINE_FUNCTION_H void assignFromDevice(const VectorSingle< T, MSpace > &src, bool srcCapacity=true)
Definition: VectorSingle.cpp:487
pFlow::boundaryBase::type_
word type_
Definition: boundaryBase.hpp:92
pFlow::boundaryBase::transferPointsToMirror
bool transferPointsToMirror(uint32 numTransfer, const uint32Vector_D &transferMask, uint32 transferBoundaryIndex, realx3 transferVector)
Definition: boundaryBase.cpp:149
pFlow::boundaryBase::empty
bool empty() const
Definition: boundaryBase.hpp:264
pFlow::boundaryBase::neighborProcPoints
virtual realx3Vector_D & neighborProcPoints()
Return a reference to point positions in the neighbor processor boundary.
Definition: boundaryBase.cpp:282
pFlow::boundaryBase::markInNegativeSide
uint32 markInNegativeSide(const word &name, uint32Vector_D &markedIndices) const
Definition: boundaryBase.cpp:193
pFlow::boundaryBase::boundaryPlane
const plane & boundaryPlane() const
the actual boundary plane of this boundary
Definition: boundaryBase.hpp:345
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::boundaryBase::updataBoundaryData
virtual bool updataBoundaryData(int step)
Update this boundary data in two steps (1 and 2).
Definition: boundaryBase.hpp:148
pFlow::boundaryBase::neighborProcessorNo_
int neighborProcessorNo_
Definition: boundaryBase.hpp:86
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::boundaryBase::neighborProcessorNo
int neighborProcessorNo() const
Definition: boundaryBase.hpp:282
pFlow::boundaryList
Definition: boundaryList.hpp:35
pFlow::boundaryBase::mirrorBoundary
boundaryBase & mirrorBoundary()
Definition: boundaryBase.cpp:259
pFlow::boundaryBase::name
const word & name() const
Definition: boundaryBase.hpp:258
pFlow::boundaryBase::beforeIteration
virtual bool beforeIteration(uint32 step, const timeInfo &ti, bool updateIter, bool iterBeforeUpdate, bool &callAgain)
Definition: boundaryBase.hpp:359
pFlow::boundaryBase::thisProcessorNo
int thisProcessorNo() const
Definition: boundaryBase.hpp:288
pFlow::boundaryBase::listsSync_
bool listsSync_
device and host list are sync
Definition: boundaryBase.hpp:65
plane.hpp
pFlow::boundaryBase::boundaryExtensionLength
virtual realx3 boundaryExtensionLength() const
The extention length (in vector form) for the boundary as required by each boundary type.
Definition: boundaryBase.hpp:233
pFlow::subscriber
Definition: subscriber.hpp:37
pFlow::timeInfo
Definition: timeInfo.hpp:28
pFlow::boundaryBase::transferData
virtual bool transferData(uint32 iter, int step, bool &callAgain)
This method is called when a transfer of data is to be performed between processors (in afterIteratio...
Definition: boundaryBase.hpp:161
pFlow::boundaryBase::boundaryPlane_
const plane & boundaryPlane_
Definition: boundaryBase.hpp:56
pFlow::boundaryBase::boundaryList
friend boundaryList
Definition: boundaryBase.hpp:54
pFlow::boundaryBase::time
const Time & time() const
Definition: boundaryBase.cpp:254
pFlow
Definition: demGeometry.hpp:27
VectorSingles.hpp
pFlow::boundaryBase::type
const word & type() const
Definition: boundaryBase.hpp:252
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::boundaryBase::indexList
const auto & indexList() const
Definition: boundaryBase.hpp:328
pFlow::boundaryBase::thisBoundaryIndex_
uint32 thisBoundaryIndex_
Definition: boundaryBase.hpp:84
pFlow::boundaryBase::afterIteration
virtual bool afterIteration(const timeInfo &ti)=0
pFlow::boundaryBase::boundaries_
boundaryList & boundaries_
a reference to the list of boundaries (never use this in the constructor).
Definition: boundaryBase.hpp:82
pFlow::boundaryBase::internal_
internalPoints & internal_
a reference to internal points
Definition: boundaryBase.hpp:78
pFlow::boundaryBase::isBoundaryMaster
bool isBoundaryMaster() const
Definition: boundaryBase.hpp:294
virtualConstructor.hpp
pFlow::boundaryBase
Definition: boundaryBase.hpp:42
pFlow::boundaryBase::isBoundaryMaster_
bool isBoundaryMaster_
Definition: boundaryBase.hpp:88
pFlow::boundaryBase::setSize
virtual void setSize(uint32 newSize)
Set the size of indexList.
Definition: boundaryBase.cpp:30
pFlow::boundaryBase::performBoundarytUpdate
bool performBoundarytUpdate() const
Is this iter the right time for updating bounday list.
Definition: boundaryBase.hpp:240
pFlow::VectorSingle< uint32 >
pFlow::boundaryBase::unSyncLists
void unSyncLists()
Definition: boundaryBase.hpp:127
pFlow::boundaryBase::size
auto size() const
Definition: boundaryBase.hpp:270
pFlow::boundaryBase::pointFieldAccessType
deviceScatteredFieldAccess< realx3 > pointFieldAccessType
Definition: boundaryBase.hpp:49
pFlow::boundaryBase::numToTransfer
virtual uint32 numToTransfer() const
Definition: boundaryBase.hpp:398
pFlow::boundaryBase::setUpdateTime
void setUpdateTime(bool val)
Definition: boundaryBase.hpp:104
pFlow::boundaryBase::iterBeforeUpdate_
bool iterBeforeUpdate_
Definition: boundaryBase.hpp:72
pFlow::boundaryBase::neighborLength_
real neighborLength_
The length defined for creating neighbor list.
Definition: boundaryBase.hpp:68
pFlow::boundaryBase::indexList_
uint32Vector_D indexList_
list of particles indices on device
Definition: boundaryBase.hpp:59
pFlow::pFlowProcessors
localProcessors & pFlowProcessors()
Definition: pFlowProcessors.cpp:5
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::boundaryBase::indexListHost_
uint32Vector_H indexListHost_
list of particles indieces on host
Definition: boundaryBase.hpp:62
pFlow::boundaryBase::iterBeforeBoundaryUpdate
bool iterBeforeBoundaryUpdate() const
Definition: boundaryBase.hpp:246
pFlow::boundaryBase::setNewIndices
void setNewIndices(const uint32Vector_D &newIndices)
Definition: boundaryBase.cpp:37
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H uint32 capacity() const
Definition: VectorSingle.cpp:304
pFlow::boundaryBase::boundaryBase
boundaryBase(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex)
Definition: boundaryBase.cpp:225
pFlow::boundaryBase::capacity
auto capacity() const
Definition: boundaryBase.hpp:276
pFlow::boundaryBase::create_vCtor
create_vCtor(boundaryBase, dictionary,(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex),(dict, bplane, internal, bndrs, thisIndex))
pFlow::boundaryBase::setRemoveKeepIndices
bool setRemoveKeepIndices(const uint32Vector_D &removeIndices, const uint32Vector_D &keepIndices)
Definition: boundaryBase.cpp:130
pFlow::boundaryBase::appendNewIndices
bool appendNewIndices(const uint32Vector_D &newIndices)
Definition: boundaryBase.cpp:47
pFlow::boundaryBase::numToRecieve
virtual uint32 numToRecieve() const
Definition: boundaryBase.hpp:404
pFlow::boundaryBase::~boundaryBase
~boundaryBase() override=default
pFlow::triple< real >
scatteredFieldAccess.hpp
pFlow::boundaryBase::operator=
boundaryBase & operator=(const boundaryBase &)=delete
pFlow::boundaryBase::updateTime_
bool updateTime_
Definition: boundaryBase.hpp:70
pFlow::boundaryBase::boundaryExtntionLengthRatio_
real boundaryExtntionLengthRatio_
the extra boundary extension beyound actual limits of boundary
Definition: boundaryBase.hpp:75
pFlow::boundaryBase::thisPoints
pointFieldAccessType thisPoints() const
Definition: boundaryBase.cpp:270
pFlow::boundaryBase::create
static uniquePtr< boundaryBase > create(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex)
Definition: boundaryBase.cpp:308
pFlow::boundaryBase::mirrorBoundaryIndex
uint32 mirrorBoundaryIndex() const
Definition: boundaryBase.hpp:306
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67
pFlow::VectorSingle::size
INLINE_FUNCTION_H uint32 size() const
Size of the vector.
Definition: VectorSingle.cpp:297
pFlow::boundaryBase::iterate
virtual bool iterate(const timeInfo &ti)=0
pFlow::Time
Definition: Time.hpp:37
pFlow::boundaryBase::neighborLength
virtual real neighborLength() const
The distance length from boundary plane where neighbor particles still exist in that distance.
Definition: boundaryBase.hpp:222
pFlow::boundaryBase::removeIndices
bool removeIndices(uint32 numRemove, const uint32Vector_D &removeMask)
Definition: boundaryBase.cpp:79