@@ -30,32 +30,14 @@ module m_thinc
3030 real (wp) :: gq3_pts(3 ) = [- 5e-1_wp * 0.7745966692414834_wp , 0._wp , 5e-1_wp * 0.7745966692414834_wp ]
3131 !> Weights: 5 / 18 , 8 / 18 , 5 / 18
3232 real (wp) :: gq3_wts(3 ) = [5._wp / 18._wp , 8._wp / 18._wp , 5._wp / 18._wp ]
33- !> ln(2 )
34- real (wp) :: ln2 = 0.6931471805599453_wp
35- $:GPU_DECLARE(create= ' [gq3_pts, gq3_wts, ln2]' )
33+ $:GPU_DECLARE(copyin= ' [gq3_pts, gq3_wts]' )
3634
3735 real (wp), allocatable, dimension (:,:,:,:) :: mthinc_nhat !> Unit normal vector
3836 real (wp), allocatable, dimension (:,:,:) :: mthinc_d !> Interface position parameter
3937 $:GPU_DECLARE(create= ' [mthinc_nhat, mthinc_d]' )
4038
4139contains
4240
43- !> @brief Stable computation of ln(cosh (x))
44- function f_log_cosh (x ) result(res)
45-
46- $:GPU_ROUTINE(parallelism= ' [seq]' )
47- real (wp), intent (in ) :: x
48- real (wp) :: res, ax
49-
50- ax = abs (x)
51- if (ax > 20._wp ) then
52- res = ax - ln2
53- else
54- res = ax + log (1._wp + exp (- 2._wp * ax)) - ln2
55- end if
56-
57- end function f_log_cosh
58-
5941 !> @brief Stable difference: log_cosh(a+ h) - log_cosh(a- h) = 2 * atanh(tanh (a)* tanh (h)). Avoids catastrophic cancellation when h
6042 !! is small relative to a.
6143 function f_log_cosh_diff (a , h ) result(res)
@@ -259,16 +241,19 @@ contains
259241 ac = v_vf(eqn_idx%adv%beg)%sf(j, k, l)
260242
261243 if (ac >= ic_eps .and. ac <= 1._wp - ic_eps) then
262- nr_x = (v_vf(eqn_idx%adv%beg)%sf(j + 1 , k, l) - v_vf(eqn_idx%adv%beg)%sf(j - 1 , k, l))* 5e-1_wp
244+ nr_x = (v_vf(eqn_idx%adv%beg)%sf(j + 1 , k, l) - v_vf(eqn_idx%adv%beg)%sf(j - 1 , k, &
245+ & l))* (x_cb(j) - x_cb(j - 1 ))/ (x_cc(j + 1 ) - x_cc(j - 1 ))
263246
264247 nr_y = 0._wp
265248 if (n > 0 ) then
266- nr_y = (v_vf(eqn_idx%adv%beg)%sf(j, k + 1 , l) - v_vf(eqn_idx%adv%beg)%sf(j, k - 1 , l))* 5e-1_wp
249+ nr_y = (v_vf(eqn_idx%adv%beg)%sf(j, k + 1 , l) - v_vf(eqn_idx%adv%beg)%sf(j, k - 1 , &
250+ & l))* (y_cb(k) - y_cb(k - 1 ))/ (y_cc(k + 1 ) - y_cc(k - 1 ))
267251 end if
268252
269253 nr_z = 0._wp
270254 if (p > 0 ) then
271- nr_z = (v_vf(eqn_idx%adv%beg)%sf(j, k, l + 1 ) - v_vf(eqn_idx%adv%beg)%sf(j, k, l - 1 ))* 5e-1_wp
255+ nr_z = (v_vf(eqn_idx%adv%beg)%sf(j, k, l + 1 ) - v_vf(eqn_idx%adv%beg)%sf(j, k, &
256+ & l - 1 ))* (z_cb(l) - z_cb(l - 1 ))/ (z_cc(l + 1 ) - z_cc(l - 1 ))
272257 end if
273258
274259 nmag = sqrt (nr_x* nr_x + nr_y* nr_y + nr_z* nr_z)
0 commit comments