2D AMRCLAW
setuse.f
Go to the documentation of this file.
1 c
58 
59 c ----------------------------------------------------------------
60 c
61  subroutine setuse(listbc,maxsp,ispot,mkid,
62  1 ilo, ihi, jlo, jhi,
63  2 iclo,ichi,jclo,jchi,kflag)
64 c
65 c :::::::::::::::::::::::: SETUSE ::::::::::::::::::::::::::::::::
66 c
67 c set up boundary list for coarse grid, to be used by fluxsv.
68 c loop around boundary of fine grids to do this. each entry has
69 c i, j, side #, fine grid #, loc in fine grid list for fluxes.
70 c for example, side 1 of fine grid fixes side 3 of coarse grid,
71 c so coarse grid list will store the # 3.
72 c wrt coarse grid, the sides are:
73 c 2
74 c 1 3 that is, right edge of a coarse cell = 3
75 c 4 top edge of a coarse cell = 2
76 c
77 c # lkid is the index into the fine grid's saved fluxes.
78 c # the fine grid will save all its fluxes all around its
79 c # perimeter. lkid tells where the coarse grid should
80 c # taking them from. (no ghost cells in this index, but
81 c # it is 1-based for indexing array, not - based for
82 c # integer index of grid location).
83 c
84 c changed 11/11/08: spheredom for periodically mapped spherical
85 c grids. could affect top and bottom if fine grid touches
86 c edge of domain in y direction. if calling with spheredom
87 c (and not yperdom) then grid is NOT periodically mapped.
88 c need kflag to indicate spherically mapped now - otherwise
89 c cant tell the difference, dont skip appropropriate loops
90 c
91 c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
92 c
93  use amr_module
94  implicit double precision (a-h,o-z)
95  dimension listbc(5,maxsp)
96 
97 
98  ibc = ispot
99  ist = iclo - 1
100  iend = ichi + 1
101  jst = jclo - 1
102  jend = jchi + 1
103 c
104 c left side (of fine grid, right side of coarse cell)
105 c
106  if (ist .lt. ilo .or. kflag .ne. 1) go to 20
107  lkid = max(jlo,jclo) - jclo + 1
108  do 10 j = max(jlo,jclo), min(jhi,jchi)
109  ispot = ispot + 1
110  listbc(1,ispot) = ist-ilo+nghost+1
111  listbc(2,ispot) = j-jlo+nghost+1
112  listbc(3,ispot) = 3
113  listbc(4,ispot) = mkid
114  listbc(5,ispot) = lkid
115  lkid = lkid + 1
116  10 continue
117 c
118 c top side (of fine grid, bottom of coarse cell)
119 c
120  20 if (kflag .eq. 1) then ! regular interior case
121  if (jend .gt. jhi) go to 40
122  lkid = (jchi-jclo+1) + max(ilo,iclo)-iclo + 1
123  do 30 i = max(ilo,iclo), min(ihi,ichi)
124  ispot = ispot + 1
125  listbc(1,ispot) = i-ilo+nghost+1
126  listbc(2,ispot) = jend-jlo+nghost+1
127  listbc(3,ispot) = 4
128  listbc(4,ispot) = mkid
129  listbc(5,ispot) = lkid
130 c write(outunit,595)ispot,(listbc(ipl,ispot),ipl=1,5)
131  595 format(" entry ",i5," has ", 5i5)
132  lkid = lkid + 1
133  30 continue
134  else if (kflag .eq. 2) then !spherical
135 c top side of a fine grid is also top side of a coarse cell due to mapping
136 c write(outunit,*)":fixing top cells with fine grid ",mkid
137 c original code was insanely complicated. look at all indices and decide.
138  level = node(nestlevel,mkid) - 1
139  lkid = (jchi-jclo+1)+ 1 ! starts here wrt fine grid. may not use on coarse grid
140  do 31 i = iclo, ichi
141  iwrap = iregsz(level) - i -1
142  if (iwrap .ge. ilo .and. iwrap .le. ihi) then
143  ispot = ispot + 1
144  listbc(1,ispot) = iwrap - ilo + nghost + 1
145  listbc(2,ispot) = jend - jlo + nghost ! note adjustment of j (one less)
146  listbc(3,ispot) = 5 ! affects TOP of mapped coarse cell in diff. way
147  listbc(4,ispot) = mkid
148  listbc(5,ispot) = lkid
149 c write(outunit,595)ispot,(listbc(ipl,ispot),ipl=1,5)
150  endif
151  lkid = lkid + 1 ! increment fine list loc even if not used
152  31 continue
153 
154  endif
155 c
156 c right side (of fine grid, left of coarse cell)
157 c (numbered from bottom to top, so not continuous in lkid numbering)
158 c
159  40 if (iend .gt. ihi .or. kflag .ne. 1) go to 60
160  lkid = (ichi-iclo+1)+(jchi-jclo+1)
161  . + max(jlo,jclo) - jclo + 1
162  do 50 j = max(jlo,jclo), min(jhi,jchi)
163  ispot = ispot + 1
164  listbc(1,ispot) = iend-ilo+nghost+1
165  listbc(2,ispot) = j-jlo+nghost+1
166  listbc(3,ispot) = 1
167  listbc(4,ispot) = mkid
168  listbc(5,ispot) = lkid
169  lkid = lkid + 1
170  50 continue
171 c
172 c bottom side (of fine grid, top of coarse cell, unless spheredom)
173 c (numbered left to right, so not continuous in lkid numbering)
174 c
175  60 if (kflag .eq. 1) then
176  if (jst .lt. jlo) go to 80
177  lkid = 2*(jchi-jclo+1)+(ichi-iclo+1) + max(ilo,iclo)-iclo + 1
178  do 70 i = max(ilo,iclo), min(ihi,ichi)
179  ispot = ispot + 1
180  listbc(1,ispot) = i-ilo+nghost+1
181  listbc(2,ispot) = jst-jlo+nghost+1
182  listbc(3,ispot) = 2
183  listbc(4,ispot) = mkid
184  listbc(5,ispot) = lkid
185  lkid = lkid + 1
186  70 continue
187  else ! spherical
188 c bottom side of fine grid affects bottom of coarse cell
189 c fine grids saves fluxes in usual way
190 c coarse grid only needs to change where to use them
191  if (kflag .ne. 3) go to 80
192 c write(outunit,*)":fixing bottom cells with fine grid ",mkid
193  level = node(nestlevel,mkid)-1
194  lkid = 2*(jchi-jclo+1) + (ichi-iclo+1) + 1
195  do 71 i = iclo, ichi
196  iwrap = iregsz(level) - i - 1
197  if (iwrap .ge. ilo .and. iwrap .le. ihi) then
198  ispot = ispot + 1
199  listbc(1,ispot) = iwrap - ilo + nghost + 1
200  listbc(2,ispot) = nghost+1 ! grid bottom is at zero index
201  listbc(3,ispot) = 6 ! affects BOTTOM of mapped coarse cell in diff. way
202  listbc(4,ispot) = mkid
203  listbc(5,ispot) = lkid
204 c write(outunit,595)ispot,(listbc(ipl,ispot),ipl=1,5)
205  endif
206  lkid = lkid + 1
207  71 continue
208 
209  endif
210 c
211  80 continue
212  return
213  end
integer, dimension(maxlv) iregsz
Definition: amr_module.f90:198
integer, dimension(nsize, maxgr) node
Definition: amr_module.f90:198
integer, parameter nestlevel
AMR level of the grid.
Definition: amr_module.f90:44
subroutine setuse(listbc, maxsp, ispot, mkid, ilo, ihi, jlo, jhi, iclo, ichi, jclo, jchi, kflag)
Add intersection information between grid mptr and a finer grid mkid to the boundary list...
Definition: setuse.f:64
integer nghost
Definition: amr_module.f90:232
The module contains the definition of a "node descriptor" as well as other global variables used duri...
Definition: amr_module.f90:21