coord_transform/m_coord_transform_toroidal_bspline.f90
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | !> @brief Module for the toroidal B-spline coordinate transformation | ||
| 2 | module m_coord_transform_toroidal_bspline | ||
| 3 | use m_common, only: wp, pi | ||
| 4 | use m_bspline_basis, only: BSplineSpace, BSplineFun, evaluate | ||
| 5 | use m_coord_transform_abstract, only: CoordTransformAbstract | ||
| 6 | |||
| 7 | implicit none | ||
| 8 | |||
| 9 | private | ||
| 10 | public :: ToroidalBSplineTransform | ||
| 11 | public :: toroidal_bspline_transform, toroidal_bspline_inverse_transform, toroidal_bspline_jacobian | ||
| 12 | public :: toroidal_bspline_jacobian_matrix, toroidal_bspline_jacobian_matrix_inv | ||
| 13 | public :: toroidal_bspline_G_matrix, toroidal_bspline_G_matrix_inv | ||
| 14 | |||
| 15 | type, extends(CoordTransformAbstract) :: ToroidalBSplineTransform | ||
| 16 | |||
| 17 | !> @brief The major radius of the toroidal coordinate system | ||
| 18 | real(wp) :: major_radius | ||
| 19 | |||
| 20 | !> @brief The minor radius of the toroidal coordinate system | ||
| 21 | real(wp) :: minor_radius | ||
| 22 | |||
| 23 | !> @brief The B-spline approximation of the cosine function in the yp-coordinate | ||
| 24 | type(BSplineFun) :: cos_bspline | ||
| 25 | |||
| 26 | !> @brief The B-spline approximation of the sine function in the yp-coordinate | ||
| 27 | type(BSplineFun) :: sin_bspline | ||
| 28 | |||
| 29 | contains | ||
| 30 | ! procedure, private, non_overridable :: twopi => toroidal_twopi | ||
| 31 | |||
| 32 | end type ToroidalBSplineTransform | ||
| 33 | |||
| 34 | interface ToroidalBSplineTransform | ||
| 35 | module procedure init_ToroidalBSplineTransform | ||
| 36 | end interface ToroidalBSplineTransform | ||
| 37 | |||
| 38 | interface | ||
| 39 | !> @brief Create a new ToroidalBSplineTransform object | ||
| 40 | !> @param[in] major_radius The major radius of the toroidal coordinate system | ||
| 41 | !> @param[in] minor_radius The minor radius of the toroidal coordinate system | ||
| 42 | !> @param[in] bspline The periodic B-spline basis in the yp-coordinate for the transformation | ||
| 43 | !> @return A new ToroidalBSplineTransform object | ||
| 44 | module function init_ToroidalBSplineTransform(major_radius, minor_radius, bspline) result(this) | ||
| 45 | real(wp), intent(in) :: major_radius, minor_radius | ||
| 46 | type(BSplineSpace), intent(in) :: bspline | ||
| 47 | type(ToroidalBSplineTransform) :: this | ||
| 48 | end function init_ToroidalBSplineTransform | ||
| 49 | |||
| 50 | !> @brief The i-th component of the B-spline approximated transformation | ||
| 51 | !> @param[in] this The ToroidalBSplineTransform object | ||
| 52 | !> @param[in] i The index of the component | ||
| 53 | !> @param[in] xp The radial coordinate | ||
| 54 | !> @param[in] yp The poloidal angle | ||
| 55 | !> @param[in] zp The toroidal angle | ||
| 56 | !> @return The i-th component of the B-spline approximated transformation | ||
| 57 | module pure real(wp) function toroidal_bspline_transform(this, i, xp, yp, zp) result(ans) | ||
| 58 | !$acc routine seq | ||
| 59 | type(ToroidalBSplineTransform), intent(in) :: this | ||
| 60 | integer, intent(in) :: i | ||
| 61 | real(wp), intent(in) :: xp, yp, zp | ||
| 62 | end function toroidal_bspline_transform | ||
| 63 | |||
| 64 | !> @brief The i-th component of the inverse B-spline approximated transformation | ||
| 65 | !> @param[in] this The ToroidalBSplineTransform object | ||
| 66 | !> @param[in] i The index of the component | ||
| 67 | !> @param[in] x The x coordinate | ||
| 68 | !> @param[in] y The y coordinate | ||
| 69 | !> @param[in] z The z coordinate | ||
| 70 | !> @return The i-th coordinate | ||
| 71 | module pure real(wp) function toroidal_bspline_inverse_transform(this, i, x, y, z) result(ans) | ||
| 72 | !$acc routine seq | ||
| 73 | type(ToroidalBSplineTransform), intent(in) :: this | ||
| 74 | integer, intent(in) :: i | ||
| 75 | real(wp), intent(in) :: x, y, z | ||
| 76 | end function toroidal_bspline_inverse_transform | ||
| 77 | |||
| 78 | !> @brief The Jacobian determinant of the B-spline approximated transformation | ||
| 79 | !> @param[in] this The ToroidalBSplineTransform object | ||
| 80 | !> @param[in] xp The radial coordinate | ||
| 81 | !> @param[in] yp The poloidal angle | ||
| 82 | !> @param[in] zp The toroidal angle | ||
| 83 | !> @return The Jacobian determinant | ||
| 84 | module pure real(wp) function toroidal_bspline_jacobian(this, xp, yp, zp) result(ans) | ||
| 85 | !$acc routine seq | ||
| 86 | type(ToroidalBSplineTransform), intent(in) :: this | ||
| 87 | real(wp), intent(in) :: xp, yp, zp | ||
| 88 | end function toroidal_bspline_jacobian | ||
| 89 | |||
| 90 | !> @brief The B-spline approximation of cos * sin' - sin * cos' \approx 2\pi | ||
| 91 | !> @param[in] this The ToroidalBSplineTransform object | ||
| 92 | !> @param[in] yp The poloidal angle | ||
| 93 | !> @return The B-spline approximation of cos * sin' - sin * cos' | ||
| 94 | module pure real(wp) function toroidal_twopi(this, yp) result(ans) | ||
| 95 | !$acc routine seq | ||
| 96 | type(ToroidalBSplineTransform), intent(in) :: this | ||
| 97 | real(wp), intent(in) :: yp | ||
| 98 | end function toroidal_twopi | ||
| 99 | |||
| 100 | !> @brief The (i, j)-th component of the Jacobian matrix of the B-spline approximated transformation | ||
| 101 | !> @param[in] this The ToroidalBSplineTransform object | ||
| 102 | !> @param[in] i The row index | ||
| 103 | !> @param[in] j The column index | ||
| 104 | !> @param[in] xp The radial coordinate | ||
| 105 | !> @param[in] yp The poloidal angle | ||
| 106 | !> @param[in] zp The toroidal angle | ||
| 107 | !> @return The (i, j)-th component of the Jacobian matrix | ||
| 108 | module pure real(wp) function toroidal_bspline_jacobian_matrix(this, i, j, xp, yp, zp) result(ans) | ||
| 109 | !$acc routine seq | ||
| 110 | type(ToroidalBSplineTransform), intent(in) :: this | ||
| 111 | integer, intent(in) :: i, j | ||
| 112 | real(wp), intent(in) :: xp, yp, zp | ||
| 113 | end function toroidal_bspline_jacobian_matrix | ||
| 114 | |||
| 115 | !> @brief The (i, j)-th component of the inverse of the Jacobian matrix of the B-spline approximated transformation | ||
| 116 | !> @param[in] this The ToroidalBSplineTransform object | ||
| 117 | !> @param[in] i The row index | ||
| 118 | !> @param[in] j The column index | ||
| 119 | !> @param[in] xp The radial coordinate | ||
| 120 | !> @param[in] yp The poloidal angle | ||
| 121 | !> @param[in] zp The toroidal angle | ||
| 122 | !> @return The (i, j)-th component of the inverse of the Jacobian matrix | ||
| 123 | module pure real(wp) function toroidal_bspline_jacobian_matrix_inv(this, i, j, xp, yp, zp) result(ans) | ||
| 124 | !$acc routine seq | ||
| 125 | type(ToroidalBSplineTransform), intent(in) :: this | ||
| 126 | integer, intent(in) :: i, j | ||
| 127 | real(wp), intent(in) :: xp, yp, zp | ||
| 128 | end function toroidal_bspline_jacobian_matrix_inv | ||
| 129 | |||
| 130 | !> @brief The (i, j)-th component of the metric tensor of the B-spline approximated transformation | ||
| 131 | !> @param[in] this The ToroidalBSplineTransform object | ||
| 132 | !> @param[in] i The row index | ||
| 133 | !> @param[in] j The column index | ||
| 134 | !> @param[in] xp The radial coordinate | ||
| 135 | !> @param[in] yp The poloidal angle | ||
| 136 | !> @param[in] zp The toroidal angle | ||
| 137 | !> @return The (i, j)-th component of the metric tensor | ||
| 138 | module pure real(wp) function toroidal_bspline_G_matrix(this, i, j, xp, yp, zp) result(ans) | ||
| 139 | !$acc routine seq | ||
| 140 | type(ToroidalBSplineTransform), intent(in) :: this | ||
| 141 | integer, intent(in) :: i, j | ||
| 142 | real(wp), intent(in) :: xp, yp, zp | ||
| 143 | end function toroidal_bspline_G_matrix | ||
| 144 | |||
| 145 | !> @brief The (i, j)-th component of the inverse metric tensor of the B-spline approximated transformation | ||
| 146 | !> @param[in] this The ToroidalBSplineTransform object | ||
| 147 | !> @param[in] i The row index | ||
| 148 | !> @param[in] j The column index | ||
| 149 | !> @param[in] xp The radial coordinate | ||
| 150 | !> @param[in] yp The poloidal angle | ||
| 151 | !> @param[in] zp The toroidal angle | ||
| 152 | !> @return The (i, j)-th component of the inverse metric tensor | ||
| 153 | module pure real(wp) function toroidal_bspline_G_matrix_inv(this, i, j, xp, yp, zp) result(ans) | ||
| 154 | !$acc routine seq | ||
| 155 | type(ToroidalBSplineTransform), intent(in) :: this | ||
| 156 | integer, intent(in) :: i, j | ||
| 157 | real(wp), intent(in) :: xp, yp, zp | ||
| 158 | end function toroidal_bspline_G_matrix_inv | ||
| 159 | |||
| 160 | end interface | ||
| 161 | |||
| 162 | ✗ | end module m_coord_transform_toroidal_bspline | |
| 163 |