gaussFaLaplacianScheme.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-------------------------------------------------------------------------------
10License
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 "facDiv.H"
30#include "faMatrices.H"
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38
39namespace fa
40{
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44template<class Type>
45tmp<faMatrix<Type>>
47(
50)
51{
52 tmp<edgeScalarField> tdeltaCoeffs = this->tlnGradScheme_().deltaCoeffs(vf);
53 const edgeScalarField& deltaCoeffs = tdeltaCoeffs();
54
55 const edgeScalarField gammaMagSf(gamma*this->mesh().magLe());
56
58 (
60 (
61 vf,
62 deltaCoeffs.dimensions()*gammaMagSf.dimensions()*vf.dimensions()
63 )
64 );
65 faMatrix<Type>& fam = tfam.ref();
66
67 fam.upper() = deltaCoeffs.internalField()*gammaMagSf.internalField();
68 fam.negSumDiag();
69
70 forAll(fam.psi().boundaryField(), patchI)
71 {
72 const faPatchField<Type>& psf = fam.psi().boundaryField()[patchI];
73 const faePatchScalarField& patchGamma =
74 gammaMagSf.boundaryField()[patchI];
75
76 fam.internalCoeffs()[patchI] = patchGamma*psf.gradientInternalCoeffs();
77 fam.boundaryCoeffs()[patchI] =
78 -patchGamma*psf.gradientBoundaryCoeffs();
79 }
80
81 if (this->tlnGradScheme_().corrected())
82 {
83 if (this->mesh().fluxRequired(vf.name()))
84 {
85 fam.faceFluxCorrectionPtr() = new
87 (
88 gammaMagSf*this->tlnGradScheme_().correction(vf)
89 );
90
91 fam.source() -=
92 this->mesh().S()
94 (
96 )().internalField();
97 }
98 else
99 {
100 fam.source() -=
101 this->mesh().S()
102 *fac::div
103 (
104 gammaMagSf*this->tlnGradScheme_().correction(vf)
105 )().internalField();
106 }
107 }
108
109 return tfam;
110}
111
112
113template<class Type>
116(
118)
119{
121 (
122 fac::div(this->tlnGradScheme_().lnGrad(vf)*vf.mesh().magLe())
123 );
124
125 tLaplacian.ref().rename("laplacian(" + vf.name() + ')');
126
127 return tLaplacian;
128}
129
130
131template<class Type>
134(
135 const edgeScalarField& gamma,
137)
138{
140 (
141 fac::div(gamma*this->tlnGradScheme_().lnGrad(vf)*vf.mesh().magLe())
142 );
143
144 tLaplacian.ref().rename
145 (
146 "laplacian(" + gamma.name() + ',' + vf.name() + ')'
147 );
148
149 return tLaplacian;
150}
151
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155} // End namespace fa
156
157// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158
159} // End namespace Foam
160
161// ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatrix.H:76
faceFluxFieldPtrType & faceFluxCorrectionPtr()
Return pointer to face-flux non-orthogonal correction field.
Definition: faMatrix.H:323
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: faPatchField.H:82
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Definition: faPatchField.H:416
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Definition: faPatchField.H:424
tmp< faMatrix< Type > > famLaplacian(const edgeScalarField &, const GeometricField< Type, faPatchField, areaMesh > &)
tmp< GeometricField< Type, faPatchField, areaMesh > > facLaplacian(const GeometricField< Type, faPatchField, areaMesh > &)
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
const scalar gamma
Definition: EEqn.H:9
dynamicFvMesh & mesh
Calculate the divergence of the given field.
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:50
Namespace for OpenFOAM.
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Calculate the matrix for the second temporal derivative.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333