2D AMRCLAW
upbnd.f
Go to the documentation of this file.
1 c
2 c ------------------------------------------------------------
3 c
4  subroutine upbnd(listbc,val,nvar,naux,mitot,mjtot,
5  1 maxsp,mptr)
6 c 1 maxsp,iused,mptr)
7 
8  use amr_module
9  implicit double precision (a-h,o-z)
10 
11 
12  dimension val(nvar,mitot,mjtot),listbc(5,maxsp),
13  1 iused(mitot,mjtot)
14 
15 c OLD INDEXING
16 c iaddaux(i,j) = locaux + i-1 + mitot*(j-1)
17 c 1 + mitot*mjtot*(mcapa-1)
18 c NEW INDEXING - SWITCHED ORDERING
19  iaddaux(i,j) = locaux + mcapa-1 + naux*(i-1)
20  1 + mitot*naux*(j-1)
21 
22 c
23 c :::::::::::::::::::::::::::: UPBND :::::::::::::::::::::::::::::
24 c We now correct the coarse grid with the flux differences stored
25 c with each of the fine grids. We use an array iused
26 c to indicate whether the flux has been updated or not for that zone.
27 c iused(i,j) = sum from (l=1,4) i(l)*2**(l-1), where i(l) = 1 if the
28 c flux for the l-th side of the (i,j)-th cell has already been
29 c updated, and i(l) = 0 if not.
30 
31 c if there is a capacity fn. it needs to be included in update formula
32 c indicated by mcapa not zero (is index of capacity fn.)
33 c ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
34 c
35 
36  do 10 j=1,mjtot
37  do 10 i=1,mitot
38  iused(i,j) = 0.
39  10 continue
40 
41  locaux = node(storeaux,mptr)
42  levc = node(nestlevel,mptr)
43  area = hxposs(levc)*hyposs(levc)
44 
45 
46  if (uprint) write(outunit,*)" upbnding grid ",mptr
47 
48  do 40 ispot = 1,maxsp
49  icrse = listbc(1,ispot)
50  if (icrse.eq.0) go to 99
51 
52  jcrse = listbc(2,ispot)
53  iside = listbc(3,ispot)
54 c continue to use iside1/norm for debugging, but should soon delete
55 c this if/then/else block needed due to new categories corresponding
56 c to mapped bcs. should still only have one update per side of coarse cell though
57  if (iside .lt. 5) then
58  iside1 = iside
59  elseif (iside .eq. 5) then
60  iside1 = 2
61  else ! iside is 6
62  iside1 = 4
63  endif
64  norm = 2**(iside1-1)
65  iflag =iused(icrse,jcrse)/norm
66  if (mod(iflag,2).eq.1) then
67  write(6,*)" *** double flux update CAN happen in upbnd ***"
68  go to 40
69  endif
70  mkid = listbc(4,ispot)
71  kidlst = node(ffluxptr,mkid)
72  lkid = listbc(5,ispot)
73 c if (mod(iside,4).gt.1) then
74 c modified to include other side options
75  if (iside .eq. 2 .or. iside .eq. 3 .or. iside .eq. 6) then
76 c (iside .eq. 2 .or. iside .eq. 3)
77  sgnm = -1.
78  else
79 c (iside .eq. 4 .or. iside .eq. 1)
80  sgnm = 1.
81  endif
82 
83 c ## debugging output
84  if (uprint) then
85  write(outunit,101) icrse,jcrse,
86  . (val(ivar,icrse,jcrse),ivar=1,nvar)
87  101 format(" old ",1x,2i4,4e15.7)
88  endif
89 
90  if (mcapa .gt. 0) then
91 c # capacity array: need to divide by capa in each cell.
92 c # modify sgnm which is reset for each grid cell.
93 c # Note capa is stored in aux(icrse,jcrse,mcapa)
94  sgnm = sgnm / alloc(iaddaux(icrse,jcrse))
95  endif
96 
97  do 20 ivar = 1,nvar
98  val(ivar,icrse,jcrse) = val(ivar,icrse,jcrse) +
99  1 sgnm*alloc(kidlst+nvar*(lkid-1)+ivar-1)/area
100  20 continue
101  iused(icrse,jcrse) = iused(icrse,jcrse) + norm
102 
103 c ## debugging output
104  if (uprint) then
105  write(outunit,102) mkid,
106  . (val(ivar,icrse,jcrse),ivar=1,nvar)
107  102 format(" new ","(grid",i3,")",4e15.7)
108  endif
109 
110  40 continue
111 c
112  99 return
113  end
subroutine upbnd(listbc, val, nvar, naux, mitot, mjtot, maxsp, mptr)
Definition: upbnd.f:4