2D AMRCLAW
prepc.f
Go to the documentation of this file.
1 c
2 c ----------------------------------------------------------
3 c
4  subroutine prepc(level,nvar)
5 c
6  use amr_module
7  implicit double precision (a-h,o-z)
8 
9 c
10 c :::::::::::::::::::: PREPC ::::::::::::::::::::::::::::::::::::::
11 c
12 c this routine called because regridding just changed the fine grids.
13 c modify coarse grid boundary lists to store fluxes in appropriate
14 c fine grids lists.
15 c assume new fine grids have node(cfluxptr) initialized to null
16 c
17 c first compute max. possible number of list cells. allocate
18 c initially so that one pass through is enough.
19 c
20 c ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
21 c
22  maxsp = 0
23  mkid = lstart(level+1)
24  10 if (mkid .eq. 0) go to 20
25  ikeep = (node(ndihi,mkid)-node(ndilo,mkid)+1)/intratx(level)
26  jkeep = (node(ndjhi,mkid)-node(ndjlo,mkid)+1)/intraty(level)
27  maxsp = maxsp + 2*(ikeep+jkeep)
28  mkid = node(levelptr,mkid)
29  go to 10
30  20 listsp(level) = maxsp
31  if (maxsp .eq. 0) go to 99
32 c
33  hxpar = hxposs(level)
34  hypar = hyposs(level)
35  hxkid = hxposs(level+1)
36  hykid = hyposs(level+1)
37  imax = iregsz(level) - 1
38  jmax = jregsz(level) - 1
39 
40  mpar = lstart(level)
41  30 if (mpar .eq. 0) go to 99
42 c
43  ispot = 0
44  ilo = node(ndilo,mpar)
45  jlo = node(ndjlo,mpar)
46  ihi = node(ndihi,mpar)
47  jhi = node(ndjhi,mpar)
48  locbc = igetsp(5*maxsp)
49 c # initialize list to 0 (0 terminator indicates end of bc list)
50  do 35 i = 1,5*maxsp
51  35 alloc(locbc+i-1) = 0.d0
52  node(cfluxptr,mpar) = locbc
53 c
54  mkid = lstart(level+1)
55  40 if (mkid .eq. 0) go to 60
56 
57  iclo = node(ndilo,mkid)/intratx(level)
58  jclo = node(ndjlo,mkid)/intraty(level)
59  ichi = node(ndihi,mkid)/intratx(level)
60  jchi = node(ndjhi,mkid)/intraty(level)
61 
62  iplo = max(ilo,iclo)
63  jplo = max(jlo,jclo)
64  iphi = min(ihi,ichi)
65  jphi = min(jhi,jchi)
66 
67 c regular intersections (will check in setuse that no duplication)
68 c this first call is only interior interfaces.
69 
70  if (iplo .le. iphi+1 .and. jplo .le. jphi+1) then
71  kflag = 1 ! interior stuff, no mappings
72  call setuse(alloc(locbc),maxsp,ispot,mkid,
73  2 ilo,ihi,jlo,jhi,iclo,ichi,jclo,jchi,kflag)
74  endif
75 
76 c for fine grids touching periodic boundary on right
77  if (xperdom .and. ilo .eq. 0 .and. ichi .eq. imax) then
78  kflag = 1 ! periodic in x
79  call setuse(alloc(locbc),maxsp,ispot,mkid,
80  2 ilo,ihi,jlo,jhi,iclo-iregsz(level),ichi-iregsz(level),
81  3 jclo,jchi,kflag)
82  endif
83 
84 c for fine grids touching periodic boundary on left
85  if (xperdom .and. iclo .eq. 0 .and. ihi .eq. imax) then
86  kflag = 1
87  call setuse(alloc(locbc),maxsp,ispot,mkid,
88  2 ilo,ihi,jlo,jhi,iclo+iregsz(level),ichi+iregsz(level),
89  3 jclo,jchi,kflag)
90  endif
91 
92 c for fine grids touching periodic boundary on top
93  if (yperdom .and. jlo .eq. 0 .and. jchi .eq. jmax) then
94  kflag = 1
95  call setuse(alloc(locbc),maxsp,ispot,mkid,
96  2 ilo,ihi,jlo,jhi,iclo,ichi,
97  3 jclo-jregsz(level),jchi-jregsz(level),kflag)
98  endif
99 
100 c for fine grids touching periodic boundary on bottom
101  if (yperdom .and. jclo .eq. 0 .and. jhi .eq. jmax) then
102  kflag = 1
103  call setuse(alloc(locbc),maxsp,ispot,mkid,
104  2 ilo,ihi,jlo,jhi,iclo,ichi,
105  3 jclo+jregsz(level),jchi+jregsz(level),kflag)
106  endif
107 
108 c for fine grids touching boundary on top in spherically mapped case
109 c and coarse grid touches top too. see if (mapped) x extent overlap.
110  if (spheredom .and. jhi .eq. jmax .and. jchi .eq. jmax) then
111  kflag = 2
112 c write(dbugunit,*)" for coarse grid ",mpar
113  iwrap2 = iregsz(level) - iclo - 1 !higher mapped index
114  iwrap1 = iregsz(level) - ichi - 1 !lower mapped index
115  if (max(ilo,iwrap1) .le. min(ihi,iwrap2)) then
116  call setuse(alloc(locbc),maxsp,ispot,mkid,
117  1 ilo,ihi,jlo,jhi,iclo,ichi,
118  2 jclo,jchi,kflag)
119  endif
120  endif
121 
122 c fine grids touching boundary on bottom for spherically mapped case
123 c coarse grid touches bottom too. see if (mapped) x extents overlap
124  if (spheredom .and. jclo .eq. 0 .and. jlo .eq. 0) then
125  kflag = 3
126  iwrap2 = iregsz(level) - iclo - 1 !higher mapped index
127  iwrap1 = iregsz(level) - ichi - 1 !lower mapped index
128  if (max(ilo,iwrap1) .le. min(ihi,iwrap2)) then
129  call setuse(alloc(locbc),maxsp,ispot,mkid,
130  1 ilo,ihi,jlo,jhi,iclo,ichi,
131  2 jclo,jchi,kflag)
132  endif
133  endif
134 
135  50 mkid = node(levelptr,mkid)
136  go to 40
137 c
138 c done with subgrid cycle. if no cells would need fixing, all done
139 c else cycle through again to set up list with info. for bc processing
140 c
141  60 continue
142 c
143 c for now, leave unused space allocated to the grid. alternative is to
144 c return (maxsp-ispot) amt starting at loc node(cfluxptr,mpar)+ispot.
145 c
146  mpar = node(levelptr,mpar)
147  go to 30
148 c
149  99 return
150  end
function igetsp(nwords)
Definition: igetsp.f:4
subroutine prepc(level, nvar)
Definition: prepc.f:4
subroutine setuse(listbc, maxsp, ispot, mkid, ilo, ihi, jlo, jhi, iclo, ichi, jclo, jchi, kflag)
Definition: setuse.f:4