www.cemf.ir
mapperNBS.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 __mapperNBS_hpp__
23 #define __mapperNBS_hpp__
24 
25 #include "phasicFlowKokkos.hpp"
26 #include "pointFlag.hpp"
27 #include "cells.hpp"
28 //#include "contactSearchFunctions.hpp"
29 
30 
31 namespace pFlow
32 {
33 
34 class mapperNBS
35 {
36 public:
37 
39 
41 
42 
43  static constexpr uint32 NoPos = 0xFFFFFFFF;
44 
46  {
47  private:
49 
51 
52  public:
53 
54  CellIterator(const HeadType& head, const NextType& next)
55  :
56  head_(head),
57  next_(next)
58  {}
59 
60  static constexpr uint32 NoPos = 0xFFFFFFFF;
61 
63  int32x3 numCells()const {
64  return int32x3(head_.extent(0), head_.extent(1), head_.extent(2));}
65 
67  uint32 start(int32 i, int32 j, int32 k)const {
68  return head_(i,j,k); }
69 
72  if(n == NoPos ) return NoPos;
73  return next_(n); }
74 
77  return next_(n);}
78  };
79 
80 private:
81 
83 
85 
86  HeadType head_{"NBS::head",1,1,1};
87 
88  NextType next_{"NBS::next", 1};
89 
91 
93 
95 
96  bool adjustableBox_ = false;
97 
98  bool nextOwner_ = true;
99 
101 
103 
104  bool setSearchBox(
105  const deviceViewType1D<realx3>& pointPos,
106  const pFlagTypeDevice& flags,
107  real cellSize
108  );
109 
110  void allocateArrays(rangeU32 nextRng);
111 
112  void checkAllocateNext(rangeU32 nextRng);
113 
114  void nullifyHead();
115 
116  void nullifyNext(rangeU32 nextRng);
117 
118 public:
119 
120  TypeInfoNV("mapperNBS");
121 
123  mapperNBS() = default;
124 
125  mapperNBS(
126  const box& domain,
127  real cellSize,
128  const deviceViewType1D<realx3>& pointPos,
129  const pFlagTypeDevice& flags,
130  bool adjustableBox,
131  bool nextOwner = true);
132 
134  mapperNBS(const mapperNBS&) = default;
135 
137  mapperNBS(mapperNBS&&) = default;
138 
140  mapperNBS& operator = (const mapperNBS&) = default;
141 
143  mapperNBS& operator = (mapperNBS&&) = default;
144 
146  ~mapperNBS()=default;
147 
149 
150  auto getCellIterator()const
151  {
152  return CellIterator(head_, next_);
153  }
154 
155  const auto& getDomainCells()const
156  {
157  return domainCells_;
158  }
159 
160  const auto& getSearchCells()const
161  {
162  return searchCells_;
163  }
164 
165  bool build(
166  const deviceViewType1D<realx3>& pointPos,
167  const pFlagTypeDevice& flags,
168  bool& searchBoxChanged);
169 
170 
171 
172 
173 };
174 
175 } // pFlow
176 
177 #endif // __mapperNBS_hpp__
178 
179 
180 
181 
182 /*
183 INLINE_FUNCTION_HD
184  auto& head()
185  {
186  return head_;
187  }
188 
189  INLINE_FUNCTION_HD
190  auto& next()
191  {
192  return next_;
193  }
194 
195  INLINE_FUNCTION_HD
196  const auto& head()const
197  {
198  return head_;
199  }
200 
201  INLINE_FUNCTION_HD
202  const auto& next()const
203  {
204  return next_;
205  }
206 
207  INLINE_FUNCTION_HD
208  auto& pointPosition()
209  {
210  return pointPosition_;
211  }
212 */
pFlow::mapperNBS::CellIterator::next
INLINE_FUNCTION_HD uint32 next(uint32 n) const
Definition: mapperNBS.hpp:76
pFlow::mapperNBS::mapperNBS
INLINE_FUNCTION_HD mapperNBS()=default
pFlow::mapperNBS::domainCells_
cells domainCells_
Definition: mapperNBS.hpp:82
pFlow::mapperNBS::allocateArrays
void allocateArrays(rangeU32 nextRng)
Definition: mapperNBS.cpp:74
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::mapperNBS::CellIterator::numCells
INLINE_FUNCTION_HD int32x3 numCells() const
Definition: mapperNBS.hpp:63
pFlow::mapperNBS::buildCount_
uint32 buildCount_
Definition: mapperNBS.hpp:94
pFlow::mapperNBS::nextOwner_
bool nextOwner_
Definition: mapperNBS.hpp:98
pFlow::mapperNBS::CellIterator::head_
HeadType head_
Definition: mapperNBS.hpp:48
pFlow::mapperNBS::build
bool build(const deviceViewType1D< realx3 > &pointPos, const pFlagTypeDevice &flags, bool &searchBoxChanged)
Definition: mapperNBS.cpp:125
pFlow::mapperNBS::~mapperNBS
INLINE_FUNCTION_HD ~mapperNBS()=default
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::mapperNBS::setSearchBox
bool setSearchBox(const deviceViewType1D< realx3 > &pointPos, const pFlagTypeDevice &flags, real cellSize)
Definition: mapperNBS.cpp:29
pFlow::mapperNBS::nullifyHead
void nullifyHead()
Definition: mapperNBS.cpp:94
pFlow::mapperNBS::CellIterator
Definition: mapperNBS.hpp:45
pFlow::mapperNBS::NoPos
static constexpr uint32 NoPos
Definition: mapperNBS.hpp:43
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
pFlow::mapperNBS
Definition: mapperNBS.hpp:34
pFlow::mapperNBS::nullifyNext
void nullifyNext(rangeU32 nextRng)
Definition: mapperNBS.cpp:99
pFlow
Definition: demGeometry.hpp:27
pFlow::mapperNBS::TypeInfoNV
TypeInfoNV("mapperNBS")
pFlow::mapperNBS::enlargementFactor_
static real enlargementFactor_
Definition: mapperNBS.hpp:102
phasicFlowKokkos.hpp
pFlow::mapperNBS::searchCells_
cells searchCells_
Definition: mapperNBS.hpp:84
pFlow::mapperNBS::getSearchCells
const auto & getSearchCells() const
Definition: mapperNBS.hpp:160
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::mapperNBS::lastCheckForBox_
uint32 lastCheckForBox_
Definition: mapperNBS.hpp:92
pFlow::deviceViewType3D
Kokkos::View< T ***, Layout, void > deviceViewType3D
3D view on device as an array on device
Definition: KokkosTypes.hpp:129
pFlow::int32x3
triple< int32 > int32x3
Definition: types.hpp:38
pFlow::mapperNBS::CellIterator::start
INLINE_FUNCTION_HD uint32 start(int32 i, int32 j, int32 k) const
Definition: mapperNBS.hpp:67
pFlow::mapperNBS::getDomainCells
const auto & getDomainCells() const
Definition: mapperNBS.hpp:155
pFlow::mapperNBS::adjustableBox_
bool adjustableBox_
Definition: mapperNBS.hpp:96
pFlow::mapperNBS::CellIterator::next_
NextType next_
Definition: mapperNBS.hpp:50
pFlow::mapperNBS::CellIterator::CellIterator
CellIterator(const HeadType &head, const NextType &next)
Definition: mapperNBS.hpp:54
pFlow::Range< uint32 >
pFlow::mapperNBS::checkInterval_
static uint32 checkInterval_
Definition: mapperNBS.hpp:100
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::mapperNBS::HeadType
deviceViewType3D< uint32 > HeadType
Definition: mapperNBS.hpp:38
pFlow::mapperNBS::CellIterator::NoPos
static constexpr uint32 NoPos
Definition: mapperNBS.hpp:60
pFlow::box
Definition: box.hpp:32
pFlow::mapperNBS::head_
HeadType head_
Definition: mapperNBS.hpp:86
pFlow::mapperNBS::checkAllocateNext
void checkAllocateNext(rangeU32 nextRng)
Definition: mapperNBS.cpp:81
pFlow::mapperNBS::operator=
INLINE_FUNCTION_HD mapperNBS & operator=(const mapperNBS &)=default
pFlow::mapperNBS::getCellIterator
auto getCellIterator() const
Definition: mapperNBS.hpp:150
pFlow::domain
Definition: domain.hpp:31
pFlow::cells
Definition: cells.hpp:31
pFlow::mapperNBS::NextType
deviceViewType1D< uint32 > NextType
Definition: mapperNBS.hpp:40
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< int32 >
pFlow::mapperNBS::nextCapacity_
uint32 nextCapacity_
Definition: mapperNBS.hpp:90
pFlow::mapperNBS::CellIterator::getNext
INLINE_FUNCTION_HD uint32 getNext(uint32 n) const
Definition: mapperNBS.hpp:71
pFlow::mapperNBS::next_
NextType next_
Definition: mapperNBS.hpp:88
pFlow::pointFlag< DefaultExecutionSpace >
pointFlag.hpp