cellSetOption.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) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2017-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::fv::cellSetOption
29
30Description
31 Intermediate abstract class for handling
32 cell-set options for the derived fvOptions.
33
34Usage
35 Minimal example by using \c constant/fvOptions:
36 \verbatim
37 <userDefinedName1>
38 {
39 // Mandatory/Optional (inherited) entries
40 ...
41
42 // Mandatory entries (unmodifiable)
43 selectionMode all;
44
45 // Optional entries (runtime modifiable)
46 timeStart 1.0;
47
48 // Conditional mandatory entries (runtime modifiable)
49
50 // when timeStart entry is present
51 duration 1.4;
52
53 // when selectionMode=cellSet
54 cellSet <name>;
55
56 // when selectionMode=cellZone
57 cellZone <name>;
58
59 // when selectionMode=points
60 points (<point1> <point2> ... <pointN>);
61
62 // when selectionMode=geometric
63 selection
64 {
65 box1
66 {
67 action use;
68 source box;
69 min (-0.1 -0.01 -0.1);
70 max (0.1 0.30 0.1);
71 }
72 ball
73 {
74 action add;
75 source sphere;
76 origin (-0.1 -0.01 -0.1);
77 radius 0.25;
78 }
79 ...
80 }
81
82 // Mandatory/Optional (derived) entries
83 ...
84 }
85 \endverbatim
86
87 where the entries mean:
88 \table
89 Property | Description | Type | Reqd | Dflt
90 selectionMode | Mode of cell selection - see below | word | yes | -
91 timeStart | Start time of fvOption | scalar | no | -1
92 duration | Duration of fvOption execution <!--
93 --> starting from timeStart | scalar | cndtnl | 0
94 cellSet | Name of operand cellSet | word | cndtnl | -
95 cellZone | Name of operand cellZone | word | cndtnl | -
96 points | Set of points in global coordinate <!--
97 --> system | vectorList | cndtnl | -
98 selection | Dictionary of geometric selections | dict | cndtnl | -
99 \endtable
100
101 Options for the \c selectionMode entry:
102 \verbatim
103 all | Use all cells in the computational domain
104 cellZone | Use specified cellZone
105 cellSet | Use specified cellSet
106 points | Use cells containing a given set of points
107 geometric | Select cells based on topoSetCellSource actions
108 \endverbatim
109
110 The inherited entries are elaborated in:
111 - \link fvOption.H \endlink
112
113 The geometric selection uses topoSetCellSource to select cells.
114 Any searchableSurface selections must describe a closed volume.
115 Ie, its hasVolumeType() method must be true.
116
117Note
118 - Source/sink options are to be added to the right-hand side of equations.
119
120See also
121 Foam::cellBitSet::select
122
123SourceFiles
124 cellSetOption.C
125
126\*---------------------------------------------------------------------------*/
127
128#ifndef Foam_fv_cellSetOption_H
129#define Foam_fv_cellSetOption_H
130
131#include "fvOption.H"
132#include "fvMesh.H"
133#include "dictionary.H"
134#include "Time.H"
135
136// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138namespace Foam
139{
140namespace fv
141{
142
143/*---------------------------------------------------------------------------*\
144 Class cellSetOption Declaration
145\*---------------------------------------------------------------------------*/
146
147class cellSetOption
148:
149 public fv::option
150{
151public:
152
153 // Public Data
154
155 //- Enumeration for selection mode types
157 {
158 smAll,
159 smCellSet,
160 smCellZone,
161 smPoints,
163 };
164
165 //- List of selection mode type names
166 static const Enum<selectionModeType> selectionModeTypeNames_;
167
168
169protected:
170
171 // Protected Data
172
173 //- Start time of fvOption
174 scalar timeStart_;
175
176 //- Duration of fvOption execution starting from timeStart
177 scalar duration_;
178
179 //- Cell selection mode
181
182 //- Name of set/zone for "cellSet" and "cellZone" selectionMode
183 wordRe zoneName_;
184
185 //- List of points for "points" selectionMode
186 List<point> points_;
187
188 //- Dictionary entries for "geometric" (topoSetCellSource) selection
189 dictionary geometricSelection_;
190
191 //- Set of cells to apply source to
193
194 //- Sum of cell volumes
195 scalar V_;
196
197
198 // Protected Functions
199
200 //- Set cell selection name or points selection from dictionary input
201 void setSelection(const dictionary& dict);
202
203 //- Set the cell selection based on user input selection mode
204 void setCellSelection();
205
206 //- Recalculate the volume
207 void setVol();
208
210public:
212 //- Runtime type information
213 TypeName("cellSetOption");
215
216 // Constructors
218 //- Construct from components
220 (
221 const word& name,
222 const word& modelType,
223 const dictionary& dict,
224 const fvMesh& mesh
225 );
226
227
228 //- Destructor
229 virtual ~cellSetOption() = default;
230
232 // Member Functions
233
234 // Access
235
236 //- Return const access to the time start
237 inline scalar timeStart() const noexcept;
238
239 //- Return const access to the duration
240 inline scalar duration() const noexcept;
241
242 //- True if within time limits
243 inline bool inTimeLimits(const scalar timeValue) const;
244
245 //- Return the cell selection mode
247
248 //- True if sub-selection should be used
249 inline bool useSubMesh() const noexcept;
250
251 //- Return const access to the name of cell set/zone
252 //- for "cellSet" / "cellZone" selection modes
253 const wordRe& zoneName() const noexcept { return zoneName_; }
254
255 //- Return const access to the total cell volume
256 inline scalar V() const noexcept;
257
258 //- Return const access to the cell selection
259 inline const labelList& cells() const noexcept;
260
261
262 // Edit
263
264 //- Adjust the time start, return the old value
265 inline scalar timeStart(scalar val) noexcept;
266
267 //- Adjust the duration, return the old value
268 inline scalar duration(scalar val) noexcept;
269
270
271 // Checks
272
273 //- Is the source active?
274 virtual bool isActive();
275
276
277 // IO
278
279 //- Read source dictionary
280 virtual bool read(const dictionary& dict);
281
282
283 // Housekeeping
284
285 //- The name of the cell set/zone [as a word]
286 //- for "cellSet" / "cellZone" selection modes)
287 const word& cellSetName() const noexcept { return zoneName_; }
288};
289
290
291// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292
293} // End namespace fv
294} // End namespace Foam
295
296// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297
298#include "cellSetOptionI.H"
299
300// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301
302#endif
303
304// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Intermediate abstract class for handling cell-set options for the derived fvOptions.
scalar timeStart() const noexcept
Return const access to the time start.
scalar duration() const noexcept
Return const access to the duration.
dictionary geometricSelection_
Dictionary entries for "geometric" (topoSetCellSource) selection.
List< point > points_
List of points for "points" selectionMode.
void setSelection(const dictionary &dict)
Set cell selection name or points selection from dictionary input.
Definition: cellSetOption.C:61
const wordRe & zoneName() const noexcept
scalar V() const noexcept
Return const access to the total cell volume.
selectionModeType
Enumeration for selection mode types.
labelList cells_
Set of cells to apply source to.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual ~cellSetOption()=default
Destructor.
TypeName("cellSetOption")
Runtime type information.
scalar V_
Sum of cell volumes.
bool useSubMesh() const noexcept
True if sub-selection should be used.
scalar duration_
Duration of fvOption execution starting from timeStart.
scalar timeStart_
Start time of fvOption.
const labelList & cells() const noexcept
Return const access to the cell selection.
virtual bool isActive()
Is the source active?
wordRe zoneName_
Name of set/zone for "cellSet" and "cellZone" selectionMode.
selectionModeType selectionMode_
Cell selection mode.
static const Enum< selectionModeType > selectionModeTypeNames_
List of selection mode type names.
const word & cellSetName() const noexcept
void setCellSelection()
Set the cell selection based on user input selection mode.
selectionModeType selectionMode() const noexcept
Return the cell selection mode.
bool inTimeLimits(const scalar timeValue) const
True if within time limits.
void setVol()
Recalculate the volume.
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:127
const word & name() const noexcept
Return const access to the source name.
Definition: fvOptionI.H:31
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
const direction noexcept
Definition: Scalar.H:223
labelList fv(nPoints)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73