Scrambler
1
|
00001 !######################################################################### 00002 ! 00003 ! Copyright (C) 2003-2012 Department of Physics and Astronomy, 00004 ! University of Rochester, 00005 ! Rochester, NY 00006 ! 00007 ! slopelim.f90 is part of AstroBEAR. 00008 ! 00009 ! AstroBEAR is free software: you can redistribute it and/or modify 00010 ! it under the terms of the GNU General Public License as published by 00011 ! the Free Software Foundation, either version 3 of the License, or 00012 ! (at your option) any later version. 00013 ! 00014 ! AstroBEAR is distributed in the hope that it will be useful, 00015 ! but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 ! GNU General Public License for more details. 00018 ! 00019 ! You should have received a copy of the GNU General Public License 00020 ! along with AstroBEAR. If not, see <http://www.gnu.org/licenses/>. 00021 ! 00022 !######################################################################### 00025 00029 00032 00033 MODULE SlopeLim 00034 00035 00036 USE GlobalDeclarations 00037 IMPLICIT NONE 00038 00039 PUBLIC 00040 INTEGER, PARAMETER :: CONSTANT_INTERP=0 00041 INTEGER, PARAMETER :: MINMOD_INTERP=1 00042 INTEGER, PARAMETER :: SUPERBEE_INTERP=2 00043 INTEGER, PARAMETER :: VANLEER_INTERP=3 00044 INTEGER, PARAMETER :: MC_INTERP=4 00045 INTEGER, PARAMETER :: PARABOLIC_INTERP=5 00046 INTEGER, PARAMETER :: LINEAR_INTERP=6 00047 INTEGER, PARAMETER :: SPECTRAL_PROLONGATION=7 00048 00049 CONTAINS 00050 00051 ! implements various limiters. 00052 PURE ELEMENTAL FUNCTION limiter(a,b,mlim) 00053 REAL(KIND=qprec),INTENT(IN) :: a,b 00054 INTEGER,INTENT(IN) :: mlim 00055 REAL(KIND=qprec) :: limiter, r 00056 ! 00057 SELECT CASE(mlim) 00058 CASE(LINEAR_INTERP) ! no limiter 00059 limiter = 0.5d0*(a+b) 00060 RETURN 00061 END SELECT 00062 ! 00063 limiter=0.d0 00064 IF(a*b<=0.d0) RETURN 00065 ! 00066 ! flatten to 1st order if noise apears if limiter is indicated 00067 ! by two digits (last digit specifies limiter) 00068 IF(mlim>10 .AND. ABS(a)<=1.d-12 .AND. ABS(b)<=1.d-12) RETURN 00069 ! 00070 SELECT CASE(mlim) 00071 CASE(CONSTANT_INTERP) ! constant 00072 limiter = 0.d0 00073 CASE(MINMOD_INTERP) ! minmod 00074 limiter = MIN(ABS(b),ABS(a)) 00075 CASE(SUPERBEE_INTERP) ! superbee 00076 limiter = MAX(MIN(ABS(b),2.d0*ABS(a)),MIN(2.d0*ABS(b),ABS(a))) 00077 CASE(VanLeer_INTERP) ! vanLeer 00078 limiter = 2.d0*ABS(a*b)/(ABS(b)+ABS(a)) 00079 CASE(MC_INTERP) ! MC 00080 limiter = MIN(2.d0*ABS(b),0.5d0*(ABS(a)+ABS(b)),2.d0*ABS(a)) 00081 END SELECT 00082 limiter=limiter*SIGN(1.d0,a) 00083 END FUNCTION limiter 00084 00085 00086 FUNCTION GetnGhost(method) 00087 INTEGER :: GetnGhost, method 00088 SELECT CASE(method) 00089 CASE(CONSTANT_INTERP) 00090 GetnGhost=0 00091 CASE(MINMOD_INTERP, SUPERBEE_INTERP, VANLEER_INTERP, MC_INTERP, LINEAR_INTERP, PARABOLIC_INTERP) 00092 GetnGhost=1 00093 END SELECT 00094 END FUNCTION GetnGhost 00095 00096 END MODULE SlopeLim