hypre_obj_PrintMatrixS Subroutine

private impure subroutine hypre_obj_PrintMatrixS(this)

Prints the matrix coefficients for debugging.

Type Bound

hypre_obj

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery


Calls

proc~~hypre_obj_printmatrixs~~CallsGraph proc~hypre_obj_printmatrixs hypre_obj%hypre_obj_PrintMatrixS hypre_structmatrixgetboxvalues hypre_structmatrixgetboxvalues proc~hypre_obj_printmatrixs->hypre_structmatrixgetboxvalues

Source Code

    impure subroutine hypre_obj_PrintMatrixS(this)
      !> Prints the matrix coefficients for debugging.
      implicit none
      class(hypre_obj), intent(inout) :: this                                  !! Hypre machinery
      ! Work variables
      real(wp), allocatable :: values(:)
      integer :: sindices(this%st_size)
      integer :: i,j,k,nval,m
      integer :: ierr

      ! Number of grid points
      nval=(this%block%hi(3)-this%block%lo(3)+1) &
          *(this%block%hi(2)-this%block%lo(2)+1) &
          *(this%block%hi(1)-this%block%lo(1)+1)*this%st_size

      ! Number of values
      allocate(values(nval))

      ! Stencil indicies
      ! must match the indices used setting the HYPRE stencil elements
      do i=1,this%st_size
        sindices(i) = i-1
      end do

      call HYPRE_StructMatrixGetBoxValues(this%matrix,this%block%lo,this%block%hi,this%st_size,sindices,values(1:nval),ierr)
      ! Loop over cell following Hypre convention (from bottom left, to top right)
      m=1
      do k=this%block%lo(3),this%block%hi(3)
        do j=this%block%lo(2),this%block%hi(2)
          do i=this%block%lo(1),this%block%hi(1)
            write(*,fmt='( 3(a,i3),a,7f12.4)') '[',i,',',j,',',k,']', values(m:m+6)
            m=m+7
          end do
        end do
      end do
      deallocate(values)

      return
    end subroutine hypre_obj_PrintMatrixS