11 public :: a2_restrict_to_box
12 public :: a2_restrict_to_boxes
13 public :: a2_restrict_tree
14 public :: a2_restrict_box
21 subroutine a2_restrict_to_box(boxes, id, iv, iv_to)
22 type(
box2_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, a2_num_children
30 c_id = boxes(id)%children(i_c)
31 if (c_id == af_no_box) cycle
32 call a2_restrict_box(boxes(c_id), boxes(id), iv, iv_to)
34 end subroutine a2_restrict_to_box
37 subroutine a2_restrict_to_boxes(boxes, ids, iv, iv_to)
38 type(
box2_t),
intent(inout) :: boxes(:)
39 integer,
intent(in) :: ids(:)
40 integer,
intent(in) :: iv
41 integer,
intent(in),
optional :: iv_to
46 call a2_restrict_to_box(boxes, ids(i), iv, iv_to)
49 end subroutine a2_restrict_to_boxes
52 subroutine a2_restrict_tree(tree, iv, iv_to)
53 type(
a2_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 a2_restrict_to_boxes(tree%boxes, tree%lvls(lvl)%parents, iv, iv_to)
62 end subroutine a2_restrict_tree
65 subroutine a2_restrict_box(box_c, box_p, iv, iv_to, use_geometry)
67 type(
box2_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(2)
76 hnc = ishft(box_c%n_cell, -1)
77 ix_offset = a2_get_child_offset(box_c)
79 if (
present(iv_to))
then 85 if (
present(use_geometry))
then 86 use_geom = use_geometry
91 if (box_p%coord_t == af_cyl .and. use_geom)
then 93 j_c = ix_offset(2) + j
96 i_c = ix_offset(1) + i
99 call a2_cyl_child_weights(box_p, i, w1, w2)
100 box_p%cc(i_c, j_c, i_dest) = 0.25_dp * (&
101 w1 * sum(box_c%cc(i_f, j_f:j_f+1, iv)) + &
102 w2 * sum(box_c%cc(i_f+1, j_f:j_f+1, iv)))
107 j_c = ix_offset(2) + j
110 i_c = ix_offset(1) + i
112 box_p%cc(i_c, j_c, i_dest) = 0.25_dp * &
113 sum(box_c%cc(i_f:i_f+1, j_f:j_f+1, iv))
117 end subroutine a2_restrict_box
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 2-dimensional version of Afiv...
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.