FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::LimitedLimiter
00026 
00027 Description
00028     Foam::LimitedLimiter
00029 
00030 \*---------------------------------------------------------------------------*/
00031 
00032 #ifndef Limited_H
00033 #define Limited_H
00034 
00035 #include <OpenFOAM/vector.H>
00036 
00037 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00038 
00039 namespace Foam
00040 {
00041 
00042 /*---------------------------------------------------------------------------*\
00043                        Class LimitedLimiter Declaration
00044 \*---------------------------------------------------------------------------*/
00045 
00046 template<class LimitedScheme>
00047 class LimitedLimiter
00048 :
00049     public LimitedScheme
00050 {
00051     //- Lower and upper bound of the variable
00052     scalar lowerBound_, upperBound_;
00053 
00054     void checkParameters(Istream& is)
00055     {
00056         if (lowerBound_ > upperBound_)
00057         {
00058             FatalIOErrorIn("checkParameters()", is)
00059                 << "Invalid bounds.  Lower = " << lowerBound_
00060                 << "  Upper = " << upperBound_
00061                 << ".  Lower bound is higher than the upper bound."
00062                 << exit(FatalIOError);
00063         }
00064     }
00065 
00066 
00067 public:
00068 
00069     LimitedLimiter
00070     (
00071         const scalar lowerBound,
00072         const scalar upperBound,
00073         Istream& is
00074     )
00075     :
00076         LimitedScheme(is),
00077         lowerBound_(lowerBound),
00078         upperBound_(upperBound)
00079     {
00080         checkParameters(is);
00081     }
00082 
00083     LimitedLimiter(Istream& is)
00084     :
00085         LimitedScheme(is),
00086         lowerBound_(readScalar(is)),
00087         upperBound_(readScalar(is))
00088     {
00089         checkParameters(is);
00090     }
00091 
00092 
00093     scalar limiter
00094     (
00095         const scalar cdWeight,
00096         const scalar faceFlux,
00097         const scalar phiP,
00098         const scalar phiN,
00099         const vector& gradcP,
00100         const vector& gradcN,
00101         const vector& d
00102     ) const
00103     {
00104         // If not between the lower and upper bounds use upwind
00105         if
00106         (
00107             (faceFlux > 0 && (phiP < lowerBound_ || phiN > upperBound_))
00108          || (faceFlux < 0 && (phiN < lowerBound_ || phiP > upperBound_))
00109          /*
00110             phiP < lowerBound_
00111          || phiP > upperBound_
00112          || phiN < lowerBound_
00113          || phiN > upperBound_
00114          */
00115         )
00116         {
00117             return 0;
00118         }
00119         else
00120         {
00121             return LimitedScheme::limiter
00122             (
00123                 cdWeight,
00124                 faceFlux,
00125                 phiP,
00126                 phiN,
00127                 gradcP,
00128                 gradcN,
00129                 d
00130             );
00131         }
00132     }
00133 };
00134 
00135 
00136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00137 
00138 } // End namespace Foam
00139 
00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00141 
00142 #endif
00143 
00144 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines