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 
191 public:
192 
193  TypeInfoTemplate2("IncludeMask", T, Operator);
194 
196  const dictionary& dict,
197  const word& opType,
199  :
200  includeMask(dict, opType, timeFolder),
201  operator_(dict),
202  field_(timeFolder.readPointField_H<T>(this->fieldName()))
203  {}
204 
205  add_vCtor(
206  includeMask,
207  IncludeMask,
208  dictionary);
209 
210  bool isIncluded(int32 n)const override
211  {
212  return operator_(field_[n]);
213  }
214 
215 };
216 
217 
218 template<typename T>
219 class IncludeMask<T,allOp<T>>
220 :
221  public includeMask
222 {
223 public:
224  TypeInfoTemplate2("IncludeMask", T, allOp<int8>);
225 
227  const dictionary& dict,
228  const word& opType,
230  :
231  includeMask(dict, opType, timeFolder)
232  {}
233 
234  add_vCtor(
235  includeMask,
236  IncludeMask,
237  dictionary);
238 
239  bool isIncluded(int32 n)const override
240  {
241  return true;
242  }
243 };
244 
245 
246 } // pFlow
247 
248 #endif //__IncludeMask_hpp__
249 
250 
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:195
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::readFromTimeFolder
Definition: readFromTimeFolder.hpp:31
pFlow::betweenOp
Definition: IncludeMask.hpp:83
pFlow::betweenOp::operator()
bool operator()(const T &compVal1, const T &compVal2, const T &val) const
Definition: IncludeMask.hpp:88
pFlow::IncludeMask::isIncluded
bool isIncluded(int32 n) const override
Definition: IncludeMask.hpp:210
pFlow::greaterThanEqOp::TypeInfoNV
TypeInfoNV("greaterThanEq")
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
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
Definition: demComponent.hpp:28
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:239
pFlow::IncludeMask
Definition: IncludeMask.hpp:181
pFlow::pointField
Definition: pointField.hpp:35
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
n
int32 n
Definition: NBSCrossLoop.hpp:24
pFlow::IncludeMask::operator_
Operator operator_
Definition: IncludeMask.hpp:187
pFlow::lessThanEqOp
Definition: IncludeMask.hpp:62
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::compareOne::compValue_
T compValue_
Definition: IncludeMask.hpp:122
pFlow::IncludeMask< T, allOp< T > >::IncludeMask
IncludeMask(const dictionary &dict, const word &opType, readFromTimeFolder &timeFolder)
Definition: IncludeMask.hpp:226
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::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::allOp::TypeInfoNV
TypeInfoNV("all")
pFlow::compareZero::compareZero
compareZero(const dictionary &dict)
pFlow::IncludeMask::TypeInfoTemplate2
TypeInfoTemplate2("IncludeMask", T, Operator)
pFlow::greaterThanEqOp::operator()
bool operator()(const T &compVal, const T &val) const
Definition: IncludeMask.hpp:47
pFlow::greaterThanEqOp
Definition: IncludeMask.hpp:42
pFlow::IncludeMask::field_
pointField_H< T > field_
Definition: IncludeMask.hpp:189
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::equal
INLINE_FUNCTION_HD bool equal(const real &s1, const real &s2)
Definition: bTypesFunctions.hpp:188
pFlow::dictionary
Definition: dictionary.hpp:38
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