www.cemf.ir
cellMapper.cpp
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 "cellMapper.hpp"
22 //#include "cellMapperKernels.hpp"
23 #include "streams.hpp"
24 
25 
27 {
28  checkAllocateNext(nextRng);
29  nullifyNext(nextRng);
31 }
32 
34 {
35 
36  auto newCap = nextRng.end();
37 
38  if( nextCapacity_ < newCap)
39  {
40  nextCapacity_ = newCap;
41  reallocNoInit(next_, nextCapacity_);
42  }
43 }
44 
46 {
47  fill(head_, NoPos);
48 }
49 
51 {
52  fill(next_, nextRng, NoPos);
53 }
54 
56  const rectangleMesh& rectMesh,
57  const hostViewType1D<realx3>& pointPos,
58  const pFlagTypeHost& flags
59 )
60 :
61  domainCells_(rectMesh)
62 {
63 
64  allocateArrays(flags.activeRange());
65 }
66 
68 (
69  const hostViewType1D<realx3>& pointPos,
70  const pFlagTypeHost & flags
71 )
72 {
73  auto aRange = flags.activeRange();
74 
75  checkAllocateNext(aRange);
76  nullifyHead();
77  nullifyNext(aRange);
78  int32x3 ind;
79  for(uint32 i=aRange.start(); i<aRange.end(); i++)
80  {
81  if( domainCells_.isInsideIndex(pointPos[i], ind) )
82  {
83  next_[i] = head_(ind.x(), ind.y(), ind.z());
84  head_(ind.x(), ind.y(), ind.z()) = i;
85  }
86  }
87 
88  return true;
89 
90 }
91 
pFlow::cellMapper::nullifyNext
void nullifyNext(rangeU32 nextRng)
Definition: cellMapper.cpp:50
pFlow::reallocFill
INLINE_FUNCTION_H void reallocFill(ViewType1D< Type, Properties... > &view, uint32 len, Type val)
Definition: KokkosUtilities.hpp:71
pFlow::rectangleMesh::ny
int32 ny() const
Definition: rectangleMesh.hpp:82
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
pFlow::cellMapper::head_
HeadType head_
Definition: cellMapper.hpp:83
pFlow::Range::end
INLINE_FUNCTION_HD T & end()
End.
Definition: Range.hpp:101
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::reallocNoInit
INLINE_FUNCTION_H void reallocNoInit(ViewType1D< Type, Properties... > &view, uint32 len)
Definition: KokkosUtilities.hpp:64
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:34
pFlow::triple::y
INLINE_FUNCTION_HD T & y()
access component
Definition: triple.hpp:144
pFlow::cellMapper::checkAllocateNext
void checkAllocateNext(rangeU32 nextRng)
Definition: cellMapper.cpp:33
cellMapper.hpp
pFlow::cellMapper::domainCells_
const rectangleMesh & domainCells_
Definition: cellMapper.hpp:81
pFlow::rectangleMesh::nz
int32 nz() const
Definition: rectangleMesh.hpp:87
pFlow::cellMapper::allocateArrays
void allocateArrays(rangeU32 nextRng)
Definition: cellMapper.cpp:26
pFlow::pointFlag::activeRange
const INLINE_FUNCTION_HD auto & activeRange() const
Definition: pointFlag.hpp:179
pFlow::Range< uint32 >
pFlow::triple::z
INLINE_FUNCTION_HD T & z()
access component
Definition: triple.hpp:156
streams.hpp
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
pFlow::cellMapper::NoPos
static constexpr uint32 NoPos
Definition: cellMapper.hpp:42
pFlow::triple::x
INLINE_FUNCTION_HD T & x()
access component
Definition: triple.hpp:132
pFlow::triple< int32 >
pFlow::cellMapper::nullifyHead
void nullifyHead()
Definition: cellMapper.cpp:45
pFlow::pointFlag< DefaultHostExecutionSpace >
pFlow::cellMapper::cellMapper
cellMapper(const rectangleMesh &rectMesh, const hostViewType1D< realx3 > &pointPos, const pFlagTypeHost &flags)
Definition: cellMapper.cpp:55
pFlow::rectangleMesh::nx
int32 nx() const
Definition: rectangleMesh.hpp:77