2D AMRCLAW
flagger.f
Go to the documentation of this file.
1 c ::::::::::::::::::::: FLAGGER :::::::::::::::::::::::::
2 c
3 c flagger = set up for and call two routines that flag using
4 c (a) spatial gradients, or other user-specified criteria
5 c (b) richardson error estimates
6 c
7 c the two approaches share an array with boundary ghost values
8 c
9 c ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10 ! Below are comments for Doxygen
28 ! TODO: what's this start_time above
29 c
30 c -----------------------------------------------------------
31 c
32  subroutine flagger(nvar,naux,lcheck,start_time)
33 
34  use amr_module
35  implicit double precision (a-h,o-z)
36 
37  integer omp_get_thread_num, omp_get_max_threads
38  integer mythread/0/, maxthreads/1/
39  integer listgrids(numgrids(lcheck)), locuse
40 
41  do jg = 1, numgrids(lcheck)
42 c mptr = listgrids(jg)
43  levst = liststart(lcheck)
44  mptr = listofgrids(levst+jg-1)
45  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
46  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
47  mitot = nx + 2*nghost
48  mjtot = ny + 2*nghost
49  if (flag_richardson) then
50  locbig = igetsp(mitot*mjtot*nvar)
51  node(tempptr,mptr) = locbig
52  else
53  locbig = 0
54  endif
55  mibuff = nx + 2*mbuff ! NOTE THIS NEW DIMENSIONING
56  mjbuff = ny + 2*mbuff ! TO ALLOW ROOM FOR BUFFERING IN PLACE
57  locamrflags = igetsp(mibuff*mjbuff)
58  node(storeflags,mptr) = locamrflags
59  end do
60 
61 !$OMP PARALLEL DO PRIVATE(jg,mptr,nx,ny,mitot,mjtot,locnew,locaux),
62 !$OMP& PRIVATE(time,dx,dy,xleft,ybot,xlow,ylow,locbig),
63 !$OMP& PRIVATE(locold,mbuff,mibuff,mjbuff,locamrflags,i),
64 !$OMP& PRIVATE(locuse),
65 !$OMP& SHARED(numgrids,listgrids,lcheck,nghost,nvar,naux),
66 !$OMP& SHARED(levSt,listStart,listOfGrids),
67 !$OMP& SHARED(tolsp,alloc,node,rnode,hxposs,hyposs,ibuff),
68 !$OMP& SHARED(start_time,possk,flag_gradient,flag_richardson)
69 !$OMP& DEFAULT(none),
70 !$OMP& SCHEDULE(DYNAMIC,1)
71  do jg = 1, numgrids(lcheck)
72 c mptr = listgrids(jg)
73  levst = liststart(lcheck)
74  mptr = listofgrids(levst+jg-1)
75  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
76  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
77  mitot = nx + 2*nghost
78  mjtot = ny + 2*nghost
79  locnew = node(store1,mptr)
80  locaux = node(storeaux,mptr)
81  time = rnode(timemult,mptr)
82  dx = hxposs(lcheck)
83  dy = hyposs(lcheck)
84  xleft = rnode(cornxlo,mptr)
85  ybot = rnode(cornylo,mptr)
86  xlow = xleft - nghost*dx
87  ylow = ybot - nghost*dy
88 c
89  locbig = node(tempptr,mptr)
90 c # straight copy into scratch array so don't mess up latest soln.
91 
92 c ## at later times want to use newest soln for spatial error flagging
93 c ## at initial time want to use initial conditions (so retain symmetry for example)
94  if (start_time+possk(lcheck) .ne. time) then !exact equality test-relying on ieee arith repeatability
95 c do in other order in case user messes up locbig in flag2refine, already have
96 c them in locnew
97  call bound(time,nvar,nghost,alloc(locnew),mitot,mjtot,mptr,
98  1 alloc(locaux),naux)
99  locuse = locnew ! flag based on newest vals
100  if (flag_richardson) then
101  do 10 i = 1, mitot*mjtot*nvar
102  10 alloc(locbig+i-1) = alloc(locnew+i-1)
103  endif
104 
105  else ! boundary values already in locold
106  locold = node(store2,mptr)
107  locuse = locold ! flag based on old vals at initial time
108  ! put back this way to agree with nosetests
109  if (flag_richardson) then
110  do 11 i = 1, mitot*mjtot*nvar
111  11 alloc(locbig+i-1) = alloc(locold+i-1)
112  endif
113  endif
114 
115 ! # need at least as big as nghost to fit ghost cells. if ibuff is bigger make
116 ! # the flagged array bigger so can buffer in place
117  mbuff = max(nghost,ibuff+1)
118  mibuff = nx + 2*mbuff ! NOTE THIS NEW DIMENSIONING
119  mjbuff = ny + 2*mbuff ! TO ALLOW ROOM FOR BUFFERING IN PLACE
120 
121 ! ## locamrflags used for flag storage. flag2refine flags directly into it.
122 ! ## richardson flags added to it. Then colate finished the job
123  locamrflags = node(storeflags,mptr)
124  do 20 i = 1, mibuff*mjbuff ! initialize
125  20 alloc(locamrflags+i-1) = goodpt
126 
127  if (flag_gradient) then
128 
129 c # call user-supplied routine to flag any points where
130 c # refinement is desired based on user's criterion.
131 c # Default version compares spatial gradient to tolsp.
132 
133 c no longer getting locbig, using "real" solution array in locnew
134  call flag2refine2(nx,ny,nghost,mbuff,nvar,naux,
135  & xleft,ybot,dx,dy,time,lcheck,
136  & tolsp,alloc(locuse),
137  & alloc(locaux),alloc(locamrflags),
138  & goodpt,badpt)
139  endif
140 c
141  if (flag_richardson) then
142  call errest(nvar,naux,lcheck,mptr,nx,ny)
143  endif
144 
145  end do
146 ! $OMP END PARALLEL DO
147 
148  return
149  end
subroutine errest(nvar, naux, lcheck, mptr, nx, ny)
Definition: errest.f:4
function igetsp(nwords)
Definition: igetsp.f:4
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.
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:51
subroutine flagger(nvar, naux, lcheck, start_time)
Set up for and call two routines that flag using (a) spatial gradients, or other user-specified crite...
Definition: flagger.f:32