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-2022 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 {
33  defineTypeNameAndDebug(fvModel, 0);
34  defineRunTimeSelectionTable(fvModel, dictionary);
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 dictionary& dict,
77  const fvMesh& mesh
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 dictionary& coeffs,
97  const fvMesh& mesh
98 )
99 {
100  const word modelType(coeffs.lookup("type"));
101 
102  Info<< indent
103  << "Selecting finite volume model type " << modelType << endl;
104 
105  libs.open
106  (
107  coeffs,
108  "libs",
109  dictionaryConstructorTablePtr_
110  );
111 
112  dictionaryConstructorTable::iterator cstrIter =
113  dictionaryConstructorTablePtr_->find(modelType);
114 
115  if (cstrIter == dictionaryConstructorTablePtr_->end())
116  {
117  FatalIOErrorInFunction(coeffs)
118  << "Unknown fvModel " << modelType << nl << nl
119  << "Valid fvModels are:" << nl
120  << dictionaryConstructorTablePtr_->sortedToc()
121  << exit(FatalIOError);
122  }
123 
124  return autoPtr<fvModel>
125  (
126  cstrIter()(name, modelType, coeffs, mesh)
127  );
128 }
129 
130 
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
136 
138 {
139  return wordList::null();
140 }
141 
142 
143 bool Foam::fvModel::addsSupToField(const word& fieldName) const
144 {
145  return findIndex(addSupFields(), fieldName) != -1;
146 }
147 
148 
149 Foam::scalar Foam::fvModel::maxDeltaT() const
150 {
151  return great;
152 }
153 
154 
156 
157 
159 
160 
162 
163 
165 {
166  coeffs_ = dict.optionalSubDict(modelType_ + "Coeffs");
167 
168  return true;
169 }
170 
171 
173 {}
174 
175 
177 {}
178 
179 
180 // ************************************************************************* //
#define IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP(Type, modelType)
Definition: fvModelM.H:71
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
virtual ~fvModel()
Destructor.
Definition: fvModel.C:131
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: fvModel.C:137
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:164
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Finite volume model abstract base class.
Definition: fvModel.H:57
virtual void preUpdateMesh()
Prepare for mesh update.
Definition: fvModel.C:172
static const List< T > & null()
Return a null List.
Definition: ListI.H:118
fvMesh & mesh
dlLibraryTable libs
Table of loaded dynamic libraries.
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1060
A class for handling words, derived from string.
Definition: word.H:59
static autoPtr< fvModel > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvModel.
Definition: fvModel.C:94
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
Definition: fvModel.C:143
virtual scalar maxDeltaT() const
Return the maximum time-step for stable operation.
Definition: fvModel.C:149
fvModel(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvModel.C:73
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
#define IMPLEMENT_FV_MODEL_ADD_SUP(Type, modelType)
Definition: fvModelM.H:33
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
void addSupType(fvMatrix< Type > &eqn, const word &fieldName) const
Add a source term to an equation.
Definition: fvModel.C:42
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
#define IMPLEMENT_FV_MODEL_ADD_RHO_SUP(Type, modelType)
Definition: fvModelM.H:51
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
virtual void correct()
Correct the fvModel.
Definition: fvModel.C:176
messageStream Info
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864
IOerror FatalIOError