All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LeastSquaresGrad.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fv::LeastSquaresGrad
26 
27 Description
28  Gradient calculated using weighted least-squares on an arbitrary stencil.
29  The stencil type is provided via a template argument and any cell-based
30  stencil is supported:
31 
32  \table
33  Stencil | Connections | Scheme name
34  centredCFCCellToCellStencil | cell-face-cell | Not Instantiated
35  centredCPCCellToCellStencil | cell-point-cell | pointCellsLeastSquares
36  centredCECCellToCellStencil | cell-edge-cell | edgeCellsLeastSquares
37  \endtable
38 
39  The first of these is not instantiated by default as the standard
40  leastSquaresGrad is equivalent and more efficient.
41 
42 Usage
43  Example of the gradient specification:
44  \verbatim
45  gradSchemes
46  {
47  default pointCellsLeastSquares;
48  }
49  \endverbatim
50 
51 See also
52  Foam::fv::LeastSquaresVectors
53  Foam::fv::leastSquaresGrad
54 
55 SourceFiles
56  LeastSquaresGrad.C
57  LeastSquaresVectors.H
58  LeastSquaresVectors.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef LeastSquaresGrad_H
63 #define LeastSquaresGrad_H
64 
65 #include "gradScheme.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 namespace fv
75 {
76 
77 /*---------------------------------------------------------------------------*\
78  Class LeastSquaresGrad Declaration
79 \*---------------------------------------------------------------------------*/
80 
81 template<class Type, class Stencil>
82 class LeastSquaresGrad
83 :
84  public fv::gradScheme<Type>
85 {
86  // Private Data
87 
88  //- Minimum determinant criterion to choose extra cells
89  scalar minDet_;
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("LeastSquares");
96 
97 
98  // Constructors
99 
100  //- Construct from Istream
101  LeastSquaresGrad(const fvMesh& mesh, Istream& schemeData)
102  :
103  gradScheme<Type>(mesh)
104  {}
105 
106  //- Disallow default bitwise copy construction
107  LeastSquaresGrad(const LeastSquaresGrad&) = delete;
108 
109 
110  // Member Functions
111 
112  //- Return the gradient of the given field to the gradScheme::grad
113  // for optional caching
115  calcGrad
116  (
117  const VolField<Type>& vsf,
118  const word& name
119  ) const;
120 
121 
122  // Member Operators
123 
124  //- Disallow default bitwise assignment
125  void operator=(const LeastSquaresGrad&) = delete;
126 };
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace fv
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 // Add the patch constructor functions to the hash tables
140 
141 #define makeLeastSquaresGradTypeScheme(SS, STENCIL, TYPE) \
142  typedef Foam::fv::LeastSquaresGrad<Foam::TYPE, Foam::STENCIL> \
143  LeastSquaresGrad##TYPE##STENCIL##_; \
144  \
145  defineTemplateTypeNameAndDebugWithName \
146  (LeastSquaresGrad##TYPE##STENCIL##_, #SS, 0); \
147  \
148  namespace Foam \
149  { \
150  namespace fv \
151  { \
152  typedef LeastSquaresGrad<Foam::TYPE, Foam::STENCIL> \
153  LeastSquaresGrad##TYPE##STENCIL##_; \
154  \
155  gradScheme<Foam::TYPE>::addIstreamConstructorToTable \
156  <LeastSquaresGrad<Foam::TYPE, Foam::STENCIL>> \
157  add##SS##STENCIL##TYPE##IstreamConstructorToTable_; \
158  } \
159  }
160 
161 #define makeLeastSquaresGradScheme(SS, STENCIL) \
162  typedef Foam::fv::LeastSquaresVectors<Foam::STENCIL> \
163  LeastSquaresVectors##STENCIL##_; \
164  \
165  defineTemplateTypeNameAndDebugWithName \
166  (LeastSquaresVectors##STENCIL##_, #SS, 0); \
167  \
168  makeLeastSquaresGradTypeScheme(SS,STENCIL,scalar) \
169  makeLeastSquaresGradTypeScheme(SS,STENCIL,vector)
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #ifdef NoRepository
174  #include "LeastSquaresGrad.C"
175 #endif
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
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:99
Gradient calculated using weighted least-squares on an arbitrary stencil. The stencil type is provide...
void operator=(const LeastSquaresGrad &)=delete
Disallow default bitwise assignment.
LeastSquaresGrad(const fvMesh &mesh, Istream &schemeData)
Construct from Istream.
virtual tmp< VolField< typename outerProduct< vector, Type >::type > > calcGrad(const VolField< Type > &vsf, const word &name) const
Return the gradient of the given field to the gradScheme::grad.
TypeName("LeastSquares")
Runtime type information.
Abstract base class for gradient schemes.
Definition: gradScheme.H:63
const fvMesh & mesh() const
Return mesh reference.
Definition: gradScheme.H:116
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
labelList fv(nPoints)