# PhasicFlow: src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.cpp 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.

ppwBndryContactSearch.cpp
Go to the documentation of this file.
#include "ppwBndryContactSearch.hpp"
#include "ppwBndryContactSearchKernels.hpp"
#include "phasicFlowKokkos.hpp"
#include "streams.hpp"
void pFlow::ppwBndryContactSearch::checkAllocateNext(uint32 n)
{
if( nextCapacity_ < n)
{
nextCapacity_ = n;
reallocNoInit(next_, n);
}
}
void pFlow::ppwBndryContactSearch::nullifyHead()
{
fill(head_, static_cast< uint32 >(-1));
}
void pFlow::ppwBndryContactSearch::nullifyNext(uint32 n)
{
fill(next_, 0u, n, static_cast< uint32 >(-1));
}
void pFlow::ppwBndryContactSearch::buildList(
const deviceScatteredFieldAccess<realx3> &points)
{
if(points.empty())return;
uint32 n = points.size();
checkAllocateNext(n);
nullifyNext(n);
nullifyHead();
pFlow::pweBndryContactSearchKernels::buildNextHead(
points,
searchCells_,
head_,
next_
);
}
pFlow::ppwBndryContactSearch::ppwBndryContactSearch
(
const box &domain,
real cellSize,
real sizeRatio
)
:
searchCells_(domain, cellSize),
head_("periodic:head",searchCells_.nx(), searchCells_.ny(), searchCells_.nz()),
sizeRatio_(sizeRatio)
{
}
bool pFlow::ppwBndryContactSearch::broadSearchPP
(
csPairContainerType &ppPairs,
const deviceScatteredFieldAccess<realx3> &points,
const deviceScatteredFieldAccess<real>& diams,
const deviceScatteredFieldAccess<realx3> &mirrorPoints,
const deviceScatteredFieldAccess<real>& mirrorDiams,
const realx3& transferVec
)
{
buildList(points);
uint32 nNotInserted = 1;
// loop until the container size fits the numebr of contact pairs
while (nNotInserted > 0)
{
nNotInserted = pFlow::pweBndryContactSearchKernels::broadSearchPP
(
ppPairs,
points,
diams,
mirrorPoints,
mirrorDiams,
transferVec,
head_,
next_,
searchCells_,
sizeRatio_
);
if(nNotInserted)
{
// - resize the container
// note that getFull now shows the number of failed insertions.
uint32 len = max(nNotInserted,100u) ;
auto oldCap = ppPairs.capacity();
ppPairs.increaseCapacityBy(len);
INFORMATION<< "Particle-particle contact pair container capacity increased from "<<
oldCap << " to "<<ppPairs.capacity()<<" in peiodicBoundaryContactSearch."<<END_INFO;
}
}
return true;
}
pFlow::unsortedPairs::capacity
INLINE_FUNCTION_HD uint32 capacity() const
Definition: unsortedPairs.hpp:168
pFlow::scatteredFieldAccess
Definition: scatteredFieldAccess.hpp:32
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
pFlow::scatteredFieldAccess::size
INLINE_FUNCTION_HD uint32 size() const
Definition: scatteredFieldAccess.hpp:134
pFlow::ppwBndryContactSearch::broadSearchPP
bool broadSearchPP(csPairContainerType &ppPairs, const deviceScatteredFieldAccess< realx3 > &points, const deviceScatteredFieldAccess< real > &diams, const deviceScatteredFieldAccess< realx3 > &mirrorPoints, const deviceScatteredFieldAccess< real > &mirrorDiams, const realx3 &transferVec)
Definition: ppwBndryContactSearch.cpp:58
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::reallocNoInit
INLINE_FUNCTION_H void reallocNoInit(ViewType1D< Type, Properties... > &view, uint32 len)
Definition: KokkosUtilities.hpp:64
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::ppwBndryContactSearch::nextCapacity_
uint32 nextCapacity_
Definition: ppwBndryContactSearch.hpp:48
pFlow::ppwBndryContactSearch::ppwBndryContactSearch
ppwBndryContactSearch(const box &domain, real cellSize, real sizeRatio=1.0)
Definition: ppwBndryContactSearch.cpp:44
pFlow::unsortedPairs
Definition: unsortedPairs.hpp:32
pFlow::ppwBndryContactSearch::next_
NextType next_
Definition: ppwBndryContactSearch.hpp:44
phasicFlowKokkos.hpp
ppwBndryContactSearchKernels.hpp
pFlow::unsortedPairs::increaseCapacityBy
INLINE_FUNCTION_H void increaseCapacityBy(uint32 len)
increase the capacity of the container by at-least len the content will be erased.
Definition: unsortedPairs.hpp:193
ppwBndryContactSearch.hpp
pFlow::ppwBndryContactSearch::buildList
void buildList(const deviceScatteredFieldAccess< realx3 > &points)
Definition: ppwBndryContactSearch.cpp:26
pFlow::pweBndryContactSearchKernels::broadSearchPP
uint32 broadSearchPP(csPairContainerType &ppPairs, const deviceScatteredFieldAccess< realx3 > &points, const deviceScatteredFieldAccess< real > &diams, const deviceScatteredFieldAccess< realx3 > &mirrorPoints, const deviceScatteredFieldAccess< real > &mirrorDiams, const realx3 &transferVec, const deviceViewType3D< uint32 > &head, const deviceViewType1D< uint32 > &next, const cells &searchCells, real sizeRatio)
Definition: ppwBndryContactSearchKernels.cpp:39
streams.hpp
pFlow::ppwBndryContactSearch::nullifyHead
void nullifyHead()
Definition: ppwBndryContactSearch.cpp:16
pFlow::pweBndryContactSearchKernels::buildNextHead
void buildNextHead(const deviceScatteredFieldAccess< realx3 > &points, const cells &searchCells, deviceViewType3D< uint32 > &head, deviceViewType1D< uint32 > &next)
Definition: ppwBndryContactSearchKernels.cpp:10
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::ppwBndryContactSearch::checkAllocateNext
void checkAllocateNext(uint32 n)
Definition: ppwBndryContactSearch.cpp:7
pFlow::box
Definition: box.hpp:32
pFlow::scatteredFieldAccess::empty
INLINE_FUNCTION_HD bool empty() const
Definition: scatteredFieldAccess.hpp:140
pFlow::domain
Definition: domain.hpp:31
pFlow::triple< real >
END_INFO
#define END_INFO
Definition: streams.hpp:37
pFlow::ppwBndryContactSearch::nullifyNext
void nullifyNext(uint32 n)
Definition: ppwBndryContactSearch.cpp:21
INFORMATION
#define INFORMATION
Definition: streams.hpp:36