limitedLnGrad.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) 2016-2017 Wikki 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::fa::limitedLnGrad
28 
29 Description
30  Central-difference lnGrad scheme with limited non-orthogonal correction.
31 
32  The limiter is controlled by a coefficient with a value between 0 and 1
33  which when 0 switches the correction off and the scheme behaves as
34  uncorrectedSnGrad, when set to 1 the full correction is applied and the
35  scheme behaves as correctedSnGrad and when set to 0.5 the limiter is
36  calculated such that the non-orthogonal contribution does not exceed the
37  orthogonal part.
38 
39 Author
40  Hrvoje Jasak, Wikki Ltd.
41 
42 SourceFiles
43  limitedLnGrad.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef limitedLnGrad_H
48 #define limitedLnGrad_H
49 
50 #include "lnGradScheme.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace fa
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class limitedLnGrad Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 template<class Type>
67 class limitedLnGrad
68 :
69  public lnGradScheme<Type>
70 {
71  // Private Data
72 
73  //- Limiter. 0 = no limiting, 1 = full limiting
74  scalar limitCoeff_;
75 
76 
77 public:
78 
79  //- Runtime type information
80  TypeName("limited");
81 
82 
83  // Generated Methods
84 
85  //- No copy construct
86  limitedLnGrad(const limitedLnGrad&) = delete;
87 
88  //- No copy assignment
89  void operator=(const limitedLnGrad&) = delete;
90 
91 
92  // Constructors
93 
94  //- Construct from mesh
95  limitedLnGrad(const faMesh& mesh)
96  :
98  {}
99 
101  //- Construct from mesh and data stream
102  limitedLnGrad(const faMesh& mesh, Istream& is)
103  :
104  lnGradScheme<Type>(mesh),
105  limitCoeff_(readScalar(is))
106  {
107  if (limitCoeff_ < 0 || limitCoeff_ > 1)
108  {
110  << "limitCoeff is specified as " << limitCoeff_
111  << " but should be >= 0 && <= 1"
112  << exit(FatalIOError);
113  }
114  }
115 
116 
117  // Destructor
118 
119  virtual ~limitedLnGrad();
120 
121 
122  // Member Functions
123 
124  //- Return the interpolation weighting factors for the given field
126  (
128  ) const
129  {
130  return this->mesh().deltaCoeffs();
131  }
132 
133  //- Return true if this scheme uses an explicit correction
134  virtual bool corrected() const
135  {
136  return !this->mesh().orthogonal();
137  }
138 
139  //- Return the explicit correction to the limitedLnGrad
140  // for the given field
143 };
144 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace fv
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #ifdef NoRepository
157  #include "limitedLnGrad.C"
158 #endif
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:133
const edgeScalarField & deltaCoeffs() const
Return reference to difference factors array.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
virtual tmp< GeometricField< Type, faePatchField, edgeMesh > > correction(const GeometricField< Type, faPatchField, areaMesh > &) const
Return the explicit correction to the limitedLnGrad.
Definition: limitedLnGrad.C:49
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
TypeName("limited")
Runtime type information.
Generic GeometricField class.
const faMesh & mesh() const noexcept
Return mesh reference.
Definition: lnGradScheme.H:130
Abstract base class for lnGrad schemes.
Definition: lnGradScheme.H:57
void operator=(const limitedLnGrad &)=delete
No copy assignment.
limitedLnGrad(const limitedLnGrad &)=delete
No copy construct.
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
bool orthogonal() const
Return whether mesh is orthogonal or not.
virtual tmp< edgeScalarField > deltaCoeffs(const GeometricField< Type, faPatchField, areaMesh > &) const
Return the interpolation weighting factors for the given field.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:637
Central-difference lnGrad scheme with limited non-orthogonal correction.
Definition: limitedLnGrad.H:62
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...