forked from altMITgcm/MITgcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gad_ppm_hat_y.F
141 lines (114 loc) · 4.77 KB
/
gad_ppm_hat_y.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_ppm_hat_y.F,v 1.1 2016/03/13 01:44:03 jmc Exp $
C $Name: $
# include "GAD_OPTIONS.h"
SUBROUTINE GAD_PPM_HAT_Y(bi,bj,kk,ix,
I method,mask,fbar,edge,
I ohat,fhat,myThid)
C |================================================================|
C | PPM_HAT_Y: reconstruct grid-cell PPM polynomials. |
C |================================================================|
implicit none
C =============================================== global variables
# include "SIZE.h"
# include "GRID.h"
# include "GAD.h"
C ====================================================== arguments
C bi,bj :: tile indexing.
C kk :: r-indexing.
C ix :: x-indexing.
C method :: advection scheme.
C mask :: row of cell-wise masking values.
C fbar :: row of cell-wise values.
C edge :: row of edge-wise values.
C ohat :: row of oscl. coeff.
C - OHAT(1,:) = D^1F/DS^1.
C - OHAT(2,:) = D^2F/DS^2.
C fhat :: row of poly. coeff.
C - FHAT(:,I) = PPM coeff.
C myThid :: thread number.
C ================================================================
integer bi,bj,kk,ix
integer method
_RL mask(1-OLy:sNy+OLy)
_RL fbar(1-OLy:sNy+OLy)
_RL edge(1-OLy:sNy+OLy)
_RL ohat(1:2,
& 1-OLy:sNy+OLy)
_RL fhat(1:3,
& 1-OLy:sNy+OLy)
integer myThid
C ====================================================== variables
C ii,iy :: local y-indexing.
C ff00 :: centre-biased cell mean.
C ffll,ffrr :: left-, and right-biased cell values.
C fell,ferr :: left-, and right-biased edge values.
C dfds :: linear slope estimates.
C uhat :: "NULL" limited poly. coeff.
C lhat :: "MONO" limited poly. coeff.
C scal :: "WENO" weights.
C fmag,fdel :: local perturbation indicators.
C ================================================================
integer ii,iy
_RL ff00,ffll,ffrr
_RL fell,ferr
_RL dfds(-1:+1)
_RL uhat(+1:+5)
_RL lhat(+1:+5)
_RL scal(+1:+2)
_RL fmag,fdel
integer mono
C ==================== reconstruct coeff. for grid-cell poynomials
do iy = 1-OLy+2, sNy+OLy-2
C =============================== assemble cell mean + edge values
ff00 = fbar(iy+0)
ffll = ff00
& + mask(iy-1)*(fbar(iy-1)-ff00)
ffrr = ff00
& + mask(iy+1)*(fbar(iy+1)-ff00)
fell = edge(iy-0)
ferr = edge(iy+1)
c select case(method)
c case(ENUM_PPM_NULL_LIMIT)
if ( method.eq.ENUM_PPM_NULL_LIMIT ) then
C =============================== "NULL" limited grid-cell profile
CALL GAD_PPM_FUN_NULL ( ff00,fell,ferr,
& lhat,mono)
c case(ENUM_PPM_MONO_LIMIT)
elseif ( method.eq.ENUM_PPM_MONO_LIMIT ) then
C =============================== "MONO" limited grid-cell profile
CALL GAD_PLM_FUN_U(ffll,ff00,ffrr,dfds)
CALL GAD_PPM_FUN_MONO ( ff00,ffll,ffrr,
& fell,ferr,dfds,lhat,mono)
c case(ENUM_PPM_WENO_LIMIT)
elseif ( method.eq.ENUM_PPM_WENO_LIMIT ) then
C =============================== "WENO" limited grid-cell profile
CALL GAD_PLM_FUN_U(ffll,ff00,ffrr,dfds)
CALL GAD_PPM_FUN_NULL ( ff00,fell,ferr,
& uhat,mono)
CALL GAD_PPM_FUN_MONO ( ff00,ffll,ffrr,
& fell,ferr,dfds,lhat,mono)
if ( mono .gt. 0) then
C =============================== only apply WENO if it is worth it
fdel = abs(ffrr-ff00)+abs(ff00-ffll)
fmag = abs(ffll)+abs(ff00)+abs(ffrr)
if (fdel .gt. 1. _d -6 * fmag) then
C =============================== calc. WENO oscillation weighting
CALL GAD_OSC_MUL_Y(iy,+2,mask,
& ohat,scal)
do ii = +1, +3
C =============================== blend limited/un-limited profile
lhat(ii) = scal(1) * uhat(ii)
& + scal(2) * lhat(ii)
end do
end if
end if
c end select
endif
do ii = +1, +3
C =============================== copy polynomial onto output data
fhat(ii,iy) = lhat(ii)
end do
end do
return
c end subroutine GAD_PPM_HAT_Y
end