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 "faMesh.H"
104 #include "Time.H"
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 namespace Foam
109 {
110 namespace fa
111 {
112 
113 /*---------------------------------------------------------------------------*\
114  Class faceSetOption Declaration
115 \*---------------------------------------------------------------------------*/
116 
117 class faceSetOption
118 :
119  public fa::option
120 {
121 public:
122 
123  // Public Enumeration
124 
125  //- Enumeration for selection mode types
126  enum selectionModeType
127  {
128  smAll,
129  smFaceSet,
130  smFaceZone,
131  smPatch,
132  };
133 
134  //- List of selection mode type names
135  static const Enum<selectionModeType> selectionModeTypeNames_;
136 
137 
138 protected:
139 
140  // Protected Data
141 
142  //- Time start
143  scalar timeStart_;
144 
145  //- Duration
146  scalar duration_;
147 
148  //- Face selection mode
150 
151  //- Face selection names (for set, zone or patch selections)
152  wordRes selectionNames_;
153 
154  //- Set of faces to apply source to
156 
157  //- Sum of face area
158  scalar A_;
159 
160 
161  // Protected Functions
162 
163  //- Set face selection name from dictionary input
164  void setSelection(const dictionary& dict);
165 
166  //- Set face selection based on user input selection mode
167  void setFaceSelection();
169  //- Recalculate the area
170  void setArea();
171 
172  //- Zero all non-selected locations within field
173  template<class Type>
174  inline void subsetFilter(List<Type>& field) const;
175 
176 
177 public:
178 
179  //- Runtime type information
180  TypeName("faceSetOption");
183  // Constructors
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 ~faceSetOption() = default;
197 
198 
199  // Member Functions
201  // Access
202 
203  //- Return const access to the time start
204  inline scalar timeStart() const noexcept;
206  //- Return const access to the duration
207  inline scalar duration() const noexcept;
208 
209  //- Return true if within time limits
210  inline bool inTimeLimits(const scalar timeValue) const;
211 
212  //- True if sub-selection should be used
213  inline bool useSubMesh() const noexcept;
214 
215  //- Return the face selection mode
217 
218  //- Return const access to the selection names
219  //- (set, zone or patch selection)
220  inline const wordRes& selectionNames() const noexcept;
221 
222  //- Return const access to the first set/zone/patch name
223  inline const wordRe& zoneName() const;
224 
225  //- Return const access to the total face area
226  inline scalar A() const noexcept;
227 
228  //- Return const access to the local finite-area face selection
229  inline const labelList& faces() const noexcept;
230 
231 
232  // Edit
233 
234  //- Adjust the time start, return the old value
235  inline scalar timeStart(scalar val) noexcept;
236 
237  //- Adjust the duration, return the old value
238  inline scalar duration(scalar val) noexcept;
239 
240 
241  // Checks
242 
243  //- Is the source active?
244  virtual bool isActive();
245 
246 
247  // IO
248 
249  //- Read source dictionary
250  virtual bool read(const dictionary& dict);
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace fa
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #include "faceSetOptionI.H"
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 #endif
266 
267 // ************************************************************************* //
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:120
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:47
"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:79
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.