INTERPOLATIONS: Avoid infinite loop in interfaces_tvd() and interfaces_mgp().
In case an interpolated cell, which should be positive, is zero or negative, and the sum of derivatives is zero as well, the correction of derivatives can enter into an infinite loop. It shouldn't normally happen, since such a situation is unphysical. Avoid the infinite loop and print a warning about encountered problems. Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
parent
5964d50720
commit
8c0c89d0af
@ -695,6 +695,7 @@ module interpolations
|
||||
use coordinates , only : im , jm , km
|
||||
use coordinates , only : ib , jb , kb , ie , je , ke
|
||||
use coordinates , only : ibl, jbl, kbl, ieu, jeu, keu
|
||||
use error , only : print_warning
|
||||
|
||||
! local variables are not implicit by default
|
||||
!
|
||||
@ -768,9 +769,15 @@ module interpolations
|
||||
! variables
|
||||
!
|
||||
if (positive) then
|
||||
do while (q(i,j,k) <= sum(abs(dq(1:NDIMS))))
|
||||
dq(:) = 0.5d+00 * dq(:)
|
||||
end do
|
||||
if (q(i,j,k) > 0.0d+00) then
|
||||
do while (q(i,j,k) <= sum(abs(dq(1:NDIMS))))
|
||||
dq(:) = 0.5d+00 * dq(:)
|
||||
end do
|
||||
else
|
||||
call print_warning("interpolations::interfaces_tvd" &
|
||||
, "Positive variable is not positive!")
|
||||
dq(:) = 0.0d+00
|
||||
end if
|
||||
end if
|
||||
|
||||
! interpolate states
|
||||
@ -933,6 +940,7 @@ module interpolations
|
||||
use coordinates , only : im , jm , km
|
||||
use coordinates , only : ib , jb , kb , ie , je , ke
|
||||
use coordinates , only : ibl, jbl, kbl, ieu, jeu, keu
|
||||
use error , only : print_warning
|
||||
|
||||
! local variables are not implicit by default
|
||||
!
|
||||
@ -1051,9 +1059,15 @@ module interpolations
|
||||
! variables
|
||||
!
|
||||
if (positive) then
|
||||
do while (q(i,j,k) <= sum(abs(dq(1:NDIMS))))
|
||||
dq(:) = 0.5d+00 * dq(:)
|
||||
end do
|
||||
if (q(i,j,k) > 0.0d+00) then
|
||||
do while (q(i,j,k) <= sum(abs(dq(1:NDIMS))))
|
||||
dq(:) = 0.5d+00 * dq(:)
|
||||
end do
|
||||
else
|
||||
call print_warning("interpolations::interfaces_mgp" &
|
||||
, "Positive variable is not positive!")
|
||||
dq(:) = 0.0d+00
|
||||
end if
|
||||
end if
|
||||
|
||||
! interpolate states
|
||||
|
Loading…
x
Reference in New Issue
Block a user