www.cemf.ir
pointStructureKernels.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 
22 #ifndef __pointStructureKernels_hpp__
23 #define __pointStructureKernels_hpp__
24 
25 #include "pointStructure.hpp"
26 #include "box.hpp"
27 
29 {
30 
31 
33  box domain,
34  int32 start,
35  int32 end,
36  int8 deleteFlag,
39  pointStructure::activePointsDevice activePoint,
40  int32 & minRange,
41  int32 & maxRange
42  )
43 {
44 
45  using rpMark =
46  Kokkos::RangePolicy<Kokkos::IndexType<int32>>;
47 
48  int32 numMarked = 0;
49  int32 minR = start-1, maxR = end+1;
50 
51  if(start<end)
52  {
53 
54  Kokkos::parallel_reduce(
55  "pointStructureKernels::markDeleteOutOfBox",
56  rpMark(start,end),
57  LAMBDA_HD(int32 i, int32& minUpdate, int32& maxUpdate, int32& valToUpdate){
58  if(activePoint(i))
59  {
60  if( !domain.isInside(points[i]) )
61  {
62  flags[i] = deleteFlag;
63  valToUpdate++;
64  }
65  else
66  {
67  minUpdate = min(minUpdate,i);
68  maxUpdate = max(maxUpdate,i);
69  }
70  }
71  },
72  Kokkos::Min<int32>(minR),
73  Kokkos::Max<int32>(maxR),
74  numMarked);
75 
76  }
77 
78  // means either range was empty or all points have been deleted.
79  if(minR<start || maxR>end)
80  {
81  minRange = 0;
82  maxRange = 0;
83  }
84  else
85  {
86  minRange = minR;
87  maxRange = maxR+1; // add one to make it half
88  }
89  return numMarked;
90 }
91 
93  int32 start,
94  int32 end,
95  int8 activeFlag,
97  int32 & minRange,
98  int32 & maxRange
99  )
100 {
101 
102  using rpScanFlag =
103  Kokkos::RangePolicy<Kokkos::IndexType<int32>>;
104 
105  int32 numActive = 0;
106 
107  if(start < end )
108  Kokkos::parallel_reduce(
109  "pointStructureKernels::scanPointFlag",
110  rpScanFlag(start, end),
111  LAMBDA_HD(
112  int32 i,
113  int32& minUpdate,
114  int32& maxUpdate,
115  int32& sumToUpdate){
116  if(flags[i] == activeFlag)
117  {
118  sumToUpdate++;
119  minUpdate = min(minUpdate,i);
120  maxUpdate = max(maxUpdate,i);
121  }
122  },
123  Kokkos::Min<int32>(minRange),
124  Kokkos::Max<int32>(maxRange),
125  numActive);
126 
127  if(numActive==0)
128  {
129  minRange = 0;
130  maxRange = 0;
131  }
132  else
133  {
134  // add one to maxRange to make it half-open
135  maxRange ++;
136  }
137 
138  return numActive;
139 }
140 
141 }
142 
143 #endif
144 
pFlow::pointStructureKernels
Definition: pointStructureKernels.hpp:28
box.hpp
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::pointStructureKernels::scanPointFlag
int32 scanPointFlag(int32 start, int32 end, int8 activeFlag, deviceViewType1D< int8 > flags, int32 &minRange, int32 &maxRange)
Definition: pointStructureKernels.hpp:92
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::pointStructureKernels::markDeleteOutOfBox
int32 markDeleteOutOfBox(box domain, int32 start, int32 end, int8 deleteFlag, deviceViewType1D< realx3 > points, deviceViewType1D< int8 > flags, pointStructure::activePointsDevice activePoint, int32 &minRange, int32 &maxRange)
Definition: pointStructureKernels.hpp:32
pFlow::min
T min(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:28
pFlow::box
Definition: box.hpp:32
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::domain
Definition: domain.hpp:31
pointStructure.hpp