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 | Copyright (C) 2011-2013 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&,
56 ) const
57 {
58  return tinterpScheme_().interpolate(vf);
59 }
60 
61 
62 template<class Type>
65 (
66  const surfaceScalarField& faceFlux,
68 ) const
69 {
70  return faceFlux*interpolate(faceFlux, vf);
71 }
72 
73 
74 template<class Type>
77 (
78  const surfaceScalarField& faceFlux,
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();
94 
95  fvm.lower() = -weights.internalField()*faceFlux.internalField();
96  fvm.upper() = fvm.lower() + faceFlux.internalField();
97  fvm.negSumDiag();
98 
99  forAll(vf.boundaryField(), patchI)
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  fvm += fvc::surfaceIntegrate(faceFlux*tinterpScheme_().correction(vf));
112  }
113 
114  return tfvm;
115 }
116 
117 
118 template<class Type>
121 (
122  const surfaceScalarField& faceFlux,
124 ) const
125 {
127  (
128  fvc::surfaceIntegrate(flux(faceFlux, vf))
129  );
130 
131  tConvection().rename
132  (
133  "convection(" + faceFlux.name() + ',' + vf.name() + ')'
134  );
135 
136  return tConvection;
137 }
138 
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 } // End namespace fv
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace Foam
147 
148 // ************************************************************************* //
Foam::fvPatchField< Type >
Foam::fv::gaussConvectionScheme::interpScheme
const surfaceInterpolationScheme< Type > & interpScheme() const
Definition: gaussConvectionScheme.C:44
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::fvMatrix::internalCoeffs
FieldField< Field, Type > & internalCoeffs()
fvBoundary scalar field containing pseudo-matrix coeffs
Definition: fvMatrix.H:303
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
Foam::fv::gaussConvectionScheme::fvcDiv
tmp< GeometricField< Type, fvPatchField, volMesh > > fvcDiv(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: gaussConvectionScheme.C:121
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::interpolate
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
fvcSurfaceIntegrate.H
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField.
Foam::fvPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< Field< scalar > > &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: fvPatchField.H:431
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
gaussConvectionScheme.H
Foam::fvMatrix::boundaryCoeffs
FieldField< Field, Type > & boundaryCoeffs()
fvBoundary scalar field containing pseudo-matrix coeffs
Definition: fvMatrix.H:310
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:65
Foam::fv::gaussConvectionScheme::interpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: gaussConvectionScheme.C:53
Foam::fvc::surfaceIntegrate
void surfaceIntegrate(Field< Type > &ivf, const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcSurfaceIntegrate.C:44
Foam::fvMatrix< Type >
Foam::fvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< Field< scalar > > &) const
Return the matrix source coefficients corresponding to the.
Definition: fvPatchField.H:442
Foam::fvc::flux
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux(const surfaceScalarField &phi, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcFlux.C:45
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::fv::gaussConvectionScheme::fvmDiv
tmp< fvMatrix< Type > > fvmDiv(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: gaussConvectionScheme.C:77