gaussFaGrad.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 "gaussFaGrad.H"
29 #include "facGrad.H"
30 #include "areaFields.H"
31 #include "edgeFields.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace fa
41 {
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 template<class Type>
46 tmp
47 <
48  GeometricField
49  <
50  typename outerProduct<vector, Type>::type, faPatchField, areaMesh
51  >
52 >
54 (
55  const GeometricField<Type, faPatchField, areaMesh>& vsf
56 ) const
57 {
58  typedef typename outerProduct<vector, Type>::type GradType;
59 
60  tmp<GeometricField<GradType, faPatchField, areaMesh>> tgGrad
61  (
63  (
64  vsf.mesh().Le()
65  *tinterpScheme_().interpolate(vsf)
66  )
67  );
68 
69  GeometricField<GradType, faPatchField, areaMesh>& gGrad = tgGrad.ref();
70 
71  gGrad.correctBoundaryConditions();
72 
73  gGrad.rename("grad(" + vsf.name() + ')');
74  correctBoundaryConditions(vsf, gGrad);
75 
76  return tgGrad;
77 }
78 
79 
80 template<class Type>
82 (
85  <
87  >& gGrad
88 )
89 {
90  forAll(vsf.boundaryField(), patchI)
91  {
92  if (!vsf.boundaryField()[patchI].coupled())
93  {
94  const vectorField m
95  (
96  vsf.mesh().Le().boundaryField()[patchI]/
97  vsf.mesh().magLe().boundaryField()[patchI]
98  );
99 
100  gGrad.boundaryFieldRef()[patchI] += m*
101  (
102  vsf.boundaryField()[patchI].snGrad()
103  - (m & gGrad.boundaryField()[patchI])
104  );
105  }
106  }
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 } // End namespace fa
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 } // End namespace Foam
117 
118 // ************************************************************************* //
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
gaussFaGrad.H
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:114
Foam::fa::gaussGrad::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > > grad(const GeometricField< Type, faPatchField, areaMesh > &) const
Return the gradient of the given field calculated.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
correctBoundaryConditions
cellMask correctBoundaryConditions()
Foam::Field< vector >
edgeFields.H
Foam::areaMesh
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:53
areaFields.H
Foam::fac::edgeIntegrate
tmp< GeometricField< Type, faPatchField, areaMesh > > edgeIntegrate(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facEdgeIntegrate.C:47
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fa::gaussGrad::correctBoundaryConditions
static void correctBoundaryConditions(const GeometricField< Type, faPatchField, areaMesh > &, GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > &)
Correct the boundary values of the gradient using the patchField.
Definition: gaussFaGrad.C:82
facGrad.H
Calculate the gradient of the given field.
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62