www.cemf.ir
IncludeMask.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 __IncludeMask_hpp__
22 #define __IncludeMask_hpp__
23 
24 
25 #include "includeMask.hpp"
26 
27 namespace pFlow
28 {
29 
30 
31 template<typename T>
33 {
34  TypeInfoNV("greaterThan");
35 
36  inline
37  bool operator()(const T &compVal, const T &val) const {
38  return val > compVal; }
39 };
40 
41 template<typename T>
43 {
44  TypeInfoNV("greaterThanEq");
45 
46  inline
47  bool operator()(const T &compVal, const T &val) const {
48  return val >= compVal; }
49 };
50 
51 template<typename T>
52 struct lessThanOp
53 {
54  TypeInfoNV("lessThan");
55 
56  inline
57  bool operator()(const T &compVal, const T &val) const {
58  return val < compVal; }
59 };
60 
61 template<typename T>
63 {
64  TypeInfoNV("lessThanEq");
65 
66  inline
67  bool operator()(const T &compVal, const T &val) const {
68  return val <= compVal; }
69 };
70 
71 template<typename T>
72 struct equalOp
73 {
74  TypeInfoNV("equal");
75 
76  inline
77  bool operator()(const T &compVal, const T &val) const {
78  return equal(val , compVal); }
79 };
80 
81 
82 template<typename T>
83 struct betweenOp
84 {
85  TypeInfoNV("between");
86 
87  inline
88  bool operator()(const T &compVal1, const T &compVal2 ,const T &val) const {
89  return val>compVal1 && val<compVal2; }
90 };
91 
92 
93 template<typename T>
95 {
96  TypeInfoNV("betweenEq");
97 
98  inline
99  bool operator()(const T &compVal1, const T &compVal2 ,const T &val) const {
100  return val>=compVal1 && val<=compVal2; }
101 };
102 
103 template<typename T>
104 struct allOp
105 {
106  TypeInfoNV("all");
107 
108  inline
109  bool operator()() const {return true; }
110 };
111 
112 
113 
114 template<typename T, template<class> class Operator>
116 {
117 public:
118 
119  using opertorType = Operator<T>;
120 
121 protected:
124 public:
125 
126  TypeInfoNV(Operator<T>::TYPENAME());
127 
128  compareOne(const dictionary& dict)
129  :
130  compValue_(dict.getVal<T>("value"))
131  {}
132 
133  bool operator()(const T& value)const
134  {
135  return operator_(compValue_, value);
136  }
137 };
138 
139 template<typename T, template<class> class Operator>
141 {
142 public:
143  using opertorType = Operator<T>;
144 protected:
148 public:
149 
150  TypeInfoNV(opertorType::TYPENAME());
151 
152  compareTwo(const dictionary& dict)
153  :
154  compValue1_(dict.getVal<T>("value1")),
155  compValue2_(dict.getVal<T>("value2"))
156  {}
157 
158  bool operator()(const T& value)const
159  {
160  return operator_(compValue1_, compValue2_, value);
161  }
162 };
163 
164 template<typename T, typename Operator>
166 {
167 protected:
168  Operator operator_{};
169 public:
170 
171  TypeInfoNV(Operator::TYPENAME());
172  compareZero(const dictionary& dict);
173 
174  bool operator()(const T& value) const
175  {
176  return operator_();
177  }
178 };
179 
180 template<typename T, typename Operator>
182 :
183  public includeMask
184 {
185 protected:
186 
187  Operator operator_;
188 
190 
192 public:
193 
194  TypeInfoTemplate12("IncludeMask", T, Operator);
195 
197  const dictionary& dict,
198  const word& opType,
200  :
201  includeMask(dict, opType, timeFolder),
202  operator_(dict),
203  fieldPtr_(timeFolder.readPointField_H<T>(this->fieldName())),
204  field_(fieldPtr_().hostView())
205  {
206  }
207 
208  add_vCtor(
209  includeMask,
210  IncludeMask,
211  dictionary);
212 
213  bool isIncluded(int32 n)const override
214  {
215  return operator_(field_[n]);
216  }
217 
218  uint32 size()const override
219  {
220  return field_.size();
221  }
222 
223 };
224 
225 
226 template<typename T>
227 class IncludeMask<T,allOp<T>>
228 :
229  public includeMask
230 {
231 public:
232  TypeInfoTemplate12("IncludeMask", T, allOp<int8>);
233 
235  const dictionary& dict,
236  const word& opType,
238  :
239  includeMask(dict, opType, timeFolder)
240  {}
241 
242  add_vCtor(
243  includeMask,
244  IncludeMask,
245  dictionary);
246 
247  bool isIncluded(int32 n)const override
248  {
249  return true;
250  }
251 
252  uint32 size()const override
253  {
254  return 0;
255  }
256 };
257 
258 
259 } // pFlow
260 
261 #endif //__IncludeMask_hpp__
262 
263 
pFlow::lessThanOp::operator()
bool operator()(const T &compVal, const T &val) const
Definition: IncludeMask.hpp:57
pFlow::equalOp::TypeInfoNV
TypeInfoNV("equal")
includeMask.hpp
pFlow::IncludeMask::IncludeMask
IncludeMask(const dictionary &dict, const word &opType, readFromTimeFolder &timeFolder)
Definition: IncludeMask.hpp:196
pFlow::lessThanOp
Definition: IncludeMask.hpp:52
pFlow::compareOne::opertorType
Operator< T > opertorType
Definition: IncludeMask.hpp:119
pFlow::compareTwo::compValue1_
T compValue1_
Definition: IncludeMask.hpp:145
pFlow::IncludeMask< T, allOp< T > >::size
uint32 size() const override
Definition: IncludeMask.hpp:252
pFlow::readFromTimeFolder
Definition: readFromTimeFolder.hpp:31
pFlow::betweenOp
Definition: IncludeMask.hpp:83
pFlow::IncludeMask::field_
hostViewType1D< T > field_
Definition: IncludeMask.hpp:191
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::betweenOp::operator()
bool operator()(const T &compVal1, const T &compVal2, const T &val) const
Definition: IncludeMask.hpp:88
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::IncludeMask::isIncluded
bool isIncluded(int32 n) const override
Definition: IncludeMask.hpp:213
pFlow::greaterThanEqOp::TypeInfoNV
TypeInfoNV("greaterThanEq")
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::greaterThanOp
Definition: IncludeMask.hpp:32
pFlow::compareOne
Definition: IncludeMask.hpp:115
pFlow::includeMask
Definition: includeMask.hpp:33
pFlow::lessThanOp::TypeInfoNV
TypeInfoNV("lessThan")
pFlow::compareTwo
Definition: IncludeMask.hpp:140
pFlow::betweenOp::TypeInfoNV
TypeInfoNV("between")
pFlow::lessThanEqOp::TypeInfoNV
TypeInfoNV("lessThanEq")
pFlow::IncludeMask::TypeInfoTemplate12
TypeInfoTemplate12("IncludeMask", T, Operator)
pFlow
Definition: demGeometry.hpp:27
pFlow::greaterThanOp::TypeInfoNV
TypeInfoNV("greaterThan")
pFlow::compareTwo::compValue2_
T compValue2_
Definition: IncludeMask.hpp:146
pFlow::IncludeMask< T, allOp< T > >::isIncluded
bool isIncluded(int32 n) const override
Definition: IncludeMask.hpp:247
pFlow::IncludeMask
Definition: IncludeMask.hpp:181
pFlow::allOp::operator()
bool operator()() const
Definition: IncludeMask.hpp:109
pFlow::compareTwo::operator_
opertorType operator_
Definition: IncludeMask.hpp:147
pFlow::compareTwo::operator()
bool operator()(const T &value) const
Definition: IncludeMask.hpp:158
pFlow::IncludeMask::operator_
Operator operator_
Definition: IncludeMask.hpp:187
pFlow::lessThanEqOp
Definition: IncludeMask.hpp:62
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::compareOne::compValue_
T compValue_
Definition: IncludeMask.hpp:122
pFlow::IncludeMask::fieldPtr_
uniquePtr< pointField_H< T > > fieldPtr_
Definition: IncludeMask.hpp:189
pFlow::IncludeMask< T, allOp< T > >::IncludeMask
IncludeMask(const dictionary &dict, const word &opType, readFromTimeFolder &timeFolder)
Definition: IncludeMask.hpp:234
pFlow::compareOne::operator_
opertorType operator_
Definition: IncludeMask.hpp:123
pFlow::IncludeMask::add_vCtor
add_vCtor(includeMask, IncludeMask, dictionary)
pFlow::lessThanEqOp::operator()
bool operator()(const T &compVal, const T &val) const
Definition: IncludeMask.hpp:67
pFlow::equalOp::operator()
bool operator()(const T &compVal, const T &val) const
Definition: IncludeMask.hpp:77
pFlow::IncludeMask::size
uint32 size() const override
Definition: IncludeMask.hpp:218
pFlow::compareZero::TypeInfoNV
TypeInfoNV(Operator::TYPENAME())
pFlow::allOp
Definition: IncludeMask.hpp:104
pFlow::compareZero::operator_
Operator operator_
Definition: IncludeMask.hpp:168
pFlow::betweenEqOp
Definition: IncludeMask.hpp:94
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
1D array (vector with host memeory space)
Definition: KokkosTypes.hpp:136
pFlow::allOp::TypeInfoNV
TypeInfoNV("all")
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::compareZero::compareZero
compareZero(const dictionary &dict)
pFlow::greaterThanEqOp::operator()
bool operator()(const T &compVal, const T &val) const
Definition: IncludeMask.hpp:47
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::greaterThanEqOp
Definition: IncludeMask.hpp:42
pFlow::greaterThanOp::operator()
bool operator()(const T &compVal, const T &val) const
Definition: IncludeMask.hpp:37
pFlow::compareTwo::opertorType
Operator< T > opertorType
Definition: IncludeMask.hpp:143
pFlow::compareOne::operator()
bool operator()(const T &value) const
Definition: IncludeMask.hpp:133
pFlow::equalOp
Definition: IncludeMask.hpp:72
pFlow::betweenEqOp::operator()
bool operator()(const T &compVal1, const T &compVal2, const T &val) const
Definition: IncludeMask.hpp:99
pFlow::compareTwo::compareTwo
compareTwo(const dictionary &dict)
Definition: IncludeMask.hpp:152
pFlow::compareOne::TypeInfoNV
TypeInfoNV(Operator< T >::TYPENAME())
pFlow::betweenEqOp::TypeInfoNV
TypeInfoNV("betweenEq")
pFlow::compareTwo::TypeInfoNV
TypeInfoNV(opertorType::TYPENAME())
pFlow::includeMask::fieldName
word fieldName() const
Definition: includeMask.hpp:66
pFlow::compareOne::compareOne
compareOne(const dictionary &dict)
Definition: IncludeMask.hpp:128
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67
pFlow::compareZero
Definition: IncludeMask.hpp:165
pFlow::timeFolder
Definition: timeFolder.hpp:32
pFlow::compareZero::operator()
bool operator()(const T &value) const
Definition: IncludeMask.hpp:174