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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::fv::cellSetOption
29 
30 Description
31  Intermediate abstract class for handling
32  cell-set options for the derived fvOptions.
33 
34 Usage
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  //OR: cellZones (<name> ...);
60 
61  // when selectionMode=points
62  points (<point1> <point2> ... <pointN>);
63 
64  // when selectionMode=geometric
65  selection
66  {
67  box1
68  {
69  action use;
70  source box;
71  min (-0.1 -0.01 -0.1);
72  max (0.1 0.30 0.1);
73  }
74  ball
75  {
76  action add;
77  source sphere;
78  origin (-0.1 -0.01 -0.1);
79  radius 0.25;
80  }
81  ...
82  }
83 
84  // Mandatory/Optional (derived) entries
85  ...
86  }
87  \endverbatim
88 
89  where the entries mean:
90  \table
91  Property | Description | Type | Reqd | Dflt
92  selectionMode | Mode of cell selection - see below | word | yes | -
93  timeStart | Start time of fvOption | scalar | no | -1
94  duration | Duration of fvOption execution <!--
95  --> starting from timeStart | scalar | cndtnl | 0
96  cellSet | Name of operand cellSet | word | cndtnl | -
97  cellZone | Name of operand cellZone | wordRe | cndtnl | -
98  cellZones | Name of operand cellZones | wordRes | cndtnl | -
99  points | Set of points in global coordinate <!--
100  --> system | vectorList | cndtnl | -
101  selection | Dictionary of geometric selections | dict | cndtnl | -
102  \endtable
103 
104  Options for the \c selectionMode entry:
105  \verbatim
106  all | Use all cells in the computational domain
107  cellZone | Use specified cellZone
108  cellSet | Use specified cellSet
109  points | Use cells containing a given set of points
110  geometric | Select cells based on topoSetCellSource actions
111  \endverbatim
112 
113  The inherited entries are elaborated in:
114  - \link fvOption.H \endlink
115 
116  The geometric selection uses topoSetCellSource to select cells.
117  Any searchableSurface selections must describe a closed volume.
118  Ie, its hasVolumeType() method must be true.
119 
120 Note
121  - Source/sink options are to be added to the right-hand side of equations.
122 
123 See also
124  Foam::cellBitSet::select
125 
126 SourceFiles
127  cellSetOption.C
128 
129 \*---------------------------------------------------------------------------*/
130 
131 #ifndef Foam_fv_cellSetOption_H
132 #define Foam_fv_cellSetOption_H
133 
134 #include "fvOption.H"
135 #include "fvMesh.H"
136 #include "dictionary.H"
137 #include "Time.H"
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 namespace Foam
142 {
143 namespace fv
144 {
145 
146 /*---------------------------------------------------------------------------*\
147  Class cellSetOption Declaration
148 \*---------------------------------------------------------------------------*/
149 
150 class cellSetOption
151 :
152  public fv::option
153 {
154 public:
155 
156  // Public Data
157 
158  //- Enumeration for selection mode types
159  enum selectionModeType
160  {
161  smAll,
162  smCellSet,
163  smCellZone,
164  smPoints,
165  smGeometric,
166  smCellType
167  };
168 
169  //- List of selection mode type names
170  static const Enum<selectionModeType> selectionModeTypeNames_;
171 
172 
173 protected:
174 
175  // Protected Data
176 
177  //- Start time of fvOption
178  scalar timeStart_;
179 
180  //- Duration of fvOption execution starting from timeStart
181  scalar duration_;
182 
183  //- Cell selection mode
185 
186  //- Face selection names (for set or zone selections)
187  wordRes selectionNames_;
188 
189  //- List of points for "points" selectionMode
190  List<point> points_;
191 
192  //- Dictionary entries for "geometric" (topoSetCellSource) selection
193  dictionary geometricSelection_;
194 
195  //- Set of cells to apply source to
197 
198  //- Sum of cell volumes
199  scalar V_;
200 
201 
202  // Protected Functions
204  //- Set cell selection name or points selection from dictionary input
205  void setSelection(const dictionary& dict);
206 
207  //- Set the cell selection based on user input selection mode
208  void setCellSelection();
209 
210  //- Recalculate the volume
211  void setVol();
212 
213 
214 public:
215 
216  //- Runtime type information
217  TypeName("cellSetOption");
220  // Constructors
222  //- Construct from components
224  (
225  const word& name,
226  const word& modelType,
227  const dictionary& dict,
228  const fvMesh& mesh
229  );
230 
231 
232  //- Destructor
233  virtual ~cellSetOption() = default;
234 
235 
236  // Member Functions
238  // Access
239 
240  //- Return const access to the time start
241  inline scalar timeStart() const noexcept;
243  //- Return const access to the duration
244  inline scalar duration() const noexcept;
245 
246  //- True if within time limits
247  inline bool inTimeLimits(const scalar timeValue) const;
248 
249  //- True if sub-selection should be used
250  inline bool useSubMesh() const noexcept;
251 
252  //- Return the cell selection mode
254 
255  //- Return const access to the selection names
256  //- (set or zone selection)
257  inline const wordRes& selectionNames() const noexcept;
258 
259  //- Return const access to the first set/zone name
260  inline const wordRe& zoneName() const;
261 
262  //- Return const access to the total cell volume
263  inline scalar V() const noexcept;
264 
265  //- Return const access to the cell selection
266  inline const labelList& cells() const noexcept;
268 
269  // Edit
270 
271  //- Adjust the time start, return the old value
272  inline scalar timeStart(scalar val) noexcept;
273 
274  //- Adjust the duration, return the old value
275  inline scalar duration(scalar val) noexcept;
276 
277 
278  // Checks
279 
280  //- Is the source active?
281  virtual bool isActive();
282 
283 
284  // IO
285 
286  //- Read source dictionary
287  virtual bool read(const dictionary& dict);
288 
289 
290  // Housekeeping
291 
292  //- The name of the cell set/zone [as a word]
293  //- for "cellSet" / "cellZone" selection modes)
294  const word& cellSetName() const { return zoneName(); }
295 };
296 
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 } // End namespace fv
301 } // End namespace Foam
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #include "cellSetOptionI.H"
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 #endif
310 
311 // ************************************************************************* //
selectionModeType selectionMode_
Cell selection mode.
scalar V_
Sum of cell volumes.
dictionary dict
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:30
const word & cellSetName() const
The name of the cell set/zone [as a word] for "cellSet" / "cellZone" selection modes) ...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
scalar timeStart() const noexcept
Return const access to the time start.
const labelList & cells() const noexcept
Return const access to the cell selection.
scalar duration_
Duration of fvOption execution starting from timeStart.
virtual bool read(const dictionary &dict)
Read source dictionary.
static const Enum< selectionModeType > selectionModeTypeNames_
List of selection mode type names.
cellSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
wordRes selectionNames_
Face selection names (for set or zone selections)
scalar duration() const noexcept
Return const access to the duration.
scalar V() const noexcept
Return const access to the total cell volume.
virtual bool isActive()
Is the source active?
selectionModeType
Enumeration for selection mode types.
A class for handling words, derived from Foam::string.
Definition: word.H:63
labelList fv(nPoints)
const wordRe & zoneName() const
Return const access to the first set/zone name.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:47
const word & name() const noexcept
Return const access to the source name.
Definition: fvOptionI.H:24
bool inTimeLimits(const scalar timeValue) const
True if within time limits.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
const direction noexcept
Definition: Scalar.H:258
dictionary geometricSelection_
Dictionary entries for "geometric" (topoSetCellSource) selection.
labelList cells_
Set of cells to apply source to.
void setCellSelection()
Set the cell selection based on user input selection mode.
void setSelection(const dictionary &dict)
Set cell selection name or points selection from dictionary input.
Definition: cellSetOption.C:56
selectionModeType selectionMode() const noexcept
Return the cell selection mode.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
List< point > points_
List of points for "points" selectionMode.
TypeName("cellSetOption")
Runtime type information.
List< label > labelList
A List of labels.
Definition: List.H:62
const wordRes & selectionNames() const noexcept
Return const access to the selection names (set or zone selection)
virtual ~cellSetOption()=default
Destructor.
bool useSubMesh() const noexcept
True if sub-selection should be used.
scalar timeStart_
Start time of fvOption.
Namespace for OpenFOAM.
void setVol()
Recalculate the volume.