3 #include "sll_assert.h"
4 #include "sll_memory.h"
5 #include "sll_working_precision.h"
35 sll_real64 :: eta_min(2)
36 sll_real64 :: eta_max(2)
38 sll_int32 :: degree(2)
41 sll_real64,
dimension(:, :, :),
pointer :: deriv
42 sll_int32 :: continuity(2)
43 sll_int32 :: deriv_size(2)
65 eta1_hermite_continuity, &
66 eta2_hermite_continuity, &
69 const_eta1_min_slope, &
70 const_eta1_max_slope, &
71 const_eta2_min_slope, &
72 const_eta2_max_slope, &
80 sll_int32,
intent(in) :: npts1
81 sll_int32,
intent(in) :: npts2
82 sll_real64,
intent(in) :: eta1_min
83 sll_real64,
intent(in) :: eta1_max
84 sll_real64,
intent(in) :: eta2_min
85 sll_real64,
intent(in) :: eta2_max
86 sll_int32,
intent(in) :: degree1
87 sll_int32,
intent(in) :: degree2
88 sll_int32,
intent(in) :: eta1_hermite_continuity
89 sll_int32,
intent(in) :: eta2_hermite_continuity
90 sll_int32,
intent(in) :: eta1_bc_type
91 sll_int32,
intent(in) :: eta2_bc_type
92 sll_real64,
intent(in),
optional :: const_eta1_min_slope
93 sll_real64,
intent(in),
optional :: const_eta1_max_slope
94 sll_real64,
intent(in),
optional :: const_eta2_min_slope
95 sll_real64,
intent(in),
optional :: const_eta2_max_slope
96 sll_real64,
dimension(:),
intent(in),
optional :: eta1_min_slopes
97 sll_real64,
dimension(:),
intent(in),
optional :: eta1_max_slopes
98 sll_real64,
dimension(:),
intent(in),
optional :: eta2_min_slopes
99 sll_real64,
dimension(:),
intent(in),
optional :: eta2_max_slopes
102 sll_allocate(interp, ierr)
114 eta1_hermite_continuity, &
115 eta2_hermite_continuity, &
118 const_eta1_min_slope, &
119 const_eta1_max_slope, &
120 const_eta2_min_slope, &
121 const_eta2_max_slope, &
139 eta1_hermite_continuity, &
140 eta2_hermite_continuity, &
143 const_eta1_min_slope, &
144 const_eta1_max_slope, &
145 const_eta2_min_slope, &
146 const_eta2_max_slope, &
154 sll_int32,
intent(in) :: npts1
155 sll_int32,
intent(in) :: npts2
156 sll_real64,
intent(in) :: eta1_min
157 sll_real64,
intent(in) :: eta1_max
158 sll_real64,
intent(in) :: eta2_min
159 sll_real64,
intent(in) :: eta2_max
160 sll_int32,
intent(in) :: degree1
161 sll_int32,
intent(in) :: degree2
162 sll_int32,
intent(in) :: eta1_hermite_continuity
163 sll_int32,
intent(in) :: eta2_hermite_continuity
164 sll_int32,
intent(in) :: eta1_bc_type
165 sll_int32,
intent(in) :: eta2_bc_type
166 sll_real64,
intent(in),
optional :: const_eta1_min_slope
167 sll_real64,
intent(in),
optional :: const_eta1_max_slope
168 sll_real64,
intent(in),
optional :: const_eta2_min_slope
169 sll_real64,
intent(in),
optional :: const_eta2_max_slope
170 sll_real64,
dimension(:),
intent(in),
optional :: eta1_min_slopes
171 sll_real64,
dimension(:),
intent(in),
optional :: eta1_max_slopes
172 sll_real64,
dimension(:),
intent(in),
optional :: eta2_min_slopes
173 sll_real64,
dimension(:),
intent(in),
optional :: eta2_max_slopes
175 sll_int32 :: deriv_size
178 interp%Nc(1:2) = (/npts1 - 1, npts2 - 1/)
179 interp%degree(1:2) = (/degree1, degree2/)
180 interp%continuity = (/eta1_hermite_continuity, eta2_hermite_continuity/)
181 interp%bc(1:2) = (/eta1_bc_type, eta2_bc_type/)
182 interp%eta_min = (/eta1_min, eta2_min/)
183 interp%eta_max = (/eta1_max, eta2_max/)
187 select case (interp%continuity(i))
189 interp%deriv_size(i) = 3
191 interp%deriv_size(i) = 2
193 print *,
'#bad value for hermite_continuity', interp%continuity
194 print *,
'#in initialize_hermite_interpolation_2d'
196 sll_assert(
present(const_eta1_min_slope))
197 sll_assert(
present(const_eta1_max_slope))
198 sll_assert(
present(const_eta2_min_slope))
199 sll_assert(
present(const_eta2_max_slope))
200 sll_assert(
present(eta1_min_slopes))
201 sll_assert(
present(eta1_max_slopes))
202 sll_assert(
present(eta2_min_slopes))
203 sll_assert(
present(eta2_max_slopes))
206 deriv_size = deriv_size*interp%deriv_size(i)
209 sll_allocate(interp%deriv(deriv_size, npts1, npts2), ierr)
217 sll_real64,
dimension(:, :),
intent(in) :: f
224 print *,
'#interp%continuity=', interp%continuity
226 print *,
'#not implemented for the moment'
227 print *,
'#in sll_s_compute_interpolants_hermite_2d'
236 print *,
'#interp%continuity=', interp%continuity
238 print *,
'#not implemented for the moment'
239 print *,
'#in sll_s_compute_interpolants_hermite_2d'
245 print *,
'#interp%bc=', interp%bc
247 print *,
'#not implemented for the moment'
248 print *,
'#in sll_s_compute_interpolants_hermite_2d'
255 sll_int32,
intent(in)::r, s
256 sll_real64,
dimension(r:s),
intent(out)::w
274 tmp = tmp*real(i - j, f64)
277 tmp = tmp*real(i - j, f64)
281 tmp = tmp*real(-j, f64)
284 tmp = tmp*real(-j, f64)
287 tmp = tmp*real(-j, f64)
295 tmp = tmp*real(i - j, f64)
298 tmp = tmp*real(i - j, f64)
302 tmp = tmp*real(-j, f64)
305 tmp = tmp*real(-j, f64)
308 tmp = tmp*real(-j, f64)
330 sll_real64,
dimension(:, :),
intent(in) :: f
331 sll_int32,
intent(in) :: num_points1
332 sll_int32,
intent(in) :: num_points2
333 sll_int32,
intent(in) :: p
334 sll_real64,
dimension(:, :, :),
intent(out) :: buf
336 sll_real64 :: w_left(-p/2:(p + 1)/2)
337 sll_real64 :: w_right((-p + 1)/2:p/2 + 1)
353 if (((2*p/2) - p) == 0)
then
354 w_right(r_right:s_right) = w_left(r_left:s_left)
356 w_right(r_right:s_right) = -w_left(s_left:r_left:-1)
359 do j = 1, num_points2
360 do i = 1, num_points1
361 buf(1, i, j) = f(i, j)
363 do ii = r_left, s_left
364 ind = modulo(i + ii - 2 + num_points1, num_points1 - 1) + 1
365 tmp = tmp + w_left(ii)*f(ind, j)
369 do ii = r_right, s_right
370 ind = modulo(i + ii - 2 + num_points1, num_points1 - 1) + 1
371 tmp = tmp + w_right(ii)*f(ind, j)
406 sll_int32,
intent(in)::n(2), d(2)
407 sll_real64,
dimension(N(1) + 1, N(2)),
intent(in)::f
408 sll_real64,
dimension(9, N(1) + 1, N(2) + 1),
intent(out)::buf3d
409 sll_real64 ::w_left_1(-d(1)/2:(d(1) + 1)/2), w_right_1((-d(1) + 1)/2:d(1)/2 + 1)
410 sll_real64 ::w_left_2(-d(2)/2:(d(2) + 1)/2), w_right_2((-d(2) + 1)/2:d(2)/2 + 1)
412 sll_int32 ::i, j, ii, r_left(2), r_right(2), s_left(2), s_right(2), ind
420 if ((2*(d(1)/2) - d(1)) == 0)
then
421 w_right_1(r_right(1):s_right(1)) = w_left_1(r_left(1):s_left(1))
423 w_right_1(r_right(1):s_right(1)) = -w_left_1(s_left(1):r_left(1):-1)
426 if ((2*(d(2)/2) - d(2)) == 0)
then
427 w_right_2(r_right(2):s_right(2)) = w_left_2(r_left(2):s_left(2))
429 w_right_2(r_right(2):s_right(2)) = -w_left_2(s_left(2):r_left(2):-1)
437 buf3d(1, i, j) = f(i, j)
439 do ii = r_left(1), s_left(1)
440 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
441 tmp = tmp + w_left_1(ii)*f(ind, j)
445 do ii = r_right(1), s_right(1)
446 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
447 tmp = tmp + w_right_1(ii)*f(ind, j)
455 do ii = r_left(2), s_left(2)
456 ind = modulo(j + ii - 1 + n(2), n(2)) + 1
457 tmp = tmp + w_left_2(ii)*f(i, ind)
461 do ii = r_right(2), s_right(2)
462 ind = modulo(j + ii - 1 + n(2), n(2)) + 1
463 tmp = tmp + w_right_2(ii)*f(i, ind)
472 do ii = r_left(1), s_left(1)
473 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
474 tmp = tmp + w_left_1(ii)*buf3d(4, ind, j)
478 do ii = r_right(1), s_right(1)
479 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
480 tmp = tmp + w_right_1(ii)*buf3d(4, ind, j)
484 do ii = r_left(1), s_left(1)
485 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
486 tmp = tmp + w_left_1(ii)*buf3d(5, ind, j)
490 do ii = r_right(1), s_right(1)
491 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
492 tmp = tmp + w_right_1(ii)*buf3d(5, ind, j)
498 buf3d(:, :, n(2) + 1) = buf3d(:, :, 1)
505 sll_int32,
intent(in)::n(2), d(2)
506 sll_real64,
dimension(N(1) + 1, N(2)),
intent(in)::f
507 sll_real64,
dimension(9, N(1) + 1, N(2) + 1),
intent(out)::buf3d
508 sll_real64 ::w_left_1(-d(1)/2:(d(1) + 1)/2), w_right_1((-d(1) + 1)/2:d(1)/2 + 1)
509 sll_real64 ::w_left_2(-d(2)/2:(d(2) + 1)/2), w_right_2((-d(2) + 1)/2:d(2)/2 + 1)
511 sll_int32 ::i, j, ii, r_left(2), r_right(2), s_left(2), s_right(2), ind
519 if ((2*(d(1)/2) - d(1)) == 0)
then
520 w_right_1(r_right(1):s_right(1)) = w_left_1(r_left(1):s_left(1))
522 w_right_1(r_right(1):s_right(1)) = -w_left_1(s_left(1):r_left(1):-1)
525 if ((2*(d(2)/2) - d(2)) == 0)
then
526 w_right_2(r_right(2):s_right(2)) = w_left_2(r_left(2):s_left(2))
528 w_right_2(r_right(2):s_right(2)) = -w_left_2(s_left(2):r_left(2):-1)
536 buf3d(1, i, j) = f(i, j)
538 do ii = r_left(1), s_left(1)
540 ind = modulo(i + ii - 1 + n(1), n(1)) + 1
541 tmp = tmp + w_left_1(ii)*f(ind, j)
545 do ii = r_right(1), s_right(1)
547 ind = modulo(i + ii - 1 + n(1), n(1)) + 1
548 tmp = tmp + w_right_1(ii)*f(ind, j)
556 do ii = r_left(2), s_left(2)
557 ind = modulo(j + ii - 1 + n(2), n(2)) + 1
558 tmp = tmp + w_left_2(ii)*f(i, ind)
562 do ii = r_right(2), s_right(2)
563 ind = modulo(j + ii - 1 + n(2), n(2)) + 1
564 tmp = tmp + w_right_2(ii)*f(i, ind)
573 do ii = r_left(1), s_left(1)
575 ind = modulo(i + ii - 1 + n(1), n(1)) + 1
576 tmp = tmp + w_left_1(ii)*buf3d(4, ind, j)
580 do ii = r_right(1), s_right(1)
582 ind = modulo(i + ii - 1 + n(1), n(1)) + 1
583 tmp = tmp + w_right_1(ii)*buf3d(4, ind, j)
587 do ii = r_left(1), s_left(1)
589 ind = modulo(i + ii - 1 + n(1), n(1)) + 1
590 tmp = tmp + w_left_1(ii)*buf3d(5, ind, j)
594 do ii = r_right(1), s_right(1)
596 ind = modulo(i + ii - 1 + n(1), n(1)) + 1
597 tmp = tmp + w_right_1(ii)*buf3d(5, ind, j)
603 buf3d(:, :, n(2) + 1) = buf3d(:, :, 1)
610 sll_real64,
intent(in) :: eta1
611 sll_real64,
intent(in) :: eta2
614 sll_real64 :: eta_tmp(2)
617 eta_tmp(1:2) = (/eta1, eta2/)
621 call localize_nat(ii(1), eta_tmp(1), interp%eta_min(1), interp%eta_max(1), interp%Nc(1))
625 call sll_s_localize_per(ii(2), eta_tmp(2), interp%eta_min(2), interp%eta_max(2), interp%Nc(2))
633 sll_int32,
intent(in)::i(2), n(2)
635 sll_real64,
intent(in)::x(2)
636 sll_real64,
intent(out)::fval
637 sll_real64,
dimension(0:8, 0:N(1), 0:N(2))::f
640 sll_real64::w(2, 0:3), tmp(0:3)
641 sll_real64::g(0:3, 0:3)
648 w(s, 0) = (2._f64*x(s) + 1)*(1._f64 - x(s))*(1._f64 - x(s));
649 w(s, 1) = x(s)*x(s)*(3._f64 - 2._f64*x(s))
650 w(s, 2) = x(s)*(1._f64 - x(s))*(1._f64 - x(s))
651 w(s, 3) = x(s)*x(s)*(x(s) - 1._f64)
655 g(0, 0) = f(0, i(1), i(2))
656 g(1, 0) = f(0, i1(1), i(2))
657 g(2, 0) = f(1, i(1), i(2))
658 g(3, 0) = f(2, i(1), i(2))
659 g(0, 1) = f(0, i(1), i1(2))
660 g(1, 1) = f(0, i1(1), i1(2))
661 g(2, 1) = f(1, i(1), i1(2))
662 g(3, 1) = f(2, i(1), i1(2))
663 g(0, 2) = f(3, i(1), i(2))
664 g(1, 2) = f(3, i1(1), i(2))
665 g(2, 2) = f(5, i(1), i(2))
666 g(3, 2) = f(6, i(1), i(2))
667 g(0, 3) = f(4, i(1), i(2))
668 g(1, 3) = f(4, i1(1), i(2))
669 g(2, 3) = f(7, i(1), i(2))
670 g(3, 3) = f(8, i(1), i(2))
673 tmp(s) = w(1, 0)*g(0, s) + w(1, 1)*g(1, s) + w(1, 2)*g(2, s) + w(1, 3)*g(3, s)
676 fval = w(2, 0)*tmp(0) + w(2, 1)*tmp(1) + w(2, 2)*tmp(2) + w(2, 3)*tmp(3)
682 sll_int32,
intent(out)::i
683 sll_real64,
intent(inout)::x
684 sll_real64,
intent(in)::xmin, xmax
685 sll_int32,
intent(in)::n
686 x = (x - xmin)/(xmax - xmin)
687 x = x - real(floor(x), f64)
698 sll_int32,
intent(out)::i
699 sll_real64,
intent(inout)::x
700 sll_real64,
intent(in)::xmin, xmax
701 sll_int32,
intent(in)::n
702 x = (x - xmin)/(xmax - xmin)
704 if (x >= real(n, f64))
then
707 if (x <= 0._f64)
then
subroutine, public sll_s_compute_interpolants_hermite_2d(interp, f)
subroutine, public sll_s_localize_per(i, x, xmin, xmax, N)
subroutine hermite_coef_nat_per(f, buf3d, N, d)
integer, parameter, public sll_p_hermite_c0
subroutine hermite_coef_per_per(f, buf3d, N, d)
integer, parameter, public sll_p_hermite_dirichlet
subroutine, public sll_s_compute_hermite_derivatives_periodic1(f, num_points1, num_points2, p, buf)
integer, parameter, public sll_p_hermite_periodic
subroutine initialize_hermite_interpolation_2d(interp, npts1, npts2, eta1_min, eta1_max, eta2_min, eta2_max, degree1, degree2, eta1_hermite_continuity, eta2_hermite_continuity, eta1_bc_type, eta2_bc_type, const_eta1_min_slope, const_eta1_max_slope, const_eta2_min_slope, const_eta2_max_slope, eta1_min_slopes, eta1_max_slopes, eta2_min_slopes, eta2_max_slopes)
subroutine interpolate_hermite(f, i, x, fval, N)
subroutine localize_nat(i, x, xmin, xmax, N)
type(sll_t_hermite_interpolation_2d) function, pointer, public sll_f_new_hermite_interpolation_2d(npts1, npts2, eta1_min, eta1_max, eta2_min, eta2_max, degree1, degree2, eta1_hermite_continuity, eta2_hermite_continuity, eta1_bc_type, eta2_bc_type, const_eta1_min_slope, const_eta1_max_slope, const_eta2_min_slope, const_eta2_max_slope, eta1_min_slopes, eta1_max_slopes, eta2_min_slopes, eta2_max_slopes)
real(kind=f64) function, public sll_f_interpolate_value_hermite_2d(eta1, eta2, interp)
subroutine, public sll_s_compute_w_hermite(w, r, s)
integer, parameter sll_hermite_c1