CarrierEqn.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) 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 \*---------------------------------------------------------------------------*/
25 
26 #include "CarrierEqn.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 :
33  psi(vf),
34  Su(psi),
35  Sp(psi)
36 {}
37 
38 
39 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
40 
41 template<class Type>
43 {
44  Su.clear();
45  Sp.clear();
46 }
47 
48 
49 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
50 
51 template<class Type>
53 {
54  Su += lEqn.allDiagonalSu();
55  Sp += lEqn.allDiagonalSp();
56 }
57 
58 
59 template<class Type>
61 {
62  Su -= lEqn.allDiagonalSu();
63  Sp -= lEqn.allDiagonalSp();
64 }
65 
66 
67 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
68 
69 template<class Type>
70 void Foam::operator+=
71 (
72  fvMatrix<Type>& fvEqn,
73  const CarrierEqn<Type>& cEqn
74 )
75 {
76  const dimensionedScalar& deltaT = fvEqn.psi().mesh().time().deltaT();
77 
78  if (cEqn.Su.valid())
79  {
80  fvEqn.dimensions() -= cEqn.Su.S().dimensions()/dimTime;
81  fvEqn.source() -= cEqn.Su.S().primitiveField()/deltaT.value();
82  }
83  if (cEqn.Sp.valid())
84  {
85  fvEqn.dimensions() +=
86  cEqn.Sp.S().dimensions()/dimTime/fvEqn.psi().dimensions();
87  fvEqn.diag() += cEqn.Sp.S().primitiveField()/deltaT.value();
88  }
89 }
90 
91 
92 template<class Type>
93 void Foam::operator-=
94 (
95  fvMatrix<Type>& fvEqn,
96  const CarrierEqn<Type>& cEqn
97 )
98 {
99  const dimensionedScalar& deltaT = fvEqn.psi().mesh().time().deltaT();
100 
101  if (cEqn.Su.valid())
102  {
103  fvEqn.dimensions() += cEqn.Su.S().dimensions()/dimTime;
104  fvEqn.source() += cEqn.Su.S().primitiveField()/deltaT.value();
105  }
106  if (cEqn.Sp.valid())
107  {
108  fvEqn.dimensions() -=
109  cEqn.Sp.S().dimensions()/dimTime/fvEqn.psi().dimensions();
110  fvEqn.diag() -= cEqn.Sp.S().primitiveField()/deltaT.value();
111  }
112 }
113 
114 
115 // ************************************************************************* //
Class to store the coefficients of a term in a carrier equation.
Definition: CarrierEqn.H:52
void operator+=(const LagrangianEqn< Type > &lEqn)
Addition assignment.
Definition: CarrierEqn.C:52
void operator-=(const LagrangianEqn< Type > &lEqn)
Subtraction assignment.
Definition: CarrierEqn.C:60
CarrierEqn(const VolField< Type > &psi)
Construct from a reference to the field.
Definition: CarrierEqn.C:31
void clear()
Clear the coefficient values.
Definition: CarrierEqn.C:42
Generic GeometricField class.
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
Definition: LagrangianEqn.H:56
tmp< LagrangianCoeff< scalar, true > > allDiagonalSp() const
Return the combined time and non-time implicit diagonal.
tmp< LagrangianCoeff< Type, false > > allDiagonalSu() const
Return the combined time and non-time explicit diagonal.
const Type & value() const
Return const reference to value.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Field< Type > & source()
Definition: fvMatrix.H:307
VolField< Type > & psi()
Definition: fvMatrix.H:289
const dimensionSet & dimensions() const
Definition: fvMatrix.H:302
scalarField & diag()
Definition: lduMatrix.C:186
const volScalarField & psi
tmp< VolField< Type > > Su(const VolField< Type > &su, const VolField< Type > &vf)
Definition: fvcSup.C:44
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
Definition: fvcSup.C:67
const dimensionSet dimTime