Limited.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) 2011-2018 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::LimitedLimiter
26 
27 Description
28  Foam::LimitedLimiter
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef Limited_H
33 #define Limited_H
34 
35 #include "vector.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 /*---------------------------------------------------------------------------*\
43  Class LimitedLimiter Declaration
44 \*---------------------------------------------------------------------------*/
45 
46 template<class LimitedScheme>
47 class LimitedLimiter
48 :
49  public LimitedScheme
50 {
51  //- Lower and upper bound of the variable
52  scalar lowerBound_, upperBound_;
53 
54  void checkParameters(Istream& is)
55  {
56  if (lowerBound_ > upperBound_)
57  {
59  << "Invalid bounds. Lower = " << lowerBound_
60  << " Upper = " << upperBound_
61  << ". Lower bound is higher than the upper bound."
62  << exit(FatalIOError);
63  }
64  }
65 
66 
67 public:
68 
70  (
71  const scalar lowerBound,
72  const scalar upperBound,
73  Istream& is
74  )
75  :
76  LimitedScheme(is),
77  lowerBound_(lowerBound),
78  upperBound_(upperBound)
79  {
80  checkParameters(is);
81  }
82 
84  :
85  LimitedScheme(is),
86  lowerBound_(readScalar(is)),
87  upperBound_(readScalar(is))
88  {
89  checkParameters(is);
90  }
91 
92 
93  scalar limiter
94  (
95  const scalar cdWeight,
96  const scalar faceFlux,
97  const scalar phiP,
98  const scalar phiN,
99  const vector& gradcP,
100  const vector& gradcN,
101  const vector& d
102  ) const
103  {
104  // If not between the lower and upper bounds use upwind
105  if
106  (
107  (faceFlux > 0 && (phiP < lowerBound_ || phiN > upperBound_))
108  || (faceFlux < 0 && (phiN < lowerBound_ || phiP > upperBound_))
109  /*
110  phiP < lowerBound_
111  || phiP > upperBound_
112  || phiN < lowerBound_
113  || phiN > upperBound_
114  */
115  )
116  {
117  return 0;
118  }
119  else
120  {
122  (
123  cdWeight,
124  faceFlux,
125  phiP,
126  phiN,
127  gradcP,
128  gradcN,
129  d
130  );
131  }
132  }
133 };
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #endif
143 
144 // ************************************************************************* //
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Class to create NVD/TVD limited weighting-factors.
Definition: LimitedScheme.H:63
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
LimitedLimiter(const scalar lowerBound, const scalar upperBound, Istream &is)
Definition: Limited.H:69
scalar limiter(const scalar cdWeight, const scalar faceFlux, const scalar phiP, const scalar phiN, const vector &gradcP, const vector &gradcN, const vector &d) const
Definition: Limited.H:93
Foam::LimitedLimiter.
Definition: Limited.H:46
virtual tmp< surfaceScalarField > limiter(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
Definition: doubleScalar.H:75
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
Namespace for OpenFOAM.
IOerror FatalIOError