facNGrad.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 "facNGrad.H"
29 #include "areaFields.H"
30 #include "edgeFields.H"
31 #include "facEdgeIntegrate.H"
32 #include "faMesh.H"
33 #include "faGradScheme.H"
34 #include "transformField.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace fac
44 {
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 template<class Type>
49 tmp
50 <
51  GeometricField
52  <
53  typename outerProduct<vector, Type>::type, faPatchField, areaMesh
54  >
55 >
56 ngrad
57 (
59 )
60 {
61  const areaVectorField& n = ssf.mesh().faceAreaNormals();
62  typedef typename outerProduct<vector,Type>::type GradType;
63 
65  fac::edgeIntegrate(ssf.mesh().Sf()*ssf);
66 
68 
69  gGrad = n*(n & gGrad);
70  gGrad.correctBoundaryConditions();
71 
72  return tgGrad;
73 }
74 
75 
76 template<class Type>
77 tmp
78 <
80  <
82  >
83 >
84 ngrad
85 (
87 )
88 {
89  typedef typename outerProduct<vector, Type>::type GradType;
91  (
92  fac::ngrad(tssf())
93  );
94  tssf.clear();
95 
96  return Grad;
97 }
98 
99 
100 template<class Type>
101 tmp
102 <
104  <
106  >
107 >
108 ngrad
109 (
111  const word& name
112 )
113 {
114  const areaVectorField& n = vf.mesh().faceAreaNormals();
115  typedef typename outerProduct<vector,Type>::type GradType;
116 
119  (
120  vf.mesh(),
121  vf.mesh().gradScheme(name)
122  ).ref().grad(vf);
123 
125 
126  gGrad = n*(n & gGrad);
128 
129  return tgGrad;
130 }
131 
132 
133 template<class Type>
134 tmp
135 <
137  <
139  >
140 >
141 ngrad
142 (
144  const word& name
145 )
146 {
147  tmp
148  <
150  <
152  >
153  > tGrad
154  (
155  fac::ngrad(tvf(), name)
156  );
157  tvf.clear();
158 
159  return tGrad;
160 }
161 
162 
163 template<class Type>
164 tmp
165 <
167  <
169  >
170 >
171 ngrad
172 (
174 )
175 {
176  return fac::ngrad(vf, "grad(" + vf.name() + ')');
177 }
178 
179 
180 template<class Type>
181 tmp
182 <
184  <
186  >
187 >
188 ngrad
189 (
191 )
192 {
193  typedef typename outerProduct<vector, Type>::type GradType;
195  (
196  fac::ngrad(tvf())
197  );
198  tvf.clear();
199 
200  return Grad;
201 }
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace fac
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace Foam
211 
212 // ************************************************************************* //
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
faMesh.H
faGradScheme.H
ref
rDeltaT ref()
transformField.H
Spatial transformation functions for primitive fields.
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
facNGrad.H
Calculate the gradient normal to the surface 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
Foam::fac::ngrad
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> ngrad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facNGrad.C:57