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>
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() = std::make_unique
86  <
88  >
89  (
90  gammaMagSf*this->tlnGradScheme_().correction(vf)
91  );
92 
93  fam.source() -=
94  this->mesh().S()
95  *fac::div
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  }
110 
111  return tfam;
112 }
113 
114 
115 template<class Type>
118 (
120 )
121 {
123  (
124  fac::div(this->tlnGradScheme_().lnGrad(vf)*vf.mesh().magLe())
125  );
126 
127  tLaplacian.ref().rename("laplacian(" + vf.name() + ')');
128 
129  return tLaplacian;
130 }
131 
132 
133 template<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 // ************************************************************************* //
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
faceFluxFieldPtrType & faceFluxCorrectionPtr()
Return pointer to face-flux non-orthogonal correction field.
Definition: faMatrix.H:412
tmp< GeometricField< Type, faPatchField, areaMesh > > facLaplacian(const GeometricField< Type, faPatchField, areaMesh > &)
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition: tmpI.H:235
const Internal & internalField() const noexcept
Return a const-reference to the dimensioned internal field.
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:43
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:46
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the evaluation of the gradient of this patch...
Definition: faPatchField.H:762
const Mesh & mesh() const noexcept
Return mesh.
Calculate the divergence of the given field.
tmp< faMatrix< Type > > famLaplacian(const edgeScalarField &, const GeometricField< Type, faPatchField, areaMesh > &)
tmp< GeometricField< Type, faePatchField, edgeMesh > > lnGrad(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLnGrad.C:40
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the evaluation of the gradient of this patchFi...
Definition: faPatchField.H:772
A special matrix type and solver, designed for finite area solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: faMatricesFwd.H:37
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: edgeFieldsFwd.H:43
const scalar gamma
Definition: EEqn.H:9
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Calculate the matrix for the second temporal derivative.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Namespace for OpenFOAM.
const dimensionSet & dimensions() const noexcept
Return dimensions.