www.cemf.ir
sortedContactList.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 #ifndef __sortedContactList_hpp__
22 #define __sortedContactList_hpp__
23 
24 #include "sortedPairs.hpp"
25 
26 namespace pFlow
27 {
28 
29 template<typename valueType, typename executionSpace, typename idType>
31 :
32  public sortedPairs<executionSpace, idType>
33 {
34 public:
35 
37 
38  using ValueType = valueType;
39 
40  using IdType = typename SortedPairs::IdType;
41 
43 
45 
46  using PairType = typename SortedPairs::PairType;
47 
49 
50  class TagReFillPairs{};
51 
52 protected:
53 
55 
57 
59 
61 
62 
64  {
65  if(auto s = this->size(); s > values_.size())
66  {
68  }
69  }
70 
71 
72 
73  using rpReFillPairs = Kokkos::RangePolicy<
75  Kokkos::Schedule<Kokkos::Static>,
76  Kokkos::IndexType<uint32>,
78 
79 public:
80 
81  TypeInfoNV("sortedContactList");
82 
83 
84  explicit sortedContactList(uint32 initialSize =1)
85  :
86  SortedPairs(initialSize),
87  values_("values", SortedPairs::capacity()),
88  sortedPairs0_("sortedPairs0", SortedPairs::capacity()),
89  values0_("values0", SortedPairs::capacity())
90  {}
91 
93  {
96  size0_ = this->size();
98  }
99 
101  {
103 
104  adjustCapacity();
105 
106  Kokkos::parallel_for(
107  "sortedContactList::reFillPairs",
108  rpReFillPairs(0, this->size() ),
109  *this
110  );
111  Kokkos::fence();
112 
113  return true;
114  }
115 
118  {
119  return values_[idx];
120  }
121 
123  void setValue(uint32 idx, const ValueType& val)const
124  {
125  values_[idx] = val;
126  }
127 
130  {
131 
132  uint32 searchLen = max(size0_/1000u,10u);
133  uint32 start = idx-min(searchLen,idx);
134  uint32 end = min(size0_,idx+searchLen);
135  auto newPair = this->sortedPairs_[idx];
136  if( auto idx0 = binarySearch(
138  start,
139  end,
140  newPair);
141  idx0!=static_cast<uint32>(-1))
142  {
143  values_[idx] = values0_[idx0];
144  }
145  else if(auto idx0 = binarySearch(
147  start,
148  end,
149  newPair);
150  idx0!= static_cast<uint32>(-1) )
151  {
152  values_[idx] = values0_[idx0];
153 
154  }
155  else
156  {
157  values_[idx] = ValueType();
158  }
159  }
160 
161 
162 
163 }; // sortedContactList
164 
165 
166 
167 } // pFlow
168 
169 
170 
171 #endif //__sortedContactList_hpp__
pFlow::sortedPairs::IdType
typename UnsortedPairs::IdType IdType
Definition: sortedPairs.hpp:41
pFlow::sortedContactList::memory_space
typename SortedPairs::memory_space memory_space
Definition: sortedContactList.hpp:44
pFlow::sortedPairs::sortedPairs_
ViewType1D< PairType, ExecutionSpace > sortedPairs_
Definition: sortedPairs.hpp:92
pFlow::unsortedPairs::capacity
INLINE_FUNCTION_HD uint32 capacity() const
Definition: unsortedPairs.hpp:168
pFlow::sortedContactList::setValue
INLINE_FUNCTION_HD void setValue(uint32 idx, const ValueType &val) const
Definition: sortedContactList.hpp:123
pFlow::sortedPairs::beforeBroadSearch
bool beforeBroadSearch()
Definition: sortedPairs.hpp:121
pFlow::sortedContactList::getValue
INLINE_FUNCTION_HD ValueType getValue(uint32 idx) const
Definition: sortedContactList.hpp:117
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::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::sortedPairs::PairType
typename UnsortedPairs::PairType PairType
Definition: sortedPairs.hpp:47
pFlow::binarySearch
INLINE_FUNCTION_HD uint32 binarySearch(const ViewType1D< Type, properties... > &view, uint32 start, uint32 end, const Type &val)
On DEVICE and HOST calls.
Definition: ViewAlgorithms.hpp:416
pFlow::sortedContactList::rpReFillPairs
Kokkos::RangePolicy< ExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< uint32 >, TagReFillPairs > rpReFillPairs
Definition: sortedContactList.hpp:77
pFlow::sortedContactList::values0_
ViewType1D< ValueType, ExecutionSpace > values0_
Definition: sortedContactList.hpp:60
pFlow
Definition: demGeometry.hpp:27
pFlow::sortedContactList::sortedPairs0_
ViewType1D< PairType, ExecutionSpace > sortedPairs0_
Definition: sortedContactList.hpp:58
pFlow::sortedContactList::adjustCapacity
void adjustCapacity()
Definition: sortedContactList.hpp:63
pFlow::sortedContactList::sortedContactList
sortedContactList(uint32 initialSize=1)
Definition: sortedContactList.hpp:84
pFlow::sortedContactList::size0_
uint32 size0_
Definition: sortedContactList.hpp:56
pFlow::sortedPairs::memory_space
typename ExecutionSpace::memory_space memory_space
Definition: sortedPairs.hpp:45
pFlow::sortedContactList::TypeInfoNV
TypeInfoNV("sortedContactList")
pFlow::sortedContactList::afterBroadSearch
bool afterBroadSearch()
Definition: sortedContactList.hpp:100
pFlow::sortedContactList::values_
ViewType1D< ValueType, ExecutionSpace > values_
Definition: sortedContactList.hpp:54
pFlow::min
T min(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:28
pFlow::sortedPairs::afterBroadSearch
bool afterBroadSearch()
Definition: sortedPairs.hpp:127
pFlow::sortedContactList::ExecutionSpace
typename SortedPairs::ExecutionSpace ExecutionSpace
Definition: sortedContactList.hpp:42
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
1D veiw as a vector
Definition: KokkosTypes.hpp:93
pFlow::sortedPairs::ContainerType
typename UnsortedPairs::ContainerType ContainerType
Definition: sortedPairs.hpp:49
pFlow::sortedContactList::TagReFillPairs
Definition: sortedContactList.hpp:50
pFlow::sortedPairs
Definition: sortedPairs.hpp:33
pFlow::sortedContactList
Definition: sortedContactList.hpp:30
pFlow::sortedContactList::ContainerType
typename SortedPairs::ContainerType ContainerType
Definition: sortedContactList.hpp:48
pFlow::sortedContactList::ValueType
valueType ValueType
Definition: sortedContactList.hpp:38
pFlow::sortedPairs::size
INLINE_FUNCTION_H uint32 size() const
Definition: sortedPairs.hpp:167
pFlow::sortedContactList::IdType
typename SortedPairs::IdType IdType
Definition: sortedContactList.hpp:40
pFlow::sortedContactList::PairType
typename SortedPairs::PairType PairType
Definition: sortedContactList.hpp:46
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::swapViews
INLINE_FUNCTION_H void swapViews(ViewType &v1, ViewType &v2)
Definition: KokkosUtilities.hpp:158
pFlow::sortedPairs::ExecutionSpace
typename UnsortedPairs::ExecutionSpace ExecutionSpace
Definition: sortedPairs.hpp:43
pFlow::sortedContactList::operator()
INLINE_FUNCTION_HD void operator()(TagReFillPairs, uint32 idx) const
Definition: sortedContactList.hpp:129
sortedPairs.hpp
pFlow::sortedContactList::beforeBroadSearch
bool beforeBroadSearch()
Definition: sortedContactList.hpp:92