| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | module cartesian_coordinates | ||
| 2 | !> Cartesian coordinate system implementation. | ||
| 3 | !> Single responsibility: identity coordinate system where all transforms | ||
| 4 | !> are trivial (covariant basis = identity matrix). | ||
| 5 | |||
| 6 | use, intrinsic :: iso_fortran_env, only: dp => real64 | ||
| 7 | use libneo_coordinates, only: coordinate_system_t | ||
| 8 | use cylindrical_cartesian, only: cart_to_cyl, cyl_to_cart | ||
| 9 | |||
| 10 | implicit none | ||
| 11 | |||
| 12 | type, extends(coordinate_system_t) :: cartesian_coordinate_system_t | ||
| 13 | contains | ||
| 14 | procedure :: evaluate_cart => cartesian_evaluate_cart | ||
| 15 | procedure :: evaluate_cyl => cartesian_evaluate_cyl | ||
| 16 | procedure :: covariant_basis => cartesian_covariant_basis | ||
| 17 | procedure :: metric_tensor => cartesian_metric_tensor | ||
| 18 | procedure :: from_cyl => cartesian_from_cyl | ||
| 19 | end type cartesian_coordinate_system_t | ||
| 20 | |||
| 21 | contains | ||
| 22 | |||
| 23 | 9 | subroutine cartesian_evaluate_cart(self, u, x) | |
| 24 | !> Return Cartesian position (identity for Cartesian coords). | ||
| 25 | class(cartesian_coordinate_system_t), intent(in) :: self | ||
| 26 | real(dp), intent(in) :: u(3) | ||
| 27 | real(dp), intent(out) :: x(3) | ||
| 28 | |||
| 29 | 9 | x = u | |
| 30 | 9 | end subroutine cartesian_evaluate_cart | |
| 31 | |||
| 32 | ✗ | subroutine cartesian_evaluate_cyl(self, u, x) | |
| 33 | !> Convert Cartesian to cylindrical. | ||
| 34 | class(cartesian_coordinate_system_t), intent(in) :: self | ||
| 35 | real(dp), intent(in) :: u(3) | ||
| 36 | real(dp), intent(out) :: x(3) | ||
| 37 | |||
| 38 | ✗ | call cart_to_cyl(u, x) | |
| 39 | ✗ | end subroutine cartesian_evaluate_cyl | |
| 40 | |||
| 41 | ✗ | subroutine cartesian_covariant_basis(self, u, e_cov) | |
| 42 | !> Covariant basis for Cartesian: identity matrix. | ||
| 43 | !> e_cov(i,j) = dx_cart_i / dx_cart_j = delta_ij | ||
| 44 | class(cartesian_coordinate_system_t), intent(in) :: self | ||
| 45 | real(dp), intent(in) :: u(3) | ||
| 46 | real(dp), intent(out) :: e_cov(3, 3) | ||
| 47 | |||
| 48 | ✗ | e_cov = 0.0_dp | |
| 49 | ✗ | e_cov(1, 1) = 1.0_dp | |
| 50 | ✗ | e_cov(2, 2) = 1.0_dp | |
| 51 | ✗ | e_cov(3, 3) = 1.0_dp | |
| 52 | ✗ | end subroutine cartesian_covariant_basis | |
| 53 | |||
| 54 | ✗ | subroutine cartesian_metric_tensor(self, u, g, ginv, sqrtg) | |
| 55 | !> Metric tensor for Cartesian: identity. | ||
| 56 | class(cartesian_coordinate_system_t), intent(in) :: self | ||
| 57 | real(dp), intent(in) :: u(3) | ||
| 58 | real(dp), intent(out) :: g(3, 3), ginv(3, 3), sqrtg | ||
| 59 | |||
| 60 | ✗ | g = 0.0_dp | |
| 61 | ✗ | g(1, 1) = 1.0_dp | |
| 62 | ✗ | g(2, 2) = 1.0_dp | |
| 63 | ✗ | g(3, 3) = 1.0_dp | |
| 64 | |||
| 65 | ✗ | ginv = g | |
| 66 | ✗ | sqrtg = 1.0_dp | |
| 67 | ✗ | end subroutine cartesian_metric_tensor | |
| 68 | |||
| 69 | ✗ | subroutine cartesian_from_cyl(self, xcyl, u, ierr) | |
| 70 | !> Convert cylindrical to Cartesian. | ||
| 71 | class(cartesian_coordinate_system_t), intent(in) :: self | ||
| 72 | real(dp), intent(in) :: xcyl(3) | ||
| 73 | real(dp), intent(out) :: u(3) | ||
| 74 | integer, intent(out) :: ierr | ||
| 75 | |||
| 76 | ✗ | call cyl_to_cart(xcyl, u) | |
| 77 | ✗ | ierr = 0 | |
| 78 | ✗ | end subroutine cartesian_from_cyl | |
| 79 | |||
| 80 | ✗ | end module cartesian_coordinates | |
| 81 |