fvmDiv.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) 2011-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 "fvmDiv.H"
27 #include "fvMesh.H"
28 #include "fvMatrix.H"
29 #include "convectionScheme.H"
30 #include "fvmSup.H"
31 #include "fvcDiv.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace fvm
41 {
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 template<class Type>
46 tmp<fvMatrix<Type>>
48 (
49  const surfaceScalarField& flux,
50  const VolField<Type>& vf,
51  const word& name
52 )
53 {
55  (
56  vf.mesh(),
57  flux,
58  vf.mesh().schemes().div(name)
59  )().fvmDiv(flux, vf);
60 }
61 
62 template<class Type>
65 (
66  const tmp<surfaceScalarField>& tflux,
67  const VolField<Type>& vf,
68  const word& name
69 )
70 {
71  tmp<fvMatrix<Type>> tdiv(fvm::div(tflux(), vf, name));
72  tflux.clear();
73  return tdiv;
74 }
75 
76 
77 template<class Type>
80 (
81  const surfaceScalarField& flux,
82  const VolField<Type>& vf
83 )
84 {
85  return fvm::div(flux, vf, "div("+flux.name()+','+vf.name()+')');
86 }
87 
88 template<class Type>
91 (
92  const tmp<surfaceScalarField>& tflux,
93  const VolField<Type>& vf
94 )
95 {
96  tmp<fvMatrix<Type>> tdiv(fvm::div(tflux(), vf));
97  tflux.clear();
98  return tdiv;
99 }
100 
101 
102 template<class Type>
105 (
106  const tmp<SurfaceField<Type>>& tflux,
107  const VolField<Type>& vf
108 )
109 {
110  tmp<fvMatrix<Type>> tdivc(fvm::Su(fvc::div(tflux()), vf));
111 
112  if (vf.mesh().schemes().fluxRequired(vf.name()))
113  {
114  tdivc.ref().faceFluxCorrectionPtr() = tflux.ptr();
115  }
116  else
117  {
118  tflux.clear();
119  }
120 
121  return tdivc;
122 }
123 
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 } // End namespace fvm
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace Foam
132 
133 // ************************************************************************* //
const Mesh & mesh() const
Return mesh.
Generic GeometricField class.
const word & name() const
Return name.
Definition: IOobject.H:310
static tmp< convectionScheme< Type > > New(const fvMesh &mesh, const surfaceScalarField &faceFlux, Istream &schemeData)
Return a pointer to a new convectionScheme created on freestore.
A class for managing temporary objects.
Definition: tmp.H:55
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:237
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
Calculate the divergence of the given field.
Calculate the matrix for the divergence of the given field and flux.
Calculate the matrix for implicit and explicit sources.
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
tmp< fvMatrix< Type > > Su(const DimensionedField< Type, volMesh > &, const VolField< Type > &)
tmp< fvMatrix< Type > > divc(const tmp< SurfaceField< Type >> &tflux, const VolField< Type > &vf)
Return the explicit div matrix.
Definition: fvmDiv.C:105
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
Definition: fvmDiv.C:48
Namespace for OpenFOAM.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47