gaussConvectionScheme.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "gaussConvectionScheme.H"
29 #include "fvcSurfaceIntegrate.H"
30 #include "fvMatrices.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace fv
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 template<class Type>
45 const surfaceInterpolationScheme<Type>&
47 {
48  return tinterpScheme_();
49 }
50 
51 
52 template<class Type>
55 (
56  const surfaceScalarField&,
58 ) const
59 {
60  return tinterpScheme_().interpolate(vf);
61 }
62 
63 
64 template<class Type>
67 (
68  const surfaceScalarField& faceFlux,
70 ) const
71 {
72  return faceFlux*interpolate(faceFlux, vf);
73 }
74 
75 
76 template<class Type>
79 (
80  const surfaceScalarField& faceFlux,
82 ) const
83 {
84  tmp<surfaceScalarField> tweights = tinterpScheme_().weights(vf);
85  const surfaceScalarField& weights = tweights();
86 
87  tmp<fvMatrix<Type>> tfvm
88  (
89  new fvMatrix<Type>
90  (
91  vf,
92  faceFlux.dimensions()*vf.dimensions()
93  )
94  );
95  fvMatrix<Type>& fvm = tfvm.ref();
96 
97  fvm.lower() = -weights.primitiveField()*faceFlux.primitiveField();
98  fvm.upper() = fvm.lower() + faceFlux.primitiveField();
99  fvm.negSumDiag();
100 
101  forAll(vf.boundaryField(), patchi)
102  {
103  const fvPatchField<Type>& psf = vf.boundaryField()[patchi];
104  const fvsPatchScalarField& patchFlux = faceFlux.boundaryField()[patchi];
105  const fvsPatchScalarField& pw = weights.boundaryField()[patchi];
106 
107  fvm.internalCoeffs()[patchi] = patchFlux*psf.valueInternalCoeffs(pw);
108  fvm.boundaryCoeffs()[patchi] = -patchFlux*psf.valueBoundaryCoeffs(pw);
109  }
110 
111  if (tinterpScheme_().corrected())
112  {
113  fvm += fvc::surfaceIntegrate(faceFlux*tinterpScheme_().correction(vf));
114  }
115 
116  return tfvm;
117 }
118 
119 
120 template<class Type>
123 (
124  const surfaceScalarField& faceFlux,
126 ) const
127 {
129  (
130  fvc::surfaceIntegrate(flux(faceFlux, vf))
131  );
132 
133  tConvection.ref().rename
134  (
135  "convection(" + faceFlux.name() + ',' + vf.name() + ')'
136  );
137 
138  return tConvection;
139 }
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace fv
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace Foam
149 
150 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
Foam::fvc::flux
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
Foam::fv::gaussConvectionScheme::interpScheme
const surfaceInterpolationScheme< Type > & interpScheme() const
Definition: gaussConvectionScheme.C:46
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::GeometricField::primitiveField
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Definition: GeometricFieldI.H:53
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
Foam::fvMatrix::boundaryCoeffs
const FieldField< Field, Type > & boundaryCoeffs() const
Definition: fvMatrix.H:323
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Foam::fv::gaussConvectionScheme::fvcDiv
tmp< GeometricField< Type, fvPatchField, volMesh > > fvcDiv(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: gaussConvectionScheme.C:123
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::fvPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< Field< scalar >> &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: fvPatchField.H:459
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:228
Foam::interpolate
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
Foam::fvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< Field< scalar >> &) const
Return the matrix source coefficients corresponding to the.
Definition: fvPatchField.H:470
fvcSurfaceIntegrate.H
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
gaussConvectionScheme.H
fv
labelList fv(nPoints)
Foam::fv::gaussConvectionScheme::flux
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: gaussConvectionScheme.C:67
Foam::fv::gaussConvectionScheme::interpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: gaussConvectionScheme.C:55
Foam::fvc::surfaceIntegrate
void surfaceIntegrate(Field< Type > &ivf, const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcSurfaceIntegrate.C:46
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::fvMatrix::internalCoeffs
const FieldField< Field, Type > & internalCoeffs() const
Definition: fvMatrix.H:309
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
Foam::fv::gaussConvectionScheme::fvmDiv
tmp< fvMatrix< Type > > fvmDiv(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: gaussConvectionScheme.C:79