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-2021 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);
38  defineRunTimeSelectionTable(option, dictionary);
39  }
40 }
41 
42 
43 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44 
46 {
47  applied_.resize(fieldNames_.size());
48  applied_ = false;
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 (
56  const word& name,
57  const word& modelType,
58  const dictionary& dict,
59  const fvPatch& patch
60 )
61 :
62  name_(name),
63  modelType_(modelType),
64  mesh_(patch.boundaryMesh().mesh()),
65  patch_(patch),
66  dict_(dict),
67  coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
68  fieldNames_(),
69  applied_(),
70  regionName_(dict.get<word>("region")),
71  regionMeshPtr_(nullptr),
72  vsmPtr_(nullptr),
73  active_(dict.getOrDefault("active", true)),
74  log(true)
75 {
76  Log << incrIndent << indent << "Source: " << name_ << endl << decrIndent;
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
81 
83 (
84  const word& name,
85  const dictionary& coeffs,
86  const fvPatch& patch
87 )
88 {
89  const word modelType(coeffs.get<word>("type"));
90 
91  Info<< indent
92  << "Selecting finite area options type " << modelType << endl;
93 
94  const_cast<Time&>(patch.boundaryMesh().mesh().time()).libs().open
95  (
96  coeffs,
97  "libs",
98  dictionaryConstructorTablePtr_
99  );
100 
101  auto* ctorPtr = dictionaryConstructorTable(modelType);
102 
103  if (!ctorPtr)
104  {
106  << "Unknown faOption model type "
107  << modelType << nl << nl
108  << "Valid faOption types are:" << nl
109  << dictionaryConstructorTablePtr_->sortedToc()
110  << exit(FatalError);
111  }
112 
113  return autoPtr<option>(ctorPtr(name, modelType, coeffs, patch));
114 }
115 
116 
117 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 
120 {
121  return active_;
122 }
123 
124 
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,
148  faMatrix<scalar>& eqn,
149  const label fieldi
150 )
151 {}
152 
153 
155 (
156  const areaScalarField& h,
157  faMatrix<vector>& eqn,
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,
184  faMatrix<tensor>& eqn,
185  const label fieldi
186 )
187 {}
188 
189 
191 (
192  const areaScalarField& h,
193  const areaScalarField& rho,
194  faMatrix<scalar>& eqn,
195  const label fieldi
196 )
197 {}
198 
199 
201 (
202  const areaScalarField& h,
203  const areaScalarField& rho,
204  faMatrix<vector>& eqn,
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,
233  const areaScalarField& rho,
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 {}
242 
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 // ************************************************************************* //
Log
#define Log
Definition: PDRblock.C:35
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::faMatrix
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatricesFwd.H:43
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fa::option::constrain
virtual void constrain(faMatrix< scalar > &eqn, const label fieldi)
Definition: faOption.C:240
Foam::List::resize
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::fa::option::resetApplied
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: faOption.C:45
Foam::fa::option::addSup
virtual void addSup(const areaScalarField &h, faMatrix< scalar > &eqn, const label fieldi)
Definition: faOption.C:146
Foam::fa::option::checkApplied
virtual void checkApplied() const
Check that the source has been applied.
Definition: faOption.C:131
Foam::fa::option::option
option(const word &name, const word &modelType, const dictionary &dict, const fvPatch &patch)
Construct from components.
Definition: faOption.C:55
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::fa::option::New
static autoPtr< option > New(const word &name, const dictionary &dict, const fvPatch &patch)
Return a reference to the selected faOption model.
Definition: faOption.C:83
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:346
rho
rho
Definition: readInitialConditions.H:88
Foam::fa::defineTypeNameAndDebug
defineTypeNameAndDebug(limitVelocity, 0)
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fa::option::applyToField
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: faOption.C:125
Foam::fa::option::fieldNames_
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: faOption.H:164
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
field
rDeltaTY field()
areaFields.H
dict
dictionary dict
Definition: searchingEngine.H:14
faOption.H
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:262
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:353
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::fa::option::isActive
virtual bool isActive()
Is the source active?
Definition: faOption.C:119
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::fa::option::correct
virtual void correct(areaScalarField &field)
Definition: faOption.C:268
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::fa::defineRunTimeSelectionTable
defineRunTimeSelectionTable(option, dictionary)
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::GeometricField< scalar, faPatchField, areaMesh >
Foam::fa::option::applied_
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
Definition: faOption.H:167
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328