8 #include "sll_memory.h"
9 #include "sll_working_precision.h"
27 sll_int32,
dimension(:, :, :, :),
pointer :: index
48 sll_real64,
dimension(:),
intent(in) ::
data
49 sll_real64,
dimension(:),
intent(in) :: eta
51 interpolator,
data, eta)
62 sll_real64,
dimension(:),
intent(inout) :: data_in
63 sll_real64,
dimension(:),
intent(out) :: data_out
64 sll_int32,
dimension(:),
intent(in) :: dorder
65 sll_real64,
intent(in) ::displacement
66 logical,
intent(in) :: hiera
68 sll_int32 :: i1, i2, i3, i4, k2, k3, k4, counter, j
69 sll_int32,
dimension(4) :: l, no, ind_order
70 sll_int32,
dimension(:, :),
allocatable :: ind
72 sll_allocate(ind(interpolator%max_level + 1, 4), i1);
73 ind_order(dorder(1)) = 0
75 do i3 = 0, interpolator%levels(dorder(3))
76 ind_order(dorder(3)) = i3
78 no(dorder(3)) = max(2**(i3 - 1), 1);
79 do i4 = 0, min(interpolator%max_level - i3, interpolator%levels(dorder(4)))
80 ind_order(dorder(4)) = i4
82 no(dorder(4)) = max(2**(i4 - 1), 1);
83 do i2 = 0, min(interpolator%max_level - i3 - i4, interpolator%levels(dorder(2)))
84 ind_order(dorder(2)) = i2
85 no(dorder(2)) = max(2**(i2 - 1), 1);
86 ind(1, dorder(1)) = 0;
87 do k2 = 0, no(dorder(2)) - 1
88 ind(ind_order(dorder(2)) + 1, dorder(2)) = k2;
89 do k3 = 0, no(dorder(3)) - 1
90 ind(ind_order(dorder(3)) + 1, dorder(3)) = k3;
91 do k4 = 0, no(dorder(4)) - 1
92 ind(ind_order(dorder(4)) + 1, dorder(4)) = k4;
93 counter = interpolator%index( &
94 ind_order(1), ind_order(2), ind_order(3), ind_order(4)) + &
95 ind(ind_order(1) + 1, 1)*no(2)*no(3)*no(4) &
96 + ind(ind_order(2) + 1, 2)*no(3)*no(4) + &
97 ind(ind_order(3) + 1, 3)*no(4) + ind(ind_order(4) + 1, 4)
99 call interpolator%interpolate_disp_1d_periodic &
100 (displacement, dorder(1), &
101 min(interpolator%levels(dorder(1)), &
102 interpolator%max_level - ind_order(dorder(2)) - &
103 ind_order(dorder(3)) - &
104 ind_order(dorder(4))), counter, data_in, data_out, hiera)
112 if (hiera .EQV. .false.)
then
114 do j = interpolator%order, 2, -1
115 call interpolator%dehierarchical_part_order &
117 interpolator%dim, 2, dorder, j)
120 call interpolator%dehierarchical_part(data_out, &
121 interpolator%dim, 2, dorder)
132 sll_real64,
dimension(:),
intent(inout) :: data_in
133 sll_real64,
dimension(:),
intent(out) :: data_out
134 sll_int32,
dimension(:),
intent(in) :: dorder
136 sll_real64,
dimension(:),
intent(in) ::displacement
137 sll_int32 :: i1, i2, i3, i4, k2, k3, k4, counter, j, index_parent, index_parent_old
138 sll_int32,
dimension(4) :: l, no, ind_order
139 sll_int32,
dimension(:, :),
allocatable :: ind
140 sll_real64 :: coordinate_self, coordinate_ancestor, factor, disp
142 sll_allocate(ind(interpolator%max_level + 1, 4), i1);
144 do j = interpolator%order, 2, -1
145 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part_order &
146 (data_in, 1, 1, dorder, j)
149 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part(data_in, 1, 1, dorder)
151 ind_order(dorder(1)) = 0
153 do i3 = 0, interpolator%levels(dorder(3))
154 ind_order(dorder(3)) = i3
156 no(dorder(3)) = max(2**(i3 - 1), 1);
157 do i4 = 0, min(interpolator%max_level - i3, interpolator%levels(dorder(4)))
158 ind_order(dorder(4)) = i4
160 no(dorder(4)) = max(2**(i4 - 1), 1);
161 do i2 = 0, min(interpolator%max_level - i3 - i4, interpolator%levels(dorder(2)))
162 ind_order(dorder(2)) = i2
163 no(dorder(2)) = max(2**(i2 - 1), 1);
164 ind(1, dorder(1)) = 0;
165 do k2 = 0, no(dorder(2)) - 1
166 ind(ind_order(dorder(2)) + 1, dorder(2)) = k2;
167 disp = displacement(2**(i2 - 1) + k2 + 1)
168 do k3 = 0, no(dorder(3)) - 1
169 ind(ind_order(dorder(3)) + 1, dorder(3)) = k3;
170 do k4 = 0, no(dorder(4)) - 1
171 ind(ind_order(dorder(4)) + 1, dorder(4)) = k4;
172 counter = interpolator%index( &
173 ind_order(1), ind_order(2), ind_order(3), ind_order(4)) + &
174 ind(ind_order(1) + 1, 1)*no(2)*no(3)*no(4) &
175 + ind(ind_order(2) + 1, 2)*no(3)*no(4) + &
176 ind(ind_order(3) + 1, 3)*no(4) + ind(ind_order(4) + 1, 4)
178 call interpolator%sll_t_sparse_grid_interpolator%interpolate_disp_1d_periodic_self &
180 min(interpolator%levels(dorder(1)), &
181 interpolator%max_level - ind_order(dorder(2)) - &
182 ind_order(dorder(3)) - &
183 ind_order(dorder(4))), counter, data_in, data_out)
185 index_parent = max(interpolator%hierarchy(counter)%parent(2*dorder(2) - 1), &
186 interpolator%hierarchy(counter)%parent(2*dorder(2)))
187 coordinate_self = interpolator%hierarchy(counter)%coordinate(dorder(2))
188 index_parent_old = counter;
189 do while (index_parent < index_parent_old)
190 coordinate_ancestor = interpolator%hierarchy(index_parent)% &
191 coordinate(dorder(2))
192 call interpolator%basis_function((coordinate_self - coordinate_ancestor)/ &
193 interpolator%length(dorder(2))* &
194 real(2**(interpolator%hierarchy(index_parent)%level(dorder(2))), f64), factor, &
195 interpolator%hierarchy(index_parent)%function_type(dorder(2)))
196 call interpolator%sll_t_sparse_grid_interpolator%interpolate_disp_1d_periodic_for_neighbor &
198 dorder(1), min(interpolator%levels(dorder(1)), &
199 interpolator%max_level - &
200 interpolator%hierarchy(index_parent)%level(dorder(2)) - &
201 ind_order(dorder(3)) - ind_order(dorder(4))), &
202 min(interpolator%levels(dorder(1)), &
203 interpolator%max_level - ind_order(dorder(2)) - &
204 ind_order(dorder(3)) - &
205 ind_order(dorder(4))), index_parent, counter, &
207 index_parent_old = index_parent;
209 max(interpolator%hierarchy(index_parent)%parent(2*dorder(2) - 1), &
210 interpolator%hierarchy(index_parent)%parent(2*dorder(2)))
221 do j = interpolator%order, 2, -1
222 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part_order &
223 (data_out, 4, 3, dorder, j)
226 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part(data_out, 4, 3, dorder)
233 sll_real64,
dimension(:),
intent(inout) :: data_in
234 sll_real64,
dimension(:),
intent(out) :: data_out
235 sll_int32,
dimension(:),
intent(in) :: dorder
236 sll_real64,
intent(in) ::displacement
237 sll_int32 :: i1, i2, i3, i4, k2, k3, k4, counter, j, index_parent, index_parent_old
238 sll_int32,
dimension(4) :: l, no, ind_order
239 sll_int32,
dimension(:, :),
allocatable :: ind
240 sll_real64 :: coordinate_self, coordinate_ancestor, factor, disp
242 sll_allocate(ind(interpolator%max_level + 1, 4), i1);
244 do j = interpolator%order, 2, -1
245 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part_order &
246 (data_in, 1, 1, dorder, j)
249 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part(data_in, 1, 1, dorder)
252 ind_order(dorder(1)) = 0
254 do i3 = 0, interpolator%levels(dorder(3))
255 ind_order(dorder(3)) = i3
257 no(dorder(3)) = max(2**(i3 - 1), 1);
258 do i4 = 0, min(interpolator%max_level - i3, interpolator%levels(dorder(4)))
259 ind_order(dorder(4)) = i4
261 no(dorder(4)) = max(2**(i4 - 1), 1);
262 do i2 = 0, min(interpolator%max_level - i3 - i4, interpolator%levels(dorder(2)))
263 ind_order(dorder(2)) = i2
264 no(dorder(2)) = max(2**(i2 - 1), 1);
265 ind(1, dorder(1)) = 0;
266 do k2 = 0, no(dorder(2)) - 1
267 ind(ind_order(dorder(2)) + 1, dorder(2)) = k2;
268 do k3 = 0, no(dorder(3)) - 1
269 ind(ind_order(dorder(3)) + 1, dorder(3)) = k3;
270 do k4 = 0, no(dorder(4)) - 1
271 ind(ind_order(dorder(4)) + 1, dorder(4)) = k4;
272 counter = interpolator%index( &
273 ind_order(1), ind_order(2), ind_order(3), ind_order(4)) + &
274 ind(ind_order(1) + 1, 1)*no(2)*no(3)*no(4) &
275 + ind(ind_order(2) + 1, 2)*no(3)*no(4) + &
276 ind(ind_order(3) + 1, 3)*no(4) + ind(ind_order(4) + 1, 4)
277 disp = displacement*interpolator%hierarchy(counter)%coordinate(dorder(2))
279 call interpolator%sll_t_sparse_grid_interpolator%interpolate_disp_1d_periodic_self &
281 min(interpolator%levels(dorder(1)), interpolator%max_level &
282 - ind_order(dorder(2)) - ind_order(dorder(3)) - &
283 ind_order(dorder(4))), counter, data_in, data_out)
285 index_parent = max(interpolator%hierarchy(counter)%parent(2*dorder(2) - 1), &
286 interpolator%hierarchy(counter)%parent(2*dorder(2)))
287 coordinate_self = interpolator%hierarchy(counter)%coordinate(dorder(2))
288 index_parent_old = counter;
289 do while (index_parent < index_parent_old)
290 coordinate_ancestor = interpolator%hierarchy(index_parent)% &
291 coordinate(dorder(2))
292 call interpolator%basis_function((coordinate_self - coordinate_ancestor)/ &
293 interpolator%length(dorder(2))* &
294 real(2**(interpolator%hierarchy(index_parent)%level(dorder(2))), f64), factor, &
295 interpolator%hierarchy(index_parent)%function_type(dorder(2)))
296 call interpolator%sll_t_sparse_grid_interpolator%interpolate_disp_1d_periodic_for_neighbor &
298 dorder(1), min(interpolator%levels(dorder(1)), &
299 interpolator%max_level - &
300 interpolator%hierarchy(index_parent)%level(dorder(2)) - &
301 ind_order(dorder(3)) - ind_order(dorder(4))), &
302 min(interpolator%levels(dorder(1)), &
303 interpolator%max_level - &
304 ind_order(dorder(2)) - ind_order(dorder(3)) - &
305 ind_order(dorder(4))), index_parent, counter, &
307 index_parent_old = index_parent;
309 max(interpolator%hierarchy(index_parent)%parent(2*dorder(2) - 1), &
310 interpolator%hierarchy(index_parent)%parent(2*dorder(2)))
321 do j = interpolator%order, 2, -1
322 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part_order &
323 (data_out, 4, 3, dorder, j)
326 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part(data_out, 4, 3, dorder)
333 sll_real64,
dimension(:),
intent(inout) :: data_in
334 sll_real64,
dimension(:),
intent(out) :: data_out
335 sll_int32,
dimension(:),
intent(in) :: dorder
336 sll_real64,
dimension(:),
intent(in) ::displacement
337 sll_int32 :: i1, i2, i3, i4, k2, k3, k4, counter, j, index_parent, index_old, index_upper, index_upper_old
338 sll_int32 :: counter_disp, l23
339 sll_int32,
dimension(4) :: l, no, ind_order
340 sll_int32,
dimension(:, :),
allocatable :: ind
341 sll_real64 :: coordinate_self, coordinate_ancestor, coordinate_self_upper, factor_upper, factor_lower, factor, disp
343 sll_allocate(ind(interpolator%max_level + 1, 4), i1);
345 do j = interpolator%order, 2, -1
346 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part_order &
347 (data_in, 1, 1, dorder, j)
350 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_part( &
351 data_in, 1, 1, dorder)
356 ind_order(dorder(1)) = 0
358 do i4 = 0, interpolator%levels(dorder(4))
359 ind_order(dorder(4)) = i4
361 no(dorder(4)) = max(2**(i4 - 1), 1);
363 do l23 = 0, min(interpolator%max_level - i4, interpolator%levels(dorder(2)))
365 ind_order(dorder(2)) = i2
366 no(dorder(2)) = max(2**(i2 - 1), 1);
368 ind_order(dorder(3)) = i3
370 no(dorder(3)) = max(2**(i3 - 1), 1);
371 ind(1, dorder(1)) = 0;
372 do k2 = 0, max(2**(ind_order(dorder(2)) - 1), 1) - 1
373 ind(ind_order(dorder(2)) + 1, dorder(2)) = k2;
374 do k3 = 0, max(2**(ind_order(dorder(3)) - 1), 1) - 1
375 counter_disp = counter_disp + 1;
376 disp = displacement(counter_disp);
377 ind(ind_order(dorder(3)) + 1, dorder(3)) = k3;
378 do k4 = 0, max(2**(ind_order(dorder(4)) - 1), 1) - 1
379 ind(ind_order(dorder(4)) + 1, dorder(4)) = k4;
384 counter = interpolator%index( &
385 ind_order(1), ind_order(2), ind_order(3), ind_order(4)) + &
386 ind(ind_order(1) + 1, 1)*no(2)*no(3)*no(4) &
387 + ind(ind_order(2) + 1, 2)*no(3)*no(4) + &
388 ind(ind_order(3) + 1, 3)*no(4) + ind(ind_order(4) + 1, 4)
391 call interpolator%sll_t_sparse_grid_interpolator%interpolate_disp_1d_periodic_self &
393 min(interpolator%levels(dorder(1)), &
394 interpolator%max_level - ind_order(dorder(2)) - &
395 ind_order(dorder(3)) - &
396 ind_order(dorder(4))), counter, data_in, data_out)
398 index_upper = counter
399 index_upper_old = index_upper + 1
405 coordinate_self = interpolator%hierarchy(counter)%coordinate(dorder(2))
406 coordinate_self_upper = interpolator%hierarchy(counter)%coordinate(dorder(3))
408 do while (index_upper < index_upper_old)
409 coordinate_ancestor = interpolator%hierarchy(index_upper)% &
410 coordinate(dorder(3))
411 call interpolator%basis_function((coordinate_self_upper - coordinate_ancestor)/ &
412 interpolator%length(dorder(3))* &
413 2**(interpolator%hierarchy(index_upper)%level(dorder(3))), &
415 interpolator%hierarchy(index_upper)%function_type(dorder(3)))
417 if (index_upper == counter)
then
419 max(interpolator%hierarchy(index_upper)%parent(2*dorder(2) - 1), &
420 interpolator%hierarchy(index_upper)%parent(2*dorder(2)))
421 index_old = index_upper
423 index_parent = index_upper;
424 index_old = index_parent + 1
427 do while (index_parent < index_old)
428 coordinate_ancestor = interpolator%hierarchy(index_parent)% &
429 coordinate(dorder(2))
430 call interpolator%basis_function((coordinate_self - coordinate_ancestor)/ &
431 interpolator%length(dorder(2))* &
432 real(2**(interpolator%hierarchy(index_parent)%level(dorder(2))), f64), &
434 interpolator%hierarchy(index_parent)%function_type(dorder(2)))
435 factor = factor_upper*factor_lower
440 call interpolator%sll_t_sparse_grid_interpolator%interpolate_disp_1d_periodic_for_neighbor &
442 dorder(1), min(interpolator%levels(dorder(1)), &
443 interpolator%max_level - &
444 interpolator%hierarchy(index_parent)%level(dorder(2)) - &
445 interpolator%hierarchy(index_parent)%level(dorder(3)) - &
446 ind_order(dorder(4))), &
447 min(interpolator%levels(dorder(1)), &
448 interpolator%max_level - ind_order(dorder(2)) - &
449 ind_order(dorder(3)) - &
450 ind_order(dorder(4))), index_parent, counter, &
452 index_old = index_parent
454 max(interpolator%hierarchy(index_parent)%parent(2*dorder(2) - 1), &
455 interpolator%hierarchy(index_parent)%parent(2*dorder(2)))
457 index_upper_old = index_upper;
459 max(interpolator%hierarchy(index_upper)%parent(2*dorder(3) - 1), &
460 interpolator%hierarchy(index_upper)%parent(2*dorder(3)));
470 call interpolator%sll_t_sparse_grid_interpolator%hierarchical_part(data_out, 3, 1, dorder)
472 do j = 2, interpolator%order
473 call interpolator%sll_t_sparse_grid_interpolator%hierarchical_part_order &
474 (data_out, 3, 1, dorder, j)
478 do j = interpolator%order, 2, -1
479 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical_order &
483 call interpolator%sll_t_sparse_grid_interpolator%dehierarchical &
561 sll_int32 :: j, l1, l2, l3, level
563 sll_real64,
dimension(:),
intent(in) ::
data, eta
564 sll_real64,
dimension(4) :: eta_norm
565 sll_real64,
dimension(4) :: phi
566 sll_int32,
dimension(4) :: no, l
567 sll_int32,
dimension(:, :),
allocatable :: ind
571 sll_allocate(ind(0:interpolator%max_level, 1:4), j)
577 eta_norm(j) = (eta(j) - interpolator%eta_min(j))/interpolator%length(j)
578 eta_norm(j) = modulo(eta_norm(j), 1.0_f64)
581 do level = 2, interpolator%max_level
582 ind(level, j) = ind(level - 1, j)*2
583 if (eta_norm(j) > scale*real(ind(level, j) + 1, f64))
then
584 ind(level, j) = ind(level, j) + 1
586 scale = scale*0.5_f64
590 do level = 0, interpolator%max_level
591 do l1 = 0, min(level, interpolator%levels(1))
593 no(1) = max(2**(l1 - 1), 1)
594 do l2 = 0, min(level - l1, interpolator%levels(2))
596 no(2) = max(2**(l2 - 1), 1)
597 do l3 = max(0, level - l1 - l2 - interpolator%levels(4)), min(level - l1 - l2, interpolator%levels(3))
598 no(3) = max(2**(l3 - 1), 1)
600 l(4) = level - l1 - l2 - l3
601 no(4) = max(2**(l(4) - 1), 1)
603 index = interpolator%index(l1, l2, l3, &
604 l(4)) + ind(l1, 1)*no(2)*no(3)*no(4) &
605 + ind(l2, 2)*no(3)*no(4) + ind(l3, 3)*no(4) + ind(l(4), 4)
607 call interpolator%basis_function(real(2**(max(l(j), 1)), f64)*eta_norm(j) &
608 - real(2*ind(l(j), j), f64) - 1.0_f64, phi(j), &
609 interpolator%hierarchy(index)%function_type(j))
611 val = val +
data(index) &
612 *phi(1)*phi(2)*phi(3)*phi(4)
695 interpolation_type, &
699 sll_real64,
dimension(:),
intent(in) :: eta_min
701 sll_real64,
dimension(:),
intent(in) :: eta_max
703 sll_int32,
dimension(:),
intent(in) :: levels
704 sll_int32,
intent(in) :: order
705 sll_int32,
intent(in) :: interpolation
706 sll_int32,
intent(in) :: interpolation_type
707 sll_int32 :: i, j, k1, k2, k3, k4, l1, l2, l3, l4, l, counter
709 sll_int32,
dimension(:),
allocatable :: novec, lvec, kvec
711 interpolator%dim = 4;
712 sll_allocate(lvec(interpolator%dim), ierr);
713 sll_allocate(kvec(interpolator%dim), ierr);
714 sll_allocate(novec(interpolator%dim), ierr);
715 interpolator%max_level = levels(1);
716 do l = 2, interpolator%dim
717 interpolator%max_level = max(levels(l), interpolator%max_level);
723 interpolator%size_basis = 0;
724 do l = 0, interpolator%max_level
725 do l1 = 0, min(l, levels(1))
726 do l2 = 0, min(l - l1, levels(2))
727 do l3 = max(0, l - l1 - l2 - levels(4)), min(l - l1 - l2, levels(3))
728 l4 = l - l1 - l2 - l3
729 interpolator%size_basis = &
730 interpolator%size_basis + &
731 max(2**(l1 - 1), 1)*max(2**(l2 - 1), 1)*max(2**(l3 - 1), 1)*max(2**(l4 - 1), 1)
737 call interpolator%initialize_sg(levels, order, interpolation, &
738 interpolation_type, eta_min, eta_max);
739 sll_allocate(interpolator%index(0:interpolator%levels(1),0:interpolator%levels(2),0:interpolator%levels(3),0:interpolator%levels(4)),ierr)
743 do l = 0, interpolator%max_level
744 interpolator%level_mapping(l) = counter;
745 do l1 = 0, min(l, interpolator%levels(1))
746 novec(1) = max(2**(l1 - 1), 1)
748 do l2 = 0, min(l - l1, interpolator%levels(2))
749 novec(2) = max(2**(l2 - 1), 1)
751 do l3 = max(0, l - l1 - l2 - interpolator%levels(4)), min(l - l1 - l2, interpolator%levels(3))
752 novec(3) = max(2**(l3 - 1), 1)
754 lvec(4) = l - l1 - l2 - l3
756 novec(4) = max(2**(l4 - 1), 1)
757 interpolator%index(l1, l2, l3, l4) = counter
758 do k1 = 0, novec(1) - 1
760 do k2 = 0, novec(2) - 1
762 do k3 = 0, novec(3) - 1
764 do k4 = 0, novec(4) - 1
766 do j = 1, interpolator%dim
770 counter = counter + 1;
779 interpolator%level_mapping(interpolator%max_level + 1) = counter;
781 do i = 1, interpolator%size_basis
782 do j = 1, interpolator%dim
783 interpolator%hierarchy(i)%coordinate(j) = &
784 interpolator%hierarchy(i)%coordinate(j)* &
785 interpolator%length(j) + &
786 interpolator%eta_min(j)
797 sll_int32,
intent(in) :: cdim
798 sll_int32,
intent(in) :: counter
799 sll_int32,
dimension(:),
intent(in) :: lvecin
800 sll_int32,
dimension(:),
intent(in) :: kvecin
801 sll_int32,
dimension(:),
intent(in) :: novecin
803 sll_int32,
dimension(4) :: lvec, kvec, novec
804 sll_int32 :: jj, stride
806 do jj = 1, interpolator%dim
807 lvec(jj) = lvecin(jj);
808 kvec(jj) = kvecin(jj);
809 novec(jj) = novecin(jj);
813 interpolator%hierarchy(counter)%level(cdim) = ld;
814 interpolator%hierarchy(counter)%index_on_level(cdim) = kd;
817 interpolator%hierarchy(counter)%coordinate(cdim) = 0.0_f64
818 interpolator%hierarchy(counter)%parent(stride) = &
820 interpolator%hierarchy(counter)%parent(stride + 1) = &
822 interpolator%hierarchy(counter)%function_type(cdim) = 0
824 interpolator%hierarchy(counter)%coordinate(cdim) = &
825 1.0_f64/(2.0_f64**ld) + real(kd, f64)*1.0_f64/(2.0_f64**(ld - 1))
827 lvec(cdim) = lvec(cdim) - 1;
828 novec(cdim) = max(novec(cdim)/2, 1);
830 kvec(cdim) = modulo((kd + 1)/2, max(2**(ld - 2), 1));
831 interpolator%hierarchy(counter)%parent( &
832 modulo(kd, 2) + stride) = &
833 interpolator%hierarchy( &
834 interpolator%index(lvec(1), lvec(2), lvec(3), lvec(4)) + &
835 kvec(1)*novec(2)*novec(3)*novec(4) + &
836 kvec(2)*novec(3)*novec(4) + &
837 kvec(3)*novec(4) + kvec(4))%parent(stride)
840 interpolator%hierarchy(counter)%parent( &
841 modulo(kd + 1, 2) + stride) = &
842 interpolator%index(lvec(1), lvec(2), lvec(3), lvec(4)) + &
843 kvec(1)*novec(2)*novec(3)*novec(4) + kvec(2)*novec(3)*novec(4) + &
844 kvec(3)*novec(4) + kvec(4)
846 interpolator%hierarchy( &
847 interpolator%hierarchy(counter)%parent( &
848 modulo(kd + 1, 2) + stride))%children(modulo(kd, 2) + stride) = counter
850 interpolator%hierarchy( &
851 interpolator%hierarchy(counter)%parent( &
852 modulo(kd + 1, 2) + stride))%children(modulo(kd + 1, 2) + stride) = counter
854 if (interpolator%order == 1)
then
855 interpolator%hierarchy(counter)% &
856 function_type(cdim) = -1
857 elseif (ld == 1 .OR. interpolator%order == 2)
then
858 interpolator%hierarchy(counter)% &
859 function_type(cdim) = 1 + modulo(kd, 2)
860 elseif (ld == 2 .OR. interpolator%order == 3)
then
861 interpolator%hierarchy(counter)% &
862 function_type(cdim) = 3 + modulo(kd, 4)
864 interpolator%hierarchy(counter)% &
865 function_type(cdim) = 7 + modulo(kd, 8)
893 sll_int32,
intent(in) :: sg_index
898 do j = 1, interpolator%dim
899 fg_index(j) = 2**(interpolator%levels(j) - &
900 interpolator%hierarchy(sg_index)%level(j))* &
901 (1 + 2*interpolator%hierarchy(sg_index)%index_on_level(j)) + 1;
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
Implementation of a 4D sparse grid with interpolation routines.
subroutine interpolate_disp_nconst_in_1d(interpolator, displacement, dorder, data_in, data_out)
Functionality: Interpolates the function values for a displacement on in dimension (periodic b....
subroutine initialize_sg4d(interpolator, levels, order, interpolation, interpolation_type, eta_min, eta_max)
Initialization function. Set up the hierarchy of the sparse grid.
subroutine interpolate_const_disp(interpolator, dorder, displacement, data_in, data_out, hiera)
Interpolation function for interpolation at (constantly) displaced grid points; displacement only in ...
integer(kind=i32) function, dimension(4) fg_index(interpolator, sg_index)
Compute the index of a sparse grid node on level "level" with index "index_on_level" on full grid wit...
real(kind=f64) function interpolate_from_interpolant_value(interpolator, data, eta)
Compute the value of the sparse grid interpolant at position eta.
subroutine interpolate4d_disp_linnconst_in_1d(interpolator, displacement, dorder, data_in, data_out)
As interpolate_disp_nconst_in_1d but displacement dependent on displacement*coordinate(dorder(2))
subroutine set_hierarchy_info(interpolator, counter, cdim, lvecin, kvecin, novecin)
For a given sparse grid point fill the hierarchy information (4D specific)
subroutine interpolate_disp_nconst_in_2d(interpolator, displacement, dorder, data_in, data_out)
As previous function but with displacement displacement*coordinate(dorder(2))
real(kind=f64) function interpolate_from_hierarchical_surplus(interpolator, data, eta)
Dimension-independent functions for sparse grid with polynomial basis functions.
Sparse grid object for 4d with interpolation routines. Note in 4d we have only an implementation of a...
Class defining the sparse grid data structure.