parcelSelectionDetail.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2018 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::Detail::parcelSelection
28 
29 Description
30  Selection of parcels based on their objectRegistry entries.
31  Normally accessed via a dictionary entry.
32 
33  Example sub-dictionary entry
34  \verbatim
35  selection
36  {
37  stride
38  {
39  // every 10th parcelId
40  action use;
41  source stride;
42  stride 10;
43  }
44  injector
45  {
46  // Only output from injectorID == 1
47  action subset;
48  source field;
49  field typeId;
50  accept (equal 1);
51  }
52  Umin
53  {
54  // Remove slow parcels
55  action subtract;
56  source field;
57  field U;
58  accept (less 1e-3);
59  }
60  diam
61  {
62  // Only particular diameter ranges
63  action subset;
64  source field;
65  field d;
66  accept (greater 1e-5) and (less 1e-3);
67  }
68  }
69  \endverbatim
70 
71  \heading Entry type
72  \table
73  Property | Description | Required | Default
74  action | all/clear/invert/ignore add/subtract/subset/use | yes |
75  source | field/stride | mostly |
76  \endtable
77 
78  \heading Stride source
79  \table
80  Property | Description | Required | Default
81  stride | The stride for the parcel id | yes |
82  \endtable
83 
84  \heading Field source
85  \table
86  Property | Description | Required | Default
87  field | The label/scalar/vector field name | yes |
88  accept | Acceptance or test criterion | yes |
89  \endtable
90 
91  The \c accept criterion has two forms:
92  -# single expression
93  - (expr)
94  -# composite expression
95  - (expr) or (expr)
96  - (expr) and (expr)
97 
98  The expressions are a (op scalar) pair that form a unary scalar
99  predicate. The \a op is one of the following:
100  - lt, less
101  - le, lessEqual, lessEq
102  - gt, greater
103  - ge, greaterEqual, greaterEq
104  - eq, equal
105  - neq, notEqual
106 
107  For example,
108  \verbatim
109  accept (less 10);
110  accept (less 10) or (greater 100);
111  accept (ge 10) and (le 20);
112  \endverbatim
113 
114 See also
115  Foam::predicates::scalars
116  Foam::functionObjects::vtkCloud
117 
118 SourceFiles
119  parcelSelectionDetail.C
120 
121 \*---------------------------------------------------------------------------*/
122 
123 #ifndef parcelSelectionDetail_H
124 #define parcelSelectionDetail_H
125 
126 #include "bitSet.H"
127 #include "Enum.H"
128 #include "objectRegistry.H"
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 namespace Foam
133 {
134 namespace Detail
135 {
136 
137 /*---------------------------------------------------------------------------*\
138  Class Detail::parcelSelection Declaration
139 \*---------------------------------------------------------------------------*/
140 
141 class parcelSelection
142 {
143 public:
144 
145  //- Enumeration defining the valid selection actions
146  enum actionType
147  {
148  ALL,
149  CLEAR,
150  INVERT,
151  ADD,
152  SUBTRACT,
153  SUBSET,
154  USE,
155  IGNORE,
156  };
157 
158  //- Names for the actionType
159  static const Enum<actionType> actionNames;
160 
161 
162  //- Enumeration defining the valid sources
163  enum sourceType
164  {
165  FIELD,
166  STRIDE
167  };
168 
169  //- Names for the sourceType
170  static const Enum<sourceType> sourceNames;
171 
172 
173  //- Enumeration defining and/or logic
174  enum logicType { AND, OR };
175 
176  //- Names for the logicType
177  static const Enum<logicType> logicNames;
178 
179 
180 protected:
181 
182  // Protected Data
184  //- The filtered parcel addressing. Eg, for the current cloud.
187  //- The filtered parcel addressing. Eg, for the current cloud.
191  // Protected Member Functions
193  //- Calculate parcel selection filter.
194  // \return True if the filter is applicable
195  bool calculateFilter
196  (
197  const objectRegistry& obrTmp,
198  const bool log = true
199  );
200 
201 public:
202 
203  // Constructors
205  //- Default construct
206  parcelSelection() = default;
208 
209  //- Destructor
210  virtual ~parcelSelection() = default;
211 };
212 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace Detail
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #endif
222 
223 // ************************************************************************* //
parcelSelection()=default
Default construct.
dimensionedScalar log(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
"subset" - subset parcel selection
bitSet parcelAddr_
The filtered parcel addressing. Eg, for the current cloud.
virtual ~parcelSelection()=default
Destructor.
static const Enum< actionType > actionNames
Names for the actionType.
"field" - select based on field value
"invert" - invert the selection
sourceType
Enumeration defining the valid sources.
bool calculateFilter(const objectRegistry &obrTmp, const bool log=true)
Calculate parcel selection filter.
actionType
Enumeration defining the valid selection actions.
"stride" - select based on stride (parcel id)
"subtract" - remove parcel selection
dictionary parcelSelect_
The filtered parcel addressing. Eg, for the current cloud.
static const Enum< sourceType > sourceNames
Names for the sourceType.
"clear" - clear the selection
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
Registry of regIOobjects.
logicType
Enumeration defining and/or logic.
static const Enum< logicType > logicNames
Names for the logicType.
Namespace for OpenFOAM.