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 -------------------------------------------------------------------------------
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 "gaussFaLaplacianScheme.H"
29 #include "facDiv.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<faMatrix<Type>>
47 (
48  const edgeScalarField& gamma,
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 
57  tmp<faMatrix<Type>> tfam
58  (
59  new faMatrix<Type>
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()
93  *fac::div
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 
113 template<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 
131 template<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 // ************************************************************************* //
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
Foam::faMatrix
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatricesFwd.H:43
Foam::fa::gaussLaplacianScheme::famLaplacian
tmp< faMatrix< Type > > famLaplacian(const edgeScalarField &, const GeometricField< Type, faPatchField, areaMesh > &)
Definition: gaussFaLaplacianScheme.C:47
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
Foam::faMatrix::faceFluxCorrectionPtr
faceFluxFieldPtrType & faceFluxCorrectionPtr()
Return pointer to face-flux non-orthogonal correction field.
Definition: faMatrix.H:308
faMatrices.H
facDiv.H
Calculate the divergence of the given field.
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
gaussFaLaplacianScheme.H
Foam::GeometricField::internalField
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
Definition: GeometricFieldI.H:43
Foam::fac::div
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:50
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::faPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Definition: faPatchField.H:409
Foam::fa::gaussLaplacianScheme::facLaplacian
tmp< GeometricField< Type, faPatchField, areaMesh > > facLaplacian(const GeometricField< Type, faPatchField, areaMesh > &)
Definition: gaussFaLaplacianScheme.C:116
Foam::fac::lnGrad
tmp< GeometricField< Type, faePatchField, edgeMesh > > lnGrad(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLnGrad.C:47
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Definition: faPatchField.H:417
gamma
const scalar gamma
Definition: EEqn.H:9
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