iterativeGaussGrad.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) 2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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 "iterativeGaussGrad.H"
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32
33template<class Type>
35<
37 <
41 >
42>
44(
46 const word& name
47) const
48{
49 typedef typename outerProduct<vector, Type>::type GradType;
52 GradSurfFieldType;
54
56 const SurfFieldType& ssf = tssf.cref();
57
59 GradFieldType& gGrad = tgGrad.ref();
60
61 const skewCorrectionVectors& skv = skewCorrectionVectors::New(vsf.mesh());
62
63 for (label i = 0; i < nIter_; ++i)
64 {
66
67 tmp<SurfFieldType> tcorr = skv() & tsgGrad;
68
69 tcorr.ref().dimensions().reset(vsf.dimensions());
70
71 if (vsf.mesh().relaxField("grad(" + vsf.name() + ")"))
72 {
73 const scalar relax =
74 vsf.mesh().fieldRelaxationFactor("grad(" + vsf.name() + ")");
75
76 // relax*prediction + (1-relax)*old
77 gGrad *= (1.0 - relax);
78 gGrad += relax*fv::gaussGrad<Type>::gradf(tcorr + ssf, name);
79 }
80 else
81 {
82 gGrad = fv::gaussGrad<Type>::gradf(tcorr + ssf, name);
83 }
84 }
85
87
88 return tgGrad;
89}
90
91
92// ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
Generic GeometricField class.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:82
Basic second-order gradient scheme using face-interpolation and Gauss' theorem.
Definition: gaussGrad.H:66
A second-order gradient scheme using face-interpolation, Gauss' theorem and iterative skew correction...
Skew-correction vectors for the skewness-corrected interpolation scheme.
A class for managing temporary objects.
Definition: tmp.H:65
const T & cref() const
Definition: tmpI.H:213
T & ref() const
Definition: tmpI.H:227
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:54
type
Volume classification types.
Definition: volumeType.H:66
A class for handling words, derived from Foam::string.
Definition: word.H:68
UEqn relax()
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: linear.H:112
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59