faceSetOption.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) 2019-2022 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::fa::faceSetOption
28 
29 Description
30  Intermediate abstract class for handling
31  face-set options for the derived faOptions.
32 
33 Usage
34  Minimal example by using \c constant/faOptions:
35  \verbatim
36  <userDefinedName1>
37  {
38  // Mandatory/Optional (inherited) entries
39  ...
40 
41  // Mandatory entries (unmodifiable)
42  selectionMode all;
43 
44  // Optional entries (runtime modifiable)
45  timeStart 1.0;
46 
47  // Conditional mandatory entries (runtime modifiable)
48 
49  // when timeStart entry is present
50  duration 1.4;
51 
52  // when selectionMode=faceZone
53  faceZones (<name> ...);
54  //or: faceZone <name>;
55 
56  // when selectionMode=patch
57  patches (<name> ...)
58  //or: patch <name>;
59  }
60  \endverbatim
61 
62  where the entries mean:
63  \table
64  Property | Description | Type | Reqd | Dflt
65  selectionMode | Mode of face selection - see below | word | yes | -
66  timeStart | Start time of faOption | scalar | no | -1
67  duration | Duration of faOption execution <!--
68  --> starting from timeStart | scalar | cndtnl | 0
69  faceSet | Name of operand faceSet | word | cndtnl | -
70  faceZone | Name of operand faceZone(s) | wordRe | cndtnl | -
71  faceZones | Names of operand faceZones | wordRes| cndtnl | -
72  patch | Name of operand poly patch(s) | wordRe | cndtnl | -
73  patches | Names of operand poly patches | wordRes| cndtnl | -
74  \endtable
75 
76  Options for the \c selectionMode entry:
77  \verbatim
78  all | Use all faces in the computational domain
79  faceSet | Use subset corresponding to specified (volume) faceSet
80  faceZones | Use subset corresponding to specified (volume) faceZones
81  faceZone | Use subset corresponding to specified (volume) faceZones
82  patch | Use subset corresponding of specified volume patches
83  patches | Use subset corresponding of specified volume patches
84  \endverbatim
85 
86  The inherited entries are elaborated in:
87  - \link faOption.H \endlink
88 
89 Note
90  - Source/sink options are to be added to the right-hand side of equations.
91 
92 SourceFiles
93  faceSetOption.C
94  faceSetOptionI.H
95 
96 \*---------------------------------------------------------------------------*/
97 
98 #ifndef Foam_fa_faceSetOption_H
99 #define Foam_fa_faceSetOption_H
100 
101 #include "faOption.H"
102 #include "faceSet.H"
103 #include "Time.H"
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 namespace Foam
108 {
109 namespace fa
110 {
111 
112 /*---------------------------------------------------------------------------*\
113  Class faceSetOption Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 class faceSetOption
117 :
118  public fa::option
119 {
120 public:
121 
122  // Public Enumeration
123 
124  //- Enumeration for selection mode types
125  enum selectionModeType
126  {
127  smAll,
128  smFaceSet,
129  smFaceZone,
130  smPatch,
131  };
132 
133  //- List of selection mode type names
134  static const Enum<selectionModeType> selectionModeTypeNames_;
135 
136 
137 protected:
138 
139  // Protected Data
140 
141  //- Time start
142  scalar timeStart_;
143 
144  //- Duration
145  scalar duration_;
146 
147  //- Face selection mode
149 
150  //- Face selection names (for set, zone or patch selections)
151  wordRes selectionNames_;
152 
153  //- Set of faces to apply source to
155 
156  //- Sum of face area
157  scalar A_;
158 
159 
160  // Protected Functions
161 
162  //- Set face selection name from dictionary input
163  void setSelection(const dictionary& dict);
164 
165  //- Set face selection based on user input selection mode
166  void setFaceSelection();
168  //- Recalculate the area
169  void setArea();
170 
171  //- Zero all non-selected locations within field
172  template<class Type>
173  inline void subsetFilter(List<Type>& field) const;
174 
175 
176 public:
177 
178  //- Runtime type information
179  TypeName("faceSetOption");
182  // Constructors
184  //- Construct from components
186  (
187  const word& name,
188  const word& modelType,
189  const dictionary& dict,
190  const fvMesh& mesh
191  );
192 
193 
194  //- Destructor
195  virtual ~faceSetOption() = default;
196 
197 
198  // Member Functions
200  // Access
201 
202  //- Return const access to the time start
203  inline scalar timeStart() const noexcept;
205  //- Return const access to the duration
206  inline scalar duration() const noexcept;
207 
208  //- Return true if within time limits
209  inline bool inTimeLimits(const scalar timeValue) const;
210 
211  //- True if sub-selection should be used
212  inline bool useSubMesh() const noexcept;
213 
214  //- Return the face selection mode
216 
217  //- Return const access to the selection names
218  //- (set, zone or patch selection)
219  inline const wordRes& selectionNames() const noexcept;
220 
221  //- Return const access to the first set/zone/patch name
222  inline const wordRe& zoneName() const;
223 
224  //- Return const access to the total face area
225  inline scalar A() const noexcept;
226 
227  //- Return const access to the local finite-area face selection
228  inline const labelList& faces() const noexcept;
229 
230 
231  // Edit
232 
233  //- Adjust the time start, return the old value
234  inline scalar timeStart(scalar val) noexcept;
235 
236  //- Adjust the duration, return the old value
237  inline scalar duration(scalar val) noexcept;
238 
239 
240  // Checks
241 
242  //- Is the source active?
243  virtual bool isActive();
244 
245 
246  // IO
247 
248  //- Read source dictionary
249  virtual bool read(const dictionary& dict);
250 };
251 
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 } // End namespace fa
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #include "faceSetOptionI.H"
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: faOptionI.H:29
dictionary dict
rDeltaTY field()
void setFaceSelection()
Set face selection based on user input selection mode.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual ~faceSetOption()=default
Destructor.
scalar timeStart() const noexcept
Return const access to the time start.
"patch" : subset with (volume) patches
wordRes selectionNames_
Face selection names (for set, zone or patch selections)
const wordRes & selectionNames() const noexcept
Return const access to the selection names (set, zone or patch selection)
const wordRe & zoneName() const
Return const access to the first set/zone/patch name.
virtual bool isActive()
Is the source active?
selectionModeType selectionMode() const noexcept
Return the face selection mode.
scalar A() const noexcept
Return const access to the total face area.
bool useSubMesh() const noexcept
True if sub-selection should be used.
scalar timeStart_
Time start.
faceSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
A class for handling words, derived from Foam::string.
Definition: word.H:63
"faceZone" : subset with (volume) zone faces
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
"all" finite-area faces
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
const word & name() const noexcept
Return const access to the source name.
Definition: faOptionI.H:23
const labelList & faces() const noexcept
Return const access to the local finite-area face selection.
const direction noexcept
Definition: Scalar.H:258
bool inTimeLimits(const scalar timeValue) const
Return true if within time limits.
static const Enum< selectionModeType > selectionModeTypeNames_
List of selection mode type names.
scalar duration() const noexcept
Return const access to the duration.
selectionModeType selectionMode_
Face selection mode.
void setSelection(const dictionary &dict)
Set face selection name from dictionary input.
Definition: faceSetOption.C:52
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual bool read(const dictionary &dict)
Read source dictionary.
"faceSet" : subset with (volume) face set
void subsetFilter(List< Type > &field) const
Zero all non-selected locations within field.
scalar A_
Sum of face area.
List< label > labelList
A List of labels.
Definition: List.H:62
selectionModeType
Enumeration for selection mode types.
scalar duration_
Duration.
void setArea()
Recalculate the area.
TypeName("faceSetOption")
Runtime type information.
Namespace for OpenFOAM.
labelList faces_
Set of faces to apply source to.