2D AMRCLAW
qad.f
Go to the documentation of this file.
1 c
2 c -------------------------------------------------------------
3 c
4  subroutine qad(valbig,mitot,mjtot,nvar,
5  . svdflx,qc1d,lenbc,lratiox,lratioy,hx,hy,
6  . maux,aux,auxc1d,delt,mptr)
7 
8  use amr_module
9  implicit double precision (a-h, o-z)
10 
11 
12  logical qprint
13 
14  dimension valbig(nvar,mitot,mjtot)
15  dimension qc1d(nvar,lenbc)
16  dimension svdflx(nvar,lenbc)
17  dimension aux(maux,mitot,mjtot)
18  dimension auxc1d(maux,lenbc)
19 
20 c
21 c ::::::::::::::::::::::::::: QAD ::::::::::::::::::::::::::::::::::
22 c solve RP between ghost cell value on fine grid and coarse grid
23 c value that ghost cell overlaps. The resulting fluctuations
24 c are added in to coarse grid value, as a conservation fixup.
25 c Done each fine grid time step. If source terms are present, the
26 c coarse grid value is advanced by source terms each fine time step too.
27 
28 c No change needed in this sub. for spherical mapping: correctly
29 c mapped vals already in bcs on this fine grid and coarse saved
30 c vals also properly prepared
31 c
32 c Side 1 is the left side of the fine grid patch. Then go around clockwise.
33 c ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
34 c
35 c # local storage
36 c # note that dimension here are bigger than dimensions used
37 c # in rp2, but shouldn't matter since wave is not used in qad
38 c # and for other arrays it is only the last parameter that is wrong
39 c # ok as long as meqn, mwaves < maxvar
40 
41  parameter(max1dp1 = max1d+1)
42  dimension ql(nvar,max1dp1), qr(nvar,max1dp1)
43  dimension wave(nvar,mwaves,max1dp1), s(mwaves,max1dp1)
44  dimension amdq(nvar,max1dp1), apdq(nvar,max1dp1)
45  dimension auxl(maxaux*max1dp1), auxr(maxaux*max1dp1)
46 c
47 c WARNING: auxl,auxr dimensioned at max possible, but used as if
48 c they were dimensioned as the real maux by max1dp1. Would be better
49 c of course to dimension by maux by max1dp1 but this wont work if maux=0
50 c So need to access using your own indexing into auxl,auxr.
51  iaddaux(iaux,i) = iaux + maux*(i-1)
52 
53  data qprint/.false./
54 c
55 c aux is auxiliary array with user parameters needed in Riemann solvers
56 c on fine grid corresponding to valbig
57 c auxc1d is coarse grid stuff from around boundary, same format as qc1d
58 c auxl, auxr are work arrays needed to pass stuff to rpn2
59 c maux is the number of aux variables, which may be zero.
60 c
61 
62  tgrid = rnode(timemult, mptr)
63  if (qprint)
64  . write(dbugunit,*)" working on grid ",mptr," time ",tgrid
65  nc = mjtot-2*nghost
66  nr = mitot-2*nghost
67  level = node(nestlevel, mptr)
68  index = 0
69 
70 c
71 c--------
72 c side 1
73 c--------
74 c
75  do 10 j = nghost+1, mjtot-nghost
76  if (maux.gt.0) then
77  do 5 ma = 1,maux
78  if (auxtype(ma).eq."xleft") then
79 c # Assuming velocity at left-face, this fix
80 c # preserves conservation in incompressible flow:
81  auxl(iaddaux(ma,j-nghost+1)) = aux(ma,nghost+1,j)
82  else
83 c # Normal case -- we set the aux arrays
84 c # from the cell corresponding to q
85  auxl(iaddaux(ma,j-nghost+1)) = aux(ma,nghost,j)
86  endif
87  5 continue
88  endif
89  do 10 ivar = 1, nvar
90  ql(ivar,j-nghost+1) = valbig(ivar,nghost,j)
91  10 continue
92 
93  lind = 0
94  ncrse = (mjtot-2*nghost)/lratioy
95  do 20 jc = 1, ncrse
96  index = index + 1
97  do 25 l = 1, lratioy
98  lind = lind + 1
99  if (maux.gt.0) then
100  do 24 ma=1,maux
101  auxr(iaddaux(ma,lind)) = auxc1d(ma,index)
102  24 continue
103  endif
104  do 25 ivar = 1, nvar
105  25 qr(ivar,lind) = qc1d(ivar,index)
106  20 continue
107 
108  if (qprint) then
109  write(dbugunit,*) 'side 1, ql and qr:'
110  do i=2,nc
111  write(dbugunit,4101) i,qr(1,i-1),ql(1,i)
112  enddo
113  4101 format(i3,4e16.6)
114  if (maux .gt. 0) then
115  write(dbugunit,*) 'side 1, auxr:'
116  do i=2,nc
117  write(dbugunit,4101) i,(auxr(iaddaux(ma,i-1)),ma=1,maux)
118  enddo
119  write(dbugunit,*) 'side 1, auxl:'
120  do i=2,nc
121  write(dbugunit,4101) i,(auxl(iaddaux(ma,i)),ma=1,maux)
122  enddo
123  endif
124  endif
125 
126  call rpn2(1,max1dp1-2*nghost,nvar,mwaves,maux,nghost,
127  . nc+1-2*nghost,ql,qr,auxl,auxr,wave,s,amdq,apdq)
128 c
129 c we have the wave. for side 1 add into sdflxm
130 c
131  influx = 0
132  do 30 j = 1, nc/lratioy
133  influx = influx + 1
134  jfine = (j-1)*lratioy
135  do 40 ivar = 1, nvar
136  do 50 l = 1, lratioy
137  svdflx(ivar,influx) = svdflx(ivar,influx)
138  . + amdq(ivar,jfine+l+1) * hy * delt
139  . + apdq(ivar,jfine+l+1) * hy * delt
140  50 continue
141  40 continue
142  30 continue
143 
144 c--------
145 c side 2
146 c--------
147 c
148  if (mjtot .eq. 2*nghost+1) then
149 c # a single row of interior cells only happens when using the
150 c # 2d amrclaw code to do a 1d problem with refinement.
151 c # (feature added in Version 4.3)
152 c # skip over sides 2 and 4 in this case
153  go to 299
154  endif
155 
156  do 210 i = nghost+1, mitot-nghost
157  if (maux.gt.0) then
158  do 205 ma = 1,maux
159  auxr(iaddaux(ma,i-nghost)) = aux(ma,i,mjtot-nghost+1)
160  205 continue
161  endif
162  do 210 ivar = 1, nvar
163  qr(ivar,i-nghost) = valbig(ivar,i,mjtot-nghost+1)
164  210 continue
165 
166  lind = 0
167  ncrse = (mitot-2*nghost)/lratiox
168  do 220 ic = 1, ncrse
169  index = index + 1
170  do 225 l = 1, lratiox
171  lind = lind + 1
172  if (maux.gt.0) then
173  do 224 ma=1,maux
174  if (auxtype(ma).eq."yleft") then
175 c # Assuming velocity at bottom-face, this fix
176 c # preserves conservation in incompressible flow:
177  ifine = (ic-1)*lratiox + nghost + l
178  auxl(iaddaux(ma,lind+1)) = aux(ma,ifine,mjtot-nghost+1)
179  else
180  auxl(iaddaux(ma,lind+1)) = auxc1d(ma,index)
181  endif
182  224 continue
183  endif
184  do 225 ivar = 1, nvar
185  225 ql(ivar,lind+1) = qc1d(ivar,index)
186  220 continue
187 
188  if (qprint) then
189  write(dbugunit,*) 'side 2, ql and qr:'
190  do i=1,nr
191  write(dbugunit,4101) i,ql(1,i+1),qr(1,i)
192  enddo
193  if (maux .gt. 0) then
194  write(dbugunit,*) 'side 2, auxr:'
195  do i = 1, nr
196  write(dbugunit,4101) i, (auxr(iaddaux(ma,i)),ma=1,maux)
197  enddo
198  write(dbugunit,*) 'side 2, auxl:'
199  do i = 1, nr
200  write(dbugunit,4101) i, (auxl(iaddaux(ma,i)),ma=1,maux)
201  enddo
202  endif
203  endif
204  call rpn2(2,max1dp1-2*nghost,nvar,mwaves,maux,nghost,
205  . nr+1-2*nghost,ql,qr,auxl,auxr,wave,s,amdq,apdq)
206 c
207 c we have the wave. for side 2. add into sdflxp
208 c
209  do 230 i = 1, nr/lratiox
210  influx = influx + 1
211  ifine = (i-1)*lratiox
212  do 240 ivar = 1, nvar
213  do 250 l = 1, lratiox
214  svdflx(ivar,influx) = svdflx(ivar,influx)
215  . - amdq(ivar,ifine+l+1) * hx * delt
216  . - apdq(ivar,ifine+l+1) * hx * delt
217  250 continue
218  240 continue
219  230 continue
220 
221  299 continue
222 
223 c--------
224 c side 3
225 c--------
226 c
227  do 310 j = nghost+1, mjtot-nghost
228  if (maux.gt.0) then
229  do 305 ma = 1,maux
230  auxr(iaddaux(ma,j-nghost)) = aux(ma,mitot-nghost+1,j)
231  305 continue
232  endif
233  do 310 ivar = 1, nvar
234  qr(ivar,j-nghost) = valbig(ivar,mitot-nghost+1,j)
235  310 continue
236 
237  lind = 0
238  ncrse = (mjtot-2*nghost)/lratioy
239  do 320 jc = 1, ncrse
240  index = index + 1
241  do 325 l = 1, lratioy
242  lind = lind + 1
243  if (maux.gt.0) then
244  do 324 ma=1,maux
245  if (auxtype(ma).eq."xleft") then
246 c # Assuming velocity at left-face, this fix
247 c # preserves conservation in incompressible flow:
248  jfine = (jc-1)*lratioy + nghost + l
249  auxl(iaddaux(ma,lind+1)) = aux(ma,mitot-nghost+1,jfine)
250  else
251  auxl(iaddaux(ma,lind+1)) = auxc1d(ma,index)
252  endif
253  324 continue
254  endif
255  do 325 ivar = 1, nvar
256  325 ql(ivar,lind+1) = qc1d(ivar,index)
257  320 continue
258 
259  if (qprint) then
260  write(dbugunit,*) 'side 3, ql and qr:'
261  do i=1,nc
262  write(dbugunit,4101) i,ql(1,i),qr(1,i)
263  enddo
264  endif
265  call rpn2(1,max1dp1-2*nghost,nvar,mwaves,maux,nghost,
266  . nc+1-2*nghost,ql,qr,auxl,auxr,wave,s,amdq,apdq)
267 c
268 c we have the wave. for side 3 add into sdflxp
269 C
270  do 330 j = 1, nc/lratioy
271  influx = influx + 1
272  jfine = (j-1)*lratioy
273  do 340 ivar = 1, nvar
274  do 350 l = 1, lratioy
275  svdflx(ivar,influx) = svdflx(ivar,influx)
276  . - amdq(ivar,jfine+l+1) * hy * delt
277  . - apdq(ivar,jfine+l+1) * hy * delt
278  350 continue
279  340 continue
280  330 continue
281 
282 c--------
283 c side 4
284 c--------
285 c
286  if (mjtot .eq. 2*nghost+1) then
287 c # a single row of interior cells only happens when using the
288 c # 2d amrclaw code to do a 1d problem with refinement.
289 c # (feature added in Version 4.3)
290 c # skip over sides 2 and 4 in this case
291  go to 499
292  endif
293 c
294  do 410 i = nghost+1, mitot-nghost
295  if (maux.gt.0) then
296  do 405 ma = 1,maux
297  if (auxtype(ma).eq."yleft") then
298 c # Assuming velocity at bottom-face, this fix
299 c # preserves conservation in incompressible flow:
300  auxl(iaddaux(ma,i-nghost+1)) = aux(ma,i,nghost+1)
301  else
302  auxl(iaddaux(ma,i-nghost+1)) = aux(ma,i,nghost)
303  endif
304  405 continue
305  endif
306  do 410 ivar = 1, nvar
307  ql(ivar,i-nghost+1) = valbig(ivar,i,nghost)
308  410 continue
309 
310  lind = 0
311  ncrse = (mitot-2*nghost)/lratiox
312  do 420 ic = 1, ncrse
313  index = index + 1
314  do 425 l = 1, lratiox
315  lind = lind + 1
316  if (maux.gt.0) then
317  do 424 ma=1,maux
318  auxr(iaddaux(ma,lind)) = auxc1d(ma,index)
319  424 continue
320  endif
321  do 425 ivar = 1, nvar
322  425 qr(ivar,lind) = qc1d(ivar,index)
323  420 continue
324 
325  if (qprint) then
326  write(dbugunit,*) 'side 4, ql and qr:'
327  do i=1,nr
328  write(dbugunit,4101) i, ql(1,i),qr(1,i)
329  enddo
330  endif
331  call rpn2(2,max1dp1-2*nghost,nvar,mwaves,maux,nghost,
332  . nr+1-2*nghost,ql,qr,auxl,auxr,wave,s,amdq,apdq)
333 c
334 c we have the wave. for side 4. add into sdflxm
335 c
336  do 430 i = 1, nr/lratiox
337  influx = influx + 1
338  ifine = (i-1)*lratiox
339  do 440 ivar = 1, nvar
340  do 450 l = 1, lratiox
341  svdflx(ivar,influx) = svdflx(ivar,influx)
342  . + amdq(ivar,ifine+l+1) * hx * delt
343  . + apdq(ivar,ifine+l+1) * hx * delt
344  450 continue
345  440 continue
346  430 continue
347 
348  499 continue
349 
350 c # for source terms:
351  if (method(5) .ne. 0) then ! should I test here if index=0 and all skipped?
352  call src1d(nvar,nghost,lenbc,qc1d,maux,auxc1d,tgrid,delt)
353 c # how can this be right - where is the integrated src term used?
354  endif
355 
356  return
357  end
subroutine src1d(meqn, mbc, mx1d, q1d, maux, aux1d, t, dt)
Definition: src1d.f90:1
subroutine qad(valbig, mitot, mjtot, nvar, svdflx, qc1d, lenbc, lratiox, lratioy, hx, hy, maux, aux, auxc1d, delt, mptr)
Definition: qad.f:4
subroutine rpn2(ixy, maxm, meqn, mwaves, maux, mbc, mx, ql, qr, auxl, auxr, wave, s, amdq, apdq)
Definition: rpn2from1d.f:5