faOption.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-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::fa::option
28
29Description
30 Base abstract class for handling finite area options (i.e. \c faOption).
31
32Usage
33 Minimal example by using \c constant/faOptions:
34 \verbatim
35 <userDefinedName1>
36 {
37 // Mandatory entries (unmodifiable)
38 type <faOptionName>;
39
40 // Mandatory entries (runtime modifiable)
41 region <regionName>;
42
43 // Optional entries (unmodifiable/runtime modifiable)
44 <faOption>Coeffs
45 {
46 // subdictionary entries
47 }
48
49 // Optional entries (runtime modifiable)
50 active true;
51 log true;
52 }
53 \endverbatim
54
55 where the entries mean:
56 \table
57 Property | Description | Type | Reqd | Dflt
58 type | Name of operand faOption | word | yes | -
59 region | Name of operand region | word | yes | -
60 <faOption>Coeffs | Dictionary containing settings of <!--
61 --> the selected faOption settings | dictionary | no | -
62 active | Flag to (de)activate faOption | bool | no | true
63 log | Flag to log faOption-related info | bool | no | true
64 \endtable
65
66Note
67 - Source/sink options are to be added to the right-hand side of equations.
68
69SourceFiles
70 faOption.C
71 faOptionIO.C
72
73\*---------------------------------------------------------------------------*/
74
75#ifndef Foam_faOption_H
76#define Foam_faOption_H
77
78#include "faMatricesFwd.H"
79#include "areaFieldsFwd.H"
80#include "dictionary.H"
81#include "fvMesh.H"
82#include "volSurfaceMapping.H"
84
85// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86
87namespace Foam
88{
89namespace fa
90{
91
92/*---------------------------------------------------------------------------*\
93 Class option Declaration
94\*---------------------------------------------------------------------------*/
95
96class option
97{
98 // Private Member Functions
99
100 //- Construct region mesh and fields
101 void constructMeshObjects();
102
103
104protected:
105
106 // Protected Data
107
108 //- Source name
109 const word name_;
110
111 //- Model type
112 const word modelType_;
113
114 //- Reference to the mesh database
115 const fvMesh& mesh_;
116
117 //- Reference to the patch
118 const fvPatch& patch_;
119
120 //- Top level source dictionary
121 dictionary dict_;
122
123 //- Dictionary containing source coefficients
124 dictionary coeffs_;
125
126 //- Field names to apply source to - populated by derived models
128
129 //- Applied flag list - corresponds to each fieldNames_ entry
130 List<bool> applied_;
131
132 //- Region name (finite-area)
134
135
136 // Protected Member Functions
137
138 //- Resize/reset applied flag list for all fieldNames_ entries
139 void resetApplied();
140
141
142private:
143
144 // Private Data
145
146 //- Demand-driven: pointer to region mesh database
147 mutable autoPtr<faMesh> regionMeshPtr_;
148
149 //- Demand-driven: volume-to-surface mapping
150 mutable autoPtr<volSurfaceMapping> vsmPtr_;
151
152 //- Source active flag
153 bool active_;
154
156public:
157
158 //- Switch write log to Info
159 bool log;
160
162 //- Runtime type information
163 TypeName("option");
165
166 // Declare run-time constructor selection table
169 (
171 option,
173 (
174 const word& name,
175 const word& modelType,
176 const dictionary& dict,
177 const fvPatch& patch
178 ),
179 (name, modelType, dict, patch)
180 );
181
182
183 // Constructors
184
185 //- Construct from components
186 option
187 (
188 const word& name,
189 const word& modelType,
190 const dictionary& dict,
191 const fvPatch& patch
192 );
193
194 //- Return clone
195 autoPtr<option> clone() const
198 return nullptr;
199 }
201 //- Return pointer to new faOption object created
202 //- on the freestore from an Istream
203 class iNew
204 {
205 //- Reference to the patch
206 const fvPatch& patch_;
207
208 //- Name
209 const word& name_;
210
211 public:
212
213 iNew
214 (
215 const fvPatch& patch,
216 const word& name
217 )
218 :
219 patch_(patch),
220 name_(name)
221 {}
222
224 {
225 const dictionary dict(is);
226
227 return autoPtr<option>
228 (
229 option::New(name_, dict, patch_)
230 );
231 }
232 };
233
234
235 // Selectors
236
237 //- Return a reference to the selected faOption model
238 static autoPtr<option> New
239 (
240 const word& name,
241 const dictionary& dict,
242 const fvPatch& patch
243 );
244
245
246 //- Destructor
247 virtual ~option() = default;
248
249
250 // Member Functions
251
252 // Access
253
254 //- Return const access to the source name
255 inline const word& name() const noexcept;
256
257 //- Return const access to the mesh database
258 inline const fvMesh& mesh() const noexcept;
259
260 //- Return const access to fvPatch
261 inline const fvPatch& patch() const noexcept;
262
263 //- Return dictionary
264 inline const dictionary& coeffs() const noexcept;
265
266 //- True if source is active
267 inline bool active() const noexcept;
268
269 //- Set the applied flag to true for field index fieldi
270 inline void setApplied(const label fieldi);
271
272 //- The region name
273 inline const word& regionName() const noexcept;
274
275 //- Return the region mesh database (demand-driven)
276 inline const faMesh& regionMesh() const;
277
278 //- Return volSurfaceMapping (demand-driven)
279 inline const volSurfaceMapping& vsm() const;
280
281
282 // Edit
283
284 //- Change source active flag, return previous value
285 inline bool active(const bool on) noexcept;
286
287
288 // Checks
289
290 //- Is the source active?
291 virtual bool isActive();
292
293 //- Return index of field name if found in fieldNames list
294 virtual label applyToField(const word& fieldName) const;
295
296 //- Check that the source has been applied
297 virtual void checkApplied() const;
298
299
300 // Evaluation
301
302 // Explicit and implicit sources
303
304 virtual void addSup
305 (
306 const areaScalarField& h,
307 faMatrix<scalar>& eqn,
308 const label fieldi
309 );
310
311 virtual void addSup
312 (
313 const areaScalarField& h,
314 faMatrix<vector>& eqn,
315 const label fieldi
316 );
317
318 virtual void addSup
319 (
320 const areaScalarField& h,
321 faMatrix<symmTensor>& eqn,
322 const label fieldi
323 );
324
325 virtual void addSup
326 (
327 const areaScalarField& h,
329 const label fieldi
330 );
331
332 virtual void addSup
333 (
334 const areaScalarField& h,
335 faMatrix<tensor>& eqn,
336 const label fieldi
337 );
338
339
340 // Explicit and implicit sources for compressible equations
341
342 virtual void addSup
343 (
344 const areaScalarField& h,
345 const areaScalarField& rho,
346 faMatrix<scalar>& eqn,
347 const label fieldi
348 );
349
350 virtual void addSup
351 (
352 const areaScalarField& h,
353 const areaScalarField& rho,
354 faMatrix<vector>& eqn,
355 const label fieldi
356 );
357
358 virtual void addSup
359 (
360 const areaScalarField& h,
361 const areaScalarField& rho,
362 faMatrix<symmTensor>& eqn,
363 const label fieldi
364 );
365
366 virtual void addSup
367 (
368 const areaScalarField& h,
369 const areaScalarField& rho,
371 const label fieldi
372 );
373
374 virtual void addSup
375 (
376 const areaScalarField& h,
377 const areaScalarField& rho,
378 faMatrix<tensor>& eqn,
379 const label fieldi
380 );
381
382
383 // Constraints
384
385 virtual void constrain
386 (
387 faMatrix<scalar>& eqn,
388 const label fieldi
389 );
390
391 virtual void constrain
392 (
393 faMatrix<vector>& eqn,
394 const label fieldi
395 );
396
397 virtual void constrain
398 (
400 const label fieldi
401 );
402
403 virtual void constrain
404 (
405 faMatrix<symmTensor>& eqn,
406 const label fieldi
407 );
408
409 virtual void constrain
410 (
411 faMatrix<tensor>& eqn,
412 const label fieldi
413 );
414
415
416 // Correction
417
418 virtual void correct(areaScalarField& field);
419 virtual void correct(areaVectorField& field);
421 virtual void correct(areaSymmTensorField& field);
422 virtual void correct(areaTensorField& field);
423
424
425 // IO
426
427 //- Write the source header information
428 virtual void writeHeader(Ostream&) const;
429
430 //- Write the source footer information
431 virtual void writeFooter(Ostream&) const;
432
433 //- Write the source properties
434 virtual void writeData(Ostream&) const;
435
436 //- Read source dictionary
437 virtual bool read(const dictionary& dict);
438};
439
440
441// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
442
443} // End namespace fa
444} // End namespace Foam
445
446// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
447
448#include "faOptionI.H"
449
450// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
451
452#endif
453
454// ************************************************************************* //
Forwards and collection of common area field types.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatrix.H:76
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
autoPtr< option > operator()(Istream &is) const
Definition: faOption.H:260
iNew(const fvPatch &patch, const word &name)
Definition: faOption.H:251
Base abstract class for handling finite area options (i.e. faOption).
Definition: faOption.H:134
autoPtr< option > clone() const
Return clone.
Definition: faOption.H:232
const word modelType_
Model type.
Definition: faOption.H:149
const word & name() const noexcept
Return const access to the source name.
Definition: faOptionI.H:30
const dictionary & coeffs() const noexcept
Return dictionary.
Definition: faOptionI.H:48
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
Definition: faOption.H:167
const fvMesh & mesh_
Reference to the mesh database.
Definition: faOption.H:152
void setApplied(const label fieldi)
Set the applied flag to true for field index fieldi.
Definition: faOptionI.H:68
virtual ~option()=default
Destructor.
word regionName_
Region name (finite-area)
Definition: faOption.H:170
TypeName("option")
Runtime type information.
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: faOption.H:164
virtual void addSup(const areaScalarField &h, faMatrix< scalar > &eqn, const label fieldi)
Definition: faOption.C:147
virtual void checkApplied() const
Check that the source has been applied.
Definition: faOption.C:132
dictionary dict_
Top level source dictionary.
Definition: faOption.H:158
bool active() const noexcept
True if source is active.
Definition: faOptionI.H:54
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: faOption.C:126
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: faOptionIO.C:54
dictionary coeffs_
Dictionary containing source coefficients.
Definition: faOption.H:161
declareRunTimeSelectionTable(autoPtr, option, dictionary,(const word &name, const word &modelType, const dictionary &dict, const fvPatch &patch),(name, modelType, dict, patch))
virtual void writeHeader(Ostream &) const
Write the source header information.
Definition: faOptionIO.C:32
virtual void writeFooter(Ostream &) const
Write the source footer information.
Definition: faOptionIO.C:38
const word & regionName() const noexcept
The region name.
Definition: faOptionI.H:74
virtual bool isActive()
Is the source active?
Definition: faOption.C:120
static autoPtr< option > New(const word &name, const dictionary &dict, const fvPatch &patch)
Return a reference to the selected faOption model.
Definition: faOption.C:83
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: faOption.C:45
const fvPatch & patch_
Reference to the patch.
Definition: faOption.H:155
virtual void writeData(Ostream &) const
Write the source properties.
Definition: faOptionIO.C:44
virtual void constrain(faMatrix< scalar > &eqn, const label fieldi)
Definition: faOption.C:241
const volSurfaceMapping & vsm() const
Return volSurfaceMapping (demand-driven)
Definition: faOptionI.H:90
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: faOptionI.H:36
const faMesh & regionMesh() const
Return the region mesh database (demand-driven)
Definition: faOptionI.H:80
const fvPatch & patch() const noexcept
Return const access to fvPatch.
Definition: faOptionI.H:42
bool log
Switch write log to Info.
Definition: faOption.H:196
const word name_
Source name.
Definition: faOption.H:146
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
Volume to surface and surface to volume mapping.
A class for handling words, derived from Foam::string.
Definition: word.H:68
thermo correct()
rDeltaTY field()
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Forward declarations of standard faMatrix types/specializations.
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
const direction noexcept
Definition: Scalar.H:223
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
volScalarField & h
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73