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-2022 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 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
27 
28 template<class Type, class AlphaRhoFieldType, class ... AlphaRhoFieldTypes>
30 (
31  const VolField<Type>& field,
32  const dimensionSet& ds,
33  const AlphaRhoFieldType& alphaRho,
34  const AlphaRhoFieldTypes& ... alphaRhos
35 )
36 {
37  return alphaRho.dimensions()*sourceDims(field, ds, alphaRhos ...);
38 }
39 
40 
41 template<class Type>
43 (
44  const VolField<Type>& field,
45  const dimensionSet& ds
46 )
47 {
48  return field.dimensions()*ds;
49 }
50 
51 
52 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
53 
54 template<class Type, class ... AlphaRhoFieldTypes>
56 (
57  const VolField<Type>& field,
58  const word& fieldName,
59  const dimensionSet& ds,
60  const AlphaRhoFieldTypes& ... alphaRhos
61 ) const
62 {
63  tmp<fvMatrix<Type>> tmtx
64  (
65  new fvMatrix<Type>
66  (
67  field,
68  sourceDims(field, ds, alphaRhos ...)
69  )
70  );
71  fvMatrix<Type>& mtx = tmtx.ref();
72 
73  if (addsSupToField(fieldName))
74  {
75  addSup(alphaRhos ..., mtx, fieldName);
76  }
77 
78  return tmtx;
79 }
80 
81 
82 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
83 
84 template<class Type>
86 (
87  const VolField<Type>& field
88 ) const
89 {
90  return this->source(field, field.name());
91 }
92 
93 
94 template<class Type>
96 (
97  const VolField<Type>& field,
98  const word& fieldName
99 ) const
100 {
101  return source(field, fieldName, dimVolume/dimTime);
102 }
103 
104 
105 template<class Type>
107 (
108  const volScalarField& rho,
109  const VolField<Type>& field
110 ) const
111 {
112  return this->source(rho, field, field.name());
113 }
114 
115 
116 template<class Type>
118 (
119  const volScalarField& rho,
120  const VolField<Type>& field,
121  const word& fieldName
122 ) const
123 {
124  return source(field, fieldName, dimVolume/dimTime, rho);
125 }
126 
127 
128 template<class Type>
130 (
131  const volScalarField& alpha,
132  const volScalarField& rho,
133  const VolField<Type>& field
134 ) const
135 {
136  return this->source(alpha, rho, field, field.name());
137 }
138 
139 
140 template<class Type>
142 (
143  const volScalarField& alpha,
144  const volScalarField& rho,
145  const VolField<Type>& field,
146  const word& fieldName
147 ) const
148 {
149  return source(field, fieldName, dimVolume/dimTime, alpha, rho);
150 }
151 
152 
153 template<class Type>
155 (
156  const geometricOneField& alpha,
157  const geometricOneField& rho,
158  const VolField<Type>& field
159 ) const
160 {
161  return this->source(field, field.name());
162 }
163 
164 
165 template<class Type>
167 (
168  const volScalarField& alpha,
169  const geometricOneField& rho,
170  const VolField<Type>& field
171 ) const
172 {
174  (
175  IOobject
176  (
177  "one",
178  this->mesh_.time().name(),
179  this->mesh_,
182  false
183  ),
184  this->mesh_,
186  );
187 
188  return this->source(alpha, one, field, field.name());
189 }
190 
191 
192 template<class Type>
194 (
195  const geometricOneField& alpha,
196  const volScalarField& rho,
197  const VolField<Type>& field
198 ) const
199 {
200  return this->source(rho, field, field.name());
201 }
202 
203 
204 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
205 
206 template<class Type>
208 (
209  const VolField<Type>& field
210 ) const
211 {
212  return this->d2dt2(field, field.name());
213 }
214 
215 
216 template<class Type>
218 (
219  const VolField<Type>& field,
220  const word& fieldName
221 ) const
222 {
223  return source(field, fieldName, dimVolume/sqr(dimTime));
224 }
225 
226 // ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const word & name() const
Return name.
Definition: IOobject.H:310
Dimension set for the base types.
Definition: dimensionSet.H:122
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
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 word &fieldName, const dimensionSet &ds, const AlphaRhoFieldTypes &... alphaRhos) const
Return source for equation with specified name and dimensions.
static dimensionSet sourceDims(const VolField< Type > &field, const dimensionSet &ds, const AlphaRhoFieldType &alphaRho, const AlphaRhoFieldTypes &... alphaRhos)
Return the dimensions of the matrix of a source term.
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
A class representing the concept of 1 (scalar(1)) used to avoid unnecessary manipulations for objects...
Definition: one.H:51
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))
tmp< VolField< Type > > d2dt2(const VolField< Type > &vf)
Definition: fvcD2dt2.C:45
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimless
const dimensionSet dimTime
const dimensionSet dimVolume