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

filteredLinear3V.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::filteredLinear3VLimiter
00026 
00027 Description
00028     Class to generate weighting factors for the filteredLinear3V
00029     differencing scheme.
00030 
00031     The aim is to remove high-frequency modes with "staggering"
00032     characteristics from vector fields by comparing the face gradient in
00033     the direction of maximum gradient with both neighbouring cell gradients
00034     and introduce small amounts of upwind in order to damp these modes.
00035 
00036     Used in conjunction with the template class LimitedScheme.
00037 
00038 SourceFiles
00039     filteredLinear3V.C
00040 
00041 \*---------------------------------------------------------------------------*/
00042 
00043 #ifndef filteredLinear3V_H
00044 #define filteredLinear3V_H
00045 
00046 #include <OpenFOAM/vector.H>
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 /*---------------------------------------------------------------------------*\
00054                  Class filteredLinear3VLimiter Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 template<class LimiterFunc>
00058 class filteredLinear3VLimiter
00059 :
00060     public LimiterFunc
00061 {
00062     // Private data
00063 
00064         // Scaling corefficient for the gradient ratio,
00065         // 0 = linear
00066         // 1 = fully limited
00067         scalar k_;
00068 
00069 public:
00070 
00071     filteredLinear3VLimiter(Istream& is)
00072     :
00073         k_(readScalar(is))
00074     {
00075         if (k_ < 0 || k_ > 1)
00076         {
00077             FatalIOErrorIn("filteredLinear3VLimiter(Istream& is)", is)
00078                 << "coefficient = " << k_
00079                 << " should be >= 0 and <= 1"
00080                 << exit(FatalIOError);
00081         }
00082     }
00083 
00084     scalar limiter
00085     (
00086         const scalar cdWeight,
00087         const scalar faceFlux,
00088         const typename LimiterFunc::phiType& phiP,
00089         const typename LimiterFunc::phiType& phiN,
00090         const typename LimiterFunc::gradPhiType& gradcP,
00091         const typename LimiterFunc::gradPhiType& gradcN,
00092         const vector& d
00093     ) const
00094     {
00095         // Difference across face
00096         vector dfV = phiN - phiP;
00097 
00098         // Scalar difference across the face
00099         // in the direction in which the difference is largest
00100         scalar df = dfV & dfV;
00101 
00102         // Twice differences across face-neighbour cells
00103         // in the direction in which the face-difference is largest
00104         scalar dP = 2*(dfV & (d & gradcP));
00105         scalar dN = 2*(dfV & (d & gradcN));
00106 
00107         // Calculate the limiter
00108         scalar limiter = 1 - k_*(dN - df)*(dP - df)/max(sqr(dN + dP), SMALL);
00109 
00110         // Limit the limiter between linear and upwind
00111         return max(min(limiter, 1), 0);
00112     }
00113 };
00114 
00115 
00116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00117 
00118 } // End namespace Foam
00119 
00120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00121 
00122 #endif
00123 
00124 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines