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