www.cemf.ir
NBSLevel0.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 "NBSLevel0.hpp"
22 #include "streams.hpp"
23 
25 (
26  csPairContainerType &pairs,
27  const deviceViewType1D<realx3> &pointPos,
28  const pFlagTypeDevice &flags,
29  const deviceViewType1D<real> &diameter
30 )
31 {
32  uint32 getFull = 1;
33 
34  // loop until the container size fits the numebr of contact pairs
35  while (getFull > 0)
36  {
37 
39  (
40  pairs,
41  sizeRatio_,
42  pointPos,
43  flags,
44  diameter,
45  getCellIterator()
46  );
47 
48  if(getFull)
49  {
50  // - resize the container
51  // note that getFull now shows the number of failed insertions.
52  uint32 len = max(getFull,500u) ;
53 
54  auto oldCap = pairs.capacity();
55 
56  pairs.increaseCapacityBy(len);
57 
58  INFORMATION<< "The contact pair container capacity increased from "<<
59  oldCap << " to "<<pairs.capacity()<<" in NBSLevel0."<<END_INFO;
60 
61  }
62 
63  }
64 
65  return true;
66 }
67 
68 
70 (
71  const box& domain,
72  real cellSize,
73  real sizeRatio,
74  const deviceViewType1D<realx3>& pointPos,
75  const pFlagTypeDevice& flags,
76  bool adjustableBox
77 )
78 :
79  mapperNBS
80  (
81  domain,
82  cellSize,
83  pointPos,
84  flags,
85  adjustableBox,
86  true
87  ),
88  sizeRatio_(sizeRatio)
89 {
90 
91 }
92 
94 (
95  csPairContainerType &pairs,
96  const deviceViewType1D<realx3> &pointPos,
97  const pFlagTypeDevice &flags,
98  const deviceViewType1D<real> &diameter,
99  bool& searchBoxChanged
100 )
101 {
102  if(!build(pointPos, flags, searchBoxChanged))
103  {
105  return false;
106  }
107 
108  if(!findPairs(pairs, pointPos, flags, diameter))
109  {
111  return false;
112  }
113 
114  return true;
115 }
116 
117 
pFlow::unsortedPairs::capacity
INLINE_FUNCTION_HD uint32 capacity() const
Definition: unsortedPairs.hpp:168
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::algorithms::KOKKOS::max
INLINE_FUNCTION_H Type max(const Type *first, uint32 numElems)
Definition: kokkosAlgorithms.hpp:104
pFlow::NBSLevel0::broadSearch
bool broadSearch(csPairContainerType &pairs, const deviceViewType1D< realx3 > &pointPos, const pFlagTypeDevice &flags, const deviceViewType1D< real > &diameter, bool &searchBoxChanged)
Definition: NBSLevel0.cpp:94
NBSLevel0.hpp
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::mapperNBS
Definition: mapperNBS.hpp:34
pFlow::NBSLevel0::findPairs
bool findPairs(csPairContainerType &pairs, const deviceViewType1D< realx3 > &pointPos, const pFlagTypeDevice &flags, const deviceViewType1D< real > &diameter)
Definition: NBSLevel0.cpp:25
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::unsortedPairs::increaseCapacityBy
INLINE_FUNCTION_H void increaseCapacityBy(uint32 len)
increase the capacity of the container by at-least len the content will be erased.
Definition: unsortedPairs.hpp:193
pFlow::NBSLevel0::NBSLevel0
INLINE_FUNCTION_HD NBSLevel0()=default
pFlow::NBSLevel0Kernels::findPairsCount
uint32 findPairsCount(csPairContainerType &pairs, real sizeRatio, const deviceViewType1D< realx3 > &pointPos, const pFlagTypeDevice &flags, const deviceViewType1D< real > &diameter, mapperNBS::CellIterator cellIter)
Definition: NBSLevel0Kernels.hpp:53
streams.hpp
pFlow::box
Definition: box.hpp:32
pFlow::domain
Definition: domain.hpp:31
END_INFO
#define END_INFO
Definition: streams.hpp:37
pFlow::pointFlag< DefaultExecutionSpace >
INFORMATION
#define INFORMATION
Definition: streams.hpp:36