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  // Private Member Functions
78 
79  //- No copy assignment
80  void operator=(const limitedLnGrad&) = delete;
81 
82 
83 public:
84 
85  //- Runtime type information
86  TypeName("limited");
87 
88 
89  // Constructors
90 
91  //- Construct from mesh
92  limitedLnGrad(const faMesh& mesh)
93  :
94  lnGradScheme<Type>(mesh)
95  {}
96 
97 
98  //- Construct from mesh and data stream
99  limitedLnGrad(const faMesh& mesh, Istream& is)
100  :
101  lnGradScheme<Type>(mesh),
102  limitCoeff_(readScalar(is))
103  {
104  if (limitCoeff_ < 0 || limitCoeff_ > 1)
105  {
107  << "limitCoeff is specified as " << limitCoeff_
108  << " but should be >= 0 && <= 1"
109  << exit(FatalIOError);
110  }
111  }
112 
113 
114  // Destructor
115 
116  virtual ~limitedLnGrad();
117 
118 
119  // Member Functions
120 
121  //- Return the interpolation weighting factors for the given field
123  (
125  ) const
126  {
127  return this->mesh().deltaCoeffs();
128  }
129 
130  //- Return true if this scheme uses an explicit correction
131  virtual bool corrected() const
132  {
133  return !this->mesh().orthogonal();
134  }
135 
136  //- Return the explicit correction to the limitedLnGrad
137  // for the given field
140 };
141 
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 } // End namespace fv
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace Foam
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 #ifdef NoRepository
154  #include "limitedLnGrad.C"
155 #endif
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
Foam::fa::limitedLnGrad
Central-difference lnGrad scheme with limited non-orthogonal correction.
Definition: limitedLnGrad.H:66
Foam::fa::limitedLnGrad::correction
virtual tmp< GeometricField< Type, faePatchField, edgeMesh > > correction(const GeometricField< Type, faPatchField, areaMesh > &) const
Return the explicit correction to the limitedLnGrad.
Definition: limitedLnGrad.C:56
Foam::fa::limitedLnGrad::~limitedLnGrad
virtual ~limitedLnGrad()
Definition: limitedLnGrad.C:47
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fa::limitedLnGrad::TypeName
TypeName("limited")
Runtime type information.
Foam::FatalIOError
IOerror FatalIOError
Foam::fa::limitedLnGrad::limitedLnGrad
limitedLnGrad(const faMesh &mesh)
Construct from mesh.
Definition: limitedLnGrad.H:91
limitedLnGrad.C
Foam::fa::lnGradScheme::mesh
const faMesh & mesh() const
Return mesh reference.
Definition: lnGradScheme.H:118
Foam::edgeInterpolation::deltaCoeffs
const edgeScalarField & deltaCoeffs() const
Return reference to difference factors array.
Definition: edgeInterpolation.C:101
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::edgeInterpolation::orthogonal
bool orthogonal() const
Return whether mesh is orthogonal or not.
Definition: edgeInterpolation.C:112
Foam::fa::limitedLnGrad::limitedLnGrad
limitedLnGrad(const faMesh &mesh, Istream &is)
Construct from mesh and data stream.
Definition: limitedLnGrad.H:98
Foam::fa::limitedLnGrad::corrected
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: limitedLnGrad.H:130
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:77
Foam::fa::limitedLnGrad::deltaCoeffs
virtual tmp< edgeScalarField > deltaCoeffs(const GeometricField< Type, faPatchField, areaMesh > &) const
Return the interpolation weighting factors for the given field.
Definition: limitedLnGrad.H:122
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401
lnGradScheme.H
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::fa::lnGradScheme
Abstract base class for lnGrad schemes.
Definition: lnGradScheme.H:62