Loading...
Searching...
No Matches
LeastSquaresGrad.H
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) 2013-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2021 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
27Class
28 Foam::fv::LeastSquaresGrad
29
30Group
31 grpFvGradSchemes
32
33Description
34 Gradient calculated using weighted least-squares on an arbitrary stencil.
35 The stencil type is provided via a template argument and any cell-based
36 stencil is supported:
37
38 \table
39 Stencil | Connections | Scheme name
40 centredCFCCellToCellStencil | cell-face-cell | Not Instantiated
41 centredCPCCellToCellStencil | cell-point-cell | pointCellsLeastSquares
42 centredCECCellToCellStencil | cell-edge-cell | edgeCellsLeastSquares
43 \endtable
44
45 The first of these is not instantiated by default as the standard
46 leastSquaresGrad is equivalent and more efficient.
47
48Usage
49 Example of the gradient specification:
50 \verbatim
51 gradSchemes
52 {
53 default pointCellsLeastSquares;
54 }
55 \endverbatim
56
57See also
58 Foam::fv::LeastSquaresVectors
59 Foam::fv::leastSquaresGrad
60
61SourceFiles
62 LeastSquaresGrad.C
63 LeastSquaresVectors.H
64 LeastSquaresVectors.C
65
66\*---------------------------------------------------------------------------*/
67
68#ifndef LeastSquaresGrad_H
69#define LeastSquaresGrad_H
70
71#include "gradScheme.H"
72
73// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74
75namespace Foam
76{
77
78// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79
80namespace fv
81{
82
83/*---------------------------------------------------------------------------*\
84 Class LeastSquaresGrad Declaration
85\*---------------------------------------------------------------------------*/
86
87template<class Type, class Stencil>
89:
90 public fv::gradScheme<Type>
91{
92 // Private Data
93
94 //- Minimum determinant criterion to choose extra cells
95 scalar minDet_;
96
97
98 // Private Member Functions
100 //- No copy construct
101 LeastSquaresGrad(const LeastSquaresGrad&) = delete;
102
103 //- No copy assignment
104 void operator=(const LeastSquaresGrad&) = delete;
105
106
107public:
108
109 //- Runtime type information
110 TypeName("LeastSquares");
111
112
113 // Constructors
114
115 //- Construct from Istream
116 LeastSquaresGrad(const fvMesh& mesh, Istream& schemeData)
117 :
118 gradScheme<Type>(mesh)
119 {}
120
121
122 // Member Functions
123
124 //- Return the gradient of the given field to the gradScheme::grad
125 //- for optional caching
126 virtual tmp
127 <
130 > calcGrad
131 (
133 const word& name
134 ) const;
135
136 //- Calculate the grad of the given field into supplied field
137 virtual void calcGrad
138 (
142 ) const;
143};
144
145
146// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147
148} // End namespace fv
149
150// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151
152} // End namespace Foam
154// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155
156// Add the patch constructor functions to the hash tables
157
158#define makeLeastSquaresGradTypeScheme(SS, STENCIL, TYPE) \
159 typedef Foam::fv::LeastSquaresGrad<Foam::TYPE, Foam::STENCIL> \
160 LeastSquaresGrad##TYPE##STENCIL##_; \
161 \
162 defineTemplateTypeNameAndDebugWithName \
163 (LeastSquaresGrad##TYPE##STENCIL##_, #SS, 0); \
164 \
165 namespace Foam \
166 { \
167 namespace fv \
168 { \
169 typedef LeastSquaresGrad<Foam::TYPE, Foam::STENCIL> \
170 LeastSquaresGrad##TYPE##STENCIL##_; \
171 \
172 gradScheme<Foam::TYPE>::addIstreamConstructorToTable \
173 <LeastSquaresGrad<Foam::TYPE, Foam::STENCIL>> \
174 add##SS##STENCIL##TYPE##IstreamConstructorToTable_; \
175 } \
176 }
177
178#define makeLeastSquaresGradScheme(SS, STENCIL) \
179 typedef Foam::fv::LeastSquaresVectors<Foam::STENCIL> \
180 LeastSquaresVectors##STENCIL##_; \
181 \
182 defineTemplateTypeNameAndDebugWithName \
183 (LeastSquaresVectors##STENCIL##_, #SS, 0); \
184 \
185 makeLeastSquaresGradTypeScheme(SS,STENCIL,scalar) \
186 makeLeastSquaresGradTypeScheme(SS,STENCIL,vector)
187
188// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189
190#ifdef NoRepository
191 #include "LeastSquaresGrad.C"
192#endif
193
194// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195
196#endif
197
198// ************************************************************************* //
Generic GeometricField class.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Gradient calculated using weighted least-squares on an arbitrary stencil. The stencil type is provide...
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.
LeastSquaresGrad(const fvMesh &mesh, Istream &schemeData)
Construct from Istream.
virtual void calcGrad(GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > &res, const GeometricField< Type, fvPatchField, volMesh > &) const
Calculate the grad of the given field into supplied field.
TypeName("LeastSquares")
Runtime type information.
Abstract base class for gradient schemes.
Definition gradScheme.H:62
const fvMesh & mesh() const
Return const reference to mesh.
Definition gradScheme.H:138
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
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
Namespace for finite-volume.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68