2D AMRCLAW
gfixup.f
Go to the documentation of this file.
1 c
2 c -----------------------------------------------------------
3 c
4  subroutine gfixup(lbase, lfnew, nvar, naux, newnumgrids,
5  . maxnumnewgrids)
6 c
7  use amr_module
8  implicit double precision (a-h,o-z)
9 
10  integer omp_get_thread_num, omp_get_max_threads
11  integer mythread/0/, maxthreads/1/
12  integer newnumgrids(maxlv), listnewgrids(maxnumnewgrids)
13 
14 c
15 c ::::::::::::::::::::::::: GFIXUP ::::::::::::::::::::::::::::::::;
16 c interpolate initial values for the newly created grids.
17 c the start of each level is located in newstl array.
18 c since only levels greater than lbase were examined, start
19 c looking there.
20 c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
21 c
22 c reclaim old storage (position 8) and list space 15 and 16
23 c before allocating new storage. remember, finest level grids
24 c (if level = mxnest so that error never estimated) don't have
25 c 2 copies of solution values at old and new times.
26 c
27 c
28  call putsp(lbase,lbase,nvar,naux)
29  level = lbase + 1
30  1 if (level .gt. lfine) go to 4
31  call putsp(lbase,level,nvar,naux)
32  mptr = lstart(level)
33  2 if (mptr .eq. 0) go to 3
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  nwords = mitot*mjtot*nvar
39  if (level .lt. mxnest)
40  . call reclam(node(store2, mptr), nwords)
41  node(store2, mptr) = 0
42  mptr = node(levelptr, mptr)
43  go to 2
44  3 level = level + 1
45  go to 1
46 c
47  4 lcheck = lbase + 1
48 
49  time = rnode(timemult, lstart(lbase))
50  5 if (lcheck .gt. mxnest) go to 99
51  hx = hxposs(lcheck)
52  hy = hyposs(lcheck)
53 
54 c
55 c prepare for doing next loop over grids at a given level in parallel
56 c unlike other level loops, these are newly created grids, not yet merged in
57 c so take grids from newstl (NEWSTartOfLevel), not lstart. Dont yet know
58 c how many either.
59  call prepnewgrids(listnewgrids,newnumgrids(lcheck),lcheck)
60 c
61 c interpolate level lcheck
62 c first get space, since cant do that part in parallel
63  do j = 1, newnumgrids(lcheck)
64  mptr = listnewgrids(j)
65  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
66  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
67  mitot = nx + 2*nghost
68  mjtot = ny + 2*nghost
69  loc = igetsp(mitot * mjtot * nvar)
70  node(store1, mptr) = loc
71  if (naux .gt. 0) then
72  locaux = igetsp(mitot * mjtot * naux)
73  else
74  locaux = 1
75  endif
76  node(storeaux, mptr) = locaux
77  end do
78 
79 c
80 !$OMP PARALLEL DO
81 !$OMP& PRIVATE(j,mptr,nx,ny,mitot,mjtot,corn1,corn2,loc)
82 !$OMP& PRIVATE(locaux,time,mic,mjc,xl,xr,yb,yt,ilo,ihi)
83 !$OMP& PRIVATE(jlo,jhi,sp_over_h,thisSetauxTime)
84 !$OMP& SHARED(newnumgrids,listnewgrids,nghost,node,hx,hy)
85 !$OMP& SHARED(rnode,intratx,intraty,lcheck,nvar,alloc,naux)
86 !$OMP& SCHEDULE(dynamic,1)
87 !$OMP& DEFAULT(none)
88 c
89  do j = 1, newnumgrids(lcheck)
90  mptr = listnewgrids(j)
91 
92 c changed to move setaux out of this loop. instead, copy aux in filval
93 c along with soln.involves changing intcopy to icall and making flag array
94 c can only do this after topo stops moving
95  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
96  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
97  mitot = nx + 2*nghost
98  mjtot = ny + 2*nghost
99  corn1 = rnode(cornxlo,mptr)
100  corn2 = rnode(cornylo,mptr)
101  loc = node(store1, mptr)
102  if (naux .gt. 0) then
103  locaux = node(storeaux, mptr)
104  else
105  locaux = 1
106  endif
107 
108 c
109 c We now fill in the values for grid mptr using filval. It uses
110 c piecewise linear interpolation to obtain values from the
111 c (lcheck - 1) grid, then overwrites those with whatever (lcheck)
112 c grids are available. We take advantage of the fact that the
113 c (lcheck - 1) grids have already been set, and that the distance
114 c between any point in mptr and a (lcheck - 1) and (lcheck - 2)
115 c interface is at least one (lcheck - 1) cell wide.
116 c
117 
118 c # make a coarsened patch with ghost cells so can use
119 c # grid interpolation routines, but only set "interior".
120 c # extra 2 cells so that can use linear interp. on
121 c # "interior" of coarser patch to fill fine grid.
122  mic = nx/intratx(lcheck-1) + 2
123  mjc = ny/intraty(lcheck-1) + 2
124  xl = rnode(cornxlo,mptr)
125  xr = rnode(cornxhi,mptr)
126  yb = rnode(cornylo,mptr)
127  yt = rnode(cornyhi,mptr)
128  ilo = node(ndilo, mptr)
129  ihi = node(ndihi, mptr)
130  jlo = node(ndjlo, mptr)
131  jhi = node(ndjhi, mptr)
132 
133  call filval(alloc(loc),mitot,mjtot,hx,hy,lcheck,time,
134  1 mic,mjc,
135  2 xl,xr,yb,yt,nvar,
136  3 mptr,ilo,ihi,jlo,jhi,
137  4 alloc(locaux),naux)
138 
139  end do
140 c
141 c done filling new grids at level. move them into lstart from newstl
142 c (so can use as source grids for filling next level). can also
143 c get rid of loc. 7 storage for old level.
144 c
145  80 mptr = lstart(lcheck)
146  85 if (mptr .eq. 0) go to 90
147  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
148  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
149  mitot = nx + 2*nghost
150  mjtot = ny + 2*nghost
151  call reclam(node(store1,mptr),mitot*mjtot*nvar)
152  if (naux .gt. 0) then
153  call reclam(node(storeaux,mptr),mitot*mjtot*naux)
154  endif
155  mold = mptr
156  mptr = node(levelptr,mptr)
157  call putnod(mold)
158  call freebndrylist(mold)
159  go to 85
160  90 lstart(lcheck) = newstl(lcheck)
161  lcheck = lcheck + 1
162  go to 5
163 c
164  99 lfine = lfnew
165 c
166 c initialize 2nd (old time) storage block for new grids not at top level
167 c
168  levend = min(lfine,mxnest-1)
169  do 110 level = lbase+1, levend
170  mptr = lstart(level)
171  105 if (mptr .eq. 0) go to 110
172  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
173  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
174  mitot = nx + 2*nghost
175  mjtot = ny + 2*nghost
176  nwords = mitot*mjtot*nvar
177  node(store2,mptr) = igetsp(nwords)
178  mptr = node(levelptr,mptr)
179  go to 105
180  110 continue
181 
182 c
183 c -------------
184 c grid structure now complete again. safe to print, etc. assuming
185 c things initialized to zero in nodget.
186 c -------------
187 c
188  return
189  end
190 c
191 c -----------------------------------------------------------------------------------------
192 c
193 c use different routine since need to scan new grid list (newstl) not lstart
194 c to make grids.
195 c could make one routine by passing in source of list, but this changed 4 other routines
196 c so I didnt want to have to deal with it
197 
198  subroutine prepnewgrids(listnewgrids,num,level)
199 
200  use amr_module
201  implicit double precision (a-h,o-z)
202  integer listnewgrids(num)
203 
204  mptr = newstl(level)
205  do j = 1, num
206  listnewgrids(j) = mptr
207  mptr = node(levelptr, mptr)
208  end do
209 
210  if (mptr .ne. 0) then
211  write(*,*)" Error in routine setting up grid array "
212  stop
213  endif
214 
215  return
216  end
function igetsp(nwords)
Definition: igetsp.f:4
subroutine filval(val, mitot, mjtot, dx, dy, level, time, mic, mjc, xleft, xright, ybot, ytop, nvar, mptr, ilo, ihi, jlo, jhi, aux, naux)
Definition: filval.f90:10
subroutine reclam(index, nwords)
Definition: reclam.f:4
subroutine freebndrylist(mold)
Definition: nodget.f:212
subroutine putnod(mptr)
Definition: putnod.f:4
subroutine gfixup(lbase, lfnew, nvar, naux, newnumgrids, maxnumnewgrids)
Definition: gfixup.f:4
subroutine prepnewgrids(listnewgrids, num, level)
Definition: gfixup.f:198
subroutine putsp(lbase, level, nvar, naux)
Definition: putsp.f:4