fvModelTemplates.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 "fvModel.H"
27 
28 // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
29 
30 template<class AlphaRhoFieldType, class ... AlphaRhoFieldTypes>
32 (
33  const dimensionSet& ds,
34  const AlphaRhoFieldType& alphaRhoField,
35  const AlphaRhoFieldTypes& ... alphaRhoFields
36 )
37 {
38  return alphaRhoField.dimensions()*sourceDims(ds, alphaRhoFields ...);
39 }
40 
41 
42 template<class AlphaRhoFieldType, class ... AlphaRhoFieldTypes>
44 (
45  const AlphaRhoFieldType& alphaRhoField,
46  const AlphaRhoFieldTypes& ... alphaRhoFields
47 )
48 {
49  return fieldName(alphaRhoFields ...);
50 }
51 
52 
53 template<class AlphaRhoFieldType>
55 (
56  const AlphaRhoFieldType& alphaRhoField
57 )
58 {
59  return alphaRhoField.name();
60 }
61 
62 
63 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
64 
65 template<class Type, class ... AlphaRhoFieldTypes>
67 (
68  const VolField<Type>& eqnField,
69  const dimensionSet& ds,
70  const AlphaRhoFieldTypes& ... alphaRhoFields
71 ) const
72 {
73  tmp<fvMatrix<Type>> tmtx
74  (
75  new fvMatrix<Type>
76  (
77  eqnField,
78  sourceDims(ds, alphaRhoFields ...)
79  )
80  );
81  fvMatrix<Type>& mtx = tmtx.ref();
82 
83  if (addsSupToField(fieldName(alphaRhoFields ...)))
84  {
85  addSup(alphaRhoFields ..., mtx);
86  }
87 
88  return tmtx;
89 }
90 
91 
92 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
93 
94 template<class Type>
96 (
97  const VolField<Type>& eqnField
98 ) const
99 {
100  return sourceTerm(eqnField, dimVolume/dimTime);
101 }
102 
103 
104 template<class Type>
106 (
107  const VolField<Type>& field
108 ) const
109 {
110  return sourceTerm(field, dimVolume/dimTime, field);
111 }
112 
113 
114 template<class Type>
116 (
117  const VolField<Type>& field,
118  const VolField<Type>& eqnField
119 ) const
120 {
121  return sourceTerm(eqnField, dimVolume/dimTime, field);
122 }
123 
124 
125 template<class Type>
127 (
128  const volScalarField& rho,
129  const VolField<Type>& field
130 ) const
131 {
132  return sourceTerm(field, dimVolume/dimTime, rho, field);
133 }
134 
135 
136 template<class Type>
138 (
139  const volScalarField& rho,
140  const VolField<Type>& field,
141  const VolField<Type>& eqnField
142 ) const
143 {
144  return sourceTerm(eqnField, dimVolume/dimTime, rho, field);
145 }
146 
147 
148 template<class Type>
150 (
151  const volScalarField& alpha,
152  const volScalarField& rho,
153  const VolField<Type>& field
154 ) const
155 {
156  return sourceTerm(field, dimVolume/dimTime, alpha, rho, field);
157 }
158 
159 
160 template<class Type>
162 (
163  const volScalarField& alpha,
164  const volScalarField& rho,
165  const VolField<Type>& field,
166  const VolField<Type>& eqnField
167 ) const
168 {
169  return sourceTerm(eqnField, dimVolume/dimTime, alpha, rho, field);
170 }
171 
172 
173 template<class Type>
175 (
176  const geometricOneField& alpha,
177  const geometricOneField& rho,
178  const VolField<Type>& field
179 ) const
180 {
181  return this->source(field);
182 }
183 
184 
185 template<class Type>
187 (
188  const volScalarField& alpha,
189  const geometricOneField& rho,
190  const VolField<Type>& field
191 ) const
192 {
193  return this->source(alpha, field);
194 }
195 
196 
197 template<class Type>
199 (
200  const geometricOneField& alpha,
201  const volScalarField& rho,
202  const VolField<Type>& field
203 ) const
204 {
205  return this->source(rho, field);
206 }
207 
208 
209 template<class Type>
211 (
212  const VolField<Type>& field
213 ) const
214 {
215  return sourceTerm(field, dimVolume/sqr(dimTime), field);
216 }
217 
218 
219 // ************************************************************************* //
Generic GeometricField class.
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
tmp< fvMatrix< Type > > sourceTerm(const VolField< Type > &eqnField, const dimensionSet &ds, const AlphaRhoFieldTypes &... alphaRhoFields) const
Return a source for an equation.
tmp< fvMatrix< Type > > d2dt2(const VolField< Type > &field) const
Return source for an equation with a second time derivative.
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
static dimensionSet sourceDims(const dimensionSet &ds, const AlphaRhoFieldType &alphaRhoField, const AlphaRhoFieldTypes &... alphaRhoFields)
Return the dimensions of the matrix of a source term.
tmp< fvMatrix< Type > > sourceProxy(const VolField< Type > &eqnField) const
Add a source term to an equation.
static const word & fieldName()
Return the name of the field associated with a source term. Special.
Definition: fvModelI.H:39
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
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))
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimTime
const dimensionSet dimVolume