temporal_from_file_periodic_for Function

private function temporal_from_file_periodic_for(me, time) result(res)

This function searches for the right values in the periodic data read from file and interpolates them if needed.

Two different kinds of interpolation between the data tuples are available. \li \a 'none': No interpolation between the data points is performed. The data is evaluated as ]t1,t2] -> v1, ]t2,t3] -> v2, ... \li \a 'linear': The value is interpolated in a linear fashion from the provided data.

Arguments

Type IntentOptional Attributes Name
type(tem_from_file_temporal_type) :: me

datatype incl. the data read from file

type(tem_time_type), intent(in) :: time

timer object incl. the current time information

Return Value real(kind=rk)

return value


Called by

proc~~temporal_from_file_periodic_for~~CalledByGraph proc~temporal_from_file_periodic_for temporal_from_file_periodic_for proc~tem_temporal_for tem_temporal_for proc~tem_temporal_for->proc~temporal_from_file_periodic_for proc~tem_spacetime_for_coord tem_spacetime_for_coord proc~tem_spacetime_for_coord->proc~tem_temporal_for proc~tem_spacetime_for_treeids tem_spacetime_for_treeIDs proc~tem_spacetime_for_treeids->proc~tem_temporal_for proc~tem_spacetime_scalar_for_index tem_spacetime_scalar_for_index proc~tem_spacetime_scalar_for_index->proc~tem_temporal_for proc~tem_spacetime_scalar_for_index->proc~tem_spacetime_for_coord proc~tem_spacetime_vector_for_coord tem_spacetime_vector_for_coord proc~tem_spacetime_vector_for_coord->proc~tem_temporal_for proc~tem_spacetime_vector_for_index tem_spacetime_vector_for_index proc~tem_spacetime_vector_for_index->proc~tem_temporal_for proc~tem_spacetime_vector_for_index->proc~tem_spacetime_vector_for_coord proc~tem_spacetime_vector_for_treeids tem_spacetime_vector_for_treeIDs proc~tem_spacetime_vector_for_treeids->proc~tem_temporal_for interface~tem_spacetime_for tem_spacetime_for interface~tem_spacetime_for->proc~tem_spacetime_for_coord interface~tem_spacetime_for->proc~tem_spacetime_for_treeids interface~tem_spacetime_for->proc~tem_spacetime_scalar_for_index interface~tem_spacetime_for->proc~tem_spacetime_vector_for_coord interface~tem_spacetime_for->proc~tem_spacetime_vector_for_index interface~tem_spacetime_for->proc~tem_spacetime_vector_for_treeids proc~tem_spacetime_for_stcoord tem_spacetime_for_stcoord interface~tem_spacetime_for->proc~tem_spacetime_for_stcoord proc~tem_spacetime_for_stcoord->proc~tem_spacetime_for_coord proc~evaluate_add_spacetime_scalarbycoordinate evaluate_add_spacetime_scalarByCoordinate proc~evaluate_add_spacetime_scalarbycoordinate->interface~tem_spacetime_for proc~evaluate_add_spacetime_scalarbytreeid evaluate_add_spacetime_scalarByTreeID proc~evaluate_add_spacetime_scalarbytreeid->interface~tem_spacetime_for proc~evaluate_add_spacetime_vectorbycoordinate evaluate_add_spacetime_vectorByCoordinate proc~evaluate_add_spacetime_vectorbycoordinate->interface~tem_spacetime_for proc~evaluate_add_spacetime_vectorbytreeid evaluate_add_spacetime_vectorByTreeID proc~evaluate_add_spacetime_vectorbytreeid->interface~tem_spacetime_for proc~evaluate_first_spacetime_scalarbycoordinate evaluate_first_spacetime_scalarByCoordinate proc~evaluate_first_spacetime_scalarbycoordinate->interface~tem_spacetime_for proc~evaluate_first_spacetime_scalarbytreeid evaluate_first_spacetime_scalarByTreeID proc~evaluate_first_spacetime_scalarbytreeid->interface~tem_spacetime_for proc~evaluate_first_spacetime_vectorbycoordinate evaluate_first_spacetime_vectorByCoordinate proc~evaluate_first_spacetime_vectorbycoordinate->interface~tem_spacetime_for proc~evaluate_first_spacetime_vectorbytreeid evaluate_first_spacetime_vectorByTreeID proc~evaluate_first_spacetime_vectorbytreeid->interface~tem_spacetime_for proc~evaluate_foag_spacetime_scalarbycoordinate evaluate_FOAG_spacetime_scalarByCoordinate proc~evaluate_foag_spacetime_scalarbycoordinate->interface~tem_spacetime_for proc~evaluate_foag_spacetime_scalarbytreeid evaluate_FOAG_spacetime_scalarByTreeID proc~evaluate_foag_spacetime_scalarbytreeid->interface~tem_spacetime_for proc~evaluate_foag_spacetime_vectorbycoordinate evaluate_FOAG_spacetime_vectorByCoordinate proc~evaluate_foag_spacetime_vectorbycoordinate->interface~tem_spacetime_for proc~evaluate_foag_spacetime_vectorbytreeid evaluate_FOAG_spacetime_vectorByTreeID proc~evaluate_foag_spacetime_vectorbytreeid->interface~tem_spacetime_for proc~get_valofindex_add_scalar_spacetime get_valOfIndex_add_scalar_spacetime proc~get_valofindex_add_scalar_spacetime->interface~tem_spacetime_for proc~get_valofindex_add_vector_spacetime get_valOfIndex_add_vector_spacetime proc~get_valofindex_add_vector_spacetime->interface~tem_spacetime_for proc~get_valofindex_first_scalar_spacetime get_valOfIndex_first_scalar_spacetime proc~get_valofindex_first_scalar_spacetime->interface~tem_spacetime_for proc~get_valofindex_first_vector_spacetime get_valOfIndex_first_vector_spacetime proc~get_valofindex_first_vector_spacetime->interface~tem_spacetime_for proc~get_valofindex_foag_scalar_spacetime get_valOfIndex_FOAG_scalar_spacetime proc~get_valofindex_foag_scalar_spacetime->interface~tem_spacetime_for proc~get_valofindex_foag_vector_spacetime get_valOfIndex_FOAG_vector_spacetime proc~get_valofindex_foag_vector_spacetime->interface~tem_spacetime_for proc~tem_update_surfpos tem_update_surfPos proc~tem_update_surfpos->interface~tem_spacetime_for

Source Code

  function temporal_from_file_periodic_for( me, time ) result(res)
    ! --------------------------------------------------------------------------
    !> datatype incl. the data read from file
    type(tem_from_file_temporal_type) :: me
    !> timer object incl. the current time information
    type(tem_time_type), intent(in)  :: time
    !> return value
    real(kind=rk) :: res
    ! --------------------------------------------------------------------------
    ! local variables
    integer :: iData
    ! period in physical units
    real(kind=rk) :: rPeriod
    real(kind=rk) :: ratio
    ! remainder in physical units
    real(kind=rk) :: rRem
    ! --------------------------------------------------------------------------

    ! calculate the period in physical units (last time signal
    ! - first time signal)
    rPeriod = me%signal%val(1,me%signal%nVals) - me%signal%val(1,1)
    ratio = time%sim / rPeriod
    rRem =  (ratio - floor(ratio))*rPeriod
    res = 1.0_rk

    ! search for the correct entry in the data read from file
    do iData = 1, me%signal%nVals-1
      if ( ( (rRem+eps) >= me%signal%val(1, iData) ) .and.                   &
        &  ( (rRem) <= me%signal%val(1, iData+1) ) )then
        exit
      end if
    end do

    if( .not. me%ramp .or. time%sim >= me%rampT)then
      select case( trim(adjustl(me%intp)) )
        case( 'none' )
          ! result is the data stored in the position directly
          res = me%signal%val(2, iData)
        case( 'linear' )
          ! result is the linear interpolation between the data from
          ! iData and iData+1
          res = ( me%signal%val(2, iData+1) - me%signal%val(2, iData) ) &
            & / ( me%signal%val(1, iData+1) - me%signal%val(1, iData) ) &
            & * (rRem - me%signal%val(1, iData) )                       &
            & + me%signal%val(2, iData)
      end select
    else
      res = me%rampVal * sin( PI * 0.5_rk * (time%sim/me%rampT))
    end if

  end function temporal_from_file_periodic_for