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>
88class LeastSquaresGrad
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
99
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
133 const word& name
134 ) const;
135};
136
137
138// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139
140} // End namespace fv
141
142// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143
144} // End namespace Foam
145
146// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147
148// Add the patch constructor functions to the hash tables
149
150#define makeLeastSquaresGradTypeScheme(SS, STENCIL, TYPE) \
151 typedef Foam::fv::LeastSquaresGrad<Foam::TYPE, Foam::STENCIL> \
152 LeastSquaresGrad##TYPE##STENCIL##_; \
153 \
154 defineTemplateTypeNameAndDebugWithName \
155 (LeastSquaresGrad##TYPE##STENCIL##_, #SS, 0); \
156 \
157 namespace Foam \
158 { \
159 namespace fv \
160 { \
161 typedef LeastSquaresGrad<Foam::TYPE, Foam::STENCIL> \
162 LeastSquaresGrad##TYPE##STENCIL##_; \
163 \
164 gradScheme<Foam::TYPE>::addIstreamConstructorToTable \
165 <LeastSquaresGrad<Foam::TYPE, Foam::STENCIL>> \
166 add##SS##STENCIL##TYPE##IstreamConstructorToTable_; \
167 } \
168 }
169
170#define makeLeastSquaresGradScheme(SS, STENCIL) \
171 typedef Foam::fv::LeastSquaresVectors<Foam::STENCIL> \
172 LeastSquaresVectors##STENCIL##_; \
173 \
174 defineTemplateTypeNameAndDebugWithName \
175 (LeastSquaresVectors##STENCIL##_, #SS, 0); \
176 \
177 makeLeastSquaresGradTypeScheme(SS,STENCIL,scalar) \
178 makeLeastSquaresGradTypeScheme(SS,STENCIL,vector)
179
180// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181
182#ifdef NoRepository
183 #include "LeastSquaresGrad.C"
184#endif
186// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188#endif
189
190// ************************************************************************* //
Generic GeometricField class.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:82
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
LeastSquaresGrad(const fvMesh &mesh, Istream &schemeData)
Construct from Istream.
TypeName("LeastSquares")
Runtime type information.
Abstract base class for gradient schemes.
Definition: gradScheme.H:66
const fvMesh & mesh() const
Return const reference to mesh.
Definition: gradScheme.H:126
A class for managing temporary objects.
Definition: tmp.H:65
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
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
labelList fv(nPoints)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73