# PhasicFlow: src/Interaction/contactSearch/methods/cellBased/NBS/NBSLevel0Kernels.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.

NBSLevel0Kernels.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.
-----------------------------------------------------------------------------*/
#include "mapperNBS.hpp"
#include "contactSearchGlobals.hpp"
#include "streams.hpp"
namespace pFlow::NBSLevel0Kernels
{
using mdrPolicyFindPairs =
Kokkos::MDRangePolicy<
Kokkos::IndexType<uint32>,
Kokkos::Rank<3>,
Kokkos::Schedule<Kokkos::Dynamic>,
DefaultExecutionSpace>;
template<typename T>
INLINE_FUNCTION_HD
void Swap(T& x, T& y)
{
T tmp = x;
x = y;
y = tmp;
}
INLINE_FUNCTION_HD
bool sphereSphereCheck(const realx3& p1, const realx3 p2, real d1, real d2)
{
return length(p2-p1) < 0.5*(d2+d1);
}
inline
uint32 findPairsCount
(
csPairContainerType& pairs,
real sizeRatio,
const deviceViewType1D<realx3>& pointPos,
const pFlagTypeDevice& flags,
const deviceViewType1D<real>& diameter,
mapperNBS::CellIterator cellIter
)
{
auto nCells = cellIter.numCells();
mdrPolicyFindPairs
mdrPolicy(
{0,0,0},
{nCells.x(), nCells.y(), nCells.z()} );
uint32 notInsertedPairs = 0u;
Kokkos::parallel_reduce (
"pFlow::NBSLevel0Kernels::findPairsCount",
mdrPolicy,
LAMBDA_HD(uint32 i, uint32 j, uint32 k, uint32& getFullUpdate){
#include "NBSLoop.hpp"
}, notInsertedPairs);
return notInsertedPairs;
}
}
mapperNBS.hpp
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::mapperNBS::CellIterator::numCells
INLINE_FUNCTION_HD int32x3 numCells() const
Definition: mapperNBS.hpp:63
pFlow::NBSLevel0Kernels::Swap
INLINE_FUNCTION_HD void Swap(T &x, T &y)
Definition: NBSLevel0Kernels.hpp:38
pFlow::NBSLevel0Kernels::sphereSphereCheck
INLINE_FUNCTION_HD bool sphereSphereCheck(const realx3 &p1, const realx3 p2, real d1, real d2)
Definition: NBSLevel0Kernels.hpp:46
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Default execution space, it can be device exe.
Definition: KokkosTypes.hpp:61
pFlow::mapperNBS::CellIterator
Definition: mapperNBS.hpp:45
pFlow::NBSLevel0Kernels
Definition: NBSLevel0Kernels.hpp:26
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
pFlow::unsortedPairs
Definition: unsortedPairs.hpp:32
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
contactSearchGlobals.hpp
pFlow::NBSLevel0Kernels::findPairsCount
uint32 findPairsCount(csPairContainerType &pairs, real sizeRatio, const deviceViewType1D< realx3 > &pointPos, const pFlagTypeDevice &flags, const deviceViewType1D< real > &diameter, mapperNBS::CellIterator cellIter)
Definition: NBSLevel0Kernels.hpp:53
streams.hpp
pFlow::NBSLevel0Kernels::mdrPolicyFindPairs
Kokkos::MDRangePolicy< Kokkos::IndexType< uint32 >, Kokkos::Rank< 3 >, Kokkos::Schedule< Kokkos::Dynamic >, DefaultExecutionSpace > mdrPolicyFindPairs
Definition: NBSLevel0Kernels.hpp:34
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
NBSLoop.hpp
pFlow::pointFlag< DefaultExecutionSpace >