2D AMRCLAW
Functions/Subroutines
setuse.f File Reference

Go to the source code of this file.

Functions/Subroutines

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, listbc, of grid mptr, to be used by fluxsv. More...
 

Function/Subroutine Documentation

◆ setuse()

subroutine setuse ( dimension(5,maxsp)  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, listbc, of grid mptr, to be used by fluxsv.

About listbc

listbc for grid mptr is a 5 by maxsp array and is saved at address point to by alloc(node(cfluxptr, mptr)). It stores information about interface between grid mptr and all grids one level finer if they intersect. These interfaces consist of multiple cell edges (or segments, whose length = cell size on grid mptr). Each column in listbc has five entries and stores information associated with one segment. A global index for all these segments is represented by ispot. The five entries for the $ ispot^{th}$ segment are explained as below:

  • listbc(1,ispot) stores LOCAL (RELATIVE to left boundary of grid mptr) i index of the cell on grid mptr that border this segment.
  • listbc(2,ispot) stores LOCAL (RELATIVE to left boundary of grid mptr) j index of the cell on grid mptr that border this segment.
  • listbc(3,ispot) stores side number, which indicates which side of this segment is a cell of grid mptr (coarse cell). If this segment is the left edge of a cell on grid mptr, this number is 1. The number increases (2, 3, 4) as it goes around a coarse cell clockwise (top edge, right edge, bottom edge).
  • listbc(4,ispot) stores grid number of the finer grid that borders this segment
  • listbc(5,ispot) stores the position of this segment with respect to the perimeter of this finer grid (grid listbc(4,ispot)). The fine grid will save all its fluxes all around its perimeter. This entry tells where the coarse grid should take them from. Note that number of fluxes saved here is equal to number of such segments (length = coarse cell size) needed to make up the perimeter.
Parameters
[in,out]listbcthe array that stores boundary information for grid mptr
[in]maxspmaximum number of segments lisbc can describe
[in,out]ispotglobal index of a segment among all segments that make up the interface between grid mptr and ANY finer grids
[in]mkidthe finer grid that may intersect with grid mptr
[in]iloglobal i index of left border of grid mptr
[in]ihiglobal i index of right border of grid mptr
[in]jloglobal j index of lower border of grid mptr
[in]jhiglobal j index of upper border of grid mptr
[in]icloglobal i index of left border of grid mkid, in level of grid mptr index space
[in]ichiglobal i index of right border of grid mptr, in level of grid mptr index space
[in]jcloglobal j index of lower border of grid mptr, in level of grid mptr index space
[in]jchiglobal j index of upper border of grid mptr, in level of grid mptr index space
[in]kflagindicate what type of domain is being used, regular cartesian or spherical domain

Definition at line 64 of file setuse.f.

References amr_module::iregsz, amr_module::nestlevel, amr_module::nghost, and amr_module::node.

Referenced by prepc().

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
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
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
Here is the caller graph for this function: