13 public :: a3_bc_dirichlet_zero
14 public :: a3_bc_neumann_zero
15 public :: a3_bc_continuous
16 public :: a3_gc_interp
17 public :: a3_gc_prolong_copy
18 public :: a3_gc_interp_lim
20 public :: a3_gc2_prolong_linear
21 public :: a3_bc2_neumann_zero
22 public :: a3_bc2_dirichlet_zero
27 module procedure a3_gc_tree_iv, a3_gc_tree_ivs
28 end interface a3_gc_tree
31 module procedure a3_gc_ids_iv, a3_gc_ids_ivs, a3_gc_ids_v1
32 end interface a3_gc_ids
35 module procedure a3_gc_box_iv, a3_gc_box_ivs, a3_gc_box_v1
42 subroutine a3_gc_tree_ivs(tree, ivs, subr_rb, subr_bc, corners, leaves_only)
43 type(
a3_t),
intent(inout) :: tree
44 integer,
intent(in) :: ivs(:)
47 logical,
intent(in),
optional :: corners
48 logical,
intent(in),
optional :: leaves_only
52 if (.not. tree%ready) error stop
"a3_gc_tree: tree not ready" 54 if (
present(leaves_only)) all_ids = .not. leaves_only
57 do lvl = lbound(tree%lvls, 1), tree%highest_lvl
58 call a3_gc_ids(tree, tree%lvls(lvl)%ids, ivs, &
59 subr_rb, subr_bc, corners)
62 do lvl = lbound(tree%lvls, 1), tree%highest_lvl
63 call a3_gc_ids(tree, tree%lvls(lvl)%leaves, ivs, &
64 subr_rb, subr_bc, corners)
67 end subroutine a3_gc_tree_ivs
71 subroutine a3_gc_tree_iv(tree, iv, subr_rb, subr_bc, corners, leaves_only)
72 type(
a3_t),
intent(inout) :: tree
73 integer,
intent(in) :: iv
76 logical,
intent(in),
optional :: corners
77 logical,
intent(in),
optional :: leaves_only
81 if (.not. tree%ready) error stop
"a3_gc_tree: tree not ready" 83 if (
present(leaves_only)) all_ids = .not. leaves_only
86 do lvl = lbound(tree%lvls, 1), tree%highest_lvl
87 call a3_gc_ids(tree, tree%lvls(lvl)%ids, iv, &
88 subr_rb, subr_bc, corners)
91 do lvl = lbound(tree%lvls, 1), tree%highest_lvl
92 call a3_gc_ids(tree, tree%lvls(lvl)%leaves, iv, &
93 subr_rb, subr_bc, corners)
96 end subroutine a3_gc_tree_iv
101 subroutine a3_gc_ids_ivs(tree, ids, ivs, subr_rb, subr_bc, corners)
102 type(
a3_t),
intent(inout) :: tree
103 integer,
intent(in) :: ids(:)
104 integer,
intent(in) :: ivs(:)
107 logical,
intent(in),
optional :: corners
112 call a3_gc_box(tree, ids(i), ivs, subr_rb, subr_bc, corners)
115 end subroutine a3_gc_ids_ivs
120 subroutine a3_gc_ids_iv(tree, ids, iv, subr_rb, subr_bc, corners)
121 type(
a3_t),
intent(inout) :: tree
122 integer,
intent(in) :: ids(:)
123 integer,
intent(in) :: iv
126 logical,
intent(in),
optional :: corners
131 call a3_gc_box(tree, ids(i), iv, subr_rb, subr_bc, corners)
134 end subroutine a3_gc_ids_iv
139 subroutine a3_gc_ids_v1(boxes, ids, iv, subr_rb, subr_bc, corners)
140 type(
box3_t),
intent(inout) :: boxes(:)
141 integer,
intent(in) :: ids(:)
142 integer,
intent(in) :: iv
145 logical,
intent(in),
optional :: corners
150 call a3_gc_box(boxes, ids(i), iv, subr_rb, subr_bc, corners)
153 end subroutine a3_gc_ids_v1
156 subroutine a3_gc_box_ivs(tree, id, ivs, subr_rb, subr_bc, corners)
157 type(
a3_t),
intent(inout) :: tree
158 integer,
intent(in) :: id
159 integer,
intent(in) :: ivs(:)
162 logical,
intent(in),
optional :: corners
163 logical :: do_corners
169 if (
present(corners)) do_corners = corners
174 if (
present(subr_rb))
then 176 else if (tree%has_cc_method(iv))
then 177 use_rb => tree%cc_methods(iv)%rb
179 error stop
"a3_gc_box: no refinement boundary method stored" 182 if (
present(subr_bc))
then 184 else if (tree%has_cc_method(iv))
then 185 use_bc => tree%cc_methods(iv)%bc
187 error stop
"a3_gc_box: no boundary condition stored" 190 call a3_gc_box_sides(tree%boxes, id, iv, use_rb, use_bc)
191 if (do_corners)
call a3_gc_box_corner(tree%boxes, id, iv)
193 end subroutine a3_gc_box_ivs
196 subroutine a3_gc_box_iv(tree, id, iv, subr_rb, subr_bc, corners)
197 type(
a3_t),
intent(inout) :: tree
198 integer,
intent(in) :: id
199 integer,
intent(in) :: iv
202 logical,
intent(in),
optional :: corners
203 logical :: do_corners
207 if (
present(subr_rb))
then 209 else if (tree%has_cc_method(iv))
then 210 use_rb => tree%cc_methods(iv)%rb
212 error stop
"a3_gc_box: no refinement boundary method stored" 215 if (
present(subr_bc))
then 217 else if (tree%has_cc_method(iv))
then 218 use_bc => tree%cc_methods(iv)%bc
220 error stop
"a3_gc_box: no boundary condition stored" 224 if (
present(corners)) do_corners = corners
226 call a3_gc_box_sides(tree%boxes, id, iv, use_rb, use_bc)
227 if (do_corners)
call a3_gc_box_corner(tree%boxes, id, iv)
228 end subroutine a3_gc_box_iv
231 subroutine a3_gc_box_v1(boxes, id, iv, subr_rb, subr_bc, corners)
232 type(
box3_t),
intent(inout) :: boxes(:)
233 integer,
intent(in) :: id
234 integer,
intent(in) :: iv
237 logical,
intent(in),
optional :: corners
238 logical :: do_corners
241 if (
present(corners)) do_corners = corners
243 call a3_gc_box_sides(boxes, id, iv, subr_rb, subr_bc)
244 if (do_corners)
call a3_gc_box_corner(boxes, id, iv)
245 end subroutine a3_gc_box_v1
249 subroutine a3_gc_box_sides(boxes, id, iv, subr_rb, subr_bc)
250 type(
box3_t),
intent(inout) :: boxes(:)
251 integer,
intent(in) :: id
252 integer,
intent(in) :: iv
255 integer :: nb, nb_id, bc_type
256 integer :: nb_dim, lo(3), hi(3), dnb(3)
258 do nb = 1, a3_num_neighbors
259 nb_id = boxes(id)%neighbors(nb)
261 if (nb_id > af_no_box)
then 263 nb_dim = a3_neighb_dim(nb)
265 hi(:) = boxes(id)%n_cell
266 lo(nb_dim) = a3_neighb_high_01(nb) * (boxes(id)%n_cell + 1)
267 hi(nb_dim) = lo(nb_dim)
268 dnb = a3_neighb_offset([nb])
269 call copy_from_nb(boxes(id), boxes(nb_id), dnb, lo, hi, iv)
270 else if (nb_id == af_no_box)
then 272 call subr_rb(boxes, id, nb, iv)
275 call subr_bc(boxes(id), nb, iv, bc_type)
276 call bc_to_gc(boxes(id), nb, iv, bc_type)
280 end subroutine a3_gc_box_sides
285 subroutine a3_gc_box_corner(boxes, id, iv)
286 type(
box3_t),
intent(inout) :: boxes(:)
287 integer,
intent(in) :: id
288 integer,
intent(in) :: iv
289 integer :: n, nb_id, dnb(3), lo(3)
290 integer :: hi(3), dim
293 do n = 1, a3_num_edges
297 nb_id = boxes(id)%neighbor_mat(a3_edge_dir(1, n), &
298 a3_edge_dir(2, n), a3_edge_dir(3, n))
300 lo = a3_edge_min_ix(:, n) * (boxes(id)%n_cell + 1)
303 if (nb_id > af_no_box)
then 305 hi(dim) = boxes(id)%n_cell
306 dnb = a3_neighb_offset(a3_nb_adj_edge(:, n))
307 call copy_from_nb(boxes(id), boxes(nb_id), dnb, lo, hi, iv)
309 call a3_edge_gc_extrap(boxes(id), lo, dim, iv)
313 do n = 1, a3_num_children
315 dnb = 2 * a3_child_dix(:, n) - 1
316 nb_id = boxes(id)%neighbor_mat(dnb(1), dnb(2), dnb(3))
317 lo = a3_child_dix(:, n) * (boxes(id)%n_cell + 1)
319 if (nb_id > af_no_box)
then 320 call copy_from_nb(boxes(id), boxes(nb_id), dnb, lo, lo, iv)
322 call a3_corner_gc_extrap(boxes(id), lo, iv)
325 end subroutine a3_gc_box_corner
327 subroutine bc_to_gc(box, nb, iv, bc_type)
328 type(
box3_t),
intent(inout) :: box
329 integer,
intent(in) :: iv
330 integer,
intent(in) :: nb
331 integer,
intent(in) :: bc_type
332 real(dp) :: c0, c1, c2
345 select case (bc_type)
346 case (af_bc_dirichlet)
351 c0 = box%dr * a3_neighb_high_pm(nb)
354 case (af_bc_continuous)
359 stop
"fill_bc: unknown boundary condition" 363 case (a3_neighb_lowx)
364 box%cc(0, 1:nc, 1:nc, iv) = &
365 c0 * box%cc(0, 1:nc, 1:nc, iv) + &
366 c1 * box%cc(1, 1:nc, 1:nc, iv) + &
367 c2 * box%cc(2, 1:nc, 1:nc, iv)
368 case (a3_neighb_highx)
369 box%cc(nc+1, 1:nc, 1:nc, iv) = &
370 c0 * box%cc(nc+1, 1:nc, 1:nc, iv) + &
371 c1 * box%cc(nc, 1:nc, 1:nc, iv) + &
372 c2 * box%cc(nc-1, 1:nc, 1:nc, iv)
373 case (a3_neighb_lowy)
374 box%cc(1:nc, 0, 1:nc, iv) = &
375 c0 * box%cc(1:nc, 0, 1:nc, iv) + &
376 c1 * box%cc(1:nc, 1, 1:nc, iv) + &
377 c2 * box%cc(1:nc, 2, 1:nc, iv)
378 case (a3_neighb_highy)
379 box%cc(1:nc, nc+1, 1:nc, iv) = &
380 c0 * box%cc(1:nc, nc+1, 1:nc, iv) + &
381 c1 * box%cc(1:nc, nc, 1:nc, iv) + &
382 c2 * box%cc(1:nc, nc-1, 1:nc, iv)
383 case (a3_neighb_lowz)
384 box%cc(1:nc, 1:nc, 0, iv) = &
385 c0 * box%cc(1:nc, 1:nc, 0, iv) + &
386 c1 * box%cc(1:nc, 1:nc, 1, iv) + &
387 c2 * box%cc(1:nc, 1:nc, 2, iv)
388 case (a3_neighb_highz)
389 box%cc(1:nc, 1:nc, nc+1, iv) = &
390 c0 * box%cc(1:nc, 1:nc, nc+1, iv) + &
391 c1 * box%cc(1:nc, 1:nc, nc, iv) + &
392 c2 * box%cc(1:nc, 1:nc, nc-1, iv)
394 end subroutine bc_to_gc
397 subroutine a3_gc_prolong_copy(boxes, id, nb, iv)
399 type(
box3_t),
intent(inout) :: boxes(:)
400 integer,
intent(in) :: id
401 integer,
intent(in) :: iv
402 integer,
intent(in) :: nb
403 integer :: p_id, nb_dim, lo(3), hi(3)
405 p_id = boxes(id)%parent
406 nb_dim = a3_neighb_dim(nb)
408 hi(:) = boxes(id)%n_cell
409 lo(nb_dim) = a3_neighb_high_01(nb) * (boxes(id)%n_cell+1)
410 hi(nb_dim) = a3_neighb_high_01(nb) * (boxes(id)%n_cell+1)
412 call a3_prolong_copy(boxes(p_id), boxes(id), iv, low=lo, high=hi)
413 end subroutine a3_gc_prolong_copy
417 subroutine a3_gc_interp(boxes, id, nb, iv)
419 integer,
intent(in) :: id
420 integer,
intent(in) :: nb
421 integer,
intent(in) :: iv
422 integer :: nc, ix, ix_c, ix_f, i, j
423 integer :: i_c1, i_c2, j_c1, j_c2, p_nb_id
424 integer :: p_id, ix_offset(3)
425 real(dp),
parameter :: sixth=1/6.0_dp, third=1/3.0_dp
426 integer :: k_c1, k_c2, k
428 nc = boxes(id)%n_cell
429 p_id = boxes(id)%parent
430 p_nb_id = boxes(p_id)%neighbors(nb)
431 ix_offset = a3_get_child_offset(boxes(id), nb)
433 if (a3_neighb_low(nb))
then 443 select case (a3_neighb_dim(nb))
446 k_c1 = ix_offset(3) + ishft(k+1, -1)
447 k_c2 = k_c1 + 1 - 2 * iand(k, 1)
449 j_c1 = ix_offset(2) + ishft(j+1, -1)
450 j_c2 = j_c1 + 1 - 2 * iand(j, 1)
451 boxes(id)%cc(ix, j, k, iv) = &
452 third * boxes(p_nb_id)%cc(ix_c, j_c1, k_c1, iv) + &
453 sixth * boxes(p_nb_id)%cc(ix_c, j_c2, k_c1, iv) + &
454 sixth * boxes(p_nb_id)%cc(ix_c, j_c1, k_c2, iv) + &
455 third * boxes(id)%cc(ix_f, j, k, iv)
460 k_c1 = ix_offset(3) + ishft(k+1, -1)
461 k_c2 = k_c1 + 1 - 2 * iand(k, 1)
463 i_c1 = ix_offset(1) + ishft(i+1, -1)
464 i_c2 = i_c1 + 1 - 2 * iand(i, 1)
465 boxes(id)%cc(i, ix, k, iv) = &
466 third * boxes(p_nb_id)%cc(i_c1, ix_c, k_c1, iv) + &
467 sixth * boxes(p_nb_id)%cc(i_c2, ix_c, k_c1, iv) + &
468 sixth * boxes(p_nb_id)%cc(i_c1, ix_c, k_c2, iv) + &
469 third * boxes(id)%cc(i, ix_f, k, iv)
474 j_c1 = ix_offset(2) + ishft(j+1, -1)
475 j_c2 = j_c1 + 1 - 2 * iand(j, 1)
477 i_c1 = ix_offset(1) + ishft(i+1, -1)
478 i_c2 = i_c1 + 1 - 2 * iand(i, 1)
479 boxes(id)%cc(i, j, ix, iv) = &
480 third * boxes(p_nb_id)%cc(i_c1, j_c1, ix_c, iv) + &
481 sixth * boxes(p_nb_id)%cc(i_c1, j_c2, ix_c, iv) + &
482 sixth * boxes(p_nb_id)%cc(i_c2, j_c1, ix_c, iv) + &
483 third * boxes(id)%cc(i, j, ix_f, iv)
488 end subroutine a3_gc_interp
493 subroutine a3_gc_interp_lim(boxes, id, nb, iv)
495 integer,
intent(in) :: id
496 integer,
intent(in) :: nb
497 integer,
intent(in) :: iv
498 integer :: nc, ix, ix_c, ix_f, i, j
499 integer :: i_c1, i_c2, j_c1, j_c2, p_nb_id
500 integer :: p_id, ix_offset(3)
502 real(dp),
parameter :: sixth=1/6.0_dp, third=1/3.0_dp
503 integer :: k_c1, k_c2, k
506 nc = boxes(id)%n_cell
507 p_id = boxes(id)%parent
508 p_nb_id = boxes(p_id)%neighbors(nb)
509 ix_offset = a3_get_child_offset(boxes(id), nb)
511 if (a3_neighb_low(nb))
then 521 select case (a3_neighb_dim(nb))
524 k_c1 = ix_offset(3) + ishft(k+1, -1)
525 k_c2 = k_c1 + 1 - 2 * iand(k, 1)
527 j_c1 = ix_offset(2) + ishft(j+1, -1)
528 j_c2 = j_c1 + 1 - 2 * iand(j, 1)
529 c1 = boxes(p_nb_id)%cc(ix_c, j_c1, k_c1, iv)
530 c2 = boxes(p_nb_id)%cc(ix_c, j_c2, k_c1, iv)
531 c3 = boxes(p_nb_id)%cc(ix_c, j_c1, k_c2, iv)
532 boxes(id)%cc(ix, j, k, iv) = third * c1 + sixth * c2 + &
533 sixth * c3 + third * boxes(id)%cc(ix_f, j, k, iv)
534 if (boxes(id)%cc(ix, j, k, iv) > 2 * c1) &
535 boxes(id)%cc(ix, j, k, iv) = 2 * c1
540 k_c1 = ix_offset(3) + ishft(k+1, -1)
541 k_c2 = k_c1 + 1 - 2 * iand(k, 1)
543 i_c1 = ix_offset(1) + ishft(i+1, -1)
544 i_c2 = i_c1 + 1 - 2 * iand(i, 1)
545 c1 = boxes(p_nb_id)%cc(i_c1, ix_c, k_c1, iv)
546 c2 = boxes(p_nb_id)%cc(i_c2, ix_c, k_c1, iv)
547 c3 = boxes(p_nb_id)%cc(i_c1, ix_c, k_c2, iv)
548 boxes(id)%cc(i, ix, k, iv) = third * c1 + sixth * c2 + &
549 sixth * c3 + third * boxes(id)%cc(i, ix_f, k, iv)
550 if (boxes(id)%cc(i, ix, k, iv) > 2 * c1) &
551 boxes(id)%cc(i, ix, k, iv) = 2 * c1
556 j_c1 = ix_offset(2) + ishft(j+1, -1)
557 j_c2 = j_c1 + 1 - 2 * iand(j, 1)
559 i_c1 = ix_offset(1) + ishft(i+1, -1)
560 i_c2 = i_c1 + 1 - 2 * iand(i, 1)
561 c1 = boxes(p_nb_id)%cc(i_c1, j_c1, ix_c, iv)
562 c2 = boxes(p_nb_id)%cc(i_c1, j_c2, ix_c, iv)
563 c3 = boxes(p_nb_id)%cc(i_c2, j_c1, ix_c, iv)
564 boxes(id)%cc(i, j, ix, iv) = third * c1 + sixth * c2 + &
565 sixth * c3 + third * boxes(id)%cc(i, j, ix_f, iv)
566 if (boxes(id)%cc(i, j, ix, iv) > 2 * c1) &
567 boxes(id)%cc(i, j, ix, iv) = 2 * c1
572 end subroutine a3_gc_interp_lim
575 subroutine a3_bc_neumann_zero(box, nb, iv, bc_type)
577 integer,
intent(in) :: nb, iv
578 integer,
intent(out) :: bc_type
580 bc_type = af_bc_neumann
581 call a3_set_box_gc(box, nb, iv, 0.0_dp)
582 end subroutine a3_bc_neumann_zero
585 subroutine a3_bc_dirichlet_zero(box, nb, iv, bc_type)
587 integer,
intent(in) :: nb, iv
588 integer,
intent(out) :: bc_type
590 bc_type = af_bc_dirichlet
591 call a3_set_box_gc(box, nb, iv, 0.0_dp)
592 end subroutine a3_bc_dirichlet_zero
595 subroutine a3_bc_continuous(box, nb, iv, bc_type)
597 integer,
intent(in) :: nb, iv
598 integer,
intent(out) :: bc_type
600 bc_type = af_bc_continuous
602 call a3_set_box_gc(box, nb, iv, 0.0_dp)
603 end subroutine a3_bc_continuous
605 subroutine copy_from_nb(box, box_nb, dnb, lo, hi, iv)
606 type(
box3_t),
intent(inout) :: box
607 type(
box3_t),
intent(in) :: box_nb
608 integer,
intent(in) :: dnb(3)
609 integer,
intent(in) :: lo(3)
610 integer,
intent(in) :: hi(3)
611 integer,
intent(in) :: iv
612 integer :: nlo(3), nhi(3)
615 nlo = lo - dnb * box%n_cell
616 nhi = hi - dnb * box%n_cell
618 box%cc(lo(1):hi(1), lo(2):hi(2), lo(3):hi(3), iv) = &
619 box_nb%cc(nlo(1):nhi(1), nlo(2):nhi(2), nlo(3):nhi(3), iv)
620 end subroutine copy_from_nb
625 subroutine a3_gc2_box(boxes, id, iv, subr_rb, subr_bc, cc, nc)
627 integer,
intent(in) :: id
628 integer,
intent(in) :: iv
631 integer,
intent(in) :: nc
633 real(dp),
intent(out) :: cc(-1:nc+2, -1:nc+2, -1:nc+2)
634 real(dp) :: gc(1:nc, 1:nc)
635 integer :: nb, nb_id, nb_dim, lo(3), hi(3)
637 cc(0:nc+1, 0:nc+1, 0:nc+1) = boxes(id)%cc(0:nc+1, 0:nc+1, 0:nc+1, iv)
639 do nb = 1, a3_num_neighbors
640 nb_id = boxes(id)%neighbors(nb)
642 if (nb_id > af_no_box)
then 643 call sides2_from_nb(boxes(nb_id), nb, iv, gc, nc)
644 else if (nb_id == af_no_box)
then 645 call subr_rb(boxes, id, nb, iv, gc, nc)
647 call subr_bc(boxes, id, nb, iv, gc, nc)
651 nb_dim = a3_neighb_dim(nb)
653 hi(:) = boxes(id)%n_cell
654 lo(nb_dim) = -1 + a3_neighb_high_01(nb) * (boxes(id)%n_cell + 3)
655 hi(nb_dim) = lo(nb_dim)
657 cc(lo(1):hi(1), lo(2):hi(2), lo(3):hi(3)) = reshape(gc, 1 + hi - lo)
659 end subroutine a3_gc2_box
662 subroutine sides2_from_nb(box_nb, nb, iv, gc_side, nc)
663 type(
box3_t),
intent(in) :: box_nb
664 integer,
intent(in) :: nb
665 integer,
intent(in) :: iv
666 integer,
intent(in) :: nc
667 real(dp),
intent(out) :: gc_side(nc, nc)
670 case (a3_neighb_lowx)
671 gc_side = box_nb%cc(nc-1, 1:nc, 1:nc, iv)
672 case (a3_neighb_highx)
673 gc_side = box_nb%cc(2, 1:nc, 1:nc, iv)
674 case (a3_neighb_lowy)
675 gc_side = box_nb%cc(1:nc, nc-1, 1:nc, iv)
676 case (a3_neighb_highy)
677 gc_side = box_nb%cc(1:nc, 2, 1:nc, iv)
678 case (a3_neighb_lowz)
679 gc_side = box_nb%cc(1:nc, 1:nc, nc-1, iv)
680 case (a3_neighb_highz)
681 gc_side = box_nb%cc(1:nc, 1:nc, 2, iv)
683 end subroutine sides2_from_nb
686 subroutine a3_gc2_prolong_linear(boxes, id, nb, iv, gc_side, nc)
688 integer,
intent(in) :: id
689 integer,
intent(in) :: nb
690 integer,
intent(in) :: iv
691 integer,
intent(in) :: nc
692 real(dp),
intent(out) :: gc_side(nc, nc)
694 integer :: i_c1, i_c2, j_c1, j_c2, p_nb_id
695 integer :: p_id, ix_offset(3)
696 integer :: k, k_c1, k_c2
698 p_id = boxes(id)%parent
699 p_nb_id = boxes(p_id)%neighbors(nb)
700 ix_offset = a3_get_child_offset(boxes(id), nb)
701 ix = a3_neighb_high_01(nb) * (nc+3) - 1
703 select case (a3_neighb_dim(nb))
705 i_c1 = ix_offset(1) + ishft(ix+1, -1)
706 i_c2 = i_c1 + 1 - 2 * iand(ix, 1)
708 k_c1 = ix_offset(3) + ishft(k+1, -1)
709 k_c2 = k_c1 + 1 - 2 * iand(k, 1)
711 j_c1 = ix_offset(2) + ishft(j+1, -1)
712 j_c2 = j_c1 + 1 - 2 * iand(j, 1)
714 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c1, k_c1, iv) + &
715 0.25_dp * boxes(p_nb_id)%cc(i_c2, j_c1, k_c1, iv) + &
716 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c2, k_c1, iv) + &
717 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c1, k_c2, iv)
721 j_c1 = ix_offset(2) + ishft(ix+1, -1)
722 j_c2 = j_c1 + 1 - 2 * iand(ix, 1)
724 k_c1 = ix_offset(3) + ishft(k+1, -1)
725 k_c2 = k_c1 + 1 - 2 * iand(k, 1)
727 i_c1 = ix_offset(1) + ishft(i+1, -1)
728 i_c2 = i_c1 + 1 - 2 * iand(i, 1)
730 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c1, k_c1, iv) + &
731 0.25_dp * boxes(p_nb_id)%cc(i_c2, j_c1, k_c1, iv) + &
732 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c2, k_c1, iv) + &
733 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c1, k_c2, iv)
737 k_c1 = ix_offset(3) + ishft(ix+1, -1)
738 k_c2 = k_c1 + 1 - 2 * iand(ix, 1)
740 j_c1 = ix_offset(2) + ishft(j+1, -1)
741 j_c2 = j_c1 + 1 - 2 * iand(j, 1)
743 i_c1 = ix_offset(1) + ishft(i+1, -1)
744 i_c2 = i_c1 + 1 - 2 * iand(i, 1)
746 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c1, k_c1, iv) + &
747 0.25_dp * boxes(p_nb_id)%cc(i_c2, j_c1, k_c1, iv) + &
748 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c2, k_c1, iv) + &
749 0.25_dp * boxes(p_nb_id)%cc(i_c1, j_c1, k_c2, iv)
754 end subroutine a3_gc2_prolong_linear
757 subroutine a3_bc2_neumann_zero(boxes, id, nb, iv, gc_side, nc)
759 integer,
intent(in) :: id
760 integer,
intent(in) :: nb
761 integer,
intent(in) :: iv
762 integer,
intent(in) :: nc
763 real(dp),
intent(out) :: gc_side(nc, nc)
766 case (a3_neighb_lowx)
767 gc_side = boxes(id)%cc(2, 1:nc, 1:nc, iv)
768 case (a3_neighb_highx)
769 gc_side = boxes(id)%cc(nc-1, 1:nc, 1:nc, iv)
770 case (a3_neighb_lowy)
771 gc_side = boxes(id)%cc(1:nc, 2, 1:nc, iv)
772 case (a3_neighb_highy)
773 gc_side = boxes(id)%cc(1:nc, nc-1, 1:nc, iv)
774 case (a3_neighb_lowz)
775 gc_side = boxes(id)%cc(1:nc, 1:nc, 2, iv)
776 case (a3_neighb_highz)
777 gc_side = boxes(id)%cc(1:nc, 1:nc, nc-1, iv)
779 end subroutine a3_bc2_neumann_zero
782 subroutine a3_bc2_dirichlet_zero(boxes, id, nb, iv, gc_side, nc)
784 integer,
intent(in) :: id, nb, iv, nc
785 real(dp),
intent(out) :: gc_side(nc, nc)
788 case (a3_neighb_lowx)
789 gc_side = -boxes(id)%cc(2, 1:nc, 1:nc, iv)
790 case (a3_neighb_highx)
791 gc_side = -boxes(id)%cc(nc-1, 1:nc, 1:nc, iv)
792 case (a3_neighb_lowy)
793 gc_side = -boxes(id)%cc(1:nc, 2, 1:nc, iv)
794 case (a3_neighb_highy)
795 gc_side = -boxes(id)%cc(1:nc, nc-1, 1:nc, iv)
796 case (a3_neighb_lowz)
797 gc_side = -boxes(id)%cc(1:nc, 1:nc, 2, iv)
798 case (a3_neighb_highz)
799 gc_side = -boxes(id)%cc(1:nc, 1:nc, nc-1, iv)
801 end subroutine a3_bc2_dirichlet_zero
805 subroutine a3_corner_gc_extrap(box, ix, iv)
806 type(
box3_t),
intent(inout) :: box
807 integer,
intent(in) :: ix(3)
808 integer,
intent(in) :: iv
811 di = 1 - 2 * iand(ix, 1)
813 box%cc(ix(1), ix(2), ix(3), iv) = &
814 box%cc(ix(1), ix(2)+di(2), ix(3)+di(3), iv) + &
815 box%cc(ix(1)+di(1), ix(2), ix(3)+di(3), iv) + &
816 box%cc(ix(1)+di(1), ix(2)+di(2), ix(3), iv) - 2 * &
817 box%cc(ix(1)+di(1), ix(2)+di(2), ix(3)+di(3), iv)
818 end subroutine a3_corner_gc_extrap
823 subroutine a3_edge_gc_extrap(box, lo, dim, iv)
824 type(
box3_t),
intent(inout) :: box
825 integer,
intent(in) :: lo(3)
826 integer,
intent(in) :: dim
827 integer,
intent(in) :: iv
828 integer :: di(3), ix(3), ia(3), ib(3), ic(3)
829 integer :: n, o_dims(3-1)
832 o_dims = [1 + mod(dim, 3), 1 + mod(dim + 1, 3)]
835 di = 1 - 2 * iand(lo, 1)
840 ia(o_dims(1)) = ia(o_dims(1)) + di(o_dims(1))
844 ib(o_dims(2)) = ib(o_dims(2)) + di(o_dims(2))
856 box%cc(ix(1), ix(2), ix(3), iv) = &
857 box%cc(ia(1), ia(2), ia(3), iv) + &
858 box%cc(ib(1), ib(2), ib(3), iv) - &
859 box%cc(ic(1), ic(2), ic(3), iv)
862 end subroutine a3_edge_gc_extrap
To fill ghost cells near physical boundaries.
Subroutine for getting extra ghost cell data (> 1) near physical boundaries.
The basic building block of afivo: a box with cell-centered and face centered data, and information about its position, neighbors, children etc.
Type which stores all the boxes and levels, as well as some information about the number of boxes...
To fill ghost cells near refinement boundaries.
This module contains the routines related to prolongation: going from coarse to fine variables...
This module contains routines related to the filling of ghost cells. Note that corner ghost cells are...
This module contains the basic types and constants that are used in the 3-dimensional version of Afiv...