328 type(scalar_field),
intent(inout) :: div
329 type(scalar_field),
intent(in) :: fields(1:3)
330 type(int_bounds_info),
intent(in) :: ix_s, iy_s, iz_s
332 real(wp) :: divergence
335# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
337# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
338#if defined(MFC_OpenACC)
339# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
341# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
342#elif defined(MFC_OpenMP)
343# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
345# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
347# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
349# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
351# 25 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
353 do x = ix_s%beg, ix_s%end
354 do y = iy_s%beg, iy_s%end
355 do z = iz_s%beg, iz_s%end
356 if (x == ix_s%beg)
then
357 divergence = (-3._wp*fields(1)%sf(x, y, z) + 4._wp*fields(1)%sf(x + 1, y, z) - fields(1)%sf(x + 2, y, &
359 else if (x == ix_s%end)
then
360 divergence = (+3._wp*fields(1)%sf(x, y, z) - 4._wp*fields(1)%sf(x - 1, y, z) + fields(1)%sf(x - 2, y, &
363 divergence = (fields(1)%sf(x + 1, y, z) - fields(1)%sf(x - 1, y, z))/(
x_cc(x + 1) -
x_cc(x - 1))
367 if (y == iy_s%beg)
then
368 divergence = divergence + (-3._wp*fields(2)%sf(x, y, z) + 4._wp*fields(2)%sf(x, y + 1, &
369 & z) - fields(2)%sf(x, y + 2, z))/(
y_cc(y + 2) -
y_cc(y))
370 else if (y == iy_s%end)
then
371 divergence = divergence + (+3._wp*fields(2)%sf(x, y, z) - 4._wp*fields(2)%sf(x, y - 1, &
372 & z) + fields(2)%sf(x, y - 2, z))/(
y_cc(y) -
y_cc(y - 2))
374 divergence = divergence + (fields(2)%sf(x, y + 1, z) - fields(2)%sf(x, y - 1, &
380 if (z == iz_s%beg)
then
381 divergence = divergence + (-3._wp*fields(3)%sf(x, y, z) + 4._wp*fields(3)%sf(x, y, &
382 & z + 1) - fields(3)%sf(x, y, z + 2))/(
z_cc(z + 2) -
z_cc(z))
383 else if (z == iz_s%end)
then
384 divergence = divergence + (+3._wp*fields(3)%sf(x, y, z) - 4._wp*fields(3)%sf(x, y, &
385 & z - 1) + fields(3)%sf(x, y, z - 2))/(
z_cc(z) -
z_cc(z - 2))
387 divergence = divergence + (fields(3)%sf(x, y, z + 1) - fields(3)%sf(x, y, &
388 & z - 1))/(
z_cc(z + 1) -
z_cc(z - 1))
392 div%sf(x, y, z) = div%sf(x, y, z) + divergence
397# 69 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
398#if defined(MFC_OpenACC)
399# 69 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
401# 69 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
402#elif defined(MFC_OpenMP)
403# 69 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
405# 69 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
407# 69 "/home/runner/work/MFC/MFC/src/common/m_finite_differences.fpp"
421 integer,
intent(in) :: q
422 integer,
intent(in) :: local_buff_size, fd_number_in, fd_order_in
423 type(int_bounds_info),
optional,
intent(in) :: offset_s
424 real(wp),
allocatable,
dimension(:,:),
intent(inout) :: fd_coeff_s
425 real(wp),
dimension(-local_buff_size:q + local_buff_size),
intent(in) :: s_cc
428 if (
present(offset_s))
then
430 le = q + offset_s%end
436#ifdef MFC_POST_PROCESS
437 if (
allocated(fd_coeff_s))
deallocate (fd_coeff_s)
438 allocate (fd_coeff_s(-fd_number_in:fd_number_in,lb:le))
442 if (fd_order_in == 1)
then
444 fd_coeff_s(-1, i) = 0._wp
445 fd_coeff_s(0, i) = -1._wp/(s_cc(i + 1) - s_cc(i))
446 fd_coeff_s(1, i) = -fd_coeff_s(0, i)
450 else if (fd_order_in == 2)
then
452 fd_coeff_s(-1, i) = -1._wp/(s_cc(i + 1) - s_cc(i - 1))
453 fd_coeff_s(0, i) = 0._wp
454 fd_coeff_s(1, i) = -fd_coeff_s(-1, i)
460 fd_coeff_s(-2, i) = 1._wp/(s_cc(i - 2) - 8._wp*s_cc(i - 1) - s_cc(i + 2) + 8._wp*s_cc(i + 1))
461 fd_coeff_s(-1, i) = -8._wp*fd_coeff_s(-2, i)
462 fd_coeff_s(0, i) = 0._wp
463 fd_coeff_s(1, i) = -fd_coeff_s(-1, i)
464 fd_coeff_s(2, i) = -fd_coeff_s(-2, i)
subroutine s_compute_finite_difference_coefficients(q, s_cc, fd_coeff_s, local_buff_size, fd_number_in, fd_order_in, offset_s)
Compute the centered finite-difference coefficients for first-order spatial derivatives in the s-coor...