fvOption.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fvOption.H"
27 #include "volFields.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  namespace fv
34  {
37  }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const word& name,
46  const word& modelType,
47  const dictionary& dict,
48  const fvMesh& mesh
49 )
50 :
51  name_(name),
52  modelType_(modelType),
53  mesh_(mesh),
54  dict_(dict),
55  coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
56  active_(dict_.lookupOrDefault<Switch>("active", true)),
57  fieldNames_(),
58  applied_()
59 {
60  Info<< incrIndent << indent << "Source: " << name_ << endl << decrIndent;
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
65 
67 (
68  const word& name,
69  const dictionary& coeffs,
70  const fvMesh& mesh
71 )
72 {
73  word modelType(coeffs.lookup("type"));
74 
75  Info<< indent
76  << "Selecting finite volume options model type " << modelType << endl;
77 
78  const_cast<Time&>(mesh.time()).libs().open
79  (
80  coeffs,
81  "libs",
82  dictionaryConstructorTablePtr_
83  );
84 
85  dictionaryConstructorTable::iterator cstrIter =
86  dictionaryConstructorTablePtr_->find(modelType);
87 
88  if (cstrIter == dictionaryConstructorTablePtr_->end())
89  {
91  << "Unknown Model type " << modelType << nl << nl
92  << "Valid model types are:" << nl
93  << dictionaryConstructorTablePtr_->sortedToc()
94  << exit(FatalError);
95  }
96 
97  return autoPtr<option>(cstrIter()(name, modelType, coeffs, mesh));
98 }
99 
100 
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
108 {
109  return active_;
110 }
111 
112 
114 {
115  return findIndex(fieldNames_, fieldName);
116 }
117 
118 
120 {
121  forAll(applied_, i)
122  {
123  if (!applied_[i])
124  {
126  << "Source " << name_ << " defined for field "
127  << fieldNames_[i] << " but never used" << endl;
128  }
129  }
130 }
131 
132 
134 (
135  fvMatrix<scalar>& eqn,
136  const label fieldi
137 )
138 {}
139 
140 
142 (
143  fvMatrix<vector>& eqn,
144  const label fieldi
145 )
146 {}
147 
148 
150 (
152  const label fieldi
153 )
154 {}
155 
156 
158 (
160  const label fieldi
161 )
162 {}
163 
164 
166 (
167  fvMatrix<tensor>& eqn,
168  const label fieldi
169 )
170 {}
171 
172 
174 (
175  const volScalarField& rho,
176  fvMatrix<scalar>& eqn,
177  const label fieldi
178 )
179 {}
180 
181 
183 (
184  const volScalarField& rho,
185  fvMatrix<vector>& eqn,
186  const label fieldi
187 )
188 {}
189 
190 
192 (
193  const volScalarField& rho,
195  const label fieldi
196 )
197 {}
198 
199 
201 (
202  const volScalarField& rho,
204  const label fieldi
205 )
206 {}
207 
208 
210 (
211  const volScalarField& rho,
212  fvMatrix<tensor>& eqn,
213  const label fieldi
214 )
215 {}
216 
217 
219 (
220  const volScalarField& alpha,
221  const volScalarField& rho,
222  fvMatrix<scalar>& eqn,
223  const label fieldi
224 )
225 {
226  addSup(alpha*rho, eqn, fieldi);
227 }
228 
229 
231 (
232  const volScalarField& alpha,
233  const volScalarField& rho,
234  fvMatrix<vector>& 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,
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,
270  fvMatrix<tensor>& eqn,
271  const label fieldi
272 )
273 {
274  addSup(alpha*rho, eqn, fieldi);
275 }
276 
277 
279 {}
280 
281 
283 {}
284 
285 
287 (
289  const label fieldi
290 )
291 {}
292 
293 
295 (
297  const label fieldi
298 )
299 {}
300 
301 
303 {}
304 
305 
307 {}
308 
309 
311 {}
312 
313 
315 {}
316 
317 
319 {}
320 
321 
323 {}
324 
325 
326 // ************************************************************************* //
defineTypeNameAndDebug(option, 0)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
virtual void correct(volScalarField &field)
Definition: fvOption.C:306
virtual ~option()
Destructor.
Definition: fvOption.C:101
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:59
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:226
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:142
static autoPtr< option > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvOption model.
Definition: fvOption.C:67
dynamicFvMesh & mesh
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:134
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:759
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
virtual void checkApplied() const
Check that the source has been applied.
Definition: fvOption.C:119
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
static const char nl
Definition: Ostream.H:265
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:240
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
defineRunTimeSelectionTable(option, dictionary)
#define WarningInFunction
Report a warning using Foam::Warning.
virtual void constrain(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:278
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
option(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvOption.C:44
virtual bool isActive()
Is the source active?
Definition: fvOption.C:107
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: fvOption.C:113
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:233
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576
Finite volume options abstract base class. Provides a base set of controls, e.g.: ...
Definition: fvOption.H:66