28 #include "sll_assert.h"
47 real(
wp),
allocatable :: bcoef(:, :)
55 procedure :: belongs_to_space => f_spline_2d__belongs_to_space
56 procedure :: eval => f_spline_2d__eval
57 procedure :: eval_deriv_x1 => f_spline_2d__eval_deriv_x1
58 procedure :: eval_deriv_x2 => f_spline_2d__eval_deriv_x2
59 procedure :: eval_deriv_x1x2 => f_spline_2d__eval_deriv_x1x2
60 procedure :: eval_array => s_spline_2d__eval_array
61 procedure :: eval_array_deriv_x1 => s_spline_2d__eval_array_deriv_x1
62 procedure :: eval_array_deriv_x2 => s_spline_2d__eval_array_deriv_x2
63 procedure :: eval_array_deriv_x1x2 => s_spline_2d__eval_array_deriv_x1x2
84 self%bspl1 => bsplines_x1
85 self%bspl2 => bsplines_x2
89 associate(n1 => bsplines_x1%ncells, &
90 n2 => bsplines_x2%ncells, &
91 p1 => bsplines_x1%degree, &
92 p2 => bsplines_x2%degree)
94 allocate (self%bcoef(1:n1 + p1, 1:n2 + p2))
111 deallocate (self%bcoef)
124 sll_pure
function f_spline_2d__belongs_to_space(self, bsplines_x1, bsplines_x2)
result(in_space)
127 class(sll_c_bsplines),
intent(in),
target :: bsplines_x1
128 class(sll_c_bsplines),
intent(in),
target :: bsplines_x2
131 in_space =
associated(self%bspl1, bsplines_x1) .and. &
132 associated(self%bspl2, bsplines_x2)
134 end function f_spline_2d__belongs_to_space
143 sll_pure
function f_spline_2d__eval(self, x1, x2)
result(y)
146 real(wp),
intent(in) :: x1
147 real(wp),
intent(in) :: x2
155 real(wp) :: values1(1:self%bspl1%degree + 1)
156 real(wp) :: values2(1:self%bspl2%degree + 1)
159 call self%bspl1%eval_basis(x1, values1, jmin(1))
160 call self%bspl2%eval_basis(x2, values2, jmin(2))
162 jmax(1) = jmin(1) + self%bspl1%degree
163 jmax(2) = jmin(2) + self%bspl2%degree
167 associate(bcoef => self%bcoef(jmin(1):jmax(1), jmin(2):jmax(2)))
169 do k2 = 1, 1 + self%bspl2%degree
170 do k1 = 1, 1 + self%bspl1%degree
171 y = y + bcoef(k1, k2)*values1(k1)*values2(k2)
176 end function f_spline_2d__eval
185 sll_pure
function f_spline_2d__eval_deriv_x1(self, x1, x2)
result(y)
188 real(wp),
intent(in) :: x1
189 real(wp),
intent(in) :: x2
197 real(wp) :: derivs1(1:self%bspl1%degree + 1)
198 real(wp) :: values2(1:self%bspl2%degree + 1)
201 call self%bspl1%eval_deriv(x1, derivs1, jmin(1))
202 call self%bspl2%eval_basis(x2, values2, jmin(2))
204 jmax(1) = jmin(1) + self%bspl1%degree
205 jmax(2) = jmin(2) + self%bspl2%degree
209 associate(bcoef => self%bcoef(jmin(1):jmax(1), jmin(2):jmax(2)))
211 do k2 = 1, 1 + self%bspl2%degree
212 do k1 = 1, 1 + self%bspl1%degree
213 y = y + bcoef(k1, k2)*derivs1(k1)*values2(k2)
218 end function f_spline_2d__eval_deriv_x1
227 sll_pure
function f_spline_2d__eval_deriv_x2(self, x1, x2)
result(y)
230 real(wp),
intent(in) :: x1
231 real(wp),
intent(in) :: x2
239 real(wp) :: values1(1:self%bspl1%degree + 1)
240 real(wp) :: derivs2(1:self%bspl2%degree + 1)
243 call self%bspl1%eval_basis(x1, values1, jmin(1))
244 call self%bspl2%eval_deriv(x2, derivs2, jmin(2))
246 jmax(1) = jmin(1) + self%bspl1%degree
247 jmax(2) = jmin(2) + self%bspl2%degree
251 associate(bcoef => self%bcoef(jmin(1):jmax(1), jmin(2):jmax(2)))
253 do k2 = 1, 1 + self%bspl2%degree
254 do k1 = 1, 1 + self%bspl1%degree
255 y = y + bcoef(k1, k2)*values1(k1)*derivs2(k2)
260 end function f_spline_2d__eval_deriv_x2
269 sll_pure
function f_spline_2d__eval_deriv_x1x2(self, x1, x2)
result(y)
272 real(wp),
intent(in) :: x1
273 real(wp),
intent(in) :: x2
281 real(wp) :: derivs1(1:self%bspl1%degree + 1)
282 real(wp) :: derivs2(1:self%bspl2%degree + 1)
285 call self%bspl1%eval_deriv(x1, derivs1, jmin(1))
286 call self%bspl2%eval_deriv(x2, derivs2, jmin(2))
288 jmax(1) = jmin(1) + self%bspl1%degree
289 jmax(2) = jmin(2) + self%bspl2%degree
293 associate(bcoef => self%bcoef(jmin(1):jmax(1), jmin(2):jmax(2)))
295 do k2 = 1, 1 + self%bspl2%degree
296 do k1 = 1, 1 + self%bspl1%degree
297 y = y + bcoef(k1, k2)*derivs1(k1)*derivs2(k2)
302 end function f_spline_2d__eval_deriv_x1x2
311 sll_pure
subroutine s_spline_2d__eval_array(self, x1, x2, y)
314 real(wp),
intent(in) :: x1(:, :)
315 real(wp),
intent(in) :: x2(:, :)
316 real(wp),
intent(out) :: y(:, :)
320 sll_assert(
size(x1, 1) ==
size(y, 1))
321 sll_assert(
size(x1, 2) ==
size(y, 2))
322 sll_assert(
size(x2, 1) ==
size(y, 1))
323 sll_assert(
size(x2, 2) ==
size(y, 2))
325 do i2 = 1,
size(x2, 2)
326 do i1 = 1,
size(x1, 1)
327 y(i1, i2) = f_spline_2d__eval(self, x1(i1, i2), x2(i1, i2))
331 end subroutine s_spline_2d__eval_array
341 sll_pure
subroutine s_spline_2d__eval_array_deriv_x1(self, x1, x2, y)
344 real(wp),
intent(in) :: x1(:, :)
345 real(wp),
intent(in) :: x2(:, :)
346 real(wp),
intent(out) :: y(:, :)
350 sll_assert(
size(x1, 1) ==
size(y, 1))
351 sll_assert(
size(x1, 2) ==
size(y, 2))
352 sll_assert(
size(x2, 1) ==
size(y, 1))
353 sll_assert(
size(x2, 2) ==
size(y, 2))
355 do i2 = 1,
size(x2, 2)
356 do i1 = 1,
size(x1, 1)
357 y(i1, i2) = f_spline_2d__eval_deriv_x1(self, x1(i1, i2), x2(i1, i2))
361 end subroutine s_spline_2d__eval_array_deriv_x1
371 sll_pure
subroutine s_spline_2d__eval_array_deriv_x2(self, x1, x2, y)
374 real(wp),
intent(in) :: x1(:, :)
375 real(wp),
intent(in) :: x2(:, :)
376 real(wp),
intent(out) :: y(:, :)
380 sll_assert(
size(x1, 1) ==
size(y, 1))
381 sll_assert(
size(x1, 2) ==
size(y, 2))
382 sll_assert(
size(x2, 1) ==
size(y, 1))
383 sll_assert(
size(x2, 2) ==
size(y, 2))
385 do i2 = 1,
size(x2, 2)
386 do i1 = 1,
size(x1, 1)
387 y(i1, i2) = f_spline_2d__eval_deriv_x2(self, x1(i1, i2), x2(i1, i2))
391 end subroutine s_spline_2d__eval_array_deriv_x2
401 sll_pure
subroutine s_spline_2d__eval_array_deriv_x1x2(self, x1, x2, y)
404 real(wp),
intent(in) :: x1(:, :)
405 real(wp),
intent(in) :: x2(:, :)
406 real(wp),
intent(out) :: y(:, :)
410 sll_assert(
size(x1, 1) ==
size(y, 1))
411 sll_assert(
size(x1, 2) ==
size(y, 2))
412 sll_assert(
size(x2, 1) ==
size(y, 1))
413 sll_assert(
size(x2, 2) ==
size(y, 2))
415 do i2 = 1,
size(x2, 2)
416 do i1 = 1,
size(x1, 1)
417 y(i1, i2) = f_spline_2d__eval_deriv_x1x2(self, x1(i1, i2), x2(i1, i2))
421 end subroutine s_spline_2d__eval_array_deriv_x1x2
Abstract class for B-splines of arbitrary degree.
Module for tensor-product 2D splines.
subroutine s_spline_2d__free(self)
Destroy 2D spline (re-initialization is possible afterwards)
integer, parameter wp
Working precision.
subroutine s_spline_2d__init(self, bsplines_x1, bsplines_x2)
Initialize 2D spline object as element of span(B-splines)
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.