helpers_grillix_m.f90 Source File


Contents

Source Code


Source Code

module helpers_grillix_m
    !! GRILLIX specific helper routines for unit tests
    use precision_grillix_m, only : GP
    use csrmat_m, only: csrmat_t
    use mesh_cart_m, only : mesh_cart_t
    implicit none

    public :: get_mat_entry_cartbased
     
contains

    real(GP) function get_mat_entry_cartbased(mat, mesh, it, jt, ig, jg)
        !! Returns a specifig entry of csr matrix based on Cartesian indexing
        !! i.e. row lt corresponds to point (it, jt) and columnd lg to point (ig, jg)
        type(csrmat_t) :: mat
        !! Matrix
        type(mesh_cart_t) :: mesh
        !! Mesh
        integer, intent(in) :: it, jt
        !! Cartesian coordinates of point 
        integer, intent(in) :: ig, jg
        !! Cartesian coordinates of point 

        integer :: k, lt, im, lm ,jm

        get_mat_entry_cartbased = 0.0_GP

        lt = mesh%cart_to_mesh_index(it, jt)
        do k = mat%i(lt), mat%i(lt+1)-1
            lm = mat%j(k)
            im = mesh%get_cart_i(lm) 
            jm = mesh%get_cart_j(lm)             
            if ((im == ig) .and. (jm == jg)) then
                get_mat_entry_cartbased = mat%val(k)
            endif
        enddo            
                
    end function
    
end module