www.cemf.ir
NBSLevel0Kernels.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include "mapperNBS.hpp"
22 #include "contactSearchGlobals.hpp"
23 
24 #include "streams.hpp"
25 
27 {
28 
29 using mdrPolicyFindPairs =
30  Kokkos::MDRangePolicy<
31  Kokkos::IndexType<uint32>,
32  Kokkos::Rank<3>,
33  Kokkos::Schedule<Kokkos::Dynamic>,
35 
36 template<typename T>
38 void Swap(T& x, T& y)
39 {
40  T tmp = x;
41  x = y;
42  y = tmp;
43 }
44 
46 bool sphereSphereCheck(const realx3& p1, const realx3 p2, real d1, real d2)
47 {
48  return length(p2-p1) < 0.5*(d2+d1);
49 }
50 
51 inline
53 (
54  csPairContainerType& pairs,
55  real sizeRatio,
56  const deviceViewType1D<realx3>& pointPos,
57  const pFlagTypeDevice& flags,
58  const deviceViewType1D<real>& diameter,
60 )
61 {
62 
63  auto nCells = cellIter.numCells();
64 
66  mdrPolicy(
67  {0,0,0},
68  {nCells.x(), nCells.y(), nCells.z()} );
69 
70  uint32 notInsertedPairs = 0u;
71 
72 
73  Kokkos::parallel_reduce (
74  "pFlow::NBSLevel0Kernels::findPairsCount",
75  mdrPolicy,
76  LAMBDA_HD(uint32 i, uint32 j, uint32 k, uint32& getFullUpdate){
77  #include "NBSLoop.hpp"
78  }, notInsertedPairs);
79 
80  return notInsertedPairs;
81 }
82 
83 }
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 >