www.cemf.ir
ppwBndryContactSearchKernels.cpp
Go to the documentation of this file.
2 
5 {
6  return pFlow::length(p2-p1) < 0.5*(d2+d1);
7 }
8 
10 (
12  const cells &searchCells,
15 )
16 {
17  if(points.empty())return;
18 
19  uint32 n= points.size();
20 
21  Kokkos::parallel_for(
22  "pFlow::ppwBndryContactSearch::buildList",
24  LAMBDA_HD(uint32 i)
25  {
26  int32x3 ind;
27  if( searchCells.pointIndexInDomain(points[i], ind) )
28  {
29  // discards points out of searchCell
30  uint32 old = Kokkos::atomic_exchange(&head(ind.x(), ind.y(), ind.z()), i);
31  next[i] = old;
32  }
33  }
34  );
35  Kokkos::fence();
36 }
37 
39 (
40  csPairContainerType &ppPairs,
43  const deviceScatteredFieldAccess<realx3> &mirrorPoints,
44  const deviceScatteredFieldAccess<real> &mirrorDiams,
45  const realx3 &transferVec,
46  const deviceViewType3D<uint32> &head,
47  const deviceViewType1D<uint32> &next,
48  const cells &searchCells,
49  const real sizeRatio
50 )
51 {
52 
53  if(points.empty()) return 0;
54  if(mirrorPoints.empty())return 0;
55 
56  auto nMirror = mirrorPoints.size();
57 
58  uint32 getFull = 0;
59 
60  Kokkos::parallel_reduce(
61  "pFlow::pweBndryContactSearchKernels::broadSearchPP",
62  deviceRPolicyStatic(0, nMirror),
63  LAMBDA_HD(const uint32 mrrI, uint32 &getFullUpdate)
64  {
65  realx3 p_m = mirrorPoints(mrrI) + transferVec;
66 
67  int32x3 ind_m;
68  if( !searchCells.pointIndexInDomain(p_m, ind_m))return;
69 
70  real d_m = sizeRatio*mirrorDiams[mrrI];
71 
72  for(int ii=-1; ii<2; ii++)
73  {
74  for(int jj=-1; jj<2; jj++)
75  {
76  for(int kk =-1; kk<2; kk++)
77  {
78  auto ind = ind_m + int32x3{ii,jj,kk};
79 
80  if(!searchCells.inCellRange(ind))continue;
81 
82  uint32 thisI = head(ind.x(),ind.y(),ind.z());
83  while (thisI!=static_cast<uint32>(-1))
84  {
85 
86  auto d_n = sizeRatio*diams[thisI];
87 
88  // first item is for this boundary and second itme, for mirror
89  if(sphereSphereCheckB(p_m, points[thisI], d_m, d_n)&&
90  ppPairs.insert(thisI,mrrI) == static_cast<uint32>(-1))
91  {
92  getFullUpdate++;
93  }
94 
95  thisI = next(thisI);
96  }
97  }
98  }
99  }
100  },
101  getFull
102  );
103 
104  return getFull;
105 }
pFlow::scatteredFieldAccess
Definition: scatteredFieldAccess.hpp:32
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::scatteredFieldAccess::size
INLINE_FUNCTION_HD uint32 size() const
Definition: scatteredFieldAccess.hpp:134
pFlow::cells::pointIndexInDomain
INLINE_FUNCTION_HD bool pointIndexInDomain(const realx3 p, int32x3 &index) const
Definition: cells.hpp:139
pFlow::unsortedPairs::insert
INLINE_FUNCTION_HD uint32 insert(idType i, idType j) const
Definition: unsortedPairs.hpp:105
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
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
pFlow::cells::inCellRange
INLINE_FUNCTION_HD bool inCellRange(const int32x3 &cell) const
Definition: cells.hpp:153
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
ppwBndryContactSearchKernels.hpp
pFlow::deviceViewType3D
Kokkos::View< T ***, Layout, void > deviceViewType3D
3D view on device as an array on device
Definition: KokkosTypes.hpp:129
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
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
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::deviceRPolicyStatic
Kokkos::RangePolicy< Kokkos::DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< pFlow::uint32 > > deviceRPolicyStatic
Definition: KokkosTypes.hpp:66
pFlow::scatteredFieldAccess::empty
INLINE_FUNCTION_HD bool empty() const
Definition: scatteredFieldAccess.hpp:140
pFlow::cells
Definition: cells.hpp:31
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
sphereSphereCheckB
INLINE_FUNCTION_HD bool sphereSphereCheckB(const pFlow::realx3 &p1, const pFlow::realx3 p2, pFlow::real d1, pFlow::real d2)
Definition: ppwBndryContactSearchKernels.cpp:4