try_cylinder_r2 Function

function try_cylinder_r2(center, axis, radius, vertices)

Uses

  • proc~~try_cylinder_r2~~UsesGraph proc~try_cylinder_r2 try_cylinder_r2 module~class_vector class_vector proc~try_cylinder_r2->module~class_vector module~class_psblas class_psblas module~class_vector->module~class_psblas module~class_stopwatch class_stopwatch module~class_psblas->module~class_stopwatch module~tools_psblas tools_psblas module~class_psblas->module~tools_psblas module~class_stopwatch->module~tools_psblas psb_base_mod psb_base_mod module~class_stopwatch->psb_base_mod psb_prec_mod psb_prec_mod module~tools_psblas->psb_prec_mod module~tools_psblas->psb_base_mod psb_krylov_mod psb_krylov_mod module~tools_psblas->psb_krylov_mod

Arguments

Type IntentOptional AttributesName
type(vector), intent(in) :: center
type(vector), intent(in) :: axis
real(kind=psb_dpk_), intent(in) :: radius
type(vertex), intent(in) :: vertices(:)

Return Value real(kind=psb_dpk_)


Calls

proc~~try_cylinder_r2~~CallsGraph proc~try_cylinder_r2 try_cylinder_r2 float float proc~try_cylinder_r2->float interface~vector_ vector_ proc~try_cylinder_r2->interface~vector_ proc~calc_error calc_error proc~try_cylinder_r2->proc~calc_error proc~vector_ vector_ interface~vector_->proc~vector_ proc~calc_error->float

Called by

proc~~try_cylinder_r2~~CalledByGraph proc~try_cylinder_r2 try_cylinder_r2 proc~alloc_cylinder alloc_cylinder proc~alloc_cylinder->proc~try_cylinder_r2 interface~alloc_cylinder alloc_cylinder interface~alloc_cylinder->proc~alloc_cylinder

Contents

Source Code


Source Code

    FUNCTION try_cylinder_r2(center,axis,radius,vertices)
        USE class_vector

        IMPLICIT NONE

        REAL(psb_dpk_)  :: try_cylinder_r2

        TYPE(vector),INTENT(IN)        :: center
        TYPE(vector),INTENT(IN)        :: axis
        REAL(psb_dpk_),INTENT(IN)   :: radius
        TYPE(vertex),INTENT(IN)        :: vertices(:)

        ! Local variables
        REAL(psb_dpk_)              :: s_t                ! total deviations
        INTEGER                        :: nverts             ! number of vertices
        INTEGER                        :: i
        REAL(psb_dpk_)              :: err                ! cumulative error
        TYPE(vector)                   :: centroid, xrad

        ! Calculate R2 for the cylinder

        nverts = SIZE(vertices)

        err = calc_error(center,axis,radius,vertices)
        centroid = vector_(0.0d0, 0.0d0, 0.0d0)

        DO i = 1,nverts

            centroid = centroid + vertices(i)%position_()

        ENDDO

        centroid = ( 1.0d0/float(nverts) )* centroid

        s_t = 0.0

        ! calculate cumulative error
        DO i = 1,nverts

            ! calculate position relative to the centroid
            xrad = centroid - vertices(i)%position_()

            s_t = s_t + xrad%mag()**2

        ENDDO

        s_t = s_t / float(nverts)

        try_cylinder_r2 = ( s_t - err ) / s_t

    END FUNCTION try_cylinder_r2