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 -------------------------------------------------------------------------------
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 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
47 
49 {
50  applied_.resize(fieldNames_.size());
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 
125 Foam::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 
290 void Foam::fv::option::constrain(fvMatrix<scalar>& eqn, const label fieldi)
291 {}
292 
293 
294 void 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 
314 void 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 // ************************************************************************* //
Foam::fv::option::correct
virtual void correct(volScalarField &field)
Definition: fvOption.C:318
volFields.H
Log
#define Log
Definition: PDRblock.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::List::resize
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::fv::option::resetApplied
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:48
Foam::fv::option::checkApplied
virtual void checkApplied() const
Check that the source has been applied.
Definition: fvOption.C:131
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:369
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:346
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:125
Foam::fv::option::option
option(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvOption.C:58
Foam::fv::option::addSup
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:146
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Foam::Field< scalar >
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::fv::option::fieldNames_
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: fvOption.H:148
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:290
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
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:85
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:82
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:353
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
Foam::fv::option::postProcessSens
virtual void postProcessSens(scalarField &sensField, const word &fieldName=word::null, const word &designVariablesName=word::null)
Definition: fvOption.C:339
Foam::fv::option::isActive
virtual bool isActive()
Is the source active?
Definition: fvOption.C:119
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:68
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
Foam::fv::option::applied_
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
Definition: fvOption.H:151
Foam::GeometricField< scalar, fvPatchField, volMesh >
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328