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-2023 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  fvOption1
38  {
39  // Mandatory entries
40  selectionMode <word>;
41 
42  // Optional entries
43  timeStart <scalar>;
44  updateSelection <bool>;
45 
46  // Conditional entries
47 
48  // when timeStart entry is present
49  duration <scalar>;
50 
51  // when selectionMode=cellSet
52  cellSet <word>;
53 
54  // when selectionMode=cellZone
55  cellZone <word>;
56 
57  //OR: cellZones (<word> ...);
58 
59  // when selectionMode=points
60  points (<point1> <point2> ... <pointN>);
61 
62  // when selectionMode=movingPoints
63  movingPoints
64  (
65  <word> <Function1<vector>>;
66  // e.g.
67  point1 <Function1<vector>>;
68  pointN <Function1<vector>>;
69  ...
70  );
71 
72  // when selectionMode=geometric
73  selection
74  {
75  topoSet1 <dictionary>;
76 
77  box1
78  {
79  action use;
80  source box;
81  min (-0.1 -0.01 -0.1);
82  max (0.1 0.30 0.1);
83  }
84  ball
85  {
86  action add;
87  source sphere;
88  origin (-0.1 -0.01 -0.1);
89  radius 0.25;
90  }
91  ...
92  }
93 
94  // Inherited entries
95  ...
96  }
97  \endverbatim
98 
99  where the entries mean:
100  \table
101  Property | Description | Type | Reqd | Deflt
102  selectionMode | Mode of cell selection - see below | word | yes | -
103  timeStart | Start time of fvOption | scalar | no | -1
104  updateSelection | Flag to enable selection updates | bool | no | false
105  duration | Duration of fvOption execution <!--
106  --> starting from timeStart | scalar | choice | 0
107  cellSet | Name of operand cellSet | word | choice | -
108  cellZone | Name of operand cellZone | wordRe | choice | -
109  cellZones | Name of operand cellZones | wordRes | choice | -
110  points | Set of points in global coordinate <!--
111  --> system | vectorList | choice | -
112  movingPoints | Set of moving points in global coordinate system <!--
113  --> | Function1<vector> | choice | -
114  selection | Dictionary of geometric selections | dict | choice | -
115  \endtable
116 
117  Options for the \c selectionMode entry:
118  \verbatim
119  all | Use all cells in the computational domain
120  cellZone | Use specified cellZone
121  cellSet | Use specified cellSet
122  points | Use cells containing a given set of points
123  movingPoints | Use cells containing a given set of moving points
124  geometric | Select cells based on topoSetCellSource actions
125  cellType | For overset only : use cells of type 'porous
126  \endverbatim
127 
128  The inherited entries are elaborated in:
129  - \link fvOption.H \endlink
130  - \link Function1.H \endlink
131 
132 Note
133  - Source/sink options are to be added to the right-hand side of equations.
134  - The geometric selection uses \c topoSetCellSource to select cells.
135  Any \c searchableSurface selections must describe a closed volume.
136  Ie, its \c hasVolumeType() method must be \c true.
137 
138 See also
139  Foam::cellBitSet::select
140 
141 SourceFiles
142  cellSetOption.C
143 
144 \*---------------------------------------------------------------------------*/
145 
146 #ifndef Foam_fv_cellSetOption_H
147 #define Foam_fv_cellSetOption_H
148 
149 #include "fvOption.H"
150 #include "fvMesh.H"
151 #include "dictionary.H"
152 #include "Time.H"
153 #include "Function1.H"
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 namespace Foam
158 {
159 namespace fv
160 {
161 
162 /*---------------------------------------------------------------------------*\
163  Class cellSetOption Declaration
164 \*---------------------------------------------------------------------------*/
165 
166 class cellSetOption
167 :
168  public fv::option
169 {
170 public:
171 
172  // Public Data
173 
174  //- Enumeration for selection mode types
175  enum selectionModeType : char
176  {
177  smAll,
178  smCellSet,
179  smCellZone,
180  smPoints,
182  smGeometric,
183  smCellType
184  };
185 
186  //- List of selection mode type names
187  static const Enum<selectionModeType> selectionModeTypeNames_;
188 
189 
190 protected:
191 
192  // Protected Data
193 
194  //- Cell selection mode
196 
197  //- Flag to enable dictionary-based updates of selections
198  bool updateSelection_;
199 
200  //- Start time of fvOption
201  scalar timeStart_;
202 
203  //- Duration of fvOption execution starting from timeStart
204  scalar duration_;
205 
206  //- Face selection names (for set or zone selections)
207  wordRes selectionNames_;
208 
209  //- List of points for "points" selectionMode
210  List<point> points_;
211 
212  //- List of points for "movingPoints" selectionMode
213  PtrList<Function1<point>> movingPoints_;
214 
215  //- Dictionary entries for "geometric" (topoSetCellSource) selection
217 
218  //- Set of cells to apply source to
220 
221  //- Sum of cell volumes
222  scalar V_;
223 
224 
225  // Protected Functions
226 
227  //- Set cell selection name or points selection from dictionary input
228  void setSelection(const dictionary& dict);
229 
230  //- Set the cell selection based on user input selection mode
231  void setCellSelection();
232 
233  //- Recalculate the volume
234  void setVol();
235 
236 
237 public:
238 
239  //- Runtime type information
240  TypeName("cellSetOption");
241 
242 
243  // Constructors
245  //- Construct from components
247  (
248  const word& name,
249  const word& modelType,
250  const dictionary& dict,
251  const fvMesh& mesh
252  );
253 
254 
255  //- Destructor
256  virtual ~cellSetOption() = default;
257 
259  // Member Functions
260 
261  // Access
262 
263  //- Return const access to the time start
264  inline scalar timeStart() const noexcept;
265 
266  //- Return const access to the duration
267  inline scalar duration() const noexcept;
269  //- True if within time limits
270  inline bool inTimeLimits(const scalar timeValue) const;
271 
272  //- True if sub-selection should be used
273  inline bool useSubMesh() const noexcept;
274 
275  //- Return the cell selection mode
277 
278  //- Return const access to the selection names
279  //- (set or zone selection)
280  inline const wordRes& selectionNames() const noexcept;
281 
282  //- Return const access to the first set/zone name
283  inline const wordRe& zoneName() const;
284 
285  //- Return const access to the total cell volume
286  inline scalar V() const noexcept;
287 
288  //- Return const access to the cell selection
289  inline const labelList& cells() const noexcept;
290 
291  //- Return flag for selection updates
292  bool isSelectionUpdated() const noexcept
293  {
294  return updateSelection_;
295  }
296 
297 
298  // Edit
299 
300  //- Adjust the time start, return the old value
301  inline scalar timeStart(scalar val) noexcept;
302 
303  //- Adjust the duration, return the old value
304  inline scalar duration(scalar val) noexcept;
305 
306 
307  // Checks
309  //- Is the source active?
310  virtual bool isActive();
311 
312 
313  // IO
314 
315  //- Read source dictionary
316  virtual bool read(const dictionary& dict);
317 
318 
319  // Housekeeping
320 
321  //- The name of the cell set/zone [as a word]
322  //- for "cellSet" / "cellZone" selection modes)
323  const word& cellSetName() const { return zoneName(); }
324 };
325 
326 
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 
329 } // End namespace fv
330 } // End namespace Foam
331 
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
333 
334 #include "cellSetOptionI.H"
335 
336 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337 
338 #endif
339 
340 // ************************************************************************* //
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:129
scalar timeStart() const noexcept
Return const access to the time start.
const labelList & cells() const noexcept
Return const access to the cell selection.
PtrList< Function1< point > > movingPoints_
List of points for "movingPoints" selectionMode.
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)
bool isSelectionUpdated() const noexcept
Return flag for selection updates.
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?
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:53
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
bool updateSelection_
Flag to enable dictionary-based updates of selections.
const direction noexcept
Definition: scalarImpl.H:255
selectionModeType
Enumeration for selection mode types.
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:57
selectionModeType selectionMode() const noexcept
Return the cell selection mode.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
List< point > points_
List of points for "points" selectionMode.
TypeName("cellSetOption")
Runtime type information.
List< label > labelList
A List of labels.
Definition: List.H:61
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.