ApplyPreconditioner Function

public function ApplyPreconditioner(params, method, x) result(y)

Arguments

Type IntentOptional Attributes Name
class(IterativeParams), intent(in) :: params
class(MethodPreconditioner), intent(in) :: method
real(kind=dp), intent(in), dimension(:) :: x

Return Value real(kind=dp), dimension(size(params%x_init))


Calls

proc~~applypreconditioner~~CallsGraph proc~applypreconditioner ApplyPreconditioner proc~backward backward proc~applypreconditioner->proc~backward proc~forward forward proc~applypreconditioner->proc~forward

Source Code

    function ApplyPreconditioner(params, method, x) result(y)
        class(IterativeParams), intent(in) :: params
        class(MethodPreconditioner), intent(in) :: method
        real(dp), dimension(:), intent(in) :: x
        real(dp), dimension(size(params%x_init)) :: y

        select case (method%id)
        case (METHOD_PRECOND_JACOBI%id)
            if (.not. allocated(params%D)) stop "ERROR :: Jacobi preconditioner requires &
                                                &preconditioner matrix D to be allocated"
            y = matmul(params%D, x)
        case (METHOD_PRECOND_GS%id)
            if (.not. allocated(params%L)) stop "ERROR :: Gauss-Seidel preconditioner requires &
                                                &preconditioner matrix L to be allocated"
            y = forward(params%L, x)
        case (METHOD_PRECOND_SOR%id)
            if (.not. allocated(params%L)) stop "ERROR :: SOR preconditioner requires &
                                                &preconditioner matrix L to be allocated"
            y = forward(params%L, x)
        case (METHOD_PRECOND_JOR%id)
            if (.not. allocated(params%D)) stop "ERROR :: JOR preconditioner requires &
                                                &preconditioner matrix D to be allocated"
            y = matmul(params%D, x)
        case (METHOD_PRECOND_ILU%id)
            if (.not. allocated(params%L) .or. &
               .not. allocated(params%U)) stop "ERROR :: ILU preconditioner requires &
                                                &preconditioner matrices L and U to be allocated"
            y = forward(params%L, x)
            y = backward(params%U, y)
        case (METHOD_PRECOND_ICF%id)
            if (.not. allocated(params%L)) stop "ERROR :: ICF preconditioner requires &
                                                &preconditioner matrix L to be allocated"
            y = forward(params%L, x)
            y = backward(transpose(params%L), y)
        case (METHOD_PRECOND_SSOR%id)
            if (.not. allocated(params%L) .or. &
               .not. allocated(params%D)) stop "ERROR :: SSOR preconditioner requires &
                                                &preconditioner matrices L and D to be allocated"
            y = forward(params%L, x)
            y = matmul(params%D, y)
            y = backward(transpose(params%L), y)
        case DEFAULT
            stop "ERROR :: Unknown preconditioner method"
        end select

    end function ApplyPreconditioner