tem_convergence_evaluate Subroutine

private subroutine tem_convergence_evaluate(me, achieved)

Evaluate if the convergence was achieved

Arguments

Type IntentOptional Attributes Name
type(tem_convergence_type), intent(inout) :: me

Convergence description contians

logical, intent(out) :: achieved

is all Scalars in current convergence_type are converged


Calls

proc~~tem_convergence_evaluate~~CallsGraph proc~tem_convergence_evaluate tem_convergence_evaluate proc~evaluate_residual evaluate_residual proc~tem_convergence_evaluate->proc~evaluate_residual proc~tem_comparator tem_comparator proc~tem_convergence_evaluate->proc~tem_comparator

Called by

proc~~tem_convergence_evaluate~~CalledByGraph proc~tem_convergence_evaluate tem_convergence_evaluate proc~tem_convergence_check_point tem_convergence_check_point proc~tem_convergence_check_point->proc~tem_convergence_evaluate proc~tem_convergence_check_element tem_convergence_check_element proc~tem_convergence_check_element->proc~tem_convergence_evaluate proc~tem_convergence_check tem_convergence_check proc~tem_convergence_check->proc~tem_convergence_check_point proc~tem_convergence_check->proc~tem_convergence_check_element

Contents


Source Code

  subroutine tem_convergence_evaluate( me, achieved )
    ! -------------------------------------------------------------------- !
    !> Convergence description contians
    type(tem_convergence_type), intent(inout) :: me
    !> is all Scalars in current convergence_type are converged
    logical, intent(out)                  :: achieved
    ! -------------------------------------------------------------------- !
    integer :: iVar, iComp, iScalar
    real(kind=rk) :: residual, threshold_fac
    logical :: isConverged(me%varMap%nScalars)
    ! -------------------------------------------------------------------- !
    ! Increase the counter for the checks
    me%nChecks = me%nChecks + 1
    iScalar = 0
    do iVar = 1, me%varMap%varPos%nVals
      do iComp = 1, me%redSpatial(iVar)%nComponents
        iScalar = iScalar + 1
        ! Compare the results against threshold
        !norm = abs(state(1) - me%result_prev)
        residual = evaluate_residual(                          &
          &          me      = me,                             &
          &          state   = me%redspatial(ivar)%val(icomp), &
          &          iScalar = iScalar                         )

        if( me%header%absoluteError ) then
          ! For absolute error, just use threshold
          threshold_fac = me%header%cond(iVar)%threshold
        else
          ! For relative errors, multiply threshold with current state value
          threshold_fac = me%redSpatial(iVar)%val(iComp) &
            &           * me%header%cond(iVar)%threshold
        end if

        isConverged(iScalar) = tem_comparator(                                 &
          &                        val       = residual,                       &
          &                        operation = me%header%cond(iVar)%operation, &
          &                        threshold = threshold_fac                   )
      end do
    end do
    ! update the convergence achieved if the last compare was succesful
    achieved = all(isConverged)

  end subroutine tem_convergence_evaluate