3 #include "sll_assert.h"
4 #include "sll_errors.h"
28 procedure(i_fun_eval),
deferred :: eval
29 procedure(i_fun_jmat),
deferred :: jmat
33 procedure :: jdet => f_singular_mapping__jdet
41 sll_pure
function i_fun_eval(self, eta)
result(x)
44 real(
wp),
intent(in) :: eta(2)
46 end function i_fun_eval
48 sll_pure
function i_fun_jmat(self, eta)
result(jmat)
51 real(
wp),
intent(in) :: eta(2)
52 real(
wp) :: jmat(2, 2)
53 end function i_fun_jmat
58 integer,
intent(in) :: n1
59 integer,
intent(in) :: n2
69 sll_pure
function f_singular_mapping__jdet(self, eta)
result(jdet)
71 real(wp),
intent(in) :: eta(2)
74 real(wp) :: jmat(2, 2)
78 jdet = jmat(1, 1)*jmat(2, 2) - jmat(1, 2)*jmat(2, 1)
80 end function f_singular_mapping__jdet
85 real(
wp),
intent(in) :: x(2)
86 real(
wp),
intent(in) :: eta0(2)
87 real(
wp),
intent(in) :: tol
88 integer,
intent(in) :: maxiter
92 real(
wp) :: eta_new(2), x_new(2), temp(2), delx(2)
93 real(
wp) :: jmat(2, 2)
97 character(len=*),
parameter :: this_fun_name =
"sll_c_singular_mapping % eval_inverse"
98 character(len=64) :: err_msg
103 if (abs(eta0(1)) < 1.0e-14_wp)
then
104 eta_new(1) = sqrt(x(1)**2 + x(2)**2)
105 eta_new(2) = modulo(atan2(x(2), x(1)),
sll_p_twopi)
114 temp = self%eval(eta_new) - x
117 jmat = self%jmat(eta_new)
120 jdet = self%jdet(eta_new)
123 delx(1) = (jmat(2, 2)*temp(1) - jmat(1, 2)*temp(2))/jdet
124 delx(2) = (-jmat(2, 1)*temp(1) + jmat(1, 1)*temp(2))/jdet
133 if (eta(1) < 0.0_wp) then; eta(1) = 1.0e-14_wp;
end if
134 if (eta(1) > 1.0_wp) then; eta(1) = 1.0_wp; return;
end if
137 x_new = self%eval(eta)
138 if (norm2(x_new - x) < tol)
return
145 write (err_msg,
'(a,i0,a)')
"Newton method did not converge after ", maxiter,
" iterations"
146 sll_error(this_fun_name, err_msg)
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_twopi
Implements the functions to write hdf5 file to store heavy data.
integer, parameter wp
Working precision.
real(wp) function, dimension(2) f_singular_mapping__eval_inverse(self, x, eta0, tol, maxiter)
Module to select the kind parameter.
integer, parameter, public f64
f64 is the kind type for 64-bit reals (double precision)
Opaque object around HDF5 file id.
Abstract type, singular mapping.