gaussFaConvectionScheme.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) 2016-2017 Wikki Ltd
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 
29 #include "facEdgeIntegrate.H"
30 #include "faMatrices.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace fa
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 template<class Type>
45 tmp<GeometricField<Type, faePatchField, edgeMesh>>
47 (
48  const edgeScalarField& faceFlux,
50 ) const
51 {
52  return faceFlux*tinterpScheme_().interpolate(vf);
53 }
54 
55 
56 template<class Type>
59 (
60  const edgeScalarField& faceFlux,
62 ) const
63 {
64  tmp<edgeScalarField> tweights = tinterpScheme_().weights(vf);
65  const edgeScalarField& weights = tweights();
66 
67  tmp<faMatrix<Type>> tfam
68  (
69  new faMatrix<Type>
70  (
71  vf,
72  faceFlux.dimensions()*vf.dimensions()
73  )
74  );
75  faMatrix<Type>& fam = tfam.ref();
76 
77  fam.lower() = -weights.internalField()*faceFlux.internalField();
78  fam.upper() = fam.lower() + faceFlux.internalField();
79  fam.negSumDiag();
80 
81  forAll(fam.psi().boundaryField(), patchI)
82  {
83  const faPatchField<Type>& psf = fam.psi().boundaryField()[patchI];
84  const faePatchScalarField& patchFlux = faceFlux.boundaryField()[patchI];
85  const faePatchScalarField& pw = weights.boundaryField()[patchI];
86 
87  fam.internalCoeffs()[patchI] = patchFlux*psf.valueInternalCoeffs(pw);
88  fam.boundaryCoeffs()[patchI] = -patchFlux*psf.valueBoundaryCoeffs(pw);
89  }
90 
91 // if (tinterpScheme_().corrected())
92 // {
93 // fam += fac::edgeIntegrate(faceFlux*tinterpScheme_().correction(vf));
94 // }
95 
96  // Non-euclidian and other corrections
98  (
99  flux(faceFlux, vf)
100  - faceFlux*tinterpScheme_().euclidianInterpolate(vf)
101  );
102 
103  fam += fac::edgeIntegrate(convFluxCorr);
104 
105  return tfam;
106 }
107 
108 
109 template<class Type>
112 (
113  const edgeScalarField& faceFlux,
115 ) const
116 {
118  (
119  fac::edgeIntegrate(flux(faceFlux, vf))
120  );
121 
122  tConvection.ref().rename
123  (
124  "convection(" + faceFlux.name() + ',' + vf.name() + ')'
125  );
126 
127  return tConvection;
128 }
129 
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 } // End namespace fa
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace Foam
138 
139 // ************************************************************************* //
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
Foam::fvc::flux
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
Foam::faMatrix
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatricesFwd.H:43
Foam::faePatchField
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: edgeFieldsFwd.H:49
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
faMatrices.H
Foam::GeometricField::internalField
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
Definition: GeometricFieldI.H:43
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::faPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< Field< scalar >> &) const
Definition: faPatchField.H:388
Foam::fa::gaussConvectionScheme::facDiv
tmp< GeometricField< Type, faPatchField, areaMesh > > facDiv(const edgeScalarField &, const GeometricField< Type, faPatchField, areaMesh > &) const
Definition: gaussFaConvectionScheme.C:112
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
facEdgeIntegrate.H
Edge integrate edgeField creating a areaField. Edge sum a edgeField creating a areaField.
Foam::fa::gaussConvectionScheme::flux
tmp< GeometricField< Type, faePatchField, edgeMesh > > flux(const edgeScalarField &, const GeometricField< Type, faPatchField, areaMesh > &) const
Definition: gaussFaConvectionScheme.C:47
Foam::faPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< Field< scalar >> &) const
Definition: faPatchField.H:399
Foam::fac::edgeIntegrate
tmp< GeometricField< Type, faPatchField, areaMesh > > edgeIntegrate(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facEdgeIntegrate.C:47
gaussFaConvectionScheme.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fa::gaussConvectionScheme::famDiv
tmp< faMatrix< Type > > famDiv(const edgeScalarField &, const GeometricField< Type, faPatchField, areaMesh > &) const
Definition: gaussFaConvectionScheme.C:59
fam
Calculate the matrix for the second temporal derivative.
Foam::GeometricField< scalar, faePatchField, edgeMesh >
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62