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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::LimitedLimiter
28
29Group
30 grpFvLimitedSurfaceInterpolationSchemes
31
32Description
33 Foam::LimitedLimiter
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef Limited_H
38#define Limited_H
39
40#include "vector.H"
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace Foam
45{
46
47/*---------------------------------------------------------------------------*\
48 Class LimitedLimiter Declaration
49\*---------------------------------------------------------------------------*/
50
51template<class LimitedScheme>
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."
68 }
69 }
70
71
72public:
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 }
89 :
90 LimitedScheme(is),
91 lowerBound_(readScalar(is)),
92 upperBound_(readScalar(is))
93 {
94 checkParameters(is);
95 }
96
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// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Foam::LimitedLimiter.
Definition: Limited.H:54
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
LimitedLimiter(const scalar lowerBound, const scalar upperBound, Istream &is)
Definition: Limited.H:74
LimitedLimiter(Istream &is)
Definition: Limited.H:87
Class to create NVD/TVD limited weighting-factors.
Definition: LimitedScheme.H:72
virtual tmp< volScalarField > limiter() const
Return the force limiter field.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Namespace for OpenFOAM.
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130