init Subroutine

subroutine init()

Initialize the simulation.

Arguments

None

Calls

proc~~init~3~~CallsGraph proc~init~3 init str str proc~init~3->str strz strz proc~init~3->strz proc~save_time_serie~2 save_time_serie proc~init~3->proc~save_time_serie~2 proc~save_time_serie~2->str
Help

Called By

proc~~init~3~~CalledByGraph proc~init~3 init program~integrate_euler_1d_caf~2 integrate_euler_1D_caf program~integrate_euler_1d_caf~2->proc~init~3
Help

Source Code


Source Code

  subroutine init()
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Initialize the simulation.
  !---------------------------------------------------------------------------------------------------------------------------------
  integer(I_P)                  :: i        !< Space counter.
  real(R_P)                     :: x_L      !< Left abscissa of local image.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
#ifdef CAF
  ! CAF images comunications
  sync all
  if (me/=1) then
    Ni = Ni[1]
    steps_max = steps_max[1]
    results = results[1]
    plots = plots[1]
    time_serie = time_serie[1]
    verbose = verbose[1]
  endif
#endif
  ! init simulation
  if (mod(Ni, we)/=0) error stop 'error: the number of cells Ni must be a multiple of the number of CAF images used!'
  Ni_image = Ni / we
  allocate(x(1:Ni_image))
  allocate(initial_state(1:Np, 1:Ni_image))
  Dx = 1._R_P / Ni
  ! Sod's problem
  cp0(1) = 1040._R_P
  cv0(1) = 743._R_P
  if (we==1) then
      BC_L = 'TRA'
      BC_R = 'TRA'
  else
    if (me==1) then
      BC_L = 'TRA'
      BC_R = 'CON-'//trim(strz(2, me+1))
    elseif (me==we) then
      BC_L = 'CON-'//trim(strz(2, me-1))
      BC_R = 'TRA'
    else
      BC_L = 'CON-'//trim(strz(2, me-1))
      BC_R = 'CON-'//trim(strz(2, me+1))
    endif
  endif
  if (me>1) then
    x_L = Ni_image * Dx * (me - 1)
  else
    x_L = 0._R_P
  endif
  do i=1, Ni_image
    x(i) = x_L + Dx * i - 0.5_R_P * Dx
    if (x(i)<=0.5_R_P) then
      initial_state(:, i) = [1._R_P, & ! rho(s)
                             0._R_P, & ! u
                             1._R_P, & ! p
                             1._R_P, & ! sum(rho(s))
                             cp0/cv0]  ! gamma = cp/cv
    else
      initial_state(:, i) = [0.125_R_P, & ! rho(s)
                             0._R_P,    & ! u
                             0.1_R_P,   & ! p
                             0.125_R_P, & ! sum(rho(s))
                             cp0/cv0]     ! gamma = cp/cv
    endif
  enddo
  if (verbose) then
    print '(A)', id//'image '//trim(str(.true., me))//' of '//trim(str(.true., we))
    print '(A)', id//'Number of total cells: '//trim(str(.true., Ni))
    print '(A)', id//'Number of time steps: '//trim(str(.true., steps_max))
    print '(A)', id//'Save final results: '//trim(str(results))
    print '(A)', id//'Save plots of results: '//trim(str(plots))
    print '(A)', id//'Save time serie of results: '//trim(str(time_serie))
    print '(A)', id//'Left BC: '//BC_L
    print '(A)', id//'Right BC: '//BC_R
    print '(A)', id//'Space resolution: '//trim(str(.true., Dx))
    print '(A)', id//'X(1) X(N): '//trim(str(.true., x(1)))//' '//trim(str(.true., x(Ni_image)))
    print '(A)', id//'Density value: '//trim(str(n=initial_state(1, 1)))//' '//trim(str(n=initial_state(1, Ni_image)))
  endif
  ! initialize integrator and domain
  call rk_integrator%init(stages=rk_stages)
  call domain%init(Ni=Ni_image, Ns=Ns, Dx=Dx, BC_L=BC_L, BC_R=BC_R, initial_state=initial_state, cp0=cp0, cv0=cv0, &
                   me=me, we=we, ord=ord)
#ifdef CAF
  allocate(Dt(1:we)[*])
#else
  allocate(Dt(1:we))
#endif
  ! initialize time serie file
  call save_time_serie(title='FOODIE test: 1D Euler equations integration, explicit TVD Runge-Kutta'// &
                             trim(str(.true., rk_stages))//' stages', &
                       filename='euler_1D_caf_integration-tvdrk-'//&
                                trim(str(.true., rk_stages))//'-image-'//&
                                trim(strz(3, me))//&
                                '-time_serie.dat', &
                       t=t)
  ! initialize time variables
  t = 0._R_P
  Dt = 0._R_P
  return
  !---------------------------------------------------------------------------------------------------------------------------------
  endsubroutine init


a a a a a add_burgers add_euler add_euler add_euler add_lorenz allocate_integrand_members allocate_integrand_members allocate_integrand_members allocate_integrand_members allocate_integrand_members amplitude_phase assign_abstract assign_integrand assign_integrand assign_integrand assign_multistage assign_multistage_multistep assign_multistep assign_real assign_real assign_real average_solution burgers_assign_burgers burgers_assign_real burgers_local_error burgers_multiply_burgers burgers_multiply_real check_error check_scheme_has_fast_mode check_scheme_has_fast_mode check_scheme_has_fast_mode class_name class_name class_name class_name class_name class_name class_name class_name class_name class_name class_name class_name class_name compute_dt compute_dt compute_dt compute_dt compute_dt compute_dt compute_dt compute_dx compute_inter_states compute_inter_states compute_inter_states compute_inter_states compute_inter_states conservative2primitive conservative2primitive conservative2primitive conservative2primitive conservative2primitive d2Burgers_dx2 dBurgers_dt dBurgers_dx description description description description destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy_abstract destroy_multistage destroy_multistage_multistep destroy_multistep destroy_rk destroy_rk dEuler_dt dEuler_dt dEuler_dt dEuler_dt dEuler_dt dLorenz_dt dt_ratio dU_dt dU_dt dU_dt E E E E E error error error euler_assign_euler euler_assign_euler euler_assign_euler euler_assign_euler euler_assign_euler euler_assign_real euler_assign_real euler_assign_real euler_local_error euler_local_error euler_local_error euler_multiply_euler euler_multiply_euler euler_multiply_euler euler_multiply_real euler_multiply_real euler_multiply_real exact_solution exact_solution exact_solution execute execute execute export_tecplot export_tecplot export_tecplot foodie_integrator_class_names foodie_integrator_factory foodie_integrator_schemes H H H H H has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode has_fast_mode impose_boundary_conditions impose_boundary_conditions impose_boundary_conditions impose_boundary_conditions impose_boundary_conditions impose_boundary_conditions init init init init init init init init init init init init init init_rk init_rk initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize_order_s initialize_order_s_1 integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integr_assign_integr integrand_add_integrand integrand_add_integrand integrand_add_integrand integrand_add_integrand_fast integrand_add_integrand_fast integrand_add_integrand_fast integrand_add_real integrand_add_real integrand_add_real integrand_dimension integrand_dimension integrand_dimension integrand_multiply_integrand integrand_multiply_integrand integrand_multiply_integrand integrand_multiply_integrand_fast integrand_multiply_integrand_fast integrand_multiply_integrand_fast integrand_multiply_real integrand_multiply_real integrand_multiply_real integrand_multiply_real_scalar integrand_multiply_real_scalar integrand_multiply_real_scalar integrand_multiply_real_scalar_fast integrand_multiply_real_scalar_fast integrand_multiply_real_scalar_fast integrand_sub_integrand integrand_sub_integrand integrand_sub_integrand integrand_sub_real integrand_sub_real integrand_sub_real integrand_subtract_integrand_fast integrand_subtract_integrand_fast integrand_subtract_integrand_fast integrate integrate integrate integrate integrate integrate integrate integrate integrate integrate integrate integrate integrate integrate integrate integrate integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_fast integrate_order_2 integrate_order_2_fast integrate_order_3 integrate_order_3_fast integrate_order_s integrate_order_s_1 integrate_order_s_1_fast integrate_order_s_fast integrate_rk integrate_rk is_admissible is_available is_class_available is_multistage is_multistage is_multistage is_multistep is_multistep is_multistep is_scheme_available is_supported is_supported is_supported is_supported is_supported is_supported is_supported is_supported is_supported is_supported is_supported is_supported is_supported local_error local_error local_error lorenz_assign_lorenz lorenz_assign_real lorenz_local_error lorenz_multiply_lorenz lorenz_multiply_real new_Dt observed_order observed_order observed_order omega output output output output output output output output output output p p p p p parse_cli parse_cli parse_cli previous_step previous_step previous_step primitive2conservative primitive2conservative primitive2conservative primitive2conservative primitive2conservative r r r r r real_add_integrand real_add_integrand real_add_integrand real_multiply_burgers real_multiply_euler real_multiply_euler real_multiply_euler real_multiply_integrand real_multiply_integrand real_multiply_integrand real_multiply_lorenz real_scalar_multiply_integrand real_scalar_multiply_integrand real_scalar_multiply_integrand real_sub_integrand real_sub_integrand real_sub_integrand reconstruct_interfaces reconstruct_interfaces_states reconstruct_interfaces_states reconstruct_interfaces_states reconstruct_interfaces_states reconstruct_interfaces_states registers_number riemann_solver riemann_solver riemann_solver riemann_solver riemann_solver save_results save_results save_results save_results save_results save_results save_results save_results save_results save_time_serie save_time_serie save_time_serie save_time_serie save_time_serie scheme_number set_cli set_cli set_cli set_sin_wave_initial_state set_square_wave_initial_state stages_number stages_number stages_number steps_number steps_number steps_number sub_burgers sub_euler sub_euler sub_euler sub_lorenz supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes supported_schemes synchronize synchronize synchronize synchronize t_fast t_fast t_fast test test test_ab test_ab test_ab test_euler test_euler test_euler test_leapfrog test_leapfrog test_leapfrog test_ls_rk test_ls_rk test_ls_rk test_tvd_rk test_tvd_rk test_tvd_rk tokenize trigger_error update_previous update_previous update_previous_steps update_previous_steps update_previous_steps