fvTotalSource.H
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-2025 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 Class
25  Foam::fvTotalSource
26 
27 Description
28  Base class for sources which are specified as a total value (e.g., volume
29  or mass flow rate), rather than a specific value (e.g., mass flow rate per
30  unit volume).
31 
32 SourceFiles
33  fvTotalSource.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef fvTotalSource_H
38 #define fvTotalSource_H
39 
40 #include "fvSource.H"
41 #include "cellZone.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class fvTotalSource Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class fvTotalSource
53 :
54  public fvSource
55 {
56 private:
57 
58  // Private Data
59 
60  //- Name of the phase
61  word phaseName_;
62 
63 
64  // Private Member Functions
65 
66  //- Non-virtual read
67  void readCoeffs(const dictionary& dict);
68 
69 
70 protected:
71 
72  // Protected Member Functions
73 
74  // Sources
75 
76  //- Add a source term to a field-less proxy equation
77  void addSource(fvMatrix<scalar>& eqn) const;
78 
79  //- Add a source term to an equation
80  template<class Type>
81  void addSupType
82  (
83  const VolField<Type>& field,
84  fvMatrix<Type>& eqn
85  ) const;
86 
87  //- Add a source term to a compressible equation
88  template<class Type>
89  void addSupType
90  (
91  const volScalarField& rho,
92  const VolField<Type>& field,
93  fvMatrix<Type>& eqn
94  ) const;
95 
96  //- Add a source term to a phase equation
97  template<class Type>
98  void addSupType
99  (
100  const volScalarField& alpha,
101  const volScalarField& rho,
102  const VolField<Type>& field,
103  fvMatrix<Type>& eqn
104  ) const;
105 
106 
107 public:
108 
109  //- Runtime type information
110  TypeName("fvTotalSource");
111 
112 
113  // Constructors
114 
115  //- Construct from explicit source name and mesh
117  (
118  const word& name,
119  const word& modelType,
120  const fvMesh& mesh,
121  const dictionary& dict
122  );
123 
124 
125  //- Destructor
126  virtual ~fvTotalSource();
127 
128 
129  // Member Functions
130 
131  // Checks
132 
133  //- Return true if the fvModel adds a source term to the given
134  // field's transport equation
135  virtual bool addsSupToField(const word& fieldName) const;
136 
137 
138  // Access
139 
140  //- Return the phase name
141  inline const word& phaseName() const;
142 
143  //- Return the cellZone that the source applies to
144  virtual const cellZone& zone() const = 0;
145 
146  //- Return the volume of cells that the source applies to
147  virtual scalar V() const = 0;
148 
149 
150  // Sources
151 
152  //- Return the source value
153  virtual dimensionedScalar S() const = 0;
154 
155 
156  // IO
157 
158  //- Read source dictionary
159  virtual bool read(const dictionary& dict);
160 };
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace Foam
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #include "fvTotalSourceI.H"
170 
171 #ifdef NoRepository
172  #include "fvTotalSourceTemplates.C"
173 #endif
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
Generic GeometricField class.
Named list of cell indices representing a sub-set of the mesh.
Definition: cellZone.H:61
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
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:96
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:57
static const word & fieldName()
Return the name of the field associated with a source term. Special.
Definition: fvModelI.H:49
Base class for finite volume sources.
Definition: fvSource.H:52
Base class for sources which are specified as a total value (e.g., volume or mass flow rate),...
Definition: fvTotalSource.H:54
void addSupType(const VolField< Type > &field, fvMatrix< Type > &eqn) const
Add a source term to an equation.
virtual const cellZone & zone() const =0
Return the cellZone that the source applies to.
virtual scalar V() const =0
Return the volume of cells that the source applies to.
const word & phaseName() const
Return the phase name.
TypeName("fvTotalSource")
Runtime type information.
fvTotalSource(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Definition: fvTotalSource.C:72
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual ~fvTotalSource()
Destructor.
Definition: fvTotalSource.C:88
virtual dimensionedScalar S() const =0
Return the source value.
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
Definition: fvTotalSource.C:94
void addSource(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: fvTotalSource.C:47
A class for handling words, derived from string.
Definition: word.H:62
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Namespace for OpenFOAM.
dictionary dict