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-2015 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  {
35  defineTypeNameAndDebug(option, 0);
36  defineRunTimeSelectionTable(option, dictionary);
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  (
85  "option::New(const word&, const dictionary&, const fvMesh&)"
86  ) << "Unknown Model type " << modelType << nl << nl
87  << "Valid model types are:" << nl
88  << dictionaryConstructorTablePtr_->sortedToc()
89  << exit(FatalError);
90  }
91 
92  return autoPtr<option>(cstrIter()(name, modelType, coeffs, mesh));
93 }
94 
95 
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 {
104  return active_;
105 }
106 
107 
109 {
110  return findIndex(fieldNames_, fieldName);
111 }
112 
113 
115 {
116  forAll(applied_, i)
117  {
118  if (!applied_[i])
119  {
120  WarningIn("void option::checkApplied() const")
121  << "Source " << name_ << " defined for field "
122  << fieldNames_[i] << " but never used" << endl;
123  }
124  }
125 }
126 
127 
129 (
130  fvMatrix<scalar>& eqn,
131  const label fieldI
132 )
133 {}
134 
135 
137 (
138  fvMatrix<vector>& eqn,
139  const label fieldI
140 )
141 {}
142 
143 
145 (
147  const label fieldI
148 )
149 {}
150 
151 
153 (
155  const label fieldI
156 )
157 {}
158 
159 
161 (
162  fvMatrix<tensor>& eqn,
163  const label fieldI
164 )
165 {}
166 
167 
169 (
170  const volScalarField& rho,
171  fvMatrix<scalar>& eqn,
172  const label fieldI
173 )
174 {}
175 
176 
178 (
179  const volScalarField& rho,
180  fvMatrix<vector>& eqn,
181  const label fieldI
182 )
183 {}
184 
185 
187 (
188  const volScalarField& rho,
190  const label fieldI
191 )
192 {}
193 
194 
196 (
197  const volScalarField& rho,
199  const label fieldI
200 )
201 {}
202 
203 
205 (
206  const volScalarField& rho,
207  fvMatrix<tensor>& eqn,
208  const label fieldI
209 )
210 {}
211 
212 
214 (
215  const volScalarField& alpha,
216  const volScalarField& rho,
217  fvMatrix<scalar>& eqn,
218  const label fieldI
219 )
220 {
221  addSup(alpha*rho, eqn, fieldI);
222 }
223 
224 
226 (
227  const volScalarField& alpha,
228  const volScalarField& rho,
229  fvMatrix<vector>& eqn,
230  const label fieldI
231 )
232 {
233  addSup(alpha*rho, eqn, fieldI);
234 }
235 
236 
238 (
239  const volScalarField& alpha,
240  const volScalarField& rho,
242  const label fieldI
243 )
244 {
245  addSup(alpha*rho, eqn, fieldI);
246 }
247 
248 
250 (
251  const volScalarField& alpha,
252  const volScalarField& rho,
254  const label fieldI
255 )
256 {
257  addSup(alpha*rho, eqn, fieldI);
258 }
259 
260 
262 (
263  const volScalarField& alpha,
264  const volScalarField& rho,
265  fvMatrix<tensor>& eqn,
266  const label fieldI
267 )
268 {
269  addSup(alpha*rho, eqn, fieldI);
270 }
271 
272 
274 {}
275 
276 
278 {}
279 
280 
282 (
284  const label fieldI
285 )
286 {}
287 
288 
290 (
292  const label fieldI
293 )
294 {}
295 
296 
298 {}
299 
300 
302 {}
303 
304 
306 {}
307 
308 
310 {}
311 
312 
314 {}
315 
316 
318 {}
319 
320 
321 // ************************************************************************* //
defineTypeNameAndDebug(cellSetOption, 0)
virtual ~option()
Destructor.
Definition: fvOption.C:96
virtual bool isActive()
Is the source active?
Definition: fvOption.C:102
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
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
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
virtual void constrain(fvMatrix< scalar > &eqn, const label fieldI)
Definition: fvOption.C:273
A class for handling words, derived from string.
Definition: word.H:59
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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:68
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
messageStream Info
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:638
Namespace for OpenFOAM.
virtual void checkApplied() const
Check that the source has been applied.
Definition: fvOption.C:114
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldI)
Definition: fvOption.C:129
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
virtual void correct(volScalarField &field)
Definition: fvOption.C:301
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
#define WarningIn(functionName)
Report a warning using Foam::Warning.
#define forAll(list, i)
Definition: UList.H:421
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
defineRunTimeSelectionTable(option, dictionary)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
labelList fv(nPoints)
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: fvOption.C:108
option(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvOption.C:44