fvModel.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2021-2023 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 "fvModel.H"
27 #include "volFields.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
35 }
36 
37 
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 
40 template<class Type>
42 (
43  fvMatrix<Type>& eqn,
44  const word& fieldName
45 ) const
46 {}
47 
48 
49 template<class Type>
51 (
52  const volScalarField& rho,
53  fvMatrix<Type>& eqn,
54  const word& fieldName
55 ) const
56 {}
57 
58 
59 template<class Type>
61 (
62  const volScalarField& alpha,
63  const volScalarField& rho,
64  fvMatrix<Type>& eqn,
65  const word& fieldName
66 ) const
67 {}
68 
69 
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 
73 (
74  const word& name,
75  const word& modelType,
76  const fvMesh& mesh,
77  const dictionary& dict
78 )
79 :
80  name_(name),
81  modelType_(modelType),
82  mesh_(mesh),
83  dict_(dict),
84  coeffs_(dict.optionalSubDict(modelType + "Coeffs"))
85 {
86  Info<< incrIndent << indent << "Name: " << name_
87  << endl << decrIndent;
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
92 
94 (
95  const word& name,
96  const fvMesh& mesh,
97  const dictionary& dict
98 )
99 {
100  const word modelType(dict.lookup("type"));
101 
102  Info<< indent
103  << "Selecting finite volume model type " << modelType << endl;
104 
105  if
106  (
107  !dictionaryConstructorTablePtr_
108  || dictionaryConstructorTablePtr_->find(modelType)
109  == dictionaryConstructorTablePtr_->end()
110  )
111  {
112  if
113  (
114  !libs.open
115  (
116  dict,
117  "libs",
118  dictionaryConstructorTablePtr_
119  )
120  )
121  {
122  libs.open("lib" + modelType.remove(':') + ".so", false);
123  }
124 
125  if (!dictionaryConstructorTablePtr_)
126  {
128  << "Unknown model type "
129  << modelType << nl << nl
130  << "Table of fvModels is empty"
131  << exit(FatalError);
132  }
133  }
134 
135  dictionaryConstructorTable::iterator cstrIter =
136  dictionaryConstructorTablePtr_->find(modelType);
137 
138  if (cstrIter == dictionaryConstructorTablePtr_->end())
139  {
141  << "Unknown fvModel " << modelType << nl << nl
142  << "Valid fvModels are:" << nl
143  << dictionaryConstructorTablePtr_->sortedToc()
144  << exit(FatalIOError);
145  }
146 
147  return autoPtr<fvModel>
148  (
149  cstrIter()(name, modelType, mesh, dict)
150  );
151 }
152 
153 
155 {}
156 
157 
158 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
159 
161 {
162  return wordList::null();
163 }
164 
165 
166 bool Foam::fvModel::addsSupToField(const word& fieldName) const
167 {
168  return findIndex(addSupFields(), fieldName) != -1;
169 }
170 
171 
172 Foam::scalar Foam::fvModel::maxDeltaT() const
173 {
174  return vGreat;
175 }
176 
177 
179 
180 
182 
183 
185 
186 
188 {
189  coeffs_ = dict.optionalSubDict(modelType_ + "Coeffs");
190 
191  return true;
192 }
193 
194 
196 {}
197 
198 
200 {}
201 
202 
203 // ************************************************************************* //
Generic GeometricField class.
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:860
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1076
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Finite volume model abstract base class.
Definition: fvModel.H:59
static autoPtr< fvModel > New(const word &name, const fvMesh &mesh, const dictionary &dict)
Return a reference to the selected fvModel.
Definition: fvModel.C:94
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: fvModel.C:160
virtual ~fvModel()
Destructor.
Definition: fvModel.C:154
virtual void correct()
Correct the fvModel.
Definition: fvModel.C:199
void addSupType(fvMatrix< Type > &eqn, const word &fieldName) const
Add a source term to an equation.
Definition: fvModel.C:42
virtual scalar maxDeltaT() const
Return the maximum time-step for stable operation.
Definition: fvModel.C:172
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:187
virtual void preUpdateMesh()
Prepare for mesh update.
Definition: fvModel.C:195
fvModel(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
Definition: fvModel.C:73
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
Definition: fvModel.C:166
bool remove(const char)
Remove all occurrences of character returning true if string changed.
Definition: string.C:132
A class for handling words, derived from string.
Definition: word.H:62
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
#define IMPLEMENT_FV_MODEL_ADD_RHO_SUP(Type, modelType)
Definition: fvModelM.H:51
#define IMPLEMENT_FV_MODEL_ADD_SUP(Type, modelType)
Definition: fvModelM.H:33
#define IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP(Type, modelType)
Definition: fvModelM.H:71
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dlLibraryTable libs
Table of loaded dynamic libraries.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
FOR_ALL_FIELD_TYPES(DefineContiguousFvWallLocationDataType)
defineTypeNameAndDebug(combustionModel, 0)
IOerror FatalIOError
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
error FatalError
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
static const char nl
Definition: Ostream.H:260
dictionary dict