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-2026 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 const Foam::wordHashSet Foam::fvModel::keywords({"type", "libs"});
39 
40 
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42 
43 template<class Type>
45 (
46  const VolField<Type>& field,
47  fvMatrix<Type>& eqn
48 ) const
49 {}
50 
51 
52 template<class Type>
54 (
55  const volScalarField& rho,
56  const VolField<Type>& field,
57  fvMatrix<Type>& eqn
58 ) const
59 {}
60 
61 
62 template<class Type>
64 (
65  const volScalarField& alpha,
66  const volScalarField& rho,
67  const VolField<Type>& field,
68  fvMatrix<Type>& eqn
69 ) const
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
74 
76 (
77  const word& name,
78  const word& modelType,
79  const fvMesh& mesh,
80  const dictionary& dict
81 )
82 :
83  name_(name),
84  modelType_(modelType),
85  mesh_(mesh)
86 {}
87 
88 
89 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
90 
92 (
93  const word& name,
94  const fvMesh& mesh,
95  const dictionary& dict
96 )
97 {
98  const word type(dict.lookup("type"));
99 
100  Info<< indentOrNl << "Selecting " << type
101  << " with name " << name << endl;
102 
103  if
104  (
105  !dictionaryConstructorTablePtr_
106  || dictionaryConstructorTablePtr_->find(type)
107  == dictionaryConstructorTablePtr_->end()
108  )
109  {
110  if
111  (
112  !libs.open
113  (
114  dict,
115  "libs",
116  dictionaryConstructorTablePtr_
117  )
118  )
119  {
120  libs.open("lib" + type.remove(':') + ".so", false);
121  }
122 
123  if (!dictionaryConstructorTablePtr_)
124  {
126  << "Unknown model type "
127  << type << nl << nl
128  << "Table of fvModels is empty"
129  << exit(FatalError);
130  }
131  }
132 
133  dictionaryConstructorTable::iterator cstrIter =
134  dictionaryConstructorTablePtr_->find(type);
135 
136  if (cstrIter == dictionaryConstructorTablePtr_->end())
137  {
139  << "Unknown fvModel " << type << nl << nl
140  << "Valid fvModels are:" << nl
141  << dictionaryConstructorTablePtr_->sortedToc()
142  << exit(FatalIOError);
143  }
144 
145  printDictionary print(dict);
146 
147  return autoPtr<fvModel>(cstrIter()(name, type, mesh, dict));
148 }
149 
150 
152 {}
153 
154 
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
156 
158 {
159  return wordList::null();
160 }
161 
162 
163 bool Foam::fvModel::addsSupToField(const word& fieldName) const
164 {
165  return findIndex(addSupFields(), fieldName) != -1;
166 }
167 
168 
169 Foam::scalar Foam::fvModel::maxDeltaT() const
170 {
171  return vGreat;
172 }
173 
174 
176 {}
177 
178 
180 
181 
183 
184 
186 
187 
188 void Foam::fvModel::preUpdateMesh()
189 {}
190 
191 
193 {}
194 
195 
197 {
198  return true;
199 }
200 
201 
202 bool Foam::fvModel::write(const bool write) const
203 {
204  return true;
205 }
206 
207 
208 // ************************************************************************* //
Generic GeometricField class.
A HashTable with keys but without contents.
Definition: HashSet.H:62
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:669
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:98
Finite volume model abstract base class.
Definition: fvModel.H:60
static autoPtr< fvModel > New(const word &name, const fvMesh &mesh, const dictionary &dict)
Return a reference to the selected fvModel.
Definition: fvModel.C:92
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: fvModel.C:157
void addSupType(const VolField< Type > &field, fvMatrix< Type > &eqn) const
Add a source term to an equation.
Definition: fvModel.C:45
virtual ~fvModel()
Destructor.
Definition: fvModel.C:151
virtual void correct()
Correct the fvModel.
Definition: fvModel.C:192
virtual scalar maxDeltaT() const
Return the maximum time-step for stable operation.
Definition: fvModel.C:169
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:196
static const wordHashSet keywords
The keywords read by this class.
Definition: fvModel.H:121
virtual bool write(const bool write=true) const
Write fvModel data.
Definition: fvModel.C:202
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: fvModel.C:175
fvModel(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
Definition: fvModel.C:76
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
Definition: fvModel.C:163
Enables the printing of a dictionary and subsequently looked-up defaulted entries.
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#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
rho
Definition: pEqn.H:1
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 & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
messageStream Info
defineRunTimeSelectionTable(fvConstraint, dictionary)
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & indentOrNl(Ostream &os)
Indent stream or add newline if indent level == 0.
Definition: Ostream.H:250
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
error FatalError
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
static const char nl
Definition: Ostream.H:297
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dictionary dict