71 recursive subroutine filrecur(level,nvar,valbig,aux,naux,t,mitot,mjtot, &
72 nrowst,ncolst,ilo,ihi,jlo,jhi,patchOnly,msrc)
81 integer,
intent(in) :: level, nvar, naux, mitot, mjtot, nrowst, ncolst
82 integer,
intent(in) :: ilo,ihi,jlo,jhi, msrc
83 real(kind=8),
intent(in) :: t
87 real(kind=8),
intent(in out) :: valbig(nvar,mitot,mjtot)
88 real(kind=8),
intent(in out) :: aux(naux,mitot,mjtot)
91 integer :: i_fine, j_fine, i_coarse, j_coarse, n, k
92 integer :: iplo, iphi, jplo, jphi
93 integer :: mitot_patch, mjtot_patch, mitot_coarse, mjtot_coarse, nghost_patch, lencrse
94 integer :: refinement_ratio_x, refinement_ratio_y
95 integer :: unset_indices(4)
96 real(kind=8) :: dx_fine, dy_fine, dx_coarse, dy_coarse
97 real(kind=8) :: xlow_coarse,ylow_coarse, xlow_fine, ylow_fine, xhi_fine,yhi_fine
98 real(kind=8) :: xcent_fine, xcent_coarse, ycent_fine, ycent_coarse,ratiox,ratioy,floor
101 integer :: clock_start, clock_finish, clock_rate
102 real(kind=8) :: cpu_start, cpu_finish
105 real(kind=8) :: eta1, eta2, valp10, valm10, valc, valp01, valm01, dupc, dumc
106 real(kind=8) :: ducc, du, fu, dvpc, dvmc, dvcc, dv, fv, valint, uslope, vslope
110 integer(kind=1) :: flaguse(ihi-ilo+1, jhi-jlo+1)
126 real(kind=8) :: valcrse((ihi-ilo+3) * (jhi-jlo+3) * nvar)
127 real(kind=8) :: auxcrse((ihi-ilo+3) * (jhi-jlo+3) * naux)
131 mitot_patch = ihi-ilo + 1
132 mjtot_patch = jhi-jlo + 1
134 dx_fine = hxposs(level)
135 dy_fine = hyposs(level)
138 xlow_fine = xlower + ilo * dx_fine
139 ylow_fine = ylower + jlo * dy_fine
145 call intfil(valbig,mitot,mjtot,t,flaguse,nrowst,ncolst, ilo, &
146 ihi,jlo,jhi,level,nvar,naux,msrc)
158 call trimbd(flaguse,mitot_patch,mjtot_patch,set,unset_indices)
169 write(outunit,*)
" error in filrecur - level 1 not set" 170 write(outunit,
'("start at row: ",i4," col ",i4)') nrowst,ncolst
171 print *,
" error in filrecur - level 1 not set" 172 print *,
" should not need more recursion " 173 print *,
" to set patch boundaries" 174 print
'("start at row: ",i4," col ",i4)', nrowst,ncolst
180 dx_coarse = hxposs(level - 1)
181 dy_coarse = hyposs(level - 1)
185 unset_indices(1) = unset_indices(1) + ilo - 1
186 unset_indices(2) = unset_indices(2) + ilo - 1
187 unset_indices(3) = unset_indices(3) + jlo - 1
188 unset_indices(4) = unset_indices(4) + jlo - 1
191 refinement_ratio_x =
intratx(level - 1)
192 refinement_ratio_y =
intraty(level - 1)
205 iplo = (unset_indices(1) - refinement_ratio_x + nghost * refinement_ratio_x) &
206 / refinement_ratio_x - nghost
207 iphi = (unset_indices(2) + refinement_ratio_x) / refinement_ratio_x
208 jplo = (unset_indices(3) - refinement_ratio_y + nghost * refinement_ratio_y) &
209 / refinement_ratio_y - nghost
210 jphi = (unset_indices(4) + refinement_ratio_y) / refinement_ratio_y
212 xlow_coarse = xlower + iplo * dx_coarse
213 ylow_coarse = ylower + jplo * dy_coarse
216 mitot_coarse = iphi - iplo + 1
217 mjtot_coarse = jphi - jplo + 1
220 if (mitot_coarse > ihi - ilo + 3 .or. &
221 mjtot_coarse > jhi - jlo + 3)
then 223 print *,
" did not make big enough work space in filrecur " 224 print *,
" need coarse space with mitot_coarse,mjtot_coarse ",mitot_coarse,mjtot_coarse
225 print *,
" made space for ilo,ihi,jlo,jhi ",ilo,ihi,jlo,jhi
234 lencrse = (ihi-ilo+3)*(jhi-jlo+3)*naux
235 do k = 1, lencrse, naux
238 call setaux(nghost_patch, mitot_coarse,mjtot_coarse, &
239 xlow_coarse, ylow_coarse, &
240 dx_coarse,dy_coarse,naux,auxcrse)
246 if ((xperdom .or. (yperdom .or. spheredom)) .and.
sticksout(iplo,iphi,jplo,jphi))
then 247 call prefilrecur(level-1,nvar,valcrse,auxcrse,naux,t,mitot_coarse,mjtot_coarse,1,1, &
248 iplo,iphi,jplo,jphi,iplo,iphi,jplo,jphi,.true.)
250 call filrecur(level-1,nvar,valcrse,auxcrse,naux,t,mitot_coarse,mjtot_coarse,1,1, &
251 iplo,iphi,jplo,jphi,.true.,-1)
255 ratiox =
real(refinement_ratio_x,kind=8)
256 ratioy =
real(refinement_ratio_y,kind=8)
260 do j_fine = 1,mjtot_patch
268 j_coarse =floor((j_fine+jlo-1)/ratioy) - jplo + 1
269 ycent_coarse = ylow_coarse + (j_coarse-.5d0)*dy_coarse
270 ycent_fine = ylower + (j_fine-1+jlo + .5d0)*dy_fine
271 eta2 = (ycent_fine-ycent_coarse)/dy_coarse
272 if (abs(eta2) .gt. .5)
then 273 write(*,*)
" filpatch y indices wrong: eta2 = ",eta2
276 do i_fine = 1,mitot_patch
283 i_coarse = floor((i_fine+ilo-1)/ratiox) - iplo + 1
284 xcent_coarse = xlow_coarse + (i_coarse-.5d0)*dx_coarse
285 xcent_fine = xlower + (i_fine-1+ilo + .5d0)*dx_fine
286 eta1 = (xcent_fine-xcent_coarse)/dx_coarse
287 if (abs(eta1) .gt. .5)
then 288 write(*,*)
" filpatch x indices wrong: eta1 = ",eta1
292 if (flaguse(i_fine,j_fine) == 0)
then 300 valp01 = valcrse(
coarse_index(n,i_coarse ,j_coarse + 1))
301 valm01 = valcrse(
coarse_index(n,i_coarse ,j_coarse - 1))
305 ducc = valp10 - valm10
306 du = min(abs(dupc), abs(dumc))
307 du = min(2.d0 * du, 0.5d0 * abs(ducc))
308 fu = max(0.d0, sign(1.d0, dupc * dumc))
309 uslope = du*sign(1.d0,ducc)*fu
313 dvcc = valp01 - valm01
314 dv = min(abs(dvpc), abs(dvmc))
315 dv = min(2.d0 * dv, 0.5d0 * abs(dvcc))
316 fv = max(0.d0,sign(1.d0, dvpc * dvmc))
317 vslope = dv*sign(1.d0,dvcc)*fv
319 valint = valc + eta1 * uslope + eta2 * vslope
321 valbig(n,i_fine+nrowst-1,j_fine+ncolst-1) = valint
331 xhi_fine = xlower + (ihi + 1) * dx_fine
332 yhi_fine = ylower + (jhi + 1) * dy_fine
336 call bc2amr(valbig,aux,mitot,mjtot,nvar,naux,dx_fine,dy_fine,level,t, &
337 xlow_fine,xhi_fine,ylow_fine,yhi_fine)
344 integer,
intent(in) :: n, i, j
348 logical pure function sticksout(iplo,iphi,jplo,jphi)
350 integer,
intent(in) :: iplo,iphi,jplo,jphi
351 sticksout = (iplo < 0 .or. jplo < 0 .or. &
352 iphi >=
iregsz(level - 1) .or. jphi >=
jregsz(level - 1))
subroutine bc2amr(val, aux, nrow, ncol, meqn, naux,
Take a grid patch with mesh widths hx,hy, of dimensions nrow by ncol, and set the values of any piece...
logical pure function sticksout(iplo, iphi, jplo, jphi)
recursive subroutine prefilrecur(level, nvar, valbig, auxbig, naux, time, mitot, mjtot, nrowst, ncolst, ilo, ihi, jlo, jhi, iglo, ighi, jglo, jghi, patchOnly)
For periodic boundary conditions more work needed to fill the piece of the boundary.
subroutine trimbd(used, nrow, ncol, set, unset_rect)
Examine the setting status of a patch.
integer, dimension(maxlv) iregsz
real(kind=8), dimension(maxlv) hyposs
real(kind=8), dimension(maxlv) hxposs
integer, dimension(maxlv) jregsz
subroutine intfil(val, mi, mj, time, flaguse, nrowst, ncolst, ilo, ihi, jlo, jhi, level, nvar, naux, msrc)
Fill values for a patch at the specified level and location, using values from grids at level level O...
real(kind=8), parameter needs_to_be_set
recursive subroutine filrecur(level, nvar, valbig, aux, naux, t, mitot, mjtot, nrowst, ncolst, ilo, ihi, jlo, jhi, patchOnly, msrc)
Fill a region (patch) described by:
integer, dimension(maxlv) intraty
integer, parameter outunit
integer, dimension(maxlv) intratx
The module contains the definition of a "node descriptor" as well as other global variables used duri...
subroutine setaux(mbc, mx, my, xlower, ylower, dx, dy, maux, aux)
integer pure function coarse_index(n, i, j)