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>
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 // ************************************************************************* //
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField...
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
void surfaceIntegrate(Field< Type > &ivf, const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition: tmpI.H:235
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< Field< scalar >> &) const
Return the matrix source coefficients corresponding to the.
Definition: fvPatchField.H:815
scalarField & upper()
Definition: lduMatrix.C:208
const surfaceInterpolationScheme< Type > & interpScheme() const
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
labelList fv(nPoints)
tmp< GeometricField< Type, fvPatchField, volMesh > > fvcDiv(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:64
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< Field< scalar >> &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: fvPatchField.H:801
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
tmp< fvMatrix< Type > > fvmDiv(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
scalarField & lower()
Definition: lduMatrix.C:179
A special matrix type and solver, designed for finite volume solutions of scalar equations.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux(const surfaceScalarField &, const GeometricField< Type, fvPatchField, volMesh > &) const
const FieldField< Field, Type > & internalCoeffs() const noexcept
fvBoundary scalar field containing pseudo-matrix coeffs for internal cells
Definition: fvMatrix.H:547
const FieldField< Field, Type > & boundaryCoeffs() const noexcept
fvBoundary scalar field containing pseudo-matrix coeffs for boundary cells
Definition: fvMatrix.H:565
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Abstract base class for surface interpolation schemes.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Namespace for OpenFOAM.
const dimensionSet & dimensions() const noexcept
Return dimensions.