phase1 of periodict boundary condition (serial)
upto now, particles are transfered from one boundary to another (mirro). this has been tested using iterateSphereParticles utility.
This commit is contained in:
parent
593cb9e6ed
commit
a900ff32bb
|
@ -52,8 +52,7 @@ protected:
|
|||
static inline
|
||||
const message defaultMessage_ =
|
||||
(
|
||||
message::BNDR_RESET+
|
||||
message::BNDR_REARRANGE
|
||||
message::BNDR_RESET
|
||||
);
|
||||
|
||||
public:
|
||||
|
|
|
@ -26,4 +26,6 @@ template<class T, class MemorySpace>
|
|||
)
|
||||
:
|
||||
BoundaryFieldType(boundary, internal)
|
||||
{}
|
||||
{
|
||||
this->addEvent(message::BNDR_DELETE);
|
||||
}
|
|
@ -25,5 +25,8 @@ template<class T, class MemorySpace>
|
|||
InternalFieldType& internal
|
||||
)
|
||||
:
|
||||
BoundaryFieldType(boundary, internal)
|
||||
{}
|
||||
BoundaryFieldType(boundary, internal)
|
||||
{
|
||||
this->addEvent(message::BNDR_APPEND)
|
||||
.addEvent(message::BNDR_TRANSFER);
|
||||
}
|
|
@ -70,8 +70,17 @@ public:
|
|||
const anyList& varList
|
||||
) override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
BoundaryFieldType::hearChanges(t,dt,iter, msg,varList);
|
||||
|
||||
if(msg.equivalentTo(message::BNDR_APPEND))
|
||||
{
|
||||
// do nothing;
|
||||
}
|
||||
if(msg.equivalentTo(message::BNDR_TRANSFER))
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -42,16 +42,18 @@ public:
|
|||
ITEM_INSERT = 4, // internal points item inserted
|
||||
RANGE_CHANGED = 5, // internal points range changed
|
||||
ITEM_REARRANGE = 6, // internal points item rearrange
|
||||
BNDR_REARRANGE = 7, // boundary indices rearrange
|
||||
BNDR_TRANSFER = 8, // boundary indices transfered
|
||||
BNDR_RESET = 9, // boundary indices reset entirely
|
||||
BNDR_DELETE = 10 // boundary indices deleted
|
||||
ITEM_FLAGCHANGED= 7, // internal points item flag changed, this occurs when transfer occurs
|
||||
BNDR_REARRANGE = 8, // boundary indices rearrange
|
||||
BNDR_TRANSFER = 9, // boundary indices transfered
|
||||
BNDR_RESET = 10, // boundary indices reset entirely
|
||||
BNDR_DELETE = 11, // boundary indices deleted
|
||||
BNDR_APPEND = 12
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static constexpr size_t numberOfEvents_ = 11;
|
||||
static constexpr size_t numberOfEvents_ = 13;
|
||||
|
||||
std::bitset<numberOfEvents_> events_{0x0000};
|
||||
|
||||
|
@ -65,10 +67,12 @@ private:
|
|||
"insertedIndices",
|
||||
"range",
|
||||
"rearrangedIndices",
|
||||
"transferredIndices",
|
||||
"rearrangedIndices",
|
||||
"transferredIndices",
|
||||
"",
|
||||
"deletedIndices"
|
||||
"deletedIndices",
|
||||
"appendedIndices"
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -141,6 +145,19 @@ public:
|
|||
{
|
||||
return remove(evnt);
|
||||
}
|
||||
|
||||
inline
|
||||
message& operator+(const message& msg)
|
||||
{
|
||||
for(size_t i=0uL; i< events_.size(); i++)
|
||||
{
|
||||
if(msg.equivalentTo(i))
|
||||
{
|
||||
events_.set(i);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
static
|
||||
auto constexpr numEvents()
|
||||
|
|
|
@ -19,6 +19,7 @@ Licence:
|
|||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "boundaryBase.hpp"
|
||||
#include "boundaryList.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "internalPoints.hpp"
|
||||
#include "anyList.hpp"
|
||||
|
@ -34,17 +35,35 @@ void pFlow::boundaryBase::setNewIndices
|
|||
indexList_.assign(newIndices, false);
|
||||
}
|
||||
|
||||
void pFlow::boundaryBase::appendNewIndices
|
||||
bool pFlow::boundaryBase::appendNewIndices
|
||||
(
|
||||
const uint32Vector_D& newIndices
|
||||
)
|
||||
{
|
||||
|
||||
indexList_.append(newIndices);
|
||||
|
||||
// TODO: notify observers about this change
|
||||
message msg;
|
||||
|
||||
// the index list should be sorted
|
||||
//sort(indexList_.deviceViewAll(), 0, newSize);
|
||||
msg.add(message::BNDR_APPEND);
|
||||
anyList varList;
|
||||
varList.emplaceBack(
|
||||
message::eventName(message::BNDR_APPEND),
|
||||
newIndices);
|
||||
|
||||
if(!notify(
|
||||
internal_.time().currentIter(),
|
||||
internal_.time().currentTime(),
|
||||
internal_.time().dt(),
|
||||
msg,
|
||||
varList))
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::boundaryBase::removeIndices
|
||||
|
@ -128,37 +147,32 @@ bool pFlow::boundaryBase::transferPoints
|
|||
keepIndices
|
||||
);
|
||||
|
||||
// third, remove the indices from this list
|
||||
setNewIndices(keepIndices);
|
||||
|
||||
// first, change the flags in the internalPoints
|
||||
if( !internal_.changePointsFlag(
|
||||
transferIndices.deviceView(),
|
||||
if( !internal_.changePointsFlagPosition(
|
||||
transferIndices,
|
||||
transferVector,
|
||||
thisBoundaryIndex(),
|
||||
transferBoundaryIndex) )
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
|
||||
// second, change the position of points
|
||||
if(!internal_.changePointsPoisition(
|
||||
transferIndices.deviceView(),
|
||||
transferVector))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// second, remove the indices from this list
|
||||
setNewIndices(keepIndices);
|
||||
|
||||
// fourth, add the indices to the mirror boundary
|
||||
internal_.boundary(transferBoundaryIndex).
|
||||
appendNewIndices(transferIndices);
|
||||
// third, add the indices to the mirror boundary
|
||||
return mirrorBoundary().appendNewIndices(transferIndices);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::boundaryBase::boundaryBase
|
||||
(
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex
|
||||
)
|
||||
:
|
||||
subscriber(dict.name()),
|
||||
|
@ -166,20 +180,23 @@ pFlow::boundaryBase::boundaryBase
|
|||
indexList_(groupNames(dict.name(), "indexList")),
|
||||
neighborLength_(dict.getVal<real>("neighborLength")),
|
||||
internal_(internal),
|
||||
boundaries_(bndrs),
|
||||
thisBoundaryIndex_(thisIndex),
|
||||
mirrorProcessoNo_(dict.getVal<uint32>("mirrorProcessorNo")),
|
||||
name_(dict.name()),
|
||||
type_(dict.getVal<word>("type"))
|
||||
{
|
||||
}
|
||||
|
||||
pFlow::boundaryBase &pFlow::boundaryBase::mirrorBoundary()
|
||||
{
|
||||
return boundaries_[mirrorBoundaryIndex()];
|
||||
}
|
||||
|
||||
void pFlow::boundaryBase::setSize(uint32 newSize)
|
||||
{
|
||||
indexList_.resize(newSize);
|
||||
/*if( indexList_.capacity() <= newSize+1 )
|
||||
{
|
||||
indexList_.reserve(newSize+1);
|
||||
}*/
|
||||
//INFORMATION<<"new size of boundary "<< name_<<" "<< indexList_.size()<<END_INFO;
|
||||
|
||||
}
|
||||
|
||||
typename pFlow::boundaryBase::pointFieldAccessType
|
||||
|
@ -202,17 +219,21 @@ typename pFlow::boundaryBase::pointFieldAccessType
|
|||
return pointFieldAccessType();
|
||||
}
|
||||
|
||||
pFlow::uniquePtr<pFlow::boundaryBase> pFlow::boundaryBase::create(
|
||||
pFlow::uniquePtr<pFlow::boundaryBase> pFlow::boundaryBase::create
|
||||
(
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal)
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex
|
||||
)
|
||||
{
|
||||
word type = dict.getVal<word>("type");
|
||||
word bType = angleBracketsNames("boundary", type);
|
||||
|
||||
if( dictionaryvCtorSelector_.search(bType) )
|
||||
{
|
||||
return dictionaryvCtorSelector_[bType] (dict, bplane, internal);
|
||||
return dictionaryvCtorSelector_[bType] (dict, bplane, internal, bndrs, thisIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace pFlow
|
|||
|
||||
class internalPoints;
|
||||
class dictionary;
|
||||
class boundaryList;
|
||||
|
||||
class boundaryBase
|
||||
:
|
||||
|
@ -53,16 +54,18 @@ private:
|
|||
/// list of particles indices on device
|
||||
uint32Vector_D indexList_;
|
||||
|
||||
uint32Vector_H indexListH_;
|
||||
|
||||
bool indexSync_ = false;
|
||||
|
||||
/// The length defined for creating neighbor list
|
||||
real neighborLength_;
|
||||
|
||||
/// a reference to
|
||||
internalPoints& internal_;
|
||||
|
||||
/// a reference to the list of boundaries
|
||||
/// (never use this in the constructor).
|
||||
boundaryList& boundaries_;
|
||||
|
||||
uint32 thisBoundaryIndex_;
|
||||
|
||||
uint32 mirrorProcessoNo_;
|
||||
|
||||
word name_;
|
||||
|
@ -73,7 +76,7 @@ protected:
|
|||
|
||||
void setNewIndices(const uint32Vector_D& newIndices);
|
||||
|
||||
void appendNewIndices(const uint32Vector_D& newIndices);
|
||||
bool appendNewIndices(const uint32Vector_D& newIndices);
|
||||
|
||||
bool removeIndices(
|
||||
uint32 numRemove,
|
||||
|
@ -85,16 +88,17 @@ protected:
|
|||
uint32 transferBoundaryIndex,
|
||||
realx3 transferVector);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("boundaryBase");
|
||||
|
||||
|
||||
boundaryBase(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal);
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex);
|
||||
|
||||
boundaryBase(const boundaryBase&) = delete;
|
||||
|
||||
|
@ -112,11 +116,13 @@ public:
|
|||
boundaryBase,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex
|
||||
),
|
||||
(dict, bplane, internal)
|
||||
(dict, bplane, internal, bndrs, thisIndex)
|
||||
);
|
||||
|
||||
virtual
|
||||
|
@ -172,6 +178,20 @@ public:
|
|||
return internal_;
|
||||
}
|
||||
|
||||
boundaryBase& mirrorBoundary();
|
||||
|
||||
inline
|
||||
uint32 thisBoundaryIndex()const
|
||||
{
|
||||
return thisBoundaryIndex_;
|
||||
}
|
||||
|
||||
inline
|
||||
uint32 mirrorBoundaryIndex()const
|
||||
{
|
||||
return thisBoundaryIndex_%2==0? thisBoundaryIndex_+1:thisBoundaryIndex_-1;
|
||||
}
|
||||
|
||||
/// @brief set the size of indexList
|
||||
/// Always make sure that size+1 <= capacity
|
||||
void setSize(uint32 newSize);
|
||||
|
@ -200,9 +220,11 @@ public:
|
|||
static
|
||||
uniquePtr<boundaryBase> create
|
||||
(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -25,12 +25,14 @@ Licence:
|
|||
|
||||
pFlow::boundaryExit::boundaryExit
|
||||
(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex
|
||||
)
|
||||
:
|
||||
boundaryBase(dict, bplane, internal)
|
||||
boundaryBase(dict, bplane, internal, bndrs, thisIndex)
|
||||
{
|
||||
exitMarginLength_ = max(
|
||||
dict.getValOrSet("exitMarginLength",(real)0.0), (real)0.0);
|
||||
|
|
|
@ -47,9 +47,11 @@ public:
|
|||
TypeInfo("boundary<exit>");
|
||||
|
||||
boundaryExit(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal);
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex);
|
||||
|
||||
virtual
|
||||
~boundaryExit() = default;
|
||||
|
|
|
@ -110,7 +110,9 @@ bool pFlow::boundaryList::setLists()
|
|||
(
|
||||
pStruct_.simDomain().boundaryDict(i),
|
||||
pStruct_.simDomain().boundaryPlane(i),
|
||||
pStruct_
|
||||
pStruct_,
|
||||
*this,
|
||||
i
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -144,7 +146,9 @@ bool pFlow::boundaryList::beforeIteration
|
|||
"Error in beforeIteration in boundary "<<bdry->name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,14 @@ Licence:
|
|||
|
||||
pFlow::boundaryNone::boundaryNone
|
||||
(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex
|
||||
)
|
||||
:
|
||||
boundaryBase(dict, bplane, internal)
|
||||
boundaryBase(dict, bplane, internal, bndrs, thisIndex)
|
||||
{}
|
||||
|
||||
bool pFlow::boundaryNone::beforeIteration
|
||||
|
|
|
@ -37,9 +37,11 @@ public:
|
|||
TypeInfo("boundary<none>");
|
||||
|
||||
boundaryNone(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal);
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex);
|
||||
|
||||
~boundaryNone() override= default;
|
||||
|
||||
|
|
|
@ -25,12 +25,14 @@ Licence:
|
|||
|
||||
pFlow::boundaryPeriodic::boundaryPeriodic
|
||||
(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex
|
||||
)
|
||||
:
|
||||
boundaryBase(dict, bplane, internal),
|
||||
boundaryBase(dict, bplane, internal, bndrs, thisIndex),
|
||||
mirrorBoundaryIndex_(dict.getVal<uint32>("mirrorBoundaryIndex"))
|
||||
{
|
||||
extendedPlane_ = boundaryBase::boundaryPlane().parallelPlane(-boundaryBase::neighborLength());
|
||||
|
@ -94,17 +96,16 @@ bool pFlow::boundaryPeriodic::beforeIteration(
|
|||
|
||||
// to obtain the transfer vector
|
||||
const auto& thisP = boundaryPlane();
|
||||
const auto& mirrorP = internal().boundary(mirrorBoundaryIndex_).boundaryPlane();
|
||||
const auto& mirrorP = mirrorBoundary().boundaryPlane();
|
||||
realx3 transferVec = thisP.normal()*(thisP.d() + mirrorP.d());
|
||||
|
||||
return transferPoints
|
||||
(
|
||||
numTransfered,
|
||||
transferFlags,
|
||||
mirrorBoundaryIndex_,
|
||||
mirrorBoundaryIndex(),
|
||||
transferVec
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::boundaryPeriodic::iterate
|
||||
|
|
|
@ -42,9 +42,11 @@ public:
|
|||
TypeInfo("boundary<periodic>");
|
||||
|
||||
boundaryPeriodic(
|
||||
const dictionary& dict,
|
||||
const plane& bplane,
|
||||
internalPoints& internal);
|
||||
const dictionary &dict,
|
||||
const plane &bplane,
|
||||
internalPoints &internal,
|
||||
boundaryList &bndrs,
|
||||
uint32 thisIndex);
|
||||
|
||||
|
||||
~boundaryPeriodic() override= default;
|
||||
|
|
|
@ -48,7 +48,7 @@ bool pFlow::internalPoints::deletePoints(const uint32Vector_D& delPoints)
|
|||
"Error in deleting points from internal points"<<endl;
|
||||
return false;
|
||||
}
|
||||
pFlagSync_ = false;
|
||||
unSyncFlag();
|
||||
|
||||
auto newRange = pFlagsD_.activeRange();
|
||||
auto newSize = size();
|
||||
|
@ -88,41 +88,62 @@ bool pFlow::internalPoints::deletePoints(const uint32Vector_D& delPoints)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::internalPoints::changePointsFlag
|
||||
bool pFlow::internalPoints::changePointsFlagPosition
|
||||
(
|
||||
deviceViewType1D<uint32> changePoints,
|
||||
uint32 boundaryIndex
|
||||
const uint32Vector_D& changePoints,
|
||||
realx3 transferVector,
|
||||
uint32 fromBoundaryIndex,
|
||||
uint32 toBoundaryIndex
|
||||
)
|
||||
{
|
||||
if(boundaryIndex>5)
|
||||
if(toBoundaryIndex>5)
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Invalid boundary index "<< boundaryIndex<<endl;
|
||||
"Invalid boundary index "<< toBoundaryIndex<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
pFlagsD_.changeFlags(changePoints, boundaryIndex);
|
||||
pFlagSync_ = false;
|
||||
WARNING<<"NOTIFY About transfering the data "<<END_WARNING;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::internalPoints::changePointsPoisition
|
||||
(
|
||||
deviceViewType1D<uint32> changePoints,
|
||||
realx3 transferVector
|
||||
)
|
||||
{
|
||||
// change the flag
|
||||
pFlagsD_.changeFlags(changePoints.deviceView(), toBoundaryIndex);
|
||||
unSyncFlag();
|
||||
|
||||
// change the position
|
||||
pFlow::internalPointsKernels::changePosition
|
||||
(
|
||||
pointPosition_.deviceViewAll(),
|
||||
changePoints,
|
||||
changePoints.deviceView(),
|
||||
transferVector
|
||||
);
|
||||
WARNING<<"Notify about the change in the position of points"<<END_WARNING;
|
||||
return true;
|
||||
|
||||
anyList varList;
|
||||
message msg;
|
||||
|
||||
varList.emplaceBack(
|
||||
message::eventName(message::ITEM_FLAGCHANGED),
|
||||
changePoints);
|
||||
varList.emplaceBack("fromBoundaryIndex", fromBoundaryIndex);
|
||||
varList.emplaceBack("toBoundaryIndex", toBoundaryIndex);
|
||||
|
||||
msg.add(message::ITEM_FLAGCHANGED);
|
||||
|
||||
if( !notify(
|
||||
time().currentIter(),
|
||||
time().currentTime(),
|
||||
time().dt(),
|
||||
msg,
|
||||
varList))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in notify for item transfer from "<< fromBoundaryIndex<<
|
||||
" to "<<toBoundaryIndex<< " boundary"<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
pFlow::internalPoints::internalPoints()
|
||||
:
|
||||
subscriber("internalPoints"),
|
||||
|
@ -203,8 +224,10 @@ typename pFlow::internalPoints::PointsTypeHost
|
|||
|
||||
auto aRange = maskH.activeRange();
|
||||
uint32 n = 0;
|
||||
|
||||
for(auto i=aRange.start(); i<aRange.end(); i++)
|
||||
{
|
||||
|
||||
if( maskH.isActive(i) )
|
||||
{
|
||||
aPoints[n] = pointsH[i];
|
||||
|
@ -226,7 +249,7 @@ bool pFlow::internalPoints::deletePoints
|
|||
"Error in deleting points from internal points"<<endl;
|
||||
return false;
|
||||
}
|
||||
pFlagSync_ = false;
|
||||
unSyncFlag();
|
||||
WARNING<<"Notify the observersin in internalPoints"<<END_WARNING;
|
||||
|
||||
return true;
|
||||
|
@ -239,7 +262,7 @@ pFlow::uint32 pFlow::internalPoints::updateFlag
|
|||
const std::array<real,6>& dist
|
||||
)
|
||||
{
|
||||
pFlagSync_ = false;
|
||||
unSyncFlag();
|
||||
return pFlagsD_.markPointRegions
|
||||
(
|
||||
dm,
|
||||
|
@ -292,7 +315,7 @@ bool pFlow::internalPoints::read
|
|||
pointPosition_.assignFromHost(fRead);
|
||||
|
||||
pFlagsD_ = pFlagTypeDevice(pointPosition_.capacity(), 0, pointPosition_.size());
|
||||
pFlagSync_ = false;
|
||||
unSyncFlag();
|
||||
syncPFlag();
|
||||
|
||||
return true;
|
||||
|
@ -328,8 +351,7 @@ bool pFlow::internalPoints::read
|
|||
|
||||
pointPosition_.assignFromHost(fRead);
|
||||
|
||||
pFlagsD_ = pFlagTypeDevice(pointPosition_.capacity(), 0, pointPosition_.size());
|
||||
pFlagSync_ = false;
|
||||
createDeviceFlag(pointPosition_.capacity(), 0, pointPosition_.size());
|
||||
syncPFlag();
|
||||
|
||||
return true;
|
||||
|
@ -347,118 +369,3 @@ bool pFlow::internalPoints::write
|
|||
auto aPoints = activePointsHost();
|
||||
return aPoints.write(os,iop);
|
||||
}
|
||||
|
||||
|
||||
/*FUNCTION_H
|
||||
bool pFlow::internalPoints::evaluateinternalPoints()
|
||||
{
|
||||
if(pointFlag_.size() != pointPosition_.size())
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"number of elements in pointFlag and pointPosition is not equal \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
setNumMaxPoints();
|
||||
|
||||
int32 minActive, maxActive;
|
||||
numActivePoints_ = pFlow::internalPointsKernels::scanPointFlag(
|
||||
0,
|
||||
numPoints_,
|
||||
static_cast<int8>(internalPoints::ACTIVE),
|
||||
pointFlag_.deviceViewAll(),
|
||||
minActive,
|
||||
maxActive
|
||||
);
|
||||
|
||||
activeRange_ = {minActive, maxActive};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
void pFlow::internalPoints::setNumMaxPoints()
|
||||
{
|
||||
maxPoints_ = pointFlag_.capacity();
|
||||
numPoints_ = pointFlag_.size();
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::realx3Field_D& pFlow::internalPoints::pointPosition()
|
||||
{
|
||||
return pointPosition_;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::int8Field_HD& pFlow::internalPoints::pointFlag()
|
||||
{
|
||||
return pointFlag_;
|
||||
}
|
||||
|
||||
pFlow::uniquePtr<pFlow::int32IndexContainer>
|
||||
pFlow::internalPoints::getNewPointsIndices(int32 numNewPoints)const
|
||||
{
|
||||
|
||||
|
||||
if( capacity() - activeRange_.second >= numNewPoints )
|
||||
{
|
||||
// fill the sequence starting from activeRange_.second-1
|
||||
return makeUnique<int32IndexContainer>(
|
||||
activeRange_.second,
|
||||
activeRange_.second+numNewPoints);
|
||||
|
||||
}
|
||||
|
||||
// second, check if there is space at the beginning
|
||||
if( activeRange_.first >= numNewPoints)
|
||||
{
|
||||
return makeUnique<int32IndexContainer>(
|
||||
0,
|
||||
numNewPoints);
|
||||
}
|
||||
|
||||
// otherwise scan the points from first to the end to find empty spaces
|
||||
int32Vector newPoints(
|
||||
numNewPoints,
|
||||
RESERVE());
|
||||
|
||||
newPoints.clear();
|
||||
int32 numAdded = 0;
|
||||
ForAll(i, pointFlag_)
|
||||
{
|
||||
if(!isActive(i))
|
||||
{
|
||||
newPoints.push_back(static_cast<int32>(i));
|
||||
numAdded++;
|
||||
}
|
||||
|
||||
if(numAdded == numNewPoints)
|
||||
{
|
||||
return makeUnique<int32IndexContainer>(
|
||||
newPoints.data(),
|
||||
numNewPoints);
|
||||
}
|
||||
}
|
||||
|
||||
// check if there is space at the end for the remaining of points
|
||||
if( numAdded <numNewPoints && capacity() - size() >= numNewPoints - numAdded )
|
||||
{
|
||||
int32 ind = size();
|
||||
for(int32 i=numAdded; i<numNewPoints; i++)
|
||||
{
|
||||
newPoints.push_back(ind);
|
||||
ind++;
|
||||
}
|
||||
|
||||
return makeUnique<int32IndexContainer>(
|
||||
newPoints.data(),
|
||||
numNewPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<<"not enough capacity for inserting particles into the point structure\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}*/
|
|
@ -53,7 +53,11 @@ public:
|
|||
|
||||
using execution_space = typename PointsType::execution_space;
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
//// - friend et al.
|
||||
|
||||
friend boundaryBase;
|
||||
|
||||
//// - data members
|
||||
|
||||
|
@ -69,22 +73,32 @@ protected:
|
|||
/// if both host and device flags sync
|
||||
mutable bool pFlagSync_ = false;
|
||||
|
||||
//// - protected members
|
||||
|
||||
void syncPFlag()const;
|
||||
|
||||
friend boundaryBase;
|
||||
|
||||
//// - protected members
|
||||
|
||||
bool deletePoints(const uint32Vector_D& delPoints);
|
||||
|
||||
bool changePointsFlag(
|
||||
deviceViewType1D<uint32> changePoints,
|
||||
uint32 boundaryIndex);
|
||||
bool changePointsFlagPosition(
|
||||
const uint32Vector_D& changePoints,
|
||||
realx3 transferVector,
|
||||
uint32 fromBoundaryIndex,
|
||||
uint32 toBoundaryIndex);
|
||||
|
||||
bool changePointsPoisition(
|
||||
deviceViewType1D<uint32> changePoints,
|
||||
realx3 transferVector);
|
||||
protected:
|
||||
|
||||
void syncPFlag()const;
|
||||
|
||||
inline
|
||||
void unSyncFlag()
|
||||
{
|
||||
pFlagSync_ = false;
|
||||
}
|
||||
|
||||
inline
|
||||
void createDeviceFlag(uint32 cap, uint32 start, uint32 end)
|
||||
{
|
||||
unSyncFlag();
|
||||
pFlagsD_ = pFlagTypeDevice(cap, start, end);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
|
@ -101,7 +115,7 @@ public:
|
|||
|
||||
|
||||
/// Construct from point positions, assume all points are active
|
||||
internalPoints(const realx3Vector& posVec);
|
||||
explicit internalPoints(const realx3Vector& posVec);
|
||||
|
||||
/// No Copy construct
|
||||
internalPoints(const internalPoints&) = delete;
|
||||
|
@ -262,134 +276,3 @@ iOstream& operator<<(iOstream& os, const internalPoints& ip)
|
|||
|
||||
#endif //__internalPoints_hpp__
|
||||
|
||||
|
||||
/*class activePointsDevice
|
||||
{
|
||||
protected:
|
||||
ViewType1D<int8> flag_;
|
||||
|
||||
bool allActive_;
|
||||
|
||||
range activeRange_;
|
||||
|
||||
public:
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
activePointsDevice(bool allActive, range active, const ViewType1D<int8>& flag)
|
||||
:
|
||||
flag_(flag),
|
||||
allActive_(allActive),
|
||||
activeRange_(active)
|
||||
{}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
activePointsDevice(const activePointsDevice&) = default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
activePointsDevice& operator=(const activePointsDevice&) = default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool operator()(int32 i)const {
|
||||
if(i<activeRange_.second && flag_[i] == 1)return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
auto activeRange()const {
|
||||
return activeRange_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
auto allActive()const {
|
||||
return allActive_;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class activePointsHost
|
||||
{
|
||||
protected:
|
||||
|
||||
ViewType1D<int8, HostSpace> flag_;
|
||||
|
||||
bool allActive_;
|
||||
|
||||
range activeRange_;
|
||||
|
||||
public:
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
activePointsHost(bool allActive, range active, const ViewType1D<int8, HostSpace>& flag)
|
||||
:
|
||||
flag_(flag),
|
||||
allActive_(allActive),
|
||||
activeRange_(active){}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
activePointsHost(const activePointsHost&) = default;
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
activePointsHost& operator=(const activePointsHost&) = default;
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
bool operator()(int32 i)const {
|
||||
if(i <activeRange_.second && flag_[i] == PointFlag::ACTIVE)return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
auto activeRange()const{
|
||||
return activeRange_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
bool allActive()const {
|
||||
return allActive_;
|
||||
}
|
||||
};*/
|
||||
|
||||
|
||||
/*FUNCTION_H`
|
||||
size_t markDeleteOutOfBox(const box& domain);*/
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// - const access to points to be newly inserted
|
||||
/*FUNCTION_H
|
||||
auto insertedPointIndex()const
|
||||
{
|
||||
return tobeInsertedIndex_;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
auto insertedPointIndexH()const
|
||||
{
|
||||
return tobeInsertedIndex_.hostView();
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
auto insertedPointIndexD()const
|
||||
{
|
||||
return tobeInsertedIndex_.deviceView();
|
||||
}
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
auto mortonSortedIndex()const
|
||||
{
|
||||
return mortonSortedIndex_;
|
||||
}
|
||||
|
||||
|
||||
// - update data structure by inserting/setting new points
|
||||
// Notifies all the fields in the registered list of data structure
|
||||
// and exclude the fields that re in the exclusionList
|
||||
// retrun nullptr if it fails
|
||||
/*FUNCTION_H
|
||||
virtual uniquePtr<int32IndexContainer> insertPoints(
|
||||
const realx3Vector& pos,
|
||||
const setFieldList& setField,
|
||||
repository& owner,
|
||||
const List<eventObserver*>& exclusionList={nullptr}
|
||||
);*/
|
||||
|
|
|
@ -27,8 +27,8 @@ bool pFlow::pointStructure::setupPointStructure(const realx3Vector& points)
|
|||
{
|
||||
PointsTypeHost hPoints
|
||||
(
|
||||
pointPosition_.name(),
|
||||
pointPosition_.fieldKey()
|
||||
pointPosition().name(),
|
||||
pointPosition().fieldKey()
|
||||
);
|
||||
|
||||
hPoints.assign(points);
|
||||
|
@ -49,8 +49,8 @@ bool pFlow::pointStructure::setupPointStructure(const PointsTypeHost &points)
|
|||
|
||||
PointsTypeHost internal
|
||||
(
|
||||
pointPosition_.name(),
|
||||
pointPosition_.fieldKey(),
|
||||
pointPosition().name(),
|
||||
pointPosition().fieldKey(),
|
||||
thisN,
|
||||
thisN,
|
||||
RESERVE()
|
||||
|
@ -80,10 +80,9 @@ bool pFlow::pointStructure::setupPointStructure(const PointsTypeHost &points)
|
|||
|
||||
bool pFlow::pointStructure::initializePoints(const PointsTypeHost &points)
|
||||
{
|
||||
pointPosition_.assignFromHost(points);
|
||||
pointPosition().assignFromHost(points);
|
||||
|
||||
pFlagsD_ = pFlagTypeDevice(pointPosition_.capacity(), 0, pointPosition_.size());
|
||||
pFlagSync_ = false;
|
||||
createDeviceFlag(pointPosition().capacity(), 0, pointPosition().size());
|
||||
syncPFlag();
|
||||
|
||||
return true;
|
||||
|
@ -205,8 +204,8 @@ bool pFlow::pointStructure::read(
|
|||
|
||||
PointsTypeHost fRead
|
||||
(
|
||||
this->pointPosition_.name(),
|
||||
this->pointPosition_.fieldKey()
|
||||
this->pointPosition().name(),
|
||||
this->pointPosition().fieldKey()
|
||||
);
|
||||
|
||||
if( !fRead.read(is, iop))
|
||||
|
|
Loading…
Reference in New Issue