13 public :: a2_interp0_to_grid
18 function a2_interp0(tree, rr, ivs, n_var)
result(vals)
20 type(
a2_t),
intent(in) :: tree
21 real(dp),
intent(in) :: rr(2)
22 integer,
intent(in) :: n_var
23 integer,
intent(in) :: ivs(n_var)
24 real(dp) :: vals(n_var)
27 loc = a2_get_loc(tree, rr)
29 if (loc%id == -1)
then 30 print *,
"a2_interp0 error, no box at ", rr
34 vals = tree%boxes(loc%id)%cc(loc%ix(1), loc%ix(2), ivs)
35 end function a2_interp0
38 function a2_interp1(tree, r, ivs, n_var, id_guess)
result(vals)
40 type(
a2_t),
intent(in) :: tree
41 real(dp),
intent(in) :: r(2)
42 integer,
intent(in) :: n_var
43 integer,
intent(in) :: ivs(n_var)
44 integer,
intent(in),
optional :: id_guess
45 real(dp) :: vals(n_var)
46 integer :: i, iv, id, ix(2)
47 real(dp) :: r_loc(2), dvec(2), ovec(2), w(2, 2)
49 id = a2_get_id_at(tree, r, id_guess)
51 if (id <= af_no_box)
then 52 print *,
"a2_interp1: point outside domain", r
57 ix = nint((r - tree%boxes(id)%r_min) / tree%boxes(id)%dr)
58 r_loc = a2_r_cc(tree%boxes(id), ix)
62 dvec = dvec / tree%boxes(id)%dr
66 w(1, 1) = ovec(1) * ovec(2)
67 w(2, 1) = dvec(1) * ovec(2)
68 w(1, 2) = ovec(1) * dvec(2)
69 w(2, 2) = dvec(1) * dvec(2)
73 vals(i) = sum(w * tree%boxes(id)%cc(ix(1):ix(1)+1, &
76 end function a2_interp1
79 subroutine a2_interp0_to_grid(tree, rr, iv, amount, to_density)
81 type(
a2_t),
intent(inout) :: tree
82 integer,
intent(in) :: iv
83 real(dp),
intent(in) :: rr(2)
84 real(dp),
intent(in) :: amount
85 logical,
intent(in) :: to_density
86 real(dp) :: actual_amount
90 loc = a2_get_loc(tree, rr)
92 if (loc%id == -1)
then 93 print *,
"a2_interp0_to_grid error, no box at ", rr
102 actual_amount = amount / tree%boxes(id)%dr**2
104 actual_amount = amount
107 tree%boxes(id)%cc(ix(1), ix(2), iv) = &
108 tree%boxes(id)%cc(ix(1), ix(2), iv) + &
110 end subroutine a2_interp0_to_grid
This module contains all kinds of different 'helper' routines for Afivo. If the number of routines fo...
Type which stores all the boxes and levels, as well as some information about the number of boxes...
This module contains routines related to interpolation, which can interpolate 'to' the grid and 'from...
This module contains the basic types and constants that are used in the 2-dimensional version of Afiv...
Type specifying the location of a cell.