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-2019 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
114  virtual tmp
115  <
118  > calcGrad
119  (
121  const word& name
122  ) const;
123 
124 
125  // Member Operators
126 
127  //- Disallow default bitwise assignment
128  void operator=(const LeastSquaresGrad&) = delete;
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 } // End namespace fv
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 // Add the patch constructor functions to the hash tables
143 
144 #define makeLeastSquaresGradTypeScheme(SS, STENCIL, TYPE) \
145  typedef Foam::fv::LeastSquaresGrad<Foam::TYPE, Foam::STENCIL> \
146  LeastSquaresGrad##TYPE##STENCIL##_; \
147  \
148  defineTemplateTypeNameAndDebugWithName \
149  (LeastSquaresGrad##TYPE##STENCIL##_, #SS, 0); \
150  \
151  namespace Foam \
152  { \
153  namespace fv \
154  { \
155  typedef LeastSquaresGrad<Foam::TYPE, Foam::STENCIL> \
156  LeastSquaresGrad##TYPE##STENCIL##_; \
157  \
158  gradScheme<Foam::TYPE>::addIstreamConstructorToTable \
159  <LeastSquaresGrad<Foam::TYPE, Foam::STENCIL>> \
160  add##SS##STENCIL##TYPE##IstreamConstructorToTable_; \
161  } \
162  }
163 
164 #define makeLeastSquaresGradScheme(SS, STENCIL) \
165  typedef Foam::fv::LeastSquaresVectors<Foam::STENCIL> \
166  LeastSquaresVectors##STENCIL##_; \
167  \
168  defineTemplateTypeNameAndDebugWithName \
169  (LeastSquaresVectors##STENCIL##_, #SS, 0); \
170  \
171  makeLeastSquaresGradTypeScheme(SS,STENCIL,scalar) \
172  makeLeastSquaresGradTypeScheme(SS,STENCIL,vector)
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #ifdef NoRepository
177  #include "LeastSquaresGrad.C"
178 #endif
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #endif
183 
184 // ************************************************************************* //
Gradient calculated using weighted least-squares on an arbitrary stencil. The stencil type is provide...
TypeName("LeastSquares")
Runtime type information.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:90
Generic GeometricField class.
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:53
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.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Abstract base class for gradient schemes.
Definition: gradScheme.H:60
LeastSquaresGrad(const fvMesh &mesh, Istream &schemeData)
Construct from Istream.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
A class for managing temporary objects.
Definition: PtrList.H:53
const fvMesh & mesh() const
Return mesh reference.
Definition: gradScheme.H:122
void operator=(const LeastSquaresGrad &)=delete
Disallow default bitwise assignment.
Namespace for OpenFOAM.