2D AMRCLAW
Functions/Subroutines
flagregions.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine flagregions (mx, my, mbuff, xlower, ylower, dx, dy, level, t, amrflags, DONTFLAG, DOFLAG)
 Modify array of flagged points to respect minlevels and maxlevels specified by regions. More...
 

Function/Subroutine Documentation

◆ flagregions()

subroutine flagregions ( integer, intent(in)  mx,
integer, intent(in)  my,
integer, intent(in)  mbuff,
real(kind=8), intent(in)  xlower,
real(kind=8), intent(in)  ylower,
real(kind=8), intent(in)  dx,
real(kind=8), intent(in)  dy,
integer, intent(in)  level,
real(kind=8), intent(in)  t,
real(kind=8), dimension(1-mbuff:mx+mbuff,1-mbuff:my+mbuff), intent(inout)  amrflags,
real(kind=8), intent(in)  DONTFLAG,
real(kind=8), intent(in)  DOFLAG 
)

Modify array of flagged points to respect minlevels and maxlevels specified by regions.

Definition at line 14 of file flagregions.f90.

References regions_module::num_regions, and regions_module::regions.

14 
15  use regions_module
16 
17  implicit none
18 
19  ! Subroutine arguments
20  integer, intent(in) :: mx,my,level,mbuff
21  real(kind=8), intent(in) :: xlower,ylower,dx,dy,t
22 
23  ! Flagging
24  real(kind=8),intent(inout) :: amrflags(1-mbuff:mx+mbuff,1-mbuff:my+mbuff)
25  real(kind=8), intent(in) :: dontflag
26  real(kind=8), intent(in) :: doflag
27 
28  logical :: allowflag
29  external allowflag
30 
31  ! Locals
32  integer :: i,j,m,minlevel,maxlevel
33  real(kind=8) :: x_low,y_low,x_hi,y_hi
34 
35 
36  ! Loop over interior points on this grid
37  ! (i,j) grid cell is [x_low,x_hi] x [y_low,y_hi]
38  do j=1,my
39  y_low = ylower + (j - 1) * dy
40  y_hi = ylower + j * dy
41 
42  do i = 1,mx
43  x_low = xlower + (i - 1) * dx
44  x_hi = xlower + i * dx
45 
46  minlevel = 0
47  maxlevel = 0
48 
49  do m=1,num_regions
50  if (t >= regions(m)%t_low .and. t <= regions(m)%t_hi .and. &
51  x_hi > regions(m)%x_low .and. x_low < regions(m)%x_hi .and. &
52  y_hi > regions(m)%y_low .and. y_low < regions(m)%y_hi ) then
53  minlevel = max(minlevel, regions(m)%min_level)
54  maxlevel = max(maxlevel, regions(m)%max_level)
55  endif
56  enddo
57 
58  if (minlevel > maxlevel) then
59  write(6,*) '*** Error: this should never happen!'
60  write(6,*) '*** minlevel > maxlevel in flagregions'
61  stop
62  endif
63 
64  if (maxlevel /= 0) then
65  ! this point lies in at least one region, so may need
66  ! to modify the exisiting flag at this point...
67  if (level < minlevel) then
68  ! Require refinement of this cell:
69  amrflags(i,j) = doflag
70  else if (level >= maxlevel) then
71  ! Do not refine of this cell:
72  amrflags(i,j) = dontflag
73  ! else leave amrflags(i,j) alone.
74  endif
75  endif
76 
77  enddo
78  enddo
79 
type(region_type), dimension(:), allocatable regions
real(kind=8) xlower
Definition: amr_module.f90:231
real(kind=8) ylower
Definition: amr_module.f90:231
logical function allowflag(x, y, t, level)
Indicate whether the grid point at (x,y,t) at this refinement level is allowed to be flagged for furt...
Definition: allowflag.f:20