3 #include "sll_assert.h"
26 real(
wp) :: eps = 1.0e-12_wp
34 procedure :: eval => s_ellipt_2d_cartesian_gradient__eval
47 real(wp),
optional,
intent(in) :: eps
49 self%mapping_discrete => mapping_discrete
51 self%spline_2d_phi => spline_2d_phi
53 if (
present(eps)) self%eps = eps
60 sll_pure
function s_ellipt_2d_cartesian_gradient__eval(self, eta)
result(gradient)
62 real(wp),
intent(in) :: eta(2)
63 real(wp) :: gradient(2)
65 real(wp) :: jdet, d1, d2, d3, d4, d5, d6, th1, th2, eps, grad_0(2), grad_eps(2), jmat(2, 2)
69 if (eta(1) == 0.0_wp)
then
74 d1 = self%spline_2d_phi%eval_deriv_x1(eta(1), th1)
75 d2 = self%spline_2d_phi%eval_deriv_x1(eta(1), th2)
77 jmat = self%mapping_discrete%jmat((/eta(1), th1/))
82 jmat = self%mapping_discrete%jmat((/eta(1), th2/))
87 gradient(1) = (d4*d2 - d1*d6)/(d4*d5 - d3*d6)
88 gradient(2) = (d1*d5 - d3*d2)/(d4*d5 - d3*d6)
91 else if (0.0_wp < eta(1) .and. eta(1) < eps)
then
96 d1 = self%spline_2d_phi%eval_deriv_x1(0.0_wp, th1)
97 d2 = self%spline_2d_phi%eval_deriv_x1(0.0_wp, th2)
99 jmat = self%mapping_discrete%jmat((/0.0_wp, th1/))
104 jmat = self%mapping_discrete%jmat((/0.0_wp, th2/))
110 grad_0(1) = (d4*d2 - d1*d6)/(d4*d5 - d3*d6)
111 grad_0(2) = (d1*d5 - d3*d2)/(d4*d5 - d3*d6)
113 jmat = self%mapping_discrete%jmat((/eps, eta(2)/))
114 jdet = self%mapping_discrete%jdet((/eps, eta(2)/))
117 grad_eps(1) = (jmat(2, 2)*self%spline_2d_phi%eval_deriv_x1(eps, eta(2)) &
118 - jmat(2, 1)*self%spline_2d_phi%eval_deriv_x2(eps, eta(2)))/jdet
119 grad_eps(2) = (-jmat(1, 2)*self%spline_2d_phi%eval_deriv_x1(eps, eta(2)) &
120 + jmat(1, 1)*self%spline_2d_phi%eval_deriv_x2(eps, eta(2)))/jdet
123 gradient(1) = (1.0_wp - eta(1)/eps)*grad_0(1) + eta(1)/eps*grad_eps(1)
124 gradient(2) = (1.0_wp - eta(1)/eps)*grad_0(2) + eta(1)/eps*grad_eps(2)
127 else if (eps <= eta(1))
then
129 jmat = self%mapping_discrete%jmat(eta)
130 jdet = self%mapping_discrete%jdet(eta)
133 gradient(1) = (jmat(2, 2)*self%spline_2d_phi%eval_deriv_x1(eta(1), eta(2)) &
134 - jmat(2, 1)*self%spline_2d_phi%eval_deriv_x2(eta(1), eta(2)))/jdet
135 gradient(2) = (-jmat(1, 2)*self%spline_2d_phi%eval_deriv_x1(eta(1), eta(2)) &
136 + jmat(1, 1)*self%spline_2d_phi%eval_deriv_x2(eta(1), eta(2)))/jdet
140 end function s_ellipt_2d_cartesian_gradient__eval
146 nullify (self%mapping_discrete)
148 nullify (self%spline_2d_phi)
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
subroutine s_ellipt_2d_cartesian_gradient__free(self)
subroutine s_ellipt_2d_cartesian_gradient__init(self, mapping_discrete, spline_2d_phi, eps)
Module for tensor-product 2D splines.
Module to select the kind parameter.
integer, parameter, public f64
f64 is the kind type for 64-bit reals (double precision)
Concrete type, discrete singular mapping.