www.cemf.ir
cellMapper.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 __cellMapper_hpp__
23 #define __cellMapper_hpp__
24 
25 #include "phasicFlowKokkos.hpp"
26 #include "pointFlag.hpp"
27 #include "rectangleMesh.hpp"
28 
29 
30 namespace pFlow
31 {
32 
34 {
35 public:
36 
38 
40 
41 
42  static constexpr uint32 NoPos = 0xFFFFFFFF;
43 
45  {
46  private:
48 
50 
51  public:
52 
53  CellIterator(const HeadType& head, const NextType& next)
54  :
55  head_(head),
56  next_(next)
57  {}
58 
59  static constexpr uint32 NoPos = 0xFFFFFFFF;
60 
62  int32x3 numCells()const {
63  return int32x3(head_.extent(0), head_.extent(1), head_.extent(2));}
64 
66  uint32 start(int32 i, int32 j, int32 k)const {
67  return head_(i,j,k); }
68 
71  if(n == NoPos ) return NoPos;
72  return next_(n); }
73 
76  return next_(n);}
77  };
78 
79 private:
80 
82 
83  HeadType head_{"NBS::head",1,1,1};
84 
85  NextType next_{"NBS::next", 1};
86 
88 
89  void allocateArrays(rangeU32 nextRng);
90 
91  void checkAllocateNext(rangeU32 nextRng);
92 
93  void nullifyHead();
94 
95  void nullifyNext(rangeU32 nextRng);
96 
97 public:
98 
99  TypeInfoNV("cellMapper");
100 
101 
102  cellMapper(
103  const rectangleMesh& rectMesh,
104  const hostViewType1D<realx3>& pointPos,
105  const pFlagTypeHost& flags);
106 
108  cellMapper(const cellMapper&) = default;
109 
111  cellMapper(cellMapper&&) = default;
112 
114  cellMapper& operator = (const cellMapper&) = default;
115 
117  cellMapper& operator = (cellMapper&&) = default;
118 
120  ~cellMapper()=default;
121 
123 
124  auto getCellIterator()const
125  {
126  return CellIterator(head_, next_);
127  }
128 
129 
130  bool build(
131  const hostViewType1D<realx3>& pointPos,
132  const pFlagTypeHost& flags);
133 };
134 
135 } // pFlow
136 
137 #endif // __cellMapper_hpp__
pFlow::cellMapper::next_
NextType next_
Definition: cellMapper.hpp:85
pFlow::cellMapper::nullifyNext
void nullifyNext(rangeU32 nextRng)
Definition: cellMapper.cpp:50
pFlow::cellMapper::head_
HeadType head_
Definition: cellMapper.hpp:83
pFlow::cellMapper::HeadType
hostViewType3D< uint32 > HeadType
Definition: cellMapper.hpp:37
pFlow::cellMapper::~cellMapper
INLINE_FUNCTION_HD ~cellMapper()=default
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::cellMapper::nextCapacity_
uint32 nextCapacity_
Definition: cellMapper.hpp:87
pFlow::cellMapper::operator=
INLINE_FUNCTION_HD cellMapper & operator=(const cellMapper &)=default
rectangleMesh.hpp
pFlow::cellMapper::CellIterator::start
INLINE_FUNCTION_H uint32 start(int32 i, int32 j, int32 k) const
Definition: cellMapper.hpp:66
pFlow::cellMapper::CellIterator::next_
NextType next_
Definition: cellMapper.hpp:49
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:34
pFlow::cellMapper::CellIterator::numCells
INLINE_FUNCTION_H int32x3 numCells() const
Definition: cellMapper.hpp:62
pFlow
Definition: demGeometry.hpp:27
pFlow::cellMapper::checkAllocateNext
void checkAllocateNext(rangeU32 nextRng)
Definition: cellMapper.cpp:33
pFlow::cellMapper::NextType
hostViewType1D< uint32 > NextType
Definition: cellMapper.hpp:39
phasicFlowKokkos.hpp
pFlow::cellMapper::CellIterator::head_
HeadType head_
Definition: cellMapper.hpp:47
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::cellMapper::domainCells_
const rectangleMesh & domainCells_
Definition: cellMapper.hpp:81
pFlow::cellMapper::getCellIterator
auto getCellIterator() const
Definition: cellMapper.hpp:124
pFlow::hostViewType3D
Kokkos::View< T ***, Layout, Kokkos::HostSpace > hostViewType3D
3D array on host
Definition: KokkosTypes.hpp:144
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::int32x3
triple< int32 > int32x3
Definition: types.hpp:38
pFlow::cellMapper::allocateArrays
void allocateArrays(rangeU32 nextRng)
Definition: cellMapper.cpp:26
pFlow::cellMapper::TypeInfoNV
TypeInfoNV("cellMapper")
pFlow::cellMapper::CellIterator::next
INLINE_FUNCTION_H uint32 next(uint32 n) const
Definition: cellMapper.hpp:75
pFlow::Range< uint32 >
pFlow::cellMapper
Definition: cellMapper.hpp:33
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
1D array (vector with host memeory space)
Definition: KokkosTypes.hpp:136
pFlow::cellMapper::build
bool build(const hostViewType1D< realx3 > &pointPos, const pFlagTypeHost &flags)
Definition: cellMapper.cpp:68
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::cellMapper::CellIterator::CellIterator
CellIterator(const HeadType &head, const NextType &next)
Definition: cellMapper.hpp:53
pFlow::cellMapper::NoPos
static constexpr uint32 NoPos
Definition: cellMapper.hpp:42
pFlow::cellMapper::CellIterator::NoPos
static constexpr uint32 NoPos
Definition: cellMapper.hpp:59
pFlow::cellMapper::CellIterator::getNext
INLINE_FUNCTION_H uint32 getNext(uint32 n) const
Definition: cellMapper.hpp:70
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< int32 >
pFlow::cellMapper::nullifyHead
void nullifyHead()
Definition: cellMapper.cpp:45
pFlow::cellMapper::CellIterator
Definition: cellMapper.hpp:44
pFlow::pointFlag< DefaultHostExecutionSpace >
pFlow::cellMapper::cellMapper
cellMapper(const rectangleMesh &rectMesh, const hostViewType1D< realx3 > &pointPos, const pFlagTypeHost &flags)
Definition: cellMapper.cpp:55
pointFlag.hpp