signal_v1d Function

private function signal_v1d(me) result(val)

Type Bound

signal_t

Arguments

Type IntentOptional Attributes Name
class(signal_t), intent(inout) :: me

Return Value real(kind=dp), (size(me%x))

interpolated value


Called by

proc~~signal_v1d~~CalledByGraph proc~signal_v1d signal_t%signal_v1d proc~scenario_update scenario_update proc~scenario_update->proc~signal_v1d proc~signal_v0d signal_t%signal_v0d proc~scenario_update->proc~signal_v0d proc~signal_v0d->proc~signal_v1d proc~solid_scenario_update solid_scenario_update proc~solid_scenario_update->proc~signal_v1d proc~source_term_definition_channel source_term_definition_channel proc~source_term_definition_channel->proc~signal_v1d proc~full_physics_definition_channel full_physics_definition_channel proc~full_physics_definition_channel->proc~source_term_definition_channel proc~full_physics_definition_mesh2d full_physics_definition_mesh2D proc~full_physics_definition_mesh2d->proc~signal_v0d proc~main_loop main_loop proc~main_loop->proc~scenario_update proc~main_loop->proc~solid_scenario_update proc~main_loop->proc~source_term_definition_channel proc~main_loop->proc~full_physics_definition_channel proc~main_loop->proc~full_physics_definition_mesh2d proc~sim_step_management simulation_t%sim_step_management proc~main_loop->proc~sim_step_management proc~boundary_resolution_from_and_to_ports boundary_resolution_from_and_to_ports proc~main_loop->proc~boundary_resolution_from_and_to_ports proc~heat_diffusion_mesh2d heat_diffusion_mesh2D proc~main_loop->proc~heat_diffusion_mesh2d proc~required_variables_for_implicit_2d_heat_diffusion required_variables_for_implicit_2D_heat_diffusion proc~required_variables_for_implicit_2d_heat_diffusion->proc~signal_v0d proc~sim_step_management->proc~signal_v0d proc~solve_boundary_mt solve_boundary_MT proc~solve_boundary_mt->proc~signal_v0d proc~solve_boundary_pt solve_boundary_PT proc~solve_boundary_pt->proc~signal_v0d proc~boundary_resolution_from_and_to_ports->proc~solve_boundary_mt proc~boundary_resolution_from_and_to_ports->proc~solve_boundary_pt proc~heat_diffusion_mesh2d->proc~required_variables_for_implicit_2d_heat_diffusion program~reims_p reims_p program~reims_p->proc~main_loop

Source Code

function signal_v1d(me) result(val)
    class(signal_t), intent(inout) :: me
    real(dp) :: val(size(me%x)) !! interpolated value
    real(dp) :: time
    type(c_ptr) :: c_cfg
    time = me%sim%t + me%sim%dt

    if(associated(me%init_signal_ext) .and. .not.c_associated(me%sign_ptr)) then
      c_cfg = C_NULL_PTR
      if(.not. me%init_signal_ext(c_funloc(expose_state_to_ext_library),len(me%cfg_str), me%cfg_str, c_cfg, me%sign_ptr,&
                                  size(me%x))) return
      if(c_associated(me%sign_ptr)) then
          call c_f_procpointer(me%sign_ptr, me%val_fpt)
          me%val_cfg = c_cfg
      endif
    endif

    if (associated(me%val_fpt)) then
        call me%val_fpt(me%val_cfg, time, val)
        return
    endif
    do ! search for correct segment index starting from previous point: me%i
        if (time >= me%time(me%i + 1)) then
            me%i = me%i + 1
        else if (time < me%time(me%i)) then
            if (me%i == 1) exit
            me%i = me%i - 1
        else
            exit
        endif
    enddo
    val = time * me%gain(:,me%i) + me%offset(:,me%i)
end function signal_v1d