13 public :: a3_interp0_to_grid
18 function a3_interp0(tree, rr, ivs, n_var)
result(vals)
20 type(
a3_t),
intent(in) :: tree
21 real(dp),
intent(in) :: rr(3)
22 integer,
intent(in) :: n_var
23 integer,
intent(in) :: ivs(n_var)
24 real(dp) :: vals(n_var)
27 loc = a3_get_loc(tree, rr)
29 if (loc%id == -1)
then 30 print *,
"a3_interp0 error, no box at ", rr
34 vals = tree%boxes(loc%id)%cc(loc%ix(1), loc%ix(2), loc%ix(3), ivs)
35 end function a3_interp0
38 function a3_interp1(tree, r, ivs, n_var, id_guess)
result(vals)
40 type(
a3_t),
intent(in) :: tree
41 real(dp),
intent(in) :: r(3)
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(3)
47 real(dp) :: r_loc(3), dvec(3), ovec(3), w(2, 2, 2)
49 id = a3_get_id_at(tree, r, id_guess)
51 if (id <= af_no_box)
then 52 print *,
"a3_interp1: point outside domain", r
57 ix = nint((r - tree%boxes(id)%r_min) / tree%boxes(id)%dr)
58 r_loc = a3_r_cc(tree%boxes(id), ix)
62 dvec = dvec / tree%boxes(id)%dr
66 w(1, 1, 1) = ovec(1) * ovec(2) * ovec(3)
67 w(2, 1, 1) = dvec(1) * ovec(2) * ovec(3)
68 w(1, 2, 1) = ovec(1) * dvec(2) * ovec(3)
69 w(2, 2, 1) = dvec(1) * dvec(2) * ovec(3)
70 w(1, 1, 2) = ovec(1) * ovec(2) * dvec(3)
71 w(2, 1, 2) = dvec(1) * ovec(2) * dvec(3)
72 w(1, 2, 2) = ovec(1) * dvec(2) * dvec(3)
73 w(2, 2, 2) = dvec(1) * dvec(2) * dvec(3)
77 vals(i) = sum(w * tree%boxes(id)%cc(ix(1):ix(1)+1, &
78 ix(2):ix(2)+1, ix(3):ix(3)+1, iv))
80 end function a3_interp1
83 subroutine a3_interp0_to_grid(tree, rr, iv, amount, to_density)
85 type(
a3_t),
intent(inout) :: tree
86 integer,
intent(in) :: iv
87 real(dp),
intent(in) :: rr(3)
88 real(dp),
intent(in) :: amount
89 logical,
intent(in) :: to_density
90 real(dp) :: actual_amount
94 loc = a3_get_loc(tree, rr)
96 if (loc%id == -1)
then 97 print *,
"a3_interp0_to_grid error, no box at ", rr
106 actual_amount = amount / tree%boxes(id)%dr**3
108 actual_amount = amount
111 tree%boxes(id)%cc(ix(1), ix(2), ix(3), iv) = &
112 tree%boxes(id)%cc(ix(1), ix(2), ix(3), iv) + &
114 end subroutine a3_interp0_to_grid
Type specifying the location of a cell.
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 3-dimensional version of Afiv...