Skip to content

Commit 0e6cd39

Browse files
committed
Removed the dimensional constant in WENO weighting
1 parent 0ebd022 commit 0e6cd39

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

src/core/MOM_CoriolisAdv.F90

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,17 +1432,34 @@ subroutine UP3_Koren_limiter_reconstruction(q4,u,qr)
14321432
real, parameter :: C1_6 = 1.0/6.0 ! The ratio of 1/6 [nondim]
14331433

14341434
if (u>0.) then
1435-
theta = (q4(2) - q4(1))/(q4(3) - q4(2) + 1e-20)
1436-
psi = max(0., min(1., C1_3 + C1_6*theta, theta)) ! limiter introduced by Koren (1993)
1437-
qr = q4(2) + psi*(q4(3) - q4(2))
1435+
if (q4(3) == q4(2)) then
1436+
qr = q4(2)
1437+
else
1438+
theta = (q4(2) - q4(1))/(q4(3) - q4(2))
1439+
psi = max(0., min(1., C1_3 + C1_6*theta, theta)) ! limiter introduced by Koren (1993)
1440+
qr = q4(2) + psi*(q4(3) - q4(2))
1441+
endif
14381442
else
1439-
theta = (q4(4) - q4(3))/(q4(3) - q4(2) + 1e-20)
1440-
psi = max(0., min(1., C1_3 + C1_6*theta, theta))
1441-
qr = q4(3) + psi*(q4(2) - q4(3))
1443+
if (q4(3) == q4(2)) then
1444+
qr = q4(3)
1445+
else
1446+
theta = (q4(4) - q4(3))/(q4(3) - q4(2))
1447+
psi = max(0., min(1., C1_3 + C1_6*theta, theta))
1448+
qr = q4(3) + psi*(q4(2) - q4(3))
1449+
endif
14421450
endif
14431451

14441452
end subroutine UP3_Koren_limiter_reconstruction
14451453

1454+
!> Compute the factor for the WENO weights
1455+
function fac_fn(tau, b) result(fac)
1456+
real, intent(in) :: tau !< Difference of the smoothness indicator [A ~> a]
1457+
real, intent(in) :: b !< The smoothness indicator [A ~> a]
1458+
real :: fac !< The factor for the weight [nondim]
1459+
1460+
fac = (1 + tau / b)**2; if (b == 0.) fac = 1.0e40
1461+
1462+
end function fac_fn
14461463

14471464

14481465
!> Reconstruct the tracer (e.g., PV, vorticity) onto the point i-1/2 using a third-order WENO scheme
@@ -1463,7 +1480,7 @@ subroutine weno_three_h_weight_reconstruction(q4, h4, u4, &
14631480
real :: c0, c1 ! Intermediate reconstruction of q [A ~> a]
14641481
real :: d0, d1 ! Intermediate reconstruction of h [L ~> m]
14651482
real :: b0, b1 ! Smoothness indicator [A ~> a]
1466-
real :: tau ! Temporary variables [nondim]
1483+
real :: tau ! Difference of smoothness indicator [A ~> a]
14671484
real :: w0, w1 ! Weights [nondim]
14681485
real :: s ! Temporary variables [nondim]
14691486
real, parameter :: C2_3 = 2.0/3.0 ! The ratio of 2/3 [nondim]
@@ -1498,8 +1515,8 @@ subroutine weno_three_h_weight_reconstruction(q4, h4, u4, &
14981515
endif
14991516

15001517
tau = abs(b0-b1)
1501-
w0 = C2_3 * (1 + (tau / (b0 + 1e-20))**2)
1502-
w1 = C1_3 * (1 + (tau / (b1 + 1e-20))**2)
1518+
w0 = C2_3 * fac_fn(tau, b0)
1519+
w1 = C1_3 * fac_fn(tau, b1)
15031520

15041521
s = 1. / (w0 + w1)
15051522
w0 = w0 * s
@@ -1562,7 +1579,7 @@ subroutine weno_five_h_weight_reconstruction(q6, h6, u6, &
15621579
real :: c0, c1, c2 ! Intermediate reconstruction of hq[A ~> a]
15631580
real :: d0, d1, d2 ! Intermediate reconstruction of h [L ~> m]
15641581
real :: b0, b1, b2 ! Smoothness indicator [A ~> a]
1565-
real :: tau ! Temporary variables [nondim]
1582+
real :: tau ! Difference of smoothness indicators [A ~> a]
15661583
real :: w0, w1, w2 ! Weights [nondim]
15671584
real :: s ! Temporary variables [nondim]
15681585
real, parameter :: C3_10 = 3.0/10.0 ! The ratio of 3/10 [nondim]
@@ -1606,9 +1623,9 @@ subroutine weno_five_h_weight_reconstruction(q6, h6, u6, &
16061623
endif
16071624

16081625
tau = abs(b0 - b2)
1609-
w0 = C3_10 * (1 + (tau / (b0 + 1e-20))**2)
1610-
w1 = C3_5 * (1 + (tau / (b1 + 1e-20))**2)
1611-
w2 = C1_10 * (1 + (tau / (b2 + 1e-20))**2)
1626+
w0 = C3_10 * fac_fn(tau, b0)
1627+
w1 = C3_5 * fac_fn(tau, b1)
1628+
w2 = C1_10 * fac_fn(tau, b2)
16121629

16131630
s = 1. / (w0 + w1 + w2)
16141631
w0 = w0 * s
@@ -1705,7 +1722,7 @@ subroutine weno_seven_h_weight_reconstruction(q8, h8, u8, &
17051722
real :: c0, c1, c2, c3 ! Intermediate reconstruction of hq [A ~> a]
17061723
real :: d0, d1, d2, d3 ! Intermediate reconstruction of h [L ~> m]
17071724
real :: b0, b1, b2, b3 ! Smoothness indicator [A ~> a]
1708-
real :: tau ! Temporary variables [nondim]
1725+
real :: tau ! Difference of smoothness indicators [A ~> a]
17091726
real :: w0, w1, w2, w3 ! Weights [nondim]
17101727
real :: s ! Temporary variables [nondim]
17111728
real, parameter :: C4_35 = 4.0/35.0 ! The ratio of 4/35 [nondim]
@@ -1758,10 +1775,10 @@ subroutine weno_seven_h_weight_reconstruction(q8, h8, u8, &
17581775
endif
17591776

17601777
tau = abs((b0 - b3) + 3 * (b1 - b2))
1761-
w0 = C4_35 * (1 + (tau / (b0 + 1e-20))**2)
1762-
w1 = C18_35 * (1 + (tau / (b1 + 1e-20))**2)
1763-
w2 = C12_35 * (1 + (tau / (b2 + 1e-20))**2)
1764-
w3 = C1_35 * (1 + (tau / (b3 + 1e-20))**2)
1778+
w0 = C4_35 * fac_fn(tau, b0)
1779+
w1 = C18_35 * fac_fn(tau, b1)
1780+
w2 = C12_35 * fac_fn(tau, b2)
1781+
w3 = C1_35 * fac_fn(tau, b3)
17651782

17661783
s = 1. / (w0 + w1 + w2 + w3)
17671784
w0 = w0 * s

0 commit comments

Comments
 (0)