Draft: Small stepgrid change - #733
Conversation
|
This is probably true for any field that is momentum related I suppose. Most of the other fields, unless they somehow have velocity issues, would not necessarily want to zero it out either. In the multilayer code we do the following: forall(i=1:mitot, j=1:mjtot, k=1:num_layers,
& q(3*(k-1)+1,i,j) / rho(k) < dry_tolerance(k))
q(3*(k-1)+1,i,j) = max(q(3*(k-1)+1,i,j), 0.d0)
q(3*(k-1)+2,i,j) = 0.d0
q(3*(k-1)+3,i,j) = 0.d0
end forallGiven the momentum equations are interspersed with the other fields, this also required another In any case, modulo the bouss code, I think being explicit about this is probably fine. The alternative would be to call something that would do only this custom bit. I suppose this might be a recurring task that may be easier to implement that way, but that may be too complex a solution for this. |
|
@mandli - I think it be worth having e.g., for dclaw it would look like this: subroutine fixdry(q, nvar, mitot, mjtot)
use geoclaw_module, only dry_tolerance
use digclaw_module, only: i_h,i_hu,i_hv,i_hm,i_pb,i_hchi
! Input parameters
integer, intent(in) :: nvar,mitot,mjtot
! Output
double precision, intent(inout) :: q(nvar,mitot,mjtot)
forall(i=1:my, j=1:mx, q(i_h,i,j) < dry_tolerance)
q(i_h,i,j) = max(q(i_h,i,j),0.d0)
q(i_hu,i,j) = 0.d0
q(i_hv,i,j) = 0.d0
q(i_hm,i,j) = 0.d0
q(i_pb,i,j) = 0.d0
q(i_hchi,i,j) = 0.d0
! do not reset i_bdif
end forall
end subroutine fixdryAnd for geoclaw it would look like: subroutine fixdry(q, nvar, mitot, mjtot)
use geoclaw_module, only dry_tolerance
! Input parameters
integer, intent(in) :: nvar,mitot,mjtot
! Output
double precision, intent(inout) :: q(nvar,mitot,mjtot)
forall(i=1:mitot, j=1:mjtot, q(1,i,j) < dry_tolerance)
q(1,i,j) = max(q(1,i,j),0.d0)
q(2:nvar,i,j) = 0.d0
end forall
end subroutine fixdryI can implement this in Geoclaw (new function, updates to the Makefile) if you think it would make sense. (suggestions for the subroutine name are welcome). |
|
@rjleveque and I chatted about this and were recalling that this type of operation is done a couple of places so having a ! =====================================================
subroutine fixdry(meqn, mbc, mx, my, q, maux, aux)
! =====================================================
!
! Reset cells whose depth is below dry_tolerance to a consistent dry state:
! zero negative depths to zero and zero the momenta. Operates over the full
! patch, ghost cells included.
!
! This routine is an override point. Applications and GeoClaw variants may
! shadow it by placing their own fixdry.f90 in the application SOURCES list
! (see the GeoClaw docs on replacing library routines). Two constraints on
! any replacement:
! * It must stay a plain external subroutine, not a module procedure
! * It must be thread safe. Both call sites run inside an !$OMP PARALLEL DO
! over grids
use geoclaw_module, only: dry_tolerance
implicit none
! Arguments
integer, intent(in) :: meqn, mbc, mx, my, maux
real(kind=8), intent(inout) :: q(meqn, 1-mbc:mx+mbc, 1-mbc:my+mbc)
real(kind=8), intent(in) :: aux(maux, 1-mbc:mx+mbc, 1-mbc:my+mbc)
! Locals
integer :: i, j
do j = 1-mbc, my+mbc
do i = 1-mbc, mx+mbc
if (q(1,i,j) < dry_tolerance) then
q(1,i,j) = max(q(1,i,j), 0.d0)
q(2,i,j) = 0.d0
q(3,i,j) = 0.d0
end if
end do
end do
end subroutine fixdryThe big difference is the addition of A couple of things to perhaps note:
|
|
@mandli @rjleveque - I've now updated this with Kyle's suggested function, put it into I didn't think it made sense for me to replace it in other locations in Geoclaw, but if one of you wants to do that on this branch, you should have push access. Let me know if there are any other improvements to make or alternative approaches to implementation to discuss. |
|
Working on some larger simulations and this (or something else I did) has seemed to make things slower. This is mostly to say that I think a timing test on full probably makes sense to do for this one. I can plan to do that (sometime this week at the latest, I hope) and report back. |
|
OK, probably was something else. On a small (but not super small) problem, I get the following timing. 259.063 s CPU time on current master, 259.480 s with this change. Without this change: With this change |
Another change based on D-Claw development: In D-Claw we have one variable in q that should not be set to zero when q(1)<drytol.
This suggestion is intended to retain geoclaw functionality, but not require a D-Claw specific routine that differs only by this line.
@rjleveque @mandli @dlgeorge