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-2021 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 <cellSetName>;
55 
56  // when selectionMode=cellZone
57  cellZone <cellZoneName>;
58 
59  // when selectionMode=points
60  points (<point1> <point2> ... <pointN>);
61 
62  // Mandatory/Optional (derived) entries
63  ...
64  }
65  \endverbatim
66 
67  where the entries mean:
68  \table
69  Property | Description | Type | Reqd | Dflt
70  selectionMode | Mode of cell selection - see below | word | yes | -
71  timeStart | Start time of fvOption | scalar | no | -1
72  duration | Duration of fvOption execution <!--
73  --> starting from timeStart | scalar | cndtnl | 0
74  cellSet | Name of operand cellSet | word | cndtnl | -
75  cellZone | Name of operand cellZone | word | cndtnl | -
76  points | Set of points in global coordinate <!--
77  --> system | vectorList | cndtnl | -
78  \endtable
79 
80  Options for the \c selectionMode entry:
81  \verbatim
82  all | Use all cells in the computational domain
83  cellZone | Use a given cellZone
84  cellSet | Use a given cellSet
85  points | Use cells containing a given set of points
86  \endverbatim
87 
88  The inherited entries are elaborated in:
89  - \link fvOption.H \endlink
90 
91 Note
92  - Source/sink options are to be added to the right-hand side of equations.
93 
94 SourceFiles
95  cellSetOption.C
96 
97 \*---------------------------------------------------------------------------*/
98 
99 #ifndef cellSetOption_H
100 #define cellSetOption_H
101 
102 #include "fvOption.H"
103 #include "cellSet.H"
104 #include "fvMesh.H"
105 #include "Time.H"
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 namespace Foam
110 {
111 namespace fv
112 {
113 
114 /*---------------------------------------------------------------------------*\
115  Class cellSetOption Declaration
116 \*---------------------------------------------------------------------------*/
117 
118 class cellSetOption
119 :
120  public fv::option
121 {
122 public:
123 
124  // Public Data
125 
126  //- Enumeration for selection mode types
127  enum selectionModeType
128  {
129  smAll,
130  smCellSet,
131  smCellZone,
132  smPoints
133  };
134 
135  //- List of selection mode type names
136  static const Enum<selectionModeType> selectionModeTypeNames_;
137 
138 
139 protected:
140 
141  // Protected Data
142 
143  //- Start time of fvOption
144  scalar timeStart_;
145 
146  //- Duration of fvOption execution starting from timeStart
147  scalar duration_;
148 
149  //- Cell selection mode
151 
152  //- Name of set/zone for "cellSet" and "cellZone" selectionMode
153  word cellSetName_;
154 
155  //- List of points for "points" selectionMode
156  List<point> points_;
157 
158  //- Set of cells to apply source to
160 
161  //- Sum of cell volumes
162  scalar V_;
163 
164 
165  // Protected Functions
166 
167  //- Set cell selection name or points selection from dictionary input
168  void setSelection(const dictionary& dict);
169 
170  //- Set the cell selection based on user input selection mode
171  void setCellSelection();
172 
173  //- Recalculate the volume
174  void setVol();
175 
176 
177 public:
178 
179  //- Runtime type information
180  TypeName("cellSetOption");
181 
182 
183  // Constructors
184 
185  //- Construct from components
187  (
188  const word& name,
189  const word& modelType,
190  const dictionary& dict,
191  const fvMesh& mesh
192  );
193 
194 
195  //- Destructor
196  virtual ~cellSetOption() = default;
197 
198 
199  // Member Functions
200 
201  // Access
202 
203  //- Return const access to the time start
204  inline scalar timeStart() const noexcept;
205 
206  //- Return const access to the duration
207  inline scalar duration() const noexcept;
208 
209  //- True if within time limits
210  inline bool inTimeLimits(const scalar timeValue) const;
211 
212  //- Return the cell selection mode
213  inline selectionModeType selectionMode() const noexcept;
214 
215  //- True if sub-selection should be used
216  inline bool useSubMesh() const noexcept;
217 
218  //- Return const access to the name of cell set/zone for
219  //- "cellSet" / "cellZone" selection modes
220  inline const word& cellSetName() const noexcept;
221 
222  //- Return const access to the total cell volume
223  inline scalar V() const noexcept;
224 
225  //- Return const access to the cell selection
226  inline const labelList& cells() const noexcept;
227 
228 
229  // Edit
230 
231  //- Adjust the time start, return the old value
232  inline scalar timeStart(scalar val) noexcept;
233 
234  //- Adjust the duration, return the old value
235  inline scalar duration(scalar val) noexcept;
236 
237 
238  // Checks
239 
240  //- Is the source active?
241  virtual bool isActive();
242 
243 
244  // IO
245 
246  //- Read source dictionary
247  virtual bool read(const dictionary& dict);
248 };
249 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 } // End namespace fv
254 } // End namespace Foam
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 #include "cellSetOptionI.H"
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::fv::cellSetOption::setVol
void setVol()
Recalculate the volume.
Definition: cellSetOption.C:94
Foam::fv::option::name
const word & name() const noexcept
Return const access to the source name.
Definition: fvOptionI.H:31
Foam::Enum< selectionModeType >
Foam::fv::cellSetOption::cells
const labelList & cells() const noexcept
Return const access to the cell selection.
Definition: cellSetOptionI.H:82
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fv::cellSetOption
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Definition: cellSetOption.H:163
Foam::fv::cellSetOption::cellSetOption
cellSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: cellSetOption.C:200
Foam::fv::cellSetOption::selectionMode_
selectionModeType selectionMode_
Cell selection mode.
Definition: cellSetOption.H:195
Foam::fv::cellSetOption::~cellSetOption
virtual ~cellSetOption()=default
Destructor.
Foam::fv::cellSetOption::V_
scalar V_
Sum of cell volumes.
Definition: cellSetOption.H:207
Foam::fv::cellSetOption::setCellSelection
void setCellSelection()
Set the cell selection based on user input selection mode.
Definition: cellSetOption.C:121
Foam::fv::cellSetOption::smPoints
Definition: cellSetOption.H:177
Foam::fv::cellSetOption::inTimeLimits
bool inTimeLimits(const scalar timeValue) const
True if within time limits.
Definition: cellSetOptionI.H:43
Foam::fv::cellSetOption::setSelection
void setSelection(const dictionary &dict)
Set cell selection name or points selection from dictionary input.
Definition: cellSetOption.C:58
Foam::fv::cellSetOption::V
scalar V() const noexcept
Return const access to the total cell volume.
Definition: cellSetOptionI.H:76
Foam::fv::option
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:126
Foam::fv::cellSetOption::isActive
virtual bool isActive()
Is the source active?
Definition: cellSetOption.C:225
Foam::fv::cellSetOption::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: cellSetOption.C:255
Foam::fv::cellSetOption::useSubMesh
bool useSubMesh() const noexcept
True if sub-selection should be used.
Definition: cellSetOptionI.H:64
Foam::fv::cellSetOption::cells_
labelList cells_
Set of cells to apply source to.
Definition: cellSetOption.H:204
Foam::fv::cellSetOption::TypeName
TypeName("cellSetOption")
Runtime type information.
Foam::fv::cellSetOption::selectionModeType
selectionModeType
Enumeration for selection mode types.
Definition: cellSetOption.H:172
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fv::cellSetOption::duration
scalar duration() const noexcept
Return const access to the duration.
Definition: cellSetOptionI.H:37
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::cellSetOption::smCellZone
Definition: cellSetOption.H:176
Foam::fv::cellSetOption::selectionMode
selectionModeType selectionMode() const noexcept
Return the cell selection mode.
Definition: cellSetOptionI.H:58
fv
labelList fv(nPoints)
Time.H
Foam::fv::cellSetOption::selectionModeTypeNames_
static const Enum< selectionModeType > selectionModeTypeNames_
List of selection mode type names.
Definition: cellSetOption.H:181
Foam::fv::option::mesh
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
Foam::fv::cellSetOption::cellSetName
const word & cellSetName() const noexcept
Definition: cellSetOptionI.H:70
fvOption.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::fv::cellSetOption::duration_
scalar duration_
Duration of fvOption execution starting from timeStart.
Definition: cellSetOption.H:192
Foam::fv::cellSetOption::timeStart
scalar timeStart() const noexcept
Return const access to the time start.
Definition: cellSetOptionI.H:31
Foam::fv::cellSetOption::cellSetName_
word cellSetName_
Name of set/zone for "cellSet" and "cellZone" selectionMode.
Definition: cellSetOption.H:198
cellSet.H
Foam::fv::cellSetOption::points_
List< point > points_
List of points for "points" selectionMode.
Definition: cellSetOption.H:201
Foam::fv::cellSetOption::smCellSet
Definition: cellSetOption.H:175
Foam::fv::cellSetOption::timeStart_
scalar timeStart_
Start time of fvOption.
Definition: cellSetOption.H:189
Foam::fv::cellSetOption::smAll
Definition: cellSetOption.H:174