calc_error Function

function calc_error(center, axis, radius, vertices)

Uses

  • proc~~calc_error~~UsesGraph proc~calc_error calc_error module~class_vector class_vector proc~calc_error->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~~calc_error~~CallsGraph proc~calc_error calc_error float float proc~calc_error->float

Called by

proc~~calc_error~~CalledByGraph proc~calc_error calc_error proc~try_cylinder_r2 try_cylinder_r2 proc~try_cylinder_r2->proc~calc_error 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 calc_error(center,axis,radius,vertices)
        USE class_vector

        IMPLICIT NONE

        REAL(psb_dpk_)  :: calc_error

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

        ! Local variables
        INTEGER                        :: nverts             ! number of vertices
        INTEGER                        :: i
        REAL(psb_dpk_)              :: err                ! cumulative error
        TYPE(vector)                   :: x,xrad,xrel


        nverts = SIZE(vertices)

        err = 0

        ! calculate cumulative error
        DO i = 1,nverts

            x = vertices(i)%position_()

            ! calculate position relative to the cylinder's center
            xrel = x - center

            ! get radial vector
            xrad = xrel - ( xrel .dot. axis) * axis

            ! because our ideal cylinder is infinitely long, the error is only
            ! the vector difference in the radial direction

            err = err + ( xrad%mag() - radius)**2

        ENDDO

        calc_error = err/float(nverts)

    END FUNCTION calc_error