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 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "fvOption.H"
30 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  namespace fv
37  {
40  }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  const word& name,
49  const word& modelType,
50  const dictionary& dict,
51  const fvMesh& mesh
52 )
53 :
54  name_(name),
55  modelType_(modelType),
56  mesh_(mesh),
57  dict_(dict),
58  coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
59  active_(dict_.lookupOrDefault<Switch>("active", true)),
60  fieldNames_(),
61  applied_(),
62  log(true)
63 {
64  Log << incrIndent << indent << "Source: " << name_ << endl << decrIndent;
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
69 
71 (
72  const word& name,
73  const dictionary& coeffs,
74  const fvMesh& mesh
75 )
76 {
77  const word modelType(coeffs.get<word>("type"));
78 
79  Info<< indent
80  << "Selecting finite volume options type " << modelType << endl;
81 
82  const_cast<Time&>(mesh.time()).libs().open
83  (
84  coeffs,
85  "libs",
86  dictionaryConstructorTablePtr_
87  );
88 
89  auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
90 
91  if (!cstrIter.found())
92  {
94  (
95  coeffs,
96  "fvOption",
97  modelType,
98  *dictionaryConstructorTablePtr_
99  ) << exit(FatalIOError);
100  }
101 
102  return autoPtr<option>(cstrIter()(name, modelType, coeffs, mesh));
103 }
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
109 {
110  return active_;
111 }
112 
113 
115 {
116  return fieldNames_.find(fieldName);
117 }
118 
119 
121 {
122  forAll(applied_, i)
123  {
124  if (!applied_[i])
125  {
127  << "Source " << name_ << " defined for field "
128  << fieldNames_[i] << " but never used" << endl;
129  }
130  }
131 }
132 
133 
135 (
136  fvMatrix<scalar>& eqn,
137  const label fieldi
138 )
139 {}
140 
141 
143 (
144  fvMatrix<vector>& eqn,
145  const label fieldi
146 )
147 {}
148 
149 
151 (
153  const label fieldi
154 )
155 {}
156 
157 
159 (
161  const label fieldi
162 )
163 {}
164 
165 
167 (
168  fvMatrix<tensor>& eqn,
169  const label fieldi
170 )
171 {}
172 
173 
175 (
176  const volScalarField& rho,
177  fvMatrix<scalar>& eqn,
178  const label fieldi
179 )
180 {}
181 
182 
184 (
185  const volScalarField& rho,
186  fvMatrix<vector>& eqn,
187  const label fieldi
188 )
189 {}
190 
191 
193 (
194  const volScalarField& rho,
196  const label fieldi
197 )
198 {}
199 
200 
202 (
203  const volScalarField& rho,
205  const label fieldi
206 )
207 {}
208 
209 
211 (
212  const volScalarField& rho,
213  fvMatrix<tensor>& eqn,
214  const label fieldi
215 )
216 {}
217 
218 
220 (
221  const volScalarField& alpha,
222  const volScalarField& rho,
223  fvMatrix<scalar>& eqn,
224  const label fieldi
225 )
226 {
227  addSup(alpha*rho, eqn, fieldi);
228 }
229 
230 
232 (
233  const volScalarField& alpha,
234  const volScalarField& rho,
235  fvMatrix<vector>& eqn,
236  const label fieldi
237 )
238 {
239  addSup(alpha*rho, eqn, fieldi);
240 }
241 
242 
244 (
245  const volScalarField& alpha,
246  const volScalarField& rho,
248  const label fieldi
249 )
250 {
251  addSup(alpha*rho, eqn, fieldi);
252 }
253 
254 
256 (
257  const volScalarField& alpha,
258  const volScalarField& rho,
260  const label fieldi
261 )
262 {
263  addSup(alpha*rho, eqn, fieldi);
264 }
265 
266 
268 (
269  const volScalarField& alpha,
270  const volScalarField& rho,
271  fvMatrix<tensor>& eqn,
272  const label fieldi
273 )
274 {
275  addSup(alpha*rho, eqn, fieldi);
276 }
277 
278 
280 {}
281 
282 
284 {}
285 
286 
288 (
290  const label fieldi
291 )
292 {}
293 
294 
296 (
298  const label fieldi
299 )
300 {}
301 
302 
304 {}
305 
306 
308 {}
309 
310 
312 {}
313 
314 
316 {}
317 
318 
320 {}
321 
322 
324 {}
325 
326 
327 // ************************************************************************* //
Foam::fv::option::correct
virtual void correct(volScalarField &field)
Definition: fvOption.C:307
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:70
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
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:120
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:337
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:314
rho
rho
Definition: readInitialConditions.H:96
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::fv::option::applyToField
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: fvOption.C:114
Foam::fv::option::option
option(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvOption.C:47
Foam::fv::option::addSup
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:135
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:380
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::fv::option
Finite volume options abstract base class. Provides a base set of controls, e.g.:
Definition: fvOption.H:69
Foam::fv::option::active_
Switch active_
Source active flag.
Definition: fvOption.H:91
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:279
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:84
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:71
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:321
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:307
Foam::fv::option::isActive
virtual bool isActive()
Is the source active?
Definition: fvOption.C:108
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
fv
labelList fv(nPoints)
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(option, 0)
Foam::autoPtr< Foam::fv::option >
Foam::HashTable::cfind
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
Definition: HashTableI.H:141
fvOption.H
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::GeometricField< scalar, fvPatchField, volMesh >
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
Log
#define Log
Report write to Foam::Info if the local log switch is true.
Definition: messageStream.H:332