facGrad.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 "facGrad.H"
29 #include "areaFields.H"
30 #include "edgeFields.H"
31 #include "facEdgeIntegrate.H"
32 #include "faMesh.H"
33 #include "faGradScheme.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace fac
43 {
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 template<class Type>
48 tmp
49 <
50  GeometricField
51  <
52  typename outerProduct<vector, Type>::type, faPatchField, areaMesh
53  >
54 >
55 grad
56 (
58 )
59 {
60  const areaVectorField &n = ssf.mesh().faceAreaNormals();
61  typedef typename outerProduct<vector,Type>::type GradType;
62 
64  fac::edgeIntegrate(ssf.mesh().Sf()*ssf);
65 
67 
68  gGrad -= n*(n & gGrad);
69  gGrad.correctBoundaryConditions();
70 
71  return tgGrad;
72 }
73 
74 template<class Type>
75 tmp
76 <
78  <
80  >
81 >
82 grad
83 (
85 )
86 {
87  typedef typename outerProduct<vector, Type>::type GradType;
89  (
90  fac::grad(tssf())
91  );
92  tssf.clear();
93  return Grad;
94 }
95 
96 
97 template<class Type>
98 tmp
99 <
101  <
103  >
104 >
105 grad
106 (
108  const word& name
109 )
110 {
111  const areaVectorField &n = vf.mesh().faceAreaNormals();
112  typedef typename outerProduct<vector,Type>::type GradType;
113 
116  (
117  vf.mesh(),
118  vf.mesh().gradScheme(name)
119  ).ref().grad(vf);
120 
122 
123  gGrad -= n*(n & gGrad);
125 
126  return tgGrad;
127 }
128 
129 
130 template<class Type>
131 tmp
132 <
134  <
136  >
137 >
138 grad
139 (
141  const word& name
142 )
143 {
144  tmp
145  <
147  <
149  >
150  > tGrad
151  (
152  fac::grad(tvf(), name)
153  );
154  tvf.clear();
155  return tGrad;
156 }
157 
158 
159 template<class Type>
160 tmp
161 <
163  <
165  >
166 >
167 grad
168 (
170 )
171 {
172  return fac::grad(vf, "grad(" + vf.name() + ')');
173 }
174 
175 
176 template<class Type>
177 tmp
178 <
180  <
182  >
183 >
184 grad
185 (
187 )
188 {
189  typedef typename outerProduct<vector, Type>::type GradType;
191  (
192  fac::grad(tvf())
193  );
194  tvf.clear();
195  return Grad;
196 }
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace fac
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace Foam
206 
207 // ************************************************************************* //
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:114
Foam::fac::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:56
faMesh.H
faGradScheme.H
ref
rDeltaT ref()
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::fa::gradScheme::New
static tmp< gradScheme< Type > > New(const faMesh &mesh, Istream &schemeData)
Return a pointer to a new gradScheme created on freestore.
Definition: faGradScheme.C:46
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
facEdgeIntegrate.H
Edge integrate edgeField creating a areaField. Edge sum a edgeField creating a areaField.
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
fac
Calculate the second temporal derivative.
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
facGrad.H
Calculate the gradient of the given field.
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53