15 recursive subroutine filrecur(level,nvar,valbig,aux,naux,t,mx,my, &
16 nrowst,ncolst,ilo,ihi,jlo,jhi)
23 use amr_module, only: timesetaux, timesetauxcpu
28 integer,
intent(in) :: level, nvar, naux, mx, my, nrowst, ncolst
29 integer,
intent(in) :: ilo,ihi,jlo,jhi
31 real(kind=8),
intent(in) :: t
34 real(kind=8),
intent(in out) :: valbig(nvar,mx,my)
35 real(kind=8),
intent(in out) :: aux(naux,mx,my)
38 integer :: i_fine, j_fine, i_coarse, j_coarse, n, k
39 integer :: iplo, iphi, jplo, jphi
40 integer :: mx_patch, my_patch, mx_coarse, my_coarse, nghost_patch, lencrse
41 integer :: refinement_ratio_x, refinement_ratio_y
42 integer :: unset_indices(4)
43 real(kind=8) :: dx_fine, dy_fine, dx_coarse, dy_coarse
44 real(kind=8) :: xlow_coarse,ylow_coarse, xlow_fine, ylow_fine, xhi_fine,yhi_fine
47 integer :: clock_start, clock_finish, clock_rate
48 real(kind=8) :: cpu_start, cpu_finish
51 real(kind=8) :: eta1, eta2, valp10, valm10, valc, valp01, valm01, dupc, dumc
52 real(kind=8) :: ducc, du, fu, dvpc, dvmc, dvcc, dv, fv, valint
56 integer(kind=1) :: flaguse(ihi-ilo+1, jhi-jlo+1)
78 real(kind=8) :: valcrse((ihi-ilo+3) * (jhi-jlo+3) * nvar)
79 real(kind=8) :: auxcrse((ihi-ilo+3) * (jhi-jlo+3) * naux)
84 mx_patch = ihi-ilo + 1
85 my_patch = jhi-jlo + 1
87 dx_fine = hxposs(level)
88 dy_fine = hyposs(level)
95 xlow_fine = xlower + ilo * dx_fine
96 ylow_fine = ylower + jlo * dy_fine
102 call intfil(valbig,mx,my,t,flaguse,nrowst,ncolst, ilo, &
103 ihi,jlo,jhi,level,nvar,naux)
114 call trimbd(flaguse,mx_patch,my_patch,set,unset_indices)
124 write(outunit,*)
" error in filrecur - level 1 not set" 125 write(outunit,
'("start at row: ",i4," col ",i4)') nrowst,ncolst
126 print *,
" error in filrecur - level 1 not set" 127 print *,
" should not need more recursion " 128 print *,
" to set patch boundaries" 129 print
'("start at row: ",i4," col ",i4)', nrowst,ncolst
135 dx_coarse = hxposs(level - 1)
136 dy_coarse = hyposs(level - 1)
140 unset_indices(1) = unset_indices(1) + ilo - 1
141 unset_indices(2) = unset_indices(2) + ilo - 1
142 unset_indices(3) = unset_indices(3) + jlo - 1
143 unset_indices(4) = unset_indices(4) + jlo - 1
146 refinement_ratio_x = intratx(level - 1)
147 refinement_ratio_y = intraty(level - 1)
152 iplo = (unset_indices(1) - refinement_ratio_x + nghost * refinement_ratio_x) &
153 / refinement_ratio_x - nghost
154 iphi = (unset_indices(2) + refinement_ratio_x) / refinement_ratio_x
155 jplo = (unset_indices(3) - refinement_ratio_y + nghost * refinement_ratio_y) &
156 / refinement_ratio_y - nghost
157 jphi = (unset_indices(4) + refinement_ratio_y) / refinement_ratio_y
159 xlow_coarse = xlower + iplo * dx_coarse
160 ylow_coarse = ylower + jplo * dy_coarse
163 mx_coarse = iphi - iplo + 1
164 my_coarse = jphi - jplo + 1
167 if (mx_coarse > ihi - ilo + 3 .or. &
168 my_coarse > jhi - jlo + 3)
then 170 print *,
" did not make big enough work space in filrecur " 171 print *,
" need coarse space with mx_coarse,my_coarse ",mx_coarse,my_coarse
172 print *,
" made space for ilo,ihi,jlo,jhi ",ilo,ihi,jlo,jhi
181 lencrse = (ihi-ilo+3)*(jhi-jlo+3)*naux
182 do k = 1, lencrse, naux
183 auxcrse(k) = needs_to_be_set
185 call system_clock(clock_start, clock_rate)
186 call cpu_time(cpu_start)
187 call setaux(nghost_patch, mx_coarse,my_coarse, &
188 xlow_coarse, ylow_coarse, &
189 dx_coarse,dy_coarse,naux,auxcrse)
190 call system_clock(clock_finish, clock_rate)
191 call cpu_time(cpu_finish)
192 timesetaux = timesetaux + clock_finish - clock_start
193 timesetauxcpu = timesetaux + cpu_finish - cpu_start
197 if ((xperdom .or. (yperdom .or. spheredom)) .and.
sticksout(iplo,iphi,jplo,jphi))
then 198 call prefilrecur(level-1,nvar,valcrse,auxcrse,naux,t,mx_coarse,my_coarse,1,1,iplo,iphi,jplo,jphi)
200 call filrecur(level-1,nvar,valcrse,auxcrse,naux,t,mx_coarse,my_coarse,1,1,iplo,iphi,jplo,jphi)
203 do i_fine = 1,mx_patch
204 i_coarse = 2 + (i_fine - (unset_indices(1) - ilo) - 1) / refinement_ratio_x
205 eta1 = (-0.5d0 +
real(mod(i_fine - 1, refinement_ratio_x),kind=8)) &
206 / real(refinement_ratio_x,kind=8)
208 do j_fine = 1,my_patch
209 j_coarse = 2 + (j_fine - (unset_indices(3) - jlo) - 1) / refinement_ratio_y
210 eta2 = (-0.5d0 +
real(mod(j_fine - 1, refinement_ratio_y),kind=8)) &
211 / real(refinement_ratio_y,kind=8)
213 if (flaguse(i_fine,j_fine) == 0)
then 220 valp01 = valcrse(
coarse_index(n,i_coarse ,j_coarse + 1))
221 valm01 = valcrse(
coarse_index(n,i_coarse ,j_coarse - 1))
225 ducc = valp10 - valm10
226 du = min(abs(dupc), abs(dumc))
227 du = min(2.d0 * du, 0.5d0 * abs(ducc))
228 fu = max(0.d0, sign(1.d0, dupc * dumc))
232 dvcc = valp01 - valm01
233 dv = min(abs(dvpc), abs(dvmc))
234 dv = min(2.d0 * dv, 0.5d0 * abs(dvcc))
235 fv = max(0.d0,sign(1.d0, dvpc * dvmc))
237 valint = valc + eta1 * du * sign(1.d0, ducc) * fu &
238 + eta2 * dv * sign(1.d0, dvcc) * fv
241 valbig(n,i_fine+nrowst-1,j_fine+ncolst-1) = valint
252 xhi_fine = xlower + (ihi + 1) * dx_fine
253 yhi_fine = ylower + (jhi + 1) * dy_fine
254 call bc2amr(valbig,aux,mx,my,nvar,naux,dx_fine,dy_fine,level,t,xlow_fine,xhi_fine, &
255 ylow_fine,yhi_fine,xlower,ylower,xupper,yupper,xperdom,yperdom,spheredom)
261 integer,
intent(in) :: n, i, j
265 logical pure function sticksout(iplo,iphi,jplo,jphi)
267 integer,
intent(in) :: iplo,iphi,jplo,jphi
268 sticksout = (iplo < 0 .or. jplo < 0 .or. &
269 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)