fvOption.C
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) 2019-2021 OpenCFD Ltd.
10 Copyright (C) 2020 PCOpt/NTUA
11 Copyright (C) 2020 FOSS GP
12-------------------------------------------------------------------------------
13License
14 This file is part of OpenFOAM.
15
16 OpenFOAM is free software: you can redistribute it and/or modify it
17 under the terms of the GNU General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28
29\*---------------------------------------------------------------------------*/
30
31#include "fvOption.H"
32#include "volFields.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
38 namespace fv
39 {
42 }
43}
44
45
46// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
47
49{
51 applied_ = false;
52}
53
54
55// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56
58(
59 const word& name,
60 const word& modelType,
61 const dictionary& dict,
62 const fvMesh& mesh
63)
64:
65 name_(name),
66 modelType_(modelType),
67 mesh_(mesh),
68 dict_(dict),
69 coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
70 fieldNames_(),
71 applied_(),
72 active_(dict_.getOrDefault("active", true)),
73 log(true)
74{
75 Log << incrIndent << indent << "Source: " << name_ << endl << decrIndent;
76}
77
78
79// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
80
82(
83 const word& name,
84 const dictionary& coeffs,
85 const fvMesh& mesh
86)
87{
88 const word modelType(coeffs.get<word>("type"));
89
90 Info<< indent
91 << "Selecting finite volume options type " << modelType << endl;
92
93 mesh.time().libs().open
94 (
95 coeffs,
96 "libs",
97 dictionaryConstructorTablePtr_
98 );
99
100 auto* ctorPtr = dictionaryConstructorTable(modelType);
101
102 if (!ctorPtr)
103 {
105 (
106 coeffs,
107 "fvOption",
108 modelType,
109 *dictionaryConstructorTablePtr_
110 ) << exit(FatalIOError);
111 }
112
113 return autoPtr<fv::option>(ctorPtr(name, modelType, coeffs, mesh));
114}
115
116
117// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118
120{
121 return active_;
122}
123
124
125Foam::label Foam::fv::option::applyToField(const word& fieldName) const
126{
127 return fieldNames_.find(fieldName);
128}
129
130
132{
133 forAll(applied_, i)
134 {
135 if (!applied_[i])
136 {
138 << "Source " << name_ << " defined for field "
139 << fieldNames_[i] << " but never used" << endl;
140 }
141 }
142}
143
144
146(
147 fvMatrix<scalar>& eqn,
148 const label fieldi
149)
150{}
151
152
154(
155 fvMatrix<vector>& eqn,
156 const label fieldi
157)
158{}
159
160
162(
164 const label fieldi
165)
166{}
167
168
170(
172 const label fieldi
173)
174{}
175
176
178(
179 fvMatrix<tensor>& eqn,
180 const label fieldi
181)
182{}
183
184
186(
187 const volScalarField& rho,
188 fvMatrix<scalar>& eqn,
189 const label fieldi
190)
191{}
192
193
195(
196 const volScalarField& rho,
197 fvMatrix<vector>& eqn,
198 const label fieldi
199)
200{}
201
202
204(
205 const volScalarField& rho,
207 const label fieldi
208)
209{}
210
211
213(
214 const volScalarField& rho,
216 const label fieldi
217)
218{}
219
220
222(
223 const volScalarField& rho,
224 fvMatrix<tensor>& eqn,
225 const label fieldi
226)
227{}
228
229
231(
232 const volScalarField& alpha,
233 const volScalarField& rho,
234 fvMatrix<scalar>& eqn,
235 const label fieldi
236)
237{
238 addSup(alpha*rho, eqn, fieldi);
239}
240
241
243(
244 const volScalarField& alpha,
245 const volScalarField& rho,
246 fvMatrix<vector>& eqn,
247 const label fieldi
248)
249{
250 addSup(alpha*rho, eqn, fieldi);
251}
252
253
255(
256 const volScalarField& alpha,
257 const volScalarField& rho,
259 const label fieldi
260)
261{
262 addSup(alpha*rho, eqn, fieldi);
263}
264
265
267(
268 const volScalarField& alpha,
269 const volScalarField& rho,
271 const label fieldi
272)
273{
274 addSup(alpha*rho, eqn, fieldi);
275}
276
277
279(
280 const volScalarField& alpha,
281 const volScalarField& rho,
282 fvMatrix<tensor>& eqn,
283 const label fieldi
284)
285{
286 addSup(alpha*rho, eqn, fieldi);
287}
288
289
290void Foam::fv::option::constrain(fvMatrix<scalar>& eqn, const label fieldi)
291{}
292
293
294void Foam::fv::option::constrain(fvMatrix<vector>& eqn, const label fieldi)
295{}
296
297
299(
301 const label fieldi
302)
303{}
304
305
307(
309 const label fieldi
310)
311{}
312
313
314void Foam::fv::option::constrain(fvMatrix<tensor>& eqn, const label fieldi)
315{}
316
317
319{}
320
321
323{}
324
325
327{}
328
329
331{}
332
333
335{}
336
337
339(
340 scalarField& sensField,
341 const word& fieldName,
342 const word& designVariablesName
343)
344{}
345
346
348(
349 vectorField& sensField,
350 const word& fieldName,
351 const word& designVariablesName
352)
353{}
354
355
357(
358 tensorField& sensField,
359 const word& fieldName,
360 const word& designVariablesName
361)
362{}
363
364
365// ************************************************************************* //
#define Log
Definition: PDRblock.C:35
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Definition: ListI.H:146
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
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
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Base abstract class for handling finite area options (i.e. faOption).
Definition: faOption.H:134
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:127
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
Definition: fvOption.H:151
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: fvOption.H:148
virtual void checkApplied() const
Check that the source has been applied.
Definition: fvOption.C:131
virtual void postProcessSens(scalarField &sensField, const word &fieldName=word::null, const word &designVariablesName=word::null)
Definition: fvOption.C:339
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: fvOption.C:125
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:146
virtual void constrain(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:290
virtual bool isActive()
Is the source active?
Definition: fvOption.C:119
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:48
const word name_
Source name.
Definition: fvOption.H:133
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
rDeltaTY field()
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
dimensionedScalar log(const dimensionedScalar &ds)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:349
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:342
IOerror FatalIOError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:356
labelList fv(nPoints)
volScalarField & alpha
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333