iterativeGaussGrad.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) 2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 Class
27  Foam::fv::iterativeGaussGrad
28 
29 Description
30  A second-order gradient scheme using face-interpolation,
31  Gauss' theorem and iterative skew correction.
32 
33 Usage
34  Minimal example by using \c system/fvSchemes:
35  \verbatim
36  gradSchemes
37  {
38  grad(<term>) iterativeGauss <interpolation scheme> <number of iters>;
39  }
40  \endverbatim
41 
42  and by using \c system/fvSolution:
43  \verbatim
44  relaxationFactors
45  {
46  fields
47  {
48  grad(<term>) <relaxation factor>;
49  }
50  }
51  \endverbatim
52 
53 SourceFiles
54  iterativeGaussGrad.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef iterativeGaussGrad_H
59 #define iterativeGaussGrad_H
60 
61 #include "gaussGrad.H"
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 namespace Foam
66 {
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace fv
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class iterativeGaussGrad Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 template<class Type>
79 :
80  public fv::gaussGrad<Type>
81 {
82  // Private Data
83 
84  //- Number of skew-correction iterations
85  label nIter_;
86 
87 
88  // Private Member Functions
89 
90  //- No copy construct
91  iterativeGaussGrad(const iterativeGaussGrad&) = delete;
92 
93  //- No copy assignment
94  void operator=(const iterativeGaussGrad&) = delete;
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("iterativeGauss");
101 
102 
103  // Constructors
104 
105  //- Construct from mesh
107  :
108  gaussGrad<Type>(mesh),
109  nIter_(1)
110  {}
111 
112  //- Construct from mesh and Istream
113  iterativeGaussGrad(const fvMesh& mesh, Istream& schemeData)
114  :
115  gaussGrad<Type>(mesh, schemeData),
116  nIter_(readLabel(schemeData))
117  {
118  if (nIter_ <= 0)
119  {
120  FatalIOErrorInFunction(schemeData)
121  << "nIter = " << nIter_
122  << " should be > 0"
123  << exit(FatalIOError);
124  }
125  }
126 
127 
128  // Member Functions
129 
130  //- Return the gradient of the given field
131  //- to the gradScheme::grad for optional caching
132  virtual tmp
133  <
135  <
137  fvPatchField,
138  volMesh
139  >
140  > calcGrad
141  (
143  const word& name
144  ) const;
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace fv
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #ifdef NoRepository
159  #include "iterativeGaussGrad.C"
160 #endif
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::volMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:51
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:114
Foam::fv::gaussGrad
Basic second-order gradient scheme using face-interpolation and Gauss' theorem.
Definition: gaussGrad.H:63
Foam::FatalIOError
IOerror FatalIOError
Foam::fv::iterativeGaussGrad::iterativeGaussGrad
iterativeGaussGrad(const fvMesh &mesh)
Construct from mesh.
Definition: iterativeGaussGrad.H:105
gaussGrad.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::fv::iterativeGaussGrad::calcGrad
virtual tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > calcGrad(const GeometricField< Type, fvPatchField, volMesh > &vsf, const word &name) const
Foam::fv::gradScheme::mesh
const fvMesh & mesh() const
Return const reference to mesh.
Definition: gradScheme.H:126
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::iterativeGaussGrad::TypeName
TypeName("iterativeGauss")
Runtime type information.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::fv::iterativeGaussGrad::iterativeGaussGrad
iterativeGaussGrad(const fvMesh &mesh, Istream &schemeData)
Construct from mesh and Istream.
Definition: iterativeGaussGrad.H:112
fv
labelList fv(nPoints)
Foam::readLabel
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:66
iterativeGaussGrad.C
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::fv::iterativeGaussGrad
A second-order gradient scheme using face-interpolation, Gauss' theorem and iterative skew correction...
Definition: iterativeGaussGrad.H:77
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53