gaussLaplacianSchemes.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) 2011-2016 OpenFOAM Foundation
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 "gaussLaplacianScheme.H"
29 #include "fvMesh.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 makeFvLaplacianScheme(gaussLaplacianScheme)
34 
35 #define declareFvmLaplacianScalarGamma(Type) \
36  \
37 template<> \
38 Foam::tmp<Foam::fvMatrix<Foam::Type>> \
39 Foam::fv::gaussLaplacianScheme<Foam::Type, Foam::scalar>::fvmLaplacian \
40 ( \
41  const GeometricField<scalar, fvsPatchField, surfaceMesh>& gamma, \
42  const GeometricField<Type, fvPatchField, volMesh>& vf \
43 ) \
44 { \
45  const fvMesh& mesh = this->mesh(); \
46  \
47  GeometricField<scalar, fvsPatchField, surfaceMesh> gammaMagSf \
48  ( \
49  gamma*mesh.magSf() \
50  ); \
51  \
52  tmp<fvMatrix<Type>> tfvm = fvmLaplacianUncorrected \
53  ( \
54  gammaMagSf, \
55  this->tsnGradScheme_().deltaCoeffs(vf), \
56  vf \
57  ); \
58  fvMatrix<Type>& fvm = tfvm.ref(); \
59  \
60  if (this->tsnGradScheme_().corrected()) \
61  { \
62  if (mesh.fluxRequired(vf.name())) \
63  { \
64  fvm.faceFluxCorrectionPtr() = std::make_unique \
65  < \
66  GeometricField<Type, fvsPatchField, surfaceMesh> \
67  > \
68  ( \
69  gammaMagSf*this->tsnGradScheme_().correction(vf) \
70  ); \
71  \
72  fvm.source() -= \
73  mesh.V()* \
74  fvc::div \
75  ( \
76  *fvm.faceFluxCorrectionPtr() \
77  )().primitiveField(); \
78  } \
79  else \
80  { \
81  fvm.source() -= \
82  mesh.V()* \
83  fvc::div \
84  ( \
85  gammaMagSf*this->tsnGradScheme_().correction(vf) \
86  )().primitiveField(); \
87  } \
88  } \
89  \
90  return tfvm; \
91 } \
92  \
93  \
94 template<> \
95 Foam::tmp<Foam::GeometricField<Foam::Type, Foam::fvPatchField, Foam::volMesh>> \
96 Foam::fv::gaussLaplacianScheme<Foam::Type, Foam::scalar>::fvcLaplacian \
97 ( \
98  const GeometricField<scalar, fvsPatchField, surfaceMesh>& gamma, \
99  const GeometricField<Type, fvPatchField, volMesh>& vf \
100 ) \
101 { \
102  const fvMesh& mesh = this->mesh(); \
103  \
104  tmp<GeometricField<Type, fvPatchField, volMesh>> tLaplacian \
105  ( \
106  fvc::div(gamma*this->tsnGradScheme_().snGrad(vf)*mesh.magSf()) \
107  ); \
108  \
109  tLaplacian.ref().rename \
110  ( \
111  "laplacian(" + gamma.name() + ',' + vf.name() + ')' \
112  ); \
113  \
114  return tLaplacian; \
115 }
116 
117 
123 
124 
125 // ************************************************************************* //
#define declareFvmLaplacianScalarGamma(Type)
makeFvLaplacianScheme(gaussLaplacianScheme)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Tensor of scalars, i.e. Tensor<scalar>.