Loading...
Searching...
No Matches
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>
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() = std::make_unique
86 <
88 >
89 (
90 gammaMagSf*this->tlnGradScheme_().correction(vf)
91 );
92
93 fam.source() -=
94 this->mesh().S()
96 (
98 )().internalField();
99 }
100 else
101 {
102 fam.source() -=
103 this->mesh().S()
104 *fac::div
105 (
106 gammaMagSf*this->tlnGradScheme_().correction(vf)
107 )().internalField();
108 }
109 }
124 fac::div(this->tlnGradScheme_().lnGrad(vf)*vf.mesh().magLe())
125 );
126
127 tLaplacian.ref().rename("laplacian(" + vf.name() + ')');
129 return tLaplacian;
130}
131
132
133template<class Type>
136(
137 const edgeScalarField& gamma,
139)
140{
142 (
143 fac::div(gamma*this->tlnGradScheme_().lnGrad(vf)*vf.mesh().magLe())
144 );
145
146 tLaplacian.ref().rename
147 (
148 "laplacian(" + gamma.name() + ',' + vf.name() + ')'
149 );
150
151 return tLaplacian;
152}
153
154
155// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156
157} // End namespace fa
158
159// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160
161} // End namespace Foam
162
163// ************************************************************************* //
const Mesh & mesh() const noexcept
Return const reference to mesh.
const dimensionSet & dimensions() const noexcept
Return dimensions.
Generic GeometricField class.
const Internal & internalField() const noexcept
Return a const-reference to the dimensioned internal field.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition faMatrix.H:108
faceFluxFieldPtrType & faceFluxCorrectionPtr()
Return pointer to face-flux non-orthogonal correction field.
Definition faMatrix.H:412
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the evaluation of the gradient of this patch...
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the evaluation of the gradient of this patchFi...
tmp< faMatrix< Type > > famLaplacian(const edgeScalarField &, const GeometricField< Type, faPatchField, areaMesh > &)
tmp< GeometricField< Type, faPatchField, areaMesh > > facLaplacian(const GeometricField< Type, faPatchField, areaMesh > &)
tmp< lnGradScheme< Type > > tlnGradScheme_
A class for managing temporary objects.
Definition tmp.H:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
const scalar gamma
Definition EEqn.H:9
dynamicFvMesh & mesh
Calculate the divergence of the given field.
Namespace for finite-area.
Definition limitHeight.C:30
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition facDiv.C:43
Namespace for OpenFOAM.
faePatchField< scalar > faePatchScalarField
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
Calculate the matrix for the second temporal derivative.
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299