Loading...
Searching...
No Matches
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 Copyright (C) 2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "facGrad.H"
30#include "areaFields.H"
31#include "edgeFields.H"
32#include "facEdgeIntegrate.H"
33#include "faMesh.H"
34#include "faGradScheme.H"
35#include "gaussFaGrad.H"
36
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38
39namespace Foam
40{
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace fac
45{
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49template<class Type>
57grad
58(
60)
61{
62 return fa::gaussGrad<Type>::gradf(ssf, "grad(" + ssf.name() + ')');
63}
64
65
66template<class Type>
68<
70 <
72 >
73>
74grad
75(
77)
78{
79 typedef typename outerProduct<vector, Type>::type GradType;
81 (
82 fac::grad(tssf())
83 );
84 tssf.clear();
85 return Grad;
86}
87
88
89template<class Type>
91<
93 <
95 >
96>
97grad
98(
100 const word& name
101)
102{
103 typedef typename outerProduct<vector,Type>::type GradType;
105
106 tmp<GradFieldType> tgGrad
107 (
109 (
110 vf.mesh(),
111 vf.mesh().gradScheme(name)
112 )
113 .cref() // const ref to tmp contents
114 .grad(vf).ptr() // steal ptr or deep copy of cached gradient
115 );
116 auto& gGrad = tgGrad.ref();
117
118 const areaVectorField& n = vf.mesh().faceAreaNormals();
119 gGrad -= n*(n & gGrad);
120 gGrad.correctBoundaryConditions();
121
122 return tgGrad;
123}
124
125
126template<class Type>
128<
130 <
132 >
133>
134grad
135(
137 const word& name
138)
139{
140 tmp
141 <
143 <
145 >
146 > tGrad
147 (
148 fac::grad(tvf(), name)
149 );
150 tvf.clear();
151 return tGrad;
152}
153
154
155template<class Type>
163grad
164(
166)
167{
168 return fac::grad(vf, "grad(" + vf.name() + ')');
169}
170
171
172template<class Type>
174<
176 <
178 >
179>
180grad
181(
183)
184{
185 typedef typename outerProduct<vector, Type>::type GradType;
187 (
188 fac::grad(tvf())
189 );
190 tvf.clear();
191 return Grad;
192}
193
194
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197} // End namespace fac
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201} // End namespace Foam
202
203// ************************************************************************* //
label n
const Mesh & mesh() const noexcept
Return const reference to mesh.
Generic GeometricField class.
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
Mesh data needed to do the Finite Area discretisation.
Definition areaFaMesh.H:50
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
static tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > > gradf(const GeometricField< Type, faePatchField, edgeMesh > &, const word &name)
Return the gradient of the given field calculated using Gauss' theorem on the given surface field.
Definition gaussFaGrad.C:48
static tmp< gradScheme< Type > > New(const faMesh &mesh, Istream &schemeData)
Return a pointer to a new gradScheme created on freestore.
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition products.H:118
A class for managing temporary objects.
Definition tmp.H:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
A class for handling words, derived from Foam::string.
Definition word.H:66
Edge integrate edgeField creating a areaField. Edge sum a edgeField creating a areaField.
Calculate the gradient of the given field.
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > > grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition facGrad.C:51
Namespace for OpenFOAM.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127