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-2020 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 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
44 
45 void Foam::fa::option::constructMeshObjects()
46 {
47  regionMeshPtr_.reset(new faMesh(mesh_));
48 
49  vsmPtr_.reset(new volSurfaceMapping(regionMeshPtr_()));
50 }
51 
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
57 (
58  const word& name,
59  const word& modelType,
60  const dictionary& dict,
61  const fvPatch& patch
62 )
63 :
64  name_(name),
65  modelType_(modelType),
66  mesh_(patch.boundaryMesh().mesh()),
67  patch_(patch),
68  dict_(dict),
69  coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
70  active_(dict.getOrDefault<Switch>("active", true)),
71  fieldNames_(),
72  applied_(),
73  regionName_(dict.get<word>("region")),
74  regionMeshPtr_(nullptr),
75  vsmPtr_(nullptr)
76 {
77  constructMeshObjects();
78 
79  Info<< incrIndent << indent << "Source: " << name_ << endl << decrIndent;
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
84 
86 (
87  const word& name,
88  const dictionary& coeffs,
89  const fvPatch& patch
90 )
91 {
92  const word modelType(coeffs.get<word>("type"));
93 
94  Info<< indent
95  << "Selecting finite area options type " << modelType << endl;
96 
97  const_cast<Time&>(patch.boundaryMesh().mesh().time()).libs().open
98  (
99  coeffs,
100  "libs",
101  dictionaryConstructorTablePtr_
102  );
103 
104  auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
105 
106  if (!cstrIter.found())
107  {
109  << "Unknown faOption model type "
110  << modelType << nl << nl
111  << "Valid faOption types are:" << nl
112  << dictionaryConstructorTablePtr_->sortedToc()
113  << exit(FatalError);
114  }
115 
116  return autoPtr<option>(cstrIter()(name, modelType, coeffs, patch));
117 }
118 
119 
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121 
123 {
124  return active_;
125 }
126 
127 
128 Foam::label Foam::fa::option::applyToField(const word& fieldName) const
129 {
130  return fieldNames_.find(fieldName);
131 }
132 
133 
135 {
136  forAll(applied_, i)
137  {
138  if (!applied_[i])
139  {
141  << "Source " << name_ << " defined for field "
142  << fieldNames_[i] << " but never used" << endl;
143  }
144  }
145 }
146 
147 
149 (
150  const areaScalarField& h,
151  faMatrix<scalar>& eqn,
152  const label fieldi
153 )
154 {}
155 
156 
158 (
159  const areaScalarField& h,
160  faMatrix<vector>& eqn,
161  const label fieldi
162 )
163 {}
164 
165 
167 (
168  const areaScalarField& h,
170  const label fieldi
171 )
172 {}
173 
174 
176 (
177  const areaScalarField& h,
179  const label fieldi
180 )
181 {}
182 
183 
185 (
186  const areaScalarField& h,
187  faMatrix<tensor>& eqn,
188  const label fieldi
189 )
190 {}
191 
192 
194 (
195  const areaScalarField& h,
196  const areaScalarField& rho,
197  faMatrix<scalar>& eqn,
198  const label fieldi
199 )
200 {}
201 
202 
204 (
205  const areaScalarField& h,
206  const areaScalarField& rho,
207  faMatrix<vector>& eqn,
208  const label fieldi
209 )
210 {}
211 
212 
214 (
215  const areaScalarField& h,
216  const areaScalarField& rho,
218  const label fieldi
219 )
220 {}
221 
222 
224 (
225  const areaScalarField& h,
226  const areaScalarField& rho,
228  const label fieldi
229 )
230 {}
231 
232 
234 (
235  const areaScalarField& h,
236  const areaScalarField& rho,
237  faMatrix<tensor>& eqn,
238  const label fieldi
239 )
240 {}
241 
242 
243 void Foam::fa::option::constrain(faMatrix<scalar>& eqn, const label fieldi)
244 {}
245 
246 
247 void Foam::fa::option::constrain(faMatrix<vector>& eqn, const label fieldi)
248 {}
249 
250 
252 (
254  const label fieldi
255 )
256 {}
257 
258 
260 (
262  const label fieldi
263 )
264 {}
265 
266 
267 void Foam::fa::option::constrain(faMatrix<tensor>& eqn, const label fieldi)
268 {}
269 
270 
272 {}
273 
274 
276 {}
277 
278 
280 {}
281 
282 
284 {}
285 
286 
288 {}
289 
290 
291 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
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: faMatrix.H:59
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fa::option::constrain
virtual void constrain(faMatrix< scalar > &eqn, const label fieldi)
Definition: faOption.C:243
Foam::fa::option::addSup
virtual void addSup(const areaScalarField &h, faMatrix< scalar > &eqn, const label fieldi)
Definition: faOption.C:149
Foam::fa::option::checkApplied
virtual void checkApplied() const
Check that the source has been applied.
Definition: faOption.C:134
Foam::fa::option::option
option(const word &name, const word &modelType, const dictionary &dict, const fvPatch &patch)
Construct from components.
Definition: faOption.C:57
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
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:86
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:327
rho
rho
Definition: readInitialConditions.H:88
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fa::option::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: faOption.H:153
Foam::fa::option::applyToField
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: faOption.C:128
Foam::fa::option::regionMeshPtr_
autoPtr< faMesh > regionMeshPtr_
Pointer to the region mesh database.
Definition: faOption.H:177
Foam::fa::option::vsmPtr_
autoPtr< volSurfaceMapping > vsmPtr_
Volume-to surface mapping.
Definition: faOption.H:180
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
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:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:334
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:320
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:122
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:271
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::HashTable::cfind
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
Definition: HashTableI.H:141
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::fa::defineTypeNameAndDebug
defineTypeNameAndDebug(faceSetOption, 0)
Foam::fa::defineRunTimeSelectionTable
defineRunTimeSelectionTable(option, dictionary)
Foam::GeometricField< scalar, faPatchField, areaMesh >
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:303