OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

Limited.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::LimitedLimiter
00027 
00028 Description
00029     Foam::LimitedLimiter
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #ifndef Limited_H
00034 #define Limited_H
00035 
00036 #include "vector.H"
00037 
00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00039 
00040 namespace Foam
00041 {
00042 
00043 /*---------------------------------------------------------------------------*\
00044                        Class LimitedLimiter Declaration
00045 \*---------------------------------------------------------------------------*/
00046 
00047 template<class LimitedScheme>
00048 class LimitedLimiter
00049 :
00050     public LimitedScheme
00051 {
00052     //- Lower and upper bound of the variable
00053     scalar lowerBound_, upperBound_;
00054 
00055     void checkParameters(Istream& is)
00056     {
00057         if (lowerBound_ > upperBound_)
00058         {
00059             FatalIOErrorIn("checkParameters()", is)
00060                 << "Invalid bounds.  Lower = " << lowerBound_
00061                 << "  Upper = " << upperBound_
00062                 << ".  Lower bound is higher than the upper bound."
00063                 << exit(FatalIOError);
00064         }
00065     }
00066 
00067 
00068 public:
00069 
00070     LimitedLimiter
00071     (
00072         const scalar lowerBound,
00073         const scalar upperBound,
00074         Istream& is
00075     )
00076     :
00077         LimitedScheme(is),
00078         lowerBound_(lowerBound),
00079         upperBound_(upperBound)
00080     {
00081         checkParameters(is);
00082     }
00083 
00084     LimitedLimiter(Istream& is)
00085     :
00086         LimitedScheme(is),
00087         lowerBound_(readScalar(is)),
00088         upperBound_(readScalar(is))
00089     {
00090         checkParameters(is);
00091     }
00092 
00093 
00094     scalar limiter
00095     (
00096         const scalar cdWeight,
00097         const scalar faceFlux,
00098         const scalar phiP,
00099         const scalar phiN,
00100         const vector& gradcP,
00101         const vector& gradcN,
00102         const vector& d
00103     ) const
00104     {
00105         // If not between the lower and upper bounds use upwind
00106         if
00107         (
00108             (faceFlux > 0 && (phiP < lowerBound_ || phiN > upperBound_))
00109          || (faceFlux < 0 && (phiN < lowerBound_ || phiP > upperBound_))
00110          /*
00111             phiP < lowerBound_
00112          || phiP > upperBound_
00113          || phiN < lowerBound_
00114          || phiN > upperBound_
00115          */
00116         )
00117         {
00118             return 0;
00119         }
00120         else
00121         {
00122             return LimitedScheme::limiter
00123             (
00124                 cdWeight,
00125                 faceFlux,
00126                 phiP,
00127                 phiN,
00128                 gradcP,
00129                 gradcN,
00130                 d
00131             );
00132         }
00133     }
00134 };
00135 
00136 
00137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00138 
00139 } // End namespace Foam
00140 
00141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00142 
00143 #endif
00144 
00145 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd