faOption.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) 2019-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "faOption.H"
29 #include "areaFields.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  namespace fa
36  {
37  defineTypeNameAndDebug(option, 0);
39  }
40 }
41 
42 
43 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44 
46 {
48  applied_ = false;
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 (
56  const word& name,
57  const word& modelType,
58  const dictionary& dict,
59  const fvMesh& mesh
60 )
61 :
62  name_(name),
63  modelType_(modelType),
64  mesh_(mesh),
65  dict_(dict),
66  coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
67  fieldNames_(),
68  applied_(),
69  regionName_(dict.get<word>("region")),
70  regionMeshPtr_(nullptr),
71  vsmPtr_(nullptr),
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 area 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  "faOption",
108  modelType,
109  *dictionaryConstructorTablePtr_
110  ) << exit(FatalIOError);
111  }
113  return autoPtr<fa::option>(ctorPtr(name, modelType, coeffs, mesh));
114 }
115 
116 
117 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 {
121  return active_;
122 }
123 
125 Foam::label Foam::fa::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  const areaScalarField& h,
149  const label fieldi
150 )
151 {}
152 
153 
155 (
156  const areaScalarField& h,
158  const label fieldi
159 )
160 {}
161 
162 
164 (
165  const areaScalarField& h,
167  const label fieldi
168 )
169 {}
170 
171 
173 (
174  const areaScalarField& h,
176  const label fieldi
177 )
178 {}
179 
180 
182 (
183  const areaScalarField& h,
185  const label fieldi
186 )
187 {}
188 
189 
191 (
192  const areaScalarField& h,
193  const areaScalarField& rho,
195  const label fieldi
196 )
197 {}
198 
199 
201 (
202  const areaScalarField& h,
203  const areaScalarField& rho,
205  const label fieldi
206 )
207 {}
208 
209 
211 (
212  const areaScalarField& h,
213  const areaScalarField& rho,
215  const label fieldi
216 )
217 {}
218 
219 
221 (
222  const areaScalarField& h,
223  const areaScalarField& rho,
225  const label fieldi
226 )
227 {}
228 
229 
231 (
232  const areaScalarField& h,
234  faMatrix<tensor>& eqn,
235  const label fieldi
236 )
237 {}
238 
239 
240 void Foam::fa::option::constrain(faMatrix<scalar>& eqn, const label fieldi)
241 {}
243 
244 void Foam::fa::option::constrain(faMatrix<vector>& eqn, const label fieldi)
245 {}
246 
247 
249 (
251  const label fieldi
252 )
253 {}
254 
255 
257 (
259  const label fieldi
260 )
261 {}
262 
263 
264 void Foam::fa::option::constrain(faMatrix<tensor>& eqn, const label fieldi)
265 {}
266 
267 
269 {}
270 
271 
273 {}
274 
275 
277 {}
278 
279 
281 {}
282 
283 
285 {}
286 
287 
288 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
rDeltaTY field()
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:493
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: faOption.H:171
dimensionedScalar log(const dimensionedScalar &ds)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void constrain(faMatrix< scalar > &eqn, const label fieldi)
Definition: faOption.C:233
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Definition: ListI.H:175
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Base abstract class for handling finite area options (i.e. faOption).
Definition: faOption.H:129
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const word name_
Source name.
Definition: faOption.H:146
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void addSup(const areaScalarField &h, faMatrix< scalar > &eqn, const label fieldi)
Definition: faOption.C:139
virtual void checkApplied() const
Check that the source has been applied.
Definition: faOption.C:124
defineTypeNameAndDebug(limitHeight, 0)
virtual void correct(areaScalarField &field)
Definition: faOption.C:261
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:511
static autoPtr< option > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected faOption model.
Definition: faOption.C:75
const dimensionedScalar h
Planck constant.
defineRunTimeSelectionTable(option, dictionary)
#define WarningInFunction
Report a warning using Foam::Warning.
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: faOption.C:38
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
#define Log
Definition: PDRblock.C:28
A special matrix type and solver, designed for finite area solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: faMatricesFwd.H:37
option(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: faOption.C:48
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: faOption.C:118
virtual bool isActive()
Is the source active?
Definition: faOption.C:112
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
Definition: faOption.H:176
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:502
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
Namespace for OpenFOAM.
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Definition: areaFieldsFwd.H:80
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...