CarrierEqn.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) 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::CarrierEqn
26 
27 Description
28  Class to store the coefficients of a term in a carrier equation
29 
30 SourceFiles
31  CarrierEqn.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef CarrierEqn_H
36 #define CarrierEqn_H
37 
38 #include "CarrierCoeff.H"
39 #include "LagrangianEqn.H"
40 #include "fvMatrix.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class CarrierEqn Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 template<class Type>
52 class CarrierEqn
53 :
54  public tmp<CarrierEqn<Type>>::refCount,
55  public CarrierEqnBase
56 {
57  // Private Data
58 
59  //- Reference to the volume field
60  const VolField<Type>& psi_;
61 
62 
63  // Private Member Functions
64 
65  //- Return the residual
66  template<class PsiFieldType>
68  (
69  const dimensionSet& dims,
70  const word& psiName,
71  const PsiFieldType& psi
72  ) const;
73 
74 
75 public:
76 
77  // Public Data
78 
79  //- Explicit coefficient
81 
82  //- Implicit coefficient
84 
85 
86  // Constructors
87 
88  //- Construct for a field
90 
91  //- Construct from a field name and a reference to the mesh. The field
92  // reference is not set and the field is assumed to be (dimensionless)
93  // unity. This is for volume sources which are expressed per unit
94  // volume and therefore have no associated field.
95  CarrierEqn(const word& psiName, const fvMesh& mesh);
96 
97  //- Copy construct
98  CarrierEqn(const CarrierEqn<Type>& eqn);
99 
100  //- Construct from tmp
101  CarrierEqn(const tmp<CarrierEqn<Type>>& tEqn);
102 
103 
104  // Member Functions
105 
106  //- Clear the coefficient values
107  void clear();
108 
109  //- Return the residual
110  tmp<VolInternalField<Type>> residual(const dimensionSet& dims) const;
111 
112 
113  // Member Operators
114 
115  //- Addition assignment
116  void operator+=(const LagrangianEqn<Type>& lEqn);
117 
118  //- Addition assignment
119  void operator+=(const tmp<LagrangianEqn<Type>>& tlEqn);
120 
121  //- Subtraction assignment
122  void operator-=(const LagrangianEqn<Type>& lEqn);
123 
124  //- Subtraction assignment
125  void operator-=(const tmp<LagrangianEqn<Type>>& tlEqn);
126 };
127 
128 
129 #define CARRIER_EQN_SCALAR_OPERATOR(Op) \
130  \
131  template<class Type> \
132  tmp<CarrierEqn<Type>> operator Op \
133  ( \
134  const CarrierEqn<Type>& eqn, \
135  const dimensionedScalar& s \
136  ); \
137  \
138  template<class Type> \
139  tmp<CarrierEqn<Type>> operator Op \
140  ( \
141  const tmp<CarrierEqn<Type>>& tEqn, \
142  const dimensionedScalar& s \
143  );
144 
145 #define CARRIER_SCALAR_EQN_OPERATOR(Op) \
146  \
147  template<class Type> \
148  tmp<CarrierEqn<Type>> operator Op \
149  ( \
150  const dimensionedScalar& s, \
151  const CarrierEqn<Type>& eqn \
152  ); \
153  \
154  template<class Type> \
155  tmp<CarrierEqn<Type>> operator Op \
156  ( \
157  const dimensionedScalar& s, \
158  const tmp<CarrierEqn<Type>>& tEqn \
159  );
160 
161 //- Multiplication
164 
165 //- Division
167 
168 #undef CARRIER_EQN_SCALAR_OPERATOR
169 #undef CARRIER_SCALAR_EQN_OPERATOR
170 
171 
172 //- Add to a finite-volume equation
173 template<class Type>
174 void operator+=(fvMatrix<Type>& fvEqn, const CarrierEqn<Type>& cEqn);
175 
176 //- Add to a finite-volume equation
177 template<class Type>
178 void operator+=(fvMatrix<Type>& fvEqn, const tmp<CarrierEqn<Type>>& tcEqn);
179 
180 //- Subtract from a finite-volume equation
181 template<class Type>
182 void operator-=(fvMatrix<Type>& fvEqn, const CarrierEqn<Type>& cEqn);
183 
184 //- Subtract from a finite-volume equation
185 template<class Type>
186 void operator-=(fvMatrix<Type>& fvEqn, const tmp<CarrierEqn<Type>>& tcEqn);
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #ifdef NoRepository
196  #include "CarrierEqn.C"
197 #endif
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #endif
202 
203 // ************************************************************************* //
#define CARRIER_EQN_SCALAR_OPERATOR(Op)
Definition: CarrierEqn.H:128
#define CARRIER_SCALAR_EQN_OPERATOR(Op)
Definition: CarrierEqn.H:144
Non-templated base class for carrier equations.
const fvMesh & mesh() const
Return the mesh.
Class to store the coefficients of a term in a carrier equation.
Definition: CarrierEqn.H:55
CarrierCoeff< scalar, true > Sp
Implicit coefficient.
Definition: CarrierEqn.H:82
void operator+=(const LagrangianEqn< Type > &lEqn)
Addition assignment.
Definition: CarrierEqn.C:178
void operator-=(const LagrangianEqn< Type > &lEqn)
Subtraction assignment.
Definition: CarrierEqn.C:194
CarrierEqn(const VolField< Type > &psi)
Construct for a field.
Definition: CarrierEqn.C:80
void clear()
Clear the coefficient values.
Definition: CarrierEqn.C:154
CarrierCoeff< Type, false > Su
Explicit coefficient.
Definition: CarrierEqn.H:79
Generic GeometricField class.
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
Definition: LagrangianEqn.H:56
Dimension set for the base types.
Definition: dimensionSet.H:125
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
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
const volScalarField & psi
Namespace for OpenFOAM.
void operator+=(fvMatrix< Type > &fvEqn, const CarrierEqn< Type > &cEqn)
Add to a finite-volume equation.
Definition: CarrierEqn.C:271
void operator-=(fvMatrix< Type > &fvEqn, const CarrierEqn< Type > &cEqn)
Subtract from a finite-volume equation.
Definition: CarrierEqn.C:299