fvSpecificSourceTemplates.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 "fvSpecificSource.H"
27 #include "volFields.H"
28 #include "fvmSup.H"
29 
30 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const VolField<Type>& field,
36  fvMatrix<Type>& eqn
37 ) const
38 {
40  << "field=" << field.name()
41  << ", eqnField=" << eqn.psi().name() << endl;
42 
44 
45  if (&field == &eqn.psi())
46  {
47  // Get the field source coefficients
50  (
51  "sourceCoeff",
52  mesh(),
53  field.dimensions(),
54  field.sources()[name()].sourceCoeff(*this)
55  );
58  (
59  "internalCoeff",
60  mesh(),
61  dimless,
62  field.sources()[name()].internalCoeff(*this)
63  );
64 
65  // Apply the source
66  eqn += tS()*sourceCoeff + fvm::Sp(tS()*internalCoeff, eqn.psi());
67  }
68  else
69  {
70  // Get the field source value
73  (
74  "value",
75  mesh(),
76  field.dimensions(),
77  field.sources()[name()].value(*this)
78  );
79 
80  // Apply the source
81  eqn += tS*value;
82  }
83 }
84 
85 
86 template<class Type>
88 (
89  const volScalarField& rho,
90  const VolField<Type>& field,
91  fvMatrix<Type>& eqn
92 ) const
93 {
95  << "rho=" << rho.name()
96  << ", field=" << field.name()
97  << ", eqnField=" << eqn.psi().name() << endl;
98 
99  addSupType(field, eqn);
100 }
101 
102 
103 template<class Type>
105 (
106  const volScalarField& alpha,
107  const volScalarField& rho,
108  const VolField<Type>& field,
109  fvMatrix<Type>& eqn
110 ) const
111 {
113  << "alpha=" << alpha.name()
114  << ", rho=" << rho.name()
115  << ", field=" << field.name()
116  << ", eqnField=" << eqn.psi().name() << endl;
117 
118  addSupType(rho, field, eqn);
119 }
120 
121 
122 // ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
static tmp< DimensionedField< Type, GeoMesh > > New(const word &name, const Mesh &mesh, const dimensionSet &, const Field< Type > &)
Return a temporary field constructed from name, mesh,.
Generic GeometricField class.
const Sources & sources() const
Return const-reference to the sources.
const word & name() const
Return name.
Definition: IOobject.H:310
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
VolField< Type > & psi()
Definition: fvMatrix.H:289
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:53
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:47
void addSupType(const VolField< Type > &field, fvMatrix< Type > &eqn) const
Add a source term to an equation.
virtual tmp< DimensionedField< scalar, volMesh > > S(const word &fieldName) const =0
Return the source value.
A class for managing temporary objects.
Definition: tmp.H:55
Calculate the matrix for implicit and explicit sources.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
#define DebugInFunction
Report an information message using Foam::Info.
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
const dimensionSet dimless