9 #include "sll_assert.h"
10 #include "sll_errors.h"
58 real(
wp),
allocatable :: derivs_x1_min(:, :)
59 real(
wp),
allocatable :: derivs_x1_max(:, :)
60 real(
wp),
allocatable :: derivs_x2_min(:, :)
61 real(
wp),
allocatable :: derivs_x2_max(:, :)
62 real(
wp),
allocatable :: mixed_derivs_a(:, :)
63 real(
wp),
allocatable :: mixed_derivs_b(:, :)
64 real(
wp),
allocatable :: mixed_derivs_c(:, :)
65 real(
wp),
allocatable :: mixed_derivs_d(:, :)
76 integer,
private :: bc_xmin(2)
77 integer,
private :: bc_xmax(2)
78 integer,
private :: nbc_xmin(2)
79 integer,
private :: nbc_xmax(2)
84 real(
wp),
allocatable,
private :: bwork(:, :)
118 integer,
intent(in) :: degree(2)
119 integer,
intent(in) :: bc_xmin(2)
120 integer,
intent(in) :: bc_xmax(2)
121 integer,
intent(in) :: nipts(2)
122 integer,
intent(out) :: ncells(2)
128 degree(i), bc_xmin(i), bc_xmax(i), nipts(i), ncells(i))
151 integer,
intent(in) :: bc_xmin(2)
152 integer,
intent(in) :: bc_xmax(2)
160 call self%spline1%init(bspl1)
161 call self%spline2%init(bspl2)
164 call self%interp1%init(bspl1, bc_xmin(1), bc_xmax(1))
165 call self%interp2%init(bspl2, bc_xmin(2), bc_xmax(2))
167 associate(n1 => bspl1%ncells, &
168 n2 => bspl2%ncells, &
169 p1 => bspl1%degree, &
173 self%bc_xmin = bc_xmin
174 self%bc_xmax = bc_xmax
178 allocate (self%bwork(1:n2 + p2, 1:n1 + p1))
183 self%nbc_xmin = merge([p1, p2]/2, 0, bc_xmin == sll_p_hermite)
184 self%nbc_xmax = merge([p1, p2]/2, 0, bc_xmax == sll_p_hermite)
203 call self%spline1%free()
204 call self%spline2%free()
205 call self%interp1%free()
206 call self%interp2%free()
209 deallocate (self%bwork)
222 real(wp),
allocatable,
intent(out) :: tau1(:)
223 real(wp),
allocatable,
intent(out) :: tau2(:)
225 call self%interp1%get_interp_points(tau1)
226 call self%interp2%get_interp_points(tau2)
242 spline, gtau, boundary_data)
245 type(sll_t_spline_2d),
intent(inout) :: spline
246 real(wp),
intent(in) :: gtau(:, :)
249 character(len=*),
parameter :: &
250 this_sub_name =
"sll_t_spline_interpolator_2d % compute_interpolant"
255 if (.not.
present(boundary_data))
then
256 if (self%bc_xmin(1) == sll_p_hermite)
then
257 sll_error(this_sub_name,
"Hermite BC at x1_min requires derivatives")
258 else if (self%bc_xmax(1) == sll_p_hermite)
then
259 sll_error(this_sub_name,
"Hermite BC at x1_max requires derivatives")
260 else if (self%bc_xmin(2) == sll_p_hermite)
then
261 sll_error(this_sub_name,
"Hermite BC at x2_min requires derivatives")
262 else if (self%bc_xmax(2) == sll_p_hermite)
then
263 sll_error(this_sub_name,
"Hermite BC at x2_max requires derivatives")
267 associate(w => spline%bcoef, &
269 n1 => self%bspl1%nbasis, &
270 n2 => self%bspl2%nbasis, &
271 a1 => self%nbc_xmin(1), &
272 a2 => self%nbc_xmin(2), &
273 b1 => self%nbc_xmax(1), &
274 b2 => self%nbc_xmax(2), &
275 p1 => self%bspl1%degree, &
276 p2 => self%bspl2%degree)
278 sll_assert(all(shape(gtau) == [n1 - a1 - b1, n2 - a2 - b2]))
279 sll_assert(spline%belongs_to_space(self%bspl1, self%bspl2))
284 sll_assert(
present(boundary_data))
285 sll_assert(
allocated(boundary_data%derivs_x1_min))
286 sll_assert(
size(boundary_data%derivs_x1_min, 1) == a1)
287 sll_assert(
size(boundary_data%derivs_x1_min, 2) == n2 - a2 - b2)
291 sll_assert(
present(boundary_data))
292 sll_assert(
allocated(boundary_data%derivs_x1_max))
293 sll_assert(
size(boundary_data%derivs_x1_max, 1) == b1)
294 sll_assert(
size(boundary_data%derivs_x1_max, 2) == n2 - a2 - b2)
298 sll_assert(
present(boundary_data))
299 sll_assert(
allocated(boundary_data%derivs_x2_min))
300 sll_assert(
size(boundary_data%derivs_x2_min, 1) == a2)
301 sll_assert(
size(boundary_data%derivs_x2_min, 2) == n1 - a1 - b1)
305 sll_assert(
present(boundary_data))
306 sll_assert(
allocated(boundary_data%derivs_x2_max))
307 sll_assert(
size(boundary_data%derivs_x2_max, 1) == b2)
308 sll_assert(
size(boundary_data%derivs_x2_max, 2) == n1 - a1 - b1)
311 if (a1 > 0 .and. a2 > 0)
then
312 sll_assert(
allocated(boundary_data%mixed_derivs_a))
313 sll_assert(
size(boundary_data%mixed_derivs_a, 1) == a1)
314 sll_assert(
size(boundary_data%mixed_derivs_a, 2) == a2)
317 if (b1 > 0 .and. a2 > 0)
then
318 sll_assert(
allocated(boundary_data%mixed_derivs_b))
319 sll_assert(
size(boundary_data%mixed_derivs_b, 1) == b1)
320 sll_assert(
size(boundary_data%mixed_derivs_b, 2) == a2)
323 if (a1 > 0 .and. b2 > 0)
then
324 sll_assert(
allocated(boundary_data%mixed_derivs_c))
325 sll_assert(
size(boundary_data%mixed_derivs_c, 1) == a1)
326 sll_assert(
size(boundary_data%mixed_derivs_c, 2) == b2)
329 if (b1 > 0 .and. b2 > 0)
then
330 sll_assert(
allocated(boundary_data%mixed_derivs_d))
331 sll_assert(
size(boundary_data%mixed_derivs_d, 1) == b1)
332 sll_assert(
size(boundary_data%mixed_derivs_d, 2) == b2)
336 w(1 + a1:n1 - b1, 1 + a2:n2 - b2) = gtau(:, :)
339 if (
present(boundary_data))
then
341 if (a1 > 0) w(1:a1, 1 + a2:n2 - b2) = boundary_data%derivs_x1_min(1:a1, :)
342 if (b1 > 0) w(n1 - b1 + 1:n1, 1 + a2:n2 - b2) = boundary_data%derivs_x1_max(1:b1, :)
344 if (a2 > 0) w(1 + a1:n1 - b1, 1:a2) = transpose(boundary_data%derivs_x2_min(1:a2, :))
345 if (b2 > 0) w(1 + a1:n1 - b1, n2 - b2 + 1:n2) = transpose(boundary_data%derivs_x2_max(1:b2, :))
347 if (a1 > 0 .and. a2 > 0) w(1:a1, 1:a2) = boundary_data%mixed_derivs_a(:, :)
348 if (b1 > 0 .and. a2 > 0) w(n1 - b1 + 1:n1, 1:a2) = boundary_data%mixed_derivs_b(:, :)
349 if (a1 > 0 .and. b2 > 0) w(1:a1, n2 - b2 + 1:n2) = boundary_data%mixed_derivs_c(:, :)
350 if (b1 > 0 .and. b2 > 0) w(n1 - b1 + 1:n1, n2 - b2 + 1:n2) = boundary_data%mixed_derivs_d(:, :)
358 call self%interp1%compute_interpolant( &
359 spline=self%spline1, &
360 gtau=w(1 + a1:n1 - b1, i2), &
361 derivs_xmin=w(1:a1, i2), &
362 derivs_xmax=w(n1 - b1 + 1:n1, i2))
364 w(1:n1, i2) = self%spline1%bcoef(1:n1)
374 call self%interp2%compute_interpolant( &
375 spline=self%spline2, &
376 gtau=wt(1 + a2:n2 - b2, i1), &
377 derivs_xmin=wt(1:a2, i1), &
378 derivs_xmax=wt(n2 - b2 + 1:n2, i1))
380 wt(1:n2, i1) = self%spline2%bcoef(1:n2)
385 if (self%bc_xmin(1) == sll_p_periodic)
then
386 wt(:, n1 + 1:n1 + p1) = wt(:, 1:p1)
392 if (self%bc_xmin(2) == sll_p_periodic)
then
393 w(:, n2 + 1:n2 + p2) = w(:, 1:p2)
Describe different boundary conditions.
Abstract class for B-splines of arbitrary degree.
Module for 1D splines, linear combination of B-spline functions.
Module for tensor-product 2D splines.
Interpolator for 1D splines of arbitrary degree, on uniform and non-uniform grids.
subroutine, public sll_s_spline_1d_compute_num_cells(degree, bc_xmin, bc_xmax, nipts, ncells)
Calculate number of cells from number of interpolation points.
Interpolator for 2D tensor-product splines of arbitrary degree, on uniform and non-uniform grids (dir...
subroutine, public sll_s_spline_2d_compute_num_cells(degree, bc_xmin, bc_xmax, nipts, ncells)
Calculate number of cells from number of interpolation points.
subroutine s_spline_interpolator_2d__compute_interpolant(self, spline, gtau, boundary_data)
Compute interpolating 2D spline.
integer, parameter wp
Working precision.
subroutine s_spline_interpolator_2d__init(self, bspl1, bspl2, bc_xmin, bc_xmax)
Initialize a 2D tensor-product spline interpolator object.
subroutine s_spline_interpolator_2d__free(self)
Destroy local objects and free allocated memory.
subroutine s_spline_interpolator_2d__get_interp_points(self, tau1, tau2)
Get coordinates of interpolation points (2D tensor grid)
Module to select the kind parameter.
integer, parameter, public f64
f64 is the kind type for 64-bit reals (double precision)
Abstract type, B-splines.
Container for 2D boundary condition data: . x1-derivatives at x1_min and x1_max, for all values of x2...
2D tensor-product spline interpolator