Skip to content

Commit c304b37

Browse files
author
Daniel J Vickers
committed
We no longer need if guards to protect against redundant compute, because we ALWAYs need levelset values at ghost points
1 parent 51bc07f commit c304b37

1 file changed

Lines changed: 25 additions & 29 deletions

File tree

src/simulation/m_compute_levelset.fpp

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -342,38 +342,34 @@ contains
342342
xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp]
343343
xy_local = matmul(inverse_rotation, xy_local)
344344

345-
if ((xy_local(1) > bottom_left(1) .and. xy_local(1) < top_right(1)) .or. &
346-
(xy_local(2) > bottom_left(2) .and. xy_local(2) < top_right(2))) then
347-
348-
side_dists(1) = bottom_left(1) - xy_local(1)
349-
side_dists(2) = top_right(1) - xy_local(1)
350-
side_dists(3) = bottom_left(2) - xy_local(2)
351-
side_dists(4) = top_right(2) - xy_local(2)
352-
min_dist = side_dists(1)
353-
idx = 1
354-
355-
do k = 2, 4
356-
if (abs(side_dists(k)) < abs(min_dist)) then
357-
idx = k
358-
min_dist = side_dists(idx)
359-
end if
360-
end do
345+
side_dists(1) = bottom_left(1) - xy_local(1)
346+
side_dists(2) = top_right(1) - xy_local(1)
347+
side_dists(3) = bottom_left(2) - xy_local(2)
348+
side_dists(4) = top_right(2) - xy_local(2)
349+
min_dist = side_dists(1)
350+
idx = 1
351+
352+
do k = 2, 4
353+
if (abs(side_dists(k)) < abs(min_dist)) then
354+
idx = k
355+
min_dist = side_dists(idx)
356+
end if
357+
end do
361358

362-
gp%levelset = side_dists(idx)
363-
dist_vec = 0._wp
364-
if (.not. f_approx_equal(side_dists(idx), 0._wp)) then
365-
if (idx == 1 .or. idx == 2) then
366-
! vector points along the x axis
367-
dist_vec(1) = side_dists(idx)/abs(side_dists(idx))
368-
else
369-
! vector points along the y axis
370-
dist_vec(2) = side_dists(idx)/abs(side_dists(idx))
371-
end if
372-
! convert the normal vector back into the global coordinate system
373-
gp%levelset_norm = matmul(rotation, dist_vec)
359+
gp%levelset = side_dists(idx)
360+
dist_vec = 0._wp
361+
if (.not. f_approx_equal(side_dists(idx), 0._wp)) then
362+
if (idx == 1 .or. idx == 2) then
363+
! vector points along the x axis
364+
dist_vec(1) = side_dists(idx)/abs(side_dists(idx))
374365
else
375-
gp%levelset_norm = 0._wp
366+
! vector points along the y axis
367+
dist_vec(2) = side_dists(idx)/abs(side_dists(idx))
376368
end if
369+
! convert the normal vector back into the global coordinate system
370+
gp%levelset_norm = matmul(rotation, dist_vec)
371+
else
372+
gp%levelset_norm = 0._wp
377373
end if
378374

379375
end subroutine s_rectangle_levelset

0 commit comments

Comments
 (0)