2D AMRCLAW
Functions/Subroutines
projec2.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine projec2 (level, numpro, rectflags, ilo, ihi, jlo, jhi, mbuff)
 This subroutine projects all level level+2 grids to a level level grid and flag the cells being projected as needing refine. More...
 

Function/Subroutine Documentation

◆ projec2()

subroutine projec2 (   level,
  numpro,
dimension(ilo-mbuff:ihi+mbuff,jlo-mbuff:jhi+mbuff)  rectflags,
  ilo,
  ihi,
  jlo,
  jhi,
  mbuff 
)

This subroutine projects all level level+2 grids to a level level grid and flag the cells being projected as needing refine.

In other words, the subroutine modify the flag array of the input grid if part of it is under any grid that is two levels finer.

This subroutine is to insure proper level nesting. For example, you just create new level 5 grids. Now you need to ensure that the new level 4 grids encompass the new level 5 grids. To do this, we project level 5 grids to level 3 grids, which means that all locations in level 3 where level 5 exists are flagged. In this example, level 3 is the level parameter on the arguments list of this subroutine. So this subroutine is actually used to ensure level+1 grids can encompasses level+2 grids.

However, note that these cells are flagged with badpro parameter defined in amr_module (not badpt as in flagregions() and flag2refine2()).

input:

  • level
  • flag array of the input grid (rectflags)

output:

  • numpro
  • flag array of the input grid (rectflags)
Parameters
levelAMR level of the grid which all fine subgrids are projected onto
numpronumber of additional flagged cells at level level (initialized to 0 in flglvl)
rectflagsarray to be flagged
iloglobal i index of the left border of the grid being projected to (being flagged)
ihiglobal i index of the right border of the grid being projected to (being flagged)
jloglobal j index of the lower border of the grid being projected to (being flagged)
jhiglobal i index of the upper border of the grid being projected to (being flagged)
mbuffwidth of the buffer zone

Definition at line 52 of file projec2.f.

References amr_module::badpro, amr_module::goodpt, amr_module::ibuff, amr_module::intratx, amr_module::intraty, amr_module::iregsz, amr_module::jregsz, amr_module::levelptr, amr_module::ndihi, amr_module::ndilo, amr_module::ndjhi, amr_module::ndjlo, amr_module::newstl, amr_module::node, amr_module::outunit, amr_module::pprint, setindices(), amr_module::spheredom, amr_module::xperdom, and amr_module::yperdom.

Referenced by bufnst2().

52 
53  use amr_module
54  implicit double precision (a-h,o-z)
55  dimension rectflags(ilo-mbuff:ihi+mbuff,jlo-mbuff:jhi+mbuff)
56  logical borderx, bordery
57  integer ist(3),iend(3),jst(3),jend(3),ishift(3),jshift(3)
58 
59  levpro = level + 2
60  lrat2x = intratx(level)*intratx(level+1)
61  lrat2y = intraty(level)*intraty(level+1)
62 
63 ! local variables:
64 ! mkid = grid doing the projecting
65  mkid = newstl(levpro)
66  10 if (mkid .eq. 0) go to 90
67  ikidlo = node(ndilo,mkid)
68  jkidlo = node(ndjlo,mkid)
69  ikidhi = node(ndihi,mkid)
70  jkidhi = node(ndjhi,mkid)
71 c
72 c project entire region of fine grids onto rectflag array if intersects
73 c possibly take care of buffering.
74 c adjust since grid descriptor (integer indices) is 0 based,
75 c do not projec the buffer region, only interior needs it
76 c since buffering will take care of rest (unless ibuff=0-see below)
77 c
78 c redo formulas using approach of nestck/baseCheck, simplified to 2 levels
79  istc = ikidlo/intratx(level+1) - 1 ! one level down
80  istc = istc/intratx(level) - 1 ! project to second level coords
81  jstc = jkidlo/intraty(level+1) - 1
82  jstc = jstc/intraty(level) - 1
83  iendc = ikidhi/intratx(level+1) + 1
84  iendc = iendc/intratx(level) + 1
85  jendc = jkidhi/intraty(level+1) + 1
86  jendc = jendc/intraty(level) + 1
87 
88 c if coarse grid not near edge of domain then periodicity wont affect it
89  borderx = (istc .le. 0 .or. iendc .ge. iregsz(level)-1) ! subtract 1 to get last cell index
90  bordery = (jstc .le. 0 .or. jendc .ge. jregsz(level)-1) ! since i/jregsz is num cells
91 
92 c
93 c take care of indices outside actual domain, in non-periodic case first
94  if (.not. (xperdom .and. borderx) .and.
95  . .not. (yperdom .and. bordery)) then
96  istc = max(istc,0)
97  jstc = max(jstc,0)
98  iendc = min(iendc,iregsz(level))
99  jendc = min(jendc,jregsz(level))
100 
101 c include mbuff in intersection test here since is ok in new alg. to project to buffer region
102  ixlo = max(istc, ilo-mbuff)
103  ixhi = min(iendc,ihi+mbuff)
104  jxlo = max(jstc, jlo-mbuff)
105  jxhi = min(jendc,jhi+mbuff)
106 
107 c test if coarsened grid mkid intersects with this grids rectflags
108  ! has not intersection
109  if (.not.((ixlo .le. ixhi) .and. (jxlo .le. jxhi))) go to 80
110 c
111  ! has intersection
112  do 60 j = jxlo, jxhi
113  do 60 i = ixlo, ixhi
114  if (rectflags(i,j) .eq. goodpt) then
115  rectflags(i,j) = badpro
116  numpro = numpro + 1
117  if (pprint) write(outunit,101) i,j,mkid
118  101 format(' pt.',2i5,' of grid ',i5,' projected' )
119  endif
120  60 continue
121  go to 80 ! done with projected this fine grid in non-periodic case
122  endif
123 
124 c
125 c periodic case. compute indics on coarsened level to find grids to project to
126  call setindices(ist,iend,jst,jend,iclo,ichi,jclo,jhci,
127  . ishift,jshift,level)
128 
129 c compare all regions of coarsened patch with one lbase grid at a time
130  do 25 i = 1, 3
131  i1 = max(istc, ist(i))
132  i2 = min(iendc, iend(i))
133  do 25 j = 1, 3
134  j1 = max(jstc, jst(j))
135  j2 = min(jendc, jend(j))
136 
137  if (.not. ((i1 .le. i2) .and. (j1 .le. j2))) go to 25
138 c
139 c patch (possibly periodically wrapped) not empty.
140 c see if intersects base grid. wrap coords for periodicity
141  i1 = i1 + ishift(i)
142  i2 = i2 + ishift(i)
143  j1 = j1 + jshift(j)
144  j2 = j2 + jshift(j)
145 
146  ixlo = max(i1,ilo-mbuff)
147  ixhi = min(i2,ihi+mbuff)
148  jxlo = max(j1,jlo-mbuff)
149  jxhi = min(j2,jhi+mbuff)
150 
151  if (.not.((ixlo.le.ixhi) .and. (jxlo.le.jxhi))) go to 25
152 
153  do jx = jxlo, jxhi
154  do ix = ixlo, ixhi
155 c project flagged point in intersected regions
156  if (rectflags(ix,jx) .eq. goodpt) then
157  rectflags(ix,jx) = badpro ! i,j already coarse grid indices
158  numpro = numpro + 1
159  if (pprint) write(outunit,101) ix,jx,mkid
160  endif
161  end do
162  end do
163 
164  25 continue
165  go to 80 ! down with simple periodic case
166 c
167 c repeat above procedure for wrapped area if nec. if ibuff > 0
168 c this will be caught in shiftset flagging
169 c DID NOT MODIFY THIS SPHEREDOM BLOCK WHEN FIXING OTHER BUGS. NEED TO LOOK AT IT
170  if (spheredom .and. ibuff .eq. 0) then
171  jstc = jkidlo/lrat2y
172  jendc = jkidhi/lrat2y
173  if (jstc .eq. 0) then
174  iwrap1 = iregsz(level) - iendc - 1
175  iwrap2 = iregsz(level) - istc - 1
176 c do 61 i = iwrap1+1, iwrap2+1
177  do 61 i = iwrap1, iwrap2 !changing this WITHOUT CHECKING, AS ABOVE. STILL NEED TO CHECK***
178  if (rectflags(i,1) .eq. goodpt) then
179  rectflags(i,1) = badpro ! only need to flag 1 wrapped buffer cell
180  numpro = numpro + 1
181  if (pprint) write(outunit,101) i,1,mkid
182  endif
183  61 continue
184 
185  endif
186  if (jendc .eq. jsize-1) then
187  iwrap1 = iregsz(level) - iendc - 1
188  iwrap2 = iregsz(level) - istc - 1
189 c do 62 i = iwrap1+1, iwrap2+1
190  do 62 i = iwrap1, iwrap2 !CHANGING W/O CHECKING
191  if (rectflags(i,jsize-1) .eq. goodpt) then
192  rectflags(i,jsize-1) = badpro ! only need to flag 1 wrapped buffer cell
193  numpro = numpro + 1
194  if (pprint) write(outunit,101) i,j,mkid
195  endif
196  62 continue
197  endif
198  endif
199 c
200 c done with gridpt. loop for grid mkid.
201 c
202  80 mkid = node(levelptr, mkid)
203  go to 10
204 c
205  90 if (pprint) then
206  write(outunit,102) numpro,level
207  102 format(i9,' more pts. projected to level ',i5)
208 
209  write(outunit,103) level
210  103 format(/,' from projec: flagged pts. (incl. buffer zone)',
211  & ' at level ',i4,':')
212 
213  do 110 j = jhi+mbuff, jlo-mbuff, -1
214  write(outunit,104)(int(rectflags(i,j)),i=ilo-mbuff,ihi+mbuff)
215 104 format(80i1)
216  110 continue
217  endif
218 c
219  99 return
real(kind=8), parameter badpro
Definition: amr_module.f90:166
integer, dimension(maxlv) iregsz
Definition: amr_module.f90:198
integer, dimension(maxlv) newstl
Definition: amr_module.f90:198
integer, parameter ndihi
global i index of right border of this grid
Definition: amr_module.f90:111
integer, dimension(maxlv) jregsz
Definition: amr_module.f90:198
integer, dimension(nsize, maxgr) node
Definition: amr_module.f90:198
real(kind=8), parameter goodpt
Definition: amr_module.f90:163
logical yperdom
Definition: amr_module.f90:230
integer, parameter ndilo
global i index of left border of this grid
Definition: amr_module.f90:108
integer, parameter ndjlo
global j index of lower border of this grid
Definition: amr_module.f90:114
logical spheredom
Definition: amr_module.f90:230
integer ibuff
Definition: amr_module.f90:198
integer, dimension(maxlv) intraty
Definition: amr_module.f90:198
integer, parameter outunit
Definition: amr_module.f90:290
subroutine setindices(ist, iend, jst, jend, ilo, ihi, jlo, jhi, ishift, jshift, level)
Definition: setIndices.f:6
integer, parameter ndjhi
global j index of upper border of this grid
Definition: amr_module.f90:117
logical pprint
Definition: amr_module.f90:297
logical xperdom
Definition: amr_module.f90:230
integer, dimension(maxlv) intratx
Definition: amr_module.f90:198
integer, parameter levelptr
node number (index) of next grid on the same level
Definition: amr_module.f90:35
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 call graph for this function:
Here is the caller graph for this function: