Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions src/2d/shallow/flag2refine2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,35 @@ subroutine flag2refine2(mx,my,mbc,mbuff,meqn,maux,xlower,ylower,dx,dy,t,level, &
eta = q(1,i,j) + aux(1,i,j)

! Check wave criteria
if (abs(eta - sea_level) > wave_tolerance) then
! Check to see if we are near shore
if (q(1,i,j) < deep_depth) then
amrflags(i,j) = DOFLAG
cycle x_loop
! Check if we are allowed to flag in deep water
! anyway
else if (level < max_level_deep) then
amrflags(i,j) = DOFLAG
cycle x_loop
! New method - level specific wave tolerance
do m=1,min(size(wave_tolerance),mxnest)
if (abs(eta - sea_level) > wave_tolerance(m) .and. level <= m) then
! Check to see if we are near shore
if (q(1,i,j) < deep_depth) then
amrflags(i,j) = DOFLAG
cycle x_loop
! Check if we are allowed to flag in deep water
! anyway
else if (level < max_level_deep) then
amrflags(i,j) = DOFLAG
cycle x_loop
endif
endif
enddo
! Check if wave tolerance array size is smaller than max level
! then refine with the last wave tolerance value for the rest of the levels
if (size(wave_tolerance) < mxnest-1) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might suggest pre-processing this so that the wave_tolerance array is always at least mxnest so you can simplify this logic and not replicate the checks.

if (abs(eta - sea_level) > wave_tolerance(size(wave_tolerance)) .and. level > size(wave_tolerance)) then
! Check to see if we are near shore
if (q(1,i,j) < deep_depth) then
amrflags(i,j) = DOFLAG
cycle x_loop
! Check if we are allowed to flag in deep water
! anyway
else if (level < max_level_deep) then
amrflags(i,j) = DOFLAG
cycle x_loop
endif
endif
endif

Expand Down
6 changes: 4 additions & 2 deletions src/2d/shallow/refinement_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module refinement_module
! ========================================================================
! Refinement Criteria
! ========================================================================
real(kind=8) :: wave_tolerance
real(kind=8), allocatable :: wave_tolerance(:)
real(kind=8), allocatable :: speed_tolerance(:)
real(kind=8) :: deep_depth
integer :: max_level_deep
Expand Down Expand Up @@ -59,7 +59,9 @@ subroutine set_refinement(file_name)
endif

! Basic criteria
read(unit,*) wave_tolerance
read(unit,'(a)') line
allocate(wave_tolerance(get_value_count(line)))
read(line,*) wave_tolerance
read(unit,'(a)') line
allocate(speed_tolerance(get_value_count(line)))
read(line,*) speed_tolerance
Expand Down