11 public :: a3_restrict_to_box
12 public :: a3_restrict_to_boxes
13 public :: a3_restrict_tree
14 public :: a3_restrict_box
21 subroutine a3_restrict_to_box(boxes, id, iv, iv_to)
22 type(
box3_t),
intent(inout) :: boxes(:)
23 integer,
intent(in) :: id
24 integer,
intent(in) :: iv
25 integer,
intent(in),
optional :: iv_to
26 integer :: nc, i_c, c_id
29 do i_c = 1, a3_num_children
30 c_id = boxes(id)%children(i_c)
31 if (c_id == af_no_box) cycle
32 call a3_restrict_box(boxes(c_id), boxes(id), iv, iv_to)
34 end subroutine a3_restrict_to_box
37 subroutine a3_restrict_to_boxes(boxes, ids, iv, iv_to)
38 type(
box3_t),
intent(inout) :: boxes(:)
39 integer,
intent(in) :: ids(:)
40 integer,
intent(in) :: iv
41 integer,
intent(in),
optional :: iv_to
46 call a3_restrict_to_box(boxes, ids(i), iv, iv_to)
49 end subroutine a3_restrict_to_boxes
52 subroutine a3_restrict_tree(tree, iv, iv_to)
53 type(
a3_t),
intent(inout) :: tree
54 integer,
intent(in) :: iv
55 integer,
intent(in),
optional :: iv_to
58 if (.not. tree%ready) stop
"Tree not ready" 59 do lvl = tree%highest_lvl-1, lbound(tree%lvls, 1), -1
60 call a3_restrict_to_boxes(tree%boxes, tree%lvls(lvl)%parents, iv, iv_to)
62 end subroutine a3_restrict_tree
65 subroutine a3_restrict_box(box_c, box_p, iv, iv_to, use_geometry)
67 type(
box3_t),
intent(inout) :: box_p
68 integer,
intent(in) :: iv
69 integer,
intent(in),
optional :: iv_to
70 logical,
intent(in),
optional :: use_geometry
71 integer :: i, j, i_f, j_f, i_c, j_c, i_dest
72 integer :: hnc, ix_offset(3)
74 integer :: k, k_f, k_c
76 hnc = ishft(box_c%n_cell, -1)
77 ix_offset = a3_get_child_offset(box_c)
79 if (
present(iv_to))
then 85 if (
present(use_geometry))
then 86 use_geom = use_geometry
92 k_c = ix_offset(3) + k
95 j_c = ix_offset(2) + j
98 i_c = ix_offset(1) + i
100 box_p%cc(i_c, j_c, k_c, i_dest) = 0.125_dp * &
101 sum(box_c%cc(i_f:i_f+1, j_f:j_f+1, k_f:k_f+1, iv))
105 end subroutine a3_restrict_box
This module contains routines for restriction: going from fine to coarse variables.
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...
This module contains the basic types and constants that are used in the 3-dimensional version of Afiv...