Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Level specific wave tolerance #241

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
49 changes: 34 additions & 15 deletions src/2d/shallow/flag2refine2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ subroutine flag2refine2(mx,my,mbc,mbuff,meqn,maux,xlower,ylower,dx,dy,t,level, &

! Generic locals
integer :: i,j,m
real(kind=8) :: x_c,y_c,x_low,y_low,x_hi,y_hi
real(kind=8) :: x_c,y_c,x_low,y_low,x_hi,y_hi,mth_level_wave_tolerance, mth_level_speed_tolerance
real(kind=8) :: speed, eta, ds

! Storm specific variables
Expand Down Expand Up @@ -175,27 +175,46 @@ subroutine flag2refine2(mx,my,mbc,mbuff,meqn,maux,xlower,ylower,dx,dy,t,level, &

if (q(1,i,j) > dry_tolerance) then
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,mxnest
if (m > size(wave_tolerance)) then
mth_level_wave_tolerance = wave_tolerance(size(wave_tolerance))
else
mth_level_wave_tolerance = wave_tolerance(m)
endif
endif

if (abs(eta - sea_level) > mth_level_wave_tolerance .and. level <= m) then
! Check to see if we are near shore
Print *, "Level is ", level
Print *, "Wave tolerance is ", mth_level_wave_tolerance

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 speed criteria, note that it might be useful to
! also have a per layer criteria since this is not
! gradient based
speed = sqrt(q(2,i,j)**2 + q(3,i,j)**2) / q(1,i,j)
do m=1,min(size(speed_tolerance),mxnest)
if (speed > speed_tolerance(m) .and. level <= m) then
do m=1,mxnest
if (m > size(speed_tolerance)) then
mth_level_speed_tolerance = speed_tolerance(size(speed_tolerance))
else
mth_level_speed_tolerance = speed_tolerance(m)
endif

if (speed > mth_level_speed_tolerance .and. level <= m) then
amrflags(i,j) = DOFLAG
cycle x_loop
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