gaussConvectionScheme.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 "gaussConvectionScheme.H"
27 #include "fvcSurfaceIntegrate.H"
28 #include "fvMatrices.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace fv
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 template<class Type>
43 const surfaceInterpolationScheme<Type>&
45 {
46  return tinterpScheme_();
47 }
48 
49 
50 template<class Type>
53 (
54  const surfaceScalarField&,
55  const VolField<Type>& vf
56 ) const
57 {
58  return tinterpScheme_().interpolate(vf);
59 }
60 
61 
62 template<class Type>
65 (
66  const surfaceScalarField& faceFlux,
67  const VolField<Type>& vf
68 ) const
69 {
70  return faceFlux*interpolate(faceFlux, vf);
71 }
72 
73 
74 template<class Type>
77 (
78  const surfaceScalarField& faceFlux,
79  const VolField<Type>& vf
80 ) const
81 {
82  tmp<surfaceScalarField> tweights = tinterpScheme_().weights(vf);
83  const surfaceScalarField& weights = tweights();
84 
85  tmp<fvMatrix<Type>> tfvm
86  (
87  new fvMatrix<Type>
88  (
89  vf,
90  faceFlux.dimensions()*vf.dimensions()
91  )
92  );
93  fvMatrix<Type>& fvm = tfvm.ref();
94 
95  fvm.lower() = -weights.primitiveField()*faceFlux.primitiveField();
96  fvm.upper() = fvm.lower() + faceFlux.primitiveField();
97  fvm.negSumDiag();
98 
100  {
101  const fvPatchField<Type>& psf = vf.boundaryField()[patchi];
102  const fvsPatchScalarField& patchFlux = faceFlux.boundaryField()[patchi];
103  const fvsPatchScalarField& pw = weights.boundaryField()[patchi];
104 
105  fvm.internalCoeffs()[patchi] = patchFlux*psf.valueInternalCoeffs(pw);
106  fvm.boundaryCoeffs()[patchi] = -patchFlux*psf.valueBoundaryCoeffs(pw);
107  }
108 
109  if (tinterpScheme_().corrected())
110  {
111  tmp<SurfaceField<Type>> tfaceFluxCorrection
112  (
113  faceFlux*tinterpScheme_().correction(vf)
114  );
115 
116  fvm += fvc::surfaceIntegrate(tfaceFluxCorrection());
117 
118  if (vf.mesh().schemes().fluxRequired(vf.name()))
119  {
120  fvm.faceFluxCorrectionPtr() = tfaceFluxCorrection.ptr();
121  }
122  }
123 
124  return tfvm;
125 }
126 
127 
128 template<class Type>
131 (
132  const surfaceScalarField& faceFlux,
133  const VolField<Type>& vf
134 ) const
135 {
136  tmp<VolField<Type>> tConvection
137  (
138  fvc::surfaceIntegrate(flux(faceFlux, vf))
139  );
140 
141  tConvection.ref().rename
142  (
143  "convection(" + faceFlux.name() + ',' + vf.name() + ')'
144  );
145 
146  return tConvection;
147 }
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace fv
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
Generic GeometricField class.
const Internal::FieldType & primitiveField() const
Return a const-reference to the primitive field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const word & name() const
Return name.
Definition: IOobject.H:310
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
SurfaceField< Type > *& faceFluxCorrectionPtr()
Return pointer to face-flux non-orthogonal correction field.
Definition: fvMatrix.H:332
FieldField< Field, Type > & internalCoeffs()
fvBoundary scalar field containing pseudo-matrix coeffs
Definition: fvMatrix.H:319
FieldField< Field, Type > & boundaryCoeffs()
fvBoundary scalar field containing pseudo-matrix coeffs
Definition: fvMatrix.H:326
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< Field< scalar >> &) const
Return the matrix source coefficients corresponding to the.
Definition: fvPatchField.H:472
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< Field< scalar >> &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: fvPatchField.H:461
tmp< fvMatrix< Type > > fvmDiv(const surfaceScalarField &, const VolField< Type > &) const
const surfaceInterpolationScheme< Type > & interpScheme() const
tmp< SurfaceField< Type > > interpolate(const surfaceScalarField &, const VolField< Type > &) const
tmp< VolField< Type > > fvcDiv(const surfaceScalarField &, const VolField< Type > &) const
tmp< SurfaceField< Type > > flux(const surfaceScalarField &, const VolField< Type > &) const
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:83
scalarField & upper()
Definition: lduMatrix.C:197
scalarField & lower()
Definition: lduMatrix.C:168
A class for managing temporary objects.
Definition: tmp.H:55
T * ptr() const
Return tmp pointer for reuse.
Definition: tmpI.H:205
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField.
label patchi
tmp< SurfaceField< typename innerProduct< vector, Type >::type > > flux(const VolField< Type > &vf)
Return the face-flux field obtained from the given volVectorField.
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
void surfaceIntegrate(Field< Type > &ivf, const SurfaceField< Type > &ssf)
Namespace for OpenFOAM.
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
labelList fv(nPoints)