2D AMRCLAW
spest2.f
Go to the documentation of this file.
1 c
2 c -------------------------------------------------------------
3 c
4  subroutine spest2 (nvar,naux,lcheck,start_time)
5 c
6  use amr_module
7  implicit double precision (a-h,o-z)
8 
9  integer omp_get_thread_num, omp_get_max_threads
10  integer mythread/0/, maxthreads/1/
11  integer listgrids(numgrids(lcheck))
12 
13 c :::::::::::::::::::::::::: SPEST2 :::::::::::::::::::::::::::::::::::
14 c For all grids at level lcheck:
15 c Call user-supplied routine flag2refine to flag any points where
16 c refinement is desired based on user's criterion.
17 c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
18 c
19 !$ maxthreads = omp_get_max_threads()
20  call prepgrids(listgrids,numgrids(lcheck),lcheck)
21 
22 c mptr = lstart(lcheck)
23 c 5 continue
24 !$OMP PARALLEL DO PRIVATE(jg,mptr,nx,ny,mitot,mjtot,locnew,locaux),
25 !$OMP& PRIVATE(time,dx,dy,xleft,ybot,xlow,ylow,locbig),
26 !$OMP& PRIVATE(locold,mbuff,mibuff,mjbuff,locamrflags,i),
27 !$OMP& SHARED(numgrids,listgrids,lcheck,nghost,nvar,naux),
28 !$OMP& SHARED(start_time,possk,flag_gradient,ibuff),
29 !$OMP& SHARED(tolsp,alloc,node,rnode,hxposs,hyposs),
30 !$OMP& DEFAULT(none),
31 !$OMP& SCHEDULE(DYNAMIC,1)
32  do jg = 1, numgrids(lcheck)
33  mptr = listgrids(jg)
34  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
35  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
36  mitot = nx + 2*nghost
37  mjtot = ny + 2*nghost
38  locnew = node(store1,mptr)
39  locaux = node(storeaux,mptr)
40  time = rnode(timemult,mptr)
41  dx = hxposs(lcheck)
42  dy = hyposs(lcheck)
43  xleft = rnode(cornxlo,mptr)
44  ybot = rnode(cornylo,mptr)
45  xlow = xleft - nghost*dx
46  ylow = ybot - nghost*dy
47 c
48  locbig = igetsp(mitot*mjtot*nvar)
49  node(tempptr,mptr) = locbig
50 c # straight copy into scratch array so don't mess up latest soln.
51 
52 c ## at later times want to use newest soln for spatial error flagging
53 c ## at initial time want to use initial conditions (so retain symmetry for example)
54  if (start_time+possk(lcheck) .ne. time) then ! exact equality test here. counting on ieee arith.
55  do 10 i = 1, mitot*mjtot*nvar
56  10 alloc(locbig+i-1) = alloc(locnew+i-1)
57 
58  call bound(time,nvar,nghost,alloc(locbig),mitot,mjtot,mptr,
59  1 alloc(locaux),naux)
60  else ! boundary values already in locold
61  locold = node(store2,mptr)
62  do 11 i = 1, mitot*mjtot*nvar
63  11 alloc(locbig+i-1) = alloc(locold+i-1)
64  endif
65 c
66 c get user flags for refinement, which might be based on spatial gradient,
67 c for example. Use old values of soln at time t before
68 c integration to get accurate boundary gradients
69 c
70  if (flag_gradient) then
71 ! need at least as big as nghost to fit ghost cells. if ibuff is bigger make
72 ! the flagged array bigger so can buffer in place
73  mbuff = max(nghost,ibuff+1)
74  mibuff = nx + 2*mbuff !NOTE THIS NEW DIMENSIONING
75 c !TO ALLOW ROOM FOR BUFFERING IN PLACE
76  mjbuff = ny + 2*mbuff
77  locamrflags = igetsp(mibuff*mjbuff)
78  node(storeflags,mptr) = locamrflags
79 
80  do 20 i = 1, mibuff*mjbuff
81  20 alloc(locamrflags+i-1) = goodpt
82 
83 c # call user-supplied routine to flag any points where
84 c # refinement is desired based on user's criterion.
85 c # Default version compares spatial gradient to tolsp.
86 
87  call flag2refine2(nx,ny,nghost,mbuff,nvar,naux,xleft,ybot,
88  & dx,dy,time,lcheck,tolsp,alloc(locbig),
89  & alloc(locaux),alloc(locamrflags),goodpt,badpt)
90  endif
91 
92  end do
93 c mptr = node(levelptr,mptr)
94 c if (mptr .ne. 0) go to 5
95 c
96  return
97  end
98 
integer, parameter timemult
current simulation time on this grid
Definition: amr_module.f90:151
integer, parameter cornxlo
x-coordinate of the left border of this grid
Definition: amr_module.f90:143
function igetsp(nwords)
Allocate contiguous space of length nword in main storage array alloc.
Definition: igetsp.f:9
integer, parameter tempptr
temporary pointer
Definition: amr_module.f90:38
real(kind=8), dimension(maxlv) hyposs
Definition: amr_module.f90:193
real(kind=8), dimension(maxlv) hxposs
Definition: amr_module.f90:193
integer, parameter ndihi
global i index of right border of this grid
Definition: amr_module.f90:111
integer, dimension(nsize, maxgr) node
Definition: amr_module.f90:198
real(kind=8), parameter goodpt
Definition: amr_module.f90:163
integer, dimension(maxlv) numgrids
Definition: amr_module.f90:198
real(kind=8), dimension(rsize, maxgr) rnode
Definition: amr_module.f90:193
real(kind=8) tolsp
Definition: amr_module.f90:197
integer, parameter storeflags
pointer to the address of memory storing flags for refinement on this grid
Definition: amr_module.f90:123
integer, parameter ndilo
global i index of left border of this grid
Definition: amr_module.f90:108
integer, parameter ndjlo
global j index of lower border of this grid
Definition: amr_module.f90:114
integer, parameter store1
pointer to the address of memory storing the first copy of solution data on this grid, usually for storing new solution
Definition: amr_module.f90:101
integer ibuff
Definition: amr_module.f90:198
integer, parameter store2
pointer to the address of memory storing the second copy of solution data on this grid...
Definition: amr_module.f90:105
logical flag_gradient
Definition: amr_module.f90:258
subroutine flag2refine2(mx, my, mbc, mbuff, meqn, maux, xlower, ylower, dx, dy, t, level, tolsp, q, aux, amrflags, DONTFLAG, DOFLAG)
User routine to control flagging of points for refinement.
real(kind=8), parameter badpt
Definition: amr_module.f90:165
subroutine prepgrids(listgrids, num, level)
Definition: advanc.f:147
real(kind=8), dimension(maxlv) possk
Definition: amr_module.f90:193
integer, parameter ndjhi
global j index of upper border of this grid
Definition: amr_module.f90:117
subroutine bound(time, nvar, ng, valbig, mitot, mjtot, mptr, aux, naux)
This routine sets the boundary values for a given grid at level level.
Definition: bound.f90:52
integer, parameter cornylo
y-coordinate of the lower border of this grid
Definition: amr_module.f90:145
integer nghost
Definition: amr_module.f90:232
The module contains the definition of a "node descriptor" as well as other global variables used duri...
Definition: amr_module.f90:21
integer, parameter storeaux
pointer to the address of memory storing auxiliary data on this grid
Definition: amr_module.f90:120
subroutine spest2(nvar, naux, lcheck, start_time)
Definition: spest2.f:5
real(kind=8), dimension(:), allocatable alloc
Definition: amr_module.f90:218