Loading...
Searching...
No Matches
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-2023 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
62
63 scalar relax = 1;
64 const bool useRelax =
65 vsf.mesh().relaxField("grad(" + vsf.name() + ")", relax);
66
67 for (label i = 0; i < nIter_; ++i)
68 {
70
71 tmp<SurfFieldType> tcorr = skv() & tsgGrad;
72
73 tcorr.ref().dimensions().reset(vsf.dimensions());
74
75 if (useRelax)
76 {
77 // relax*prediction + (1-relax)*old
78 gGrad *= (1.0 - relax);
79 gGrad += relax*fv::gaussGrad<Type>::gradf(tcorr + ssf, name);
80 }
81 else
82 {
83 gGrad = fv::gaussGrad<Type>::gradf(tcorr + ssf, name);
84 }
85 }
86
88
89 return tgGrad;
90}
91
92
93// ************************************************************************* //
const Mesh & mesh() const noexcept
Return const reference to mesh.
const dimensionSet & dimensions() const noexcept
Return dimensions.
Generic GeometricField class.
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
static FOAM_NO_DANGLING_REFERENCE const skewCorrectionVectors & New(const fvMesh &mesh, Args &&... args)
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
static void correctBoundaryConditions(const GeometricField< Type, fvPatchField, volMesh > &, GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > &)
Correct the boundary values of the gradient using the patchField snGrad functions.
Definition gaussGrad.C:199
static tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > gradf(const GeometricField< Type, fvsPatchField, surfaceMesh > &, const word &name)
Return the gradient of the given field calculated using Gauss' theorem on the given surface field.
Definition gaussGrad.C:38
virtual tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > calcGrad(const GeometricField< Type, fvPatchField, volMesh > &vsf, const word &name) const
Return the gradient of the given field to the gradScheme::grad for optional caching.
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition products.H:118
Skew-correction vectors for the skewness-corrected interpolation scheme.
A class for managing temporary objects.
Definition tmp.H:75
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
Definition tmpI.H:221
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
Mesh data needed to do the Finite Volume discretisation.
Definition volMesh.H:47
A class for handling words, derived from Foam::string.
Definition word.H:66
UEqn relax()
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition linear.H:120
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127