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 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
39 
40 template<class Type>
42 (
43  const VolField<Type>& field,
44  fvMatrix<Type>& eqn
45 ) const
46 {}
47 
48 
49 template<class Type>
51 (
52  const volScalarField& rho,
53  const VolField<Type>& field,
54  fvMatrix<Type>& eqn
55 ) const
56 {}
57 
58 
59 template<class Type>
61 (
62  const volScalarField& alpha,
63  const volScalarField& rho,
64  const VolField<Type>& field,
65  fvMatrix<Type>& eqn
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 
181 
183 
184 
186 
187 
189 
190 
191 void Foam::fvModel::preUpdateMesh()
192 {}
193 
194 
196 {}
197 
198 
200 {
201  coeffs_ = dict.optionalSubDict(modelType_ + "Coeffs");
202 
203  return true;
204 }
205 
206 
207 bool Foam::fvModel::write(const bool write) const
208 {
209  return true;
210 }
211 
212 
213 // ************************************************************************* //
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:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:710
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:921
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:99
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
void addSupType(const VolField< Type > &field, fvMatrix< Type > &eqn) const
Add a source term to an equation.
Definition: fvModel.C:42
virtual ~fvModel()
Destructor.
Definition: fvModel.C:154
virtual void correct()
Correct the fvModel.
Definition: fvModel.C:195
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:199
virtual bool write(const bool write=true) const
Write fvModel data.
Definition: fvModel.C:207
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: fvModel.C:178
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:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
#define IMPLEMENT_FV_MODEL_ADD_FIELD_SUP(Type, modelType)
Definition: fvModelM.H:33
#define IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP(Type, modelType)
Definition: fvModelM.H:71
#define IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP(Type, modelType)
Definition: fvModelM.H:51
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
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:241
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
messageStream Info
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:234
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
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:227
static const char nl
Definition: Ostream.H:266
dictionary dict