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-2020 OpenCFD Ltd.
10  Copyright (C) 2020 PCOpt/NTUA
11  Copyright (C) 2020 FOSS GP
12 -------------------------------------------------------------------------------
13 License
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 
36 namespace Foam
37 {
38  namespace fv
39  {
40  defineTypeNameAndDebug(option, 0);
41  defineRunTimeSelectionTable(option, dictionary);
42  }
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const word& name,
51  const word& modelType,
52  const dictionary& dict,
53  const fvMesh& mesh
54 )
55 :
56  name_(name),
57  modelType_(modelType),
58  mesh_(mesh),
59  dict_(dict),
60  coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
61  active_(dict_.getOrDefault<Switch>("active", true)),
62  fieldNames_(),
63  applied_(),
64  log(true)
65 {
66  Log << incrIndent << indent << "Source: " << name_ << endl << decrIndent;
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
71 
73 (
74  const word& name,
75  const dictionary& coeffs,
76  const fvMesh& mesh
77 )
78 {
79  const word modelType(coeffs.get<word>("type"));
80 
81  Info<< indent
82  << "Selecting finite volume options type " << modelType << endl;
83 
84  mesh.time().libs().open
85  (
86  coeffs,
87  "libs",
88  dictionaryConstructorTablePtr_
89  );
90 
91  auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
92 
93  if (!cstrIter.found())
94  {
96  (
97  coeffs,
98  "fvOption",
99  modelType,
100  *dictionaryConstructorTablePtr_
101  ) << exit(FatalIOError);
102  }
103 
104  return autoPtr<option>(cstrIter()(name, modelType, coeffs, mesh));
105 }
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  return active_;
113 }
114 
115 
116 Foam::label Foam::fv::option::applyToField(const word& fieldName) const
117 {
118  return fieldNames_.find(fieldName);
119 }
120 
121 
123 {
124  forAll(applied_, i)
125  {
126  if (!applied_[i])
127  {
129  << "Source " << name_ << " defined for field "
130  << fieldNames_[i] << " but never used" << endl;
131  }
132  }
133 }
134 
135 
137 (
138  fvMatrix<scalar>& eqn,
139  const label fieldi
140 )
141 {}
142 
143 
145 (
146  fvMatrix<vector>& eqn,
147  const label fieldi
148 )
149 {}
150 
151 
153 (
155  const label fieldi
156 )
157 {}
158 
159 
161 (
163  const label fieldi
164 )
165 {}
166 
167 
169 (
170  fvMatrix<tensor>& eqn,
171  const label fieldi
172 )
173 {}
174 
175 
177 (
178  const volScalarField& rho,
179  fvMatrix<scalar>& eqn,
180  const label fieldi
181 )
182 {}
183 
184 
186 (
187  const volScalarField& rho,
188  fvMatrix<vector>& eqn,
189  const label fieldi
190 )
191 {}
192 
193 
195 (
196  const volScalarField& rho,
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,
215  fvMatrix<tensor>& eqn,
216  const label fieldi
217 )
218 {}
219 
220 
222 (
223  const volScalarField& alpha,
224  const volScalarField& rho,
225  fvMatrix<scalar>& eqn,
226  const label fieldi
227 )
228 {
229  addSup(alpha*rho, eqn, fieldi);
230 }
231 
232 
234 (
235  const volScalarField& alpha,
236  const volScalarField& rho,
237  fvMatrix<vector>& eqn,
238  const label fieldi
239 )
240 {
241  addSup(alpha*rho, eqn, fieldi);
242 }
243 
244 
246 (
247  const volScalarField& alpha,
248  const volScalarField& rho,
250  const label fieldi
251 )
252 {
253  addSup(alpha*rho, eqn, fieldi);
254 }
255 
256 
258 (
259  const volScalarField& alpha,
260  const volScalarField& rho,
262  const label fieldi
263 )
264 {
265  addSup(alpha*rho, eqn, fieldi);
266 }
267 
268 
270 (
271  const volScalarField& alpha,
272  const volScalarField& rho,
273  fvMatrix<tensor>& eqn,
274  const label fieldi
275 )
276 {
277  addSup(alpha*rho, eqn, fieldi);
278 }
279 
280 
281 void Foam::fv::option::constrain(fvMatrix<scalar>& eqn, const label fieldi)
282 {}
283 
284 
285 void Foam::fv::option::constrain(fvMatrix<vector>& eqn, const label fieldi)
286 {}
287 
288 
290 (
292  const label fieldi
293 )
294 {}
295 
296 
298 (
300  const label fieldi
301 )
302 {}
303 
304 
305 void Foam::fv::option::constrain(fvMatrix<tensor>& eqn, const label fieldi)
306 {}
307 
308 
310 {}
311 
312 
314 {}
315 
316 
318 {}
319 
320 
322 {}
323 
324 
326 {}
327 
328 
330 (
331  scalarField& sensField,
332  const word& fieldName,
333  const word& designVariablesName
334 )
335 {}
336 
337 
339 (
340  vectorField& sensField,
341  const word& fieldName,
342  const word& designVariablesName
343 )
344 {}
345 
346 
348 (
349  tensorField& sensField,
350  const word& fieldName,
351  const word& designVariablesName
352 )
353 {}
354 
355 
356 // ************************************************************************* //
Foam::fv::option::correct
virtual void correct(volScalarField &field)
Definition: fvOption.C:309
volFields.H
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Log
#define Log
Definition: PDRblock.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fv::option::checkApplied
virtual void checkApplied() const
Check that the source has been applied.
Definition: fvOption.C:122
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:327
rho
rho
Definition: readInitialConditions.H:88
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fv::option::applyToField
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: fvOption.C:116
Foam::fv::option::option
option(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvOption.C:49
Foam::fv::option::addSup
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:137
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:406
Foam::Field< scalar >
Foam::fv::option::active_
Switch active_
Source active flag.
Definition: fvOption.H:148
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
field
rDeltaTY field()
Foam::fv::defineRunTimeSelectionTable
defineRunTimeSelectionTable(option, dictionary)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fv::option::constrain
virtual void constrain(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:281
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:262
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam::fv::option::New
static autoPtr< option > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvOption model.
Definition: fvOption.C:73
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:334
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:320
Foam::fv::option::postProcessSens
virtual void postProcessSens(scalarField &sensField, const word &fieldName=word::null, const word &designVariablesName=word::null)
Definition: fvOption.C:330
Foam::fv::option::isActive
virtual bool isActive()
Is the source active?
Definition: fvOption.C:110
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
fv
labelList fv(nPoints)
Foam::autoPtr< Foam::fv::option >
fvOption.H
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
Foam::GeometricField< scalar, fvPatchField, volMesh >
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:303