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 | Copyright (C) 2011-2016 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.subDict(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  dictionaryConstructorTable::iterator cstrIter =
79  dictionaryConstructorTablePtr_->find(modelType);
80 
81  if (cstrIter == dictionaryConstructorTablePtr_->end())
82  {
84  << "Unknown Model type " << modelType << nl << nl
85  << "Valid model types are:" << nl
86  << dictionaryConstructorTablePtr_->sortedToc()
87  << exit(FatalError);
88  }
89 
90  return autoPtr<option>(cstrIter()(name, modelType, coeffs, mesh));
91 }
92 
93 
95 {}
96 
97 
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 
101 {
102  return active_;
103 }
104 
105 
107 {
108  return findIndex(fieldNames_, fieldName);
109 }
110 
111 
113 {
114  forAll(applied_, i)
115  {
116  if (!applied_[i])
117  {
119  << "Source " << name_ << " defined for field "
120  << fieldNames_[i] << " but never used" << endl;
121  }
122  }
123 }
124 
125 
127 (
128  fvMatrix<scalar>& eqn,
129  const label fieldi
130 )
131 {}
132 
133 
135 (
136  fvMatrix<vector>& eqn,
137  const label fieldi
138 )
139 {}
140 
141 
143 (
145  const label fieldi
146 )
147 {}
148 
149 
151 (
153  const label fieldi
154 )
155 {}
156 
157 
159 (
160  fvMatrix<tensor>& eqn,
161  const label fieldi
162 )
163 {}
164 
165 
167 (
168  const volScalarField& rho,
169  fvMatrix<scalar>& eqn,
170  const label fieldi
171 )
172 {}
173 
174 
176 (
177  const volScalarField& rho,
178  fvMatrix<vector>& eqn,
179  const label fieldi
180 )
181 {}
182 
183 
185 (
186  const volScalarField& rho,
188  const label fieldi
189 )
190 {}
191 
192 
194 (
195  const volScalarField& rho,
197  const label fieldi
198 )
199 {}
200 
201 
203 (
204  const volScalarField& rho,
205  fvMatrix<tensor>& eqn,
206  const label fieldi
207 )
208 {}
209 
210 
212 (
213  const volScalarField& alpha,
214  const volScalarField& rho,
215  fvMatrix<scalar>& eqn,
216  const label fieldi
217 )
218 {
219  addSup(alpha*rho, eqn, fieldi);
220 }
221 
222 
224 (
225  const volScalarField& alpha,
226  const volScalarField& rho,
227  fvMatrix<vector>& eqn,
228  const label fieldi
229 )
230 {
231  addSup(alpha*rho, eqn, fieldi);
232 }
233 
234 
236 (
237  const volScalarField& alpha,
238  const volScalarField& rho,
240  const label fieldi
241 )
242 {
243  addSup(alpha*rho, eqn, fieldi);
244 }
245 
246 
248 (
249  const volScalarField& alpha,
250  const volScalarField& rho,
252  const label fieldi
253 )
254 {
255  addSup(alpha*rho, eqn, fieldi);
256 }
257 
258 
260 (
261  const volScalarField& alpha,
262  const volScalarField& rho,
263  fvMatrix<tensor>& eqn,
264  const label fieldi
265 )
266 {
267  addSup(alpha*rho, eqn, fieldi);
268 }
269 
270 
272 {}
273 
274 
276 {}
277 
278 
280 (
282  const label fieldi
283 )
284 {}
285 
286 
288 (
290  const label fieldi
291 )
292 {}
293 
294 
296 {}
297 
298 
300 {}
301 
302 
304 {}
305 
306 
308 {}
309 
310 
312 {}
313 
314 
316 {}
317 
318 
319 // ************************************************************************* //
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:299
virtual ~option()
Destructor.
Definition: fvOption.C:94
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:223
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
virtual void checkApplied() const
Check that the source has been applied.
Definition: fvOption.C:112
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
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:633
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
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
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:127
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
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:71
static const char nl
Definition: Ostream.H:262
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:237
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
defineRunTimeSelectionTable(option, dictionary)
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: fvOption.C:106
#define WarningInFunction
Report a warning using Foam::Warning.
virtual void constrain(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:271
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:100
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:230
Namespace for OpenFOAM.
Finite volume options abstract base class. Provides a base set of controls, e.g.: ...
Definition: fvOption.H:66
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451