resolve_particle_boundary_candidate Subroutine

public subroutine resolve_particle_boundary_candidate(mesh, sim, snapshot, bfield, x0, v0, q, m, dt, x_candidate, v_candidate, hit, result, boundary_contract, boundary_rng_counter, sampled_electric_field)

構築済みcandidateとその場評価値からbox eventを解決する。

Arguments

Type IntentOptional Attributes Name
type(mesh_type), intent(in) :: mesh
type(sim_config), intent(in) :: sim
type(electrostatic_snapshot_type), intent(inout) :: snapshot
real(kind=dp), intent(in) :: bfield(3)
real(kind=dp), intent(in) :: x0(3)
real(kind=dp), intent(in) :: v0(3)
real(kind=dp), intent(in) :: q
real(kind=dp), intent(in) :: m
real(kind=dp), intent(in) :: dt
real(kind=dp), intent(in) :: x_candidate(3)
real(kind=dp), intent(in) :: v_candidate(3)
type(hit_info), intent(in), optional :: hit
type(particle_step_result), intent(out) :: result
type(external_boundary_contract_type), intent(in), optional :: boundary_contract
integer(kind=i64), intent(in), optional :: boundary_rng_counter(4)
real(kind=dp), intent(in), optional :: sampled_electric_field(3)

Calls

proc~~resolve_particle_boundary_candidate~~CallsGraph proc~resolve_particle_boundary_candidate resolve_particle_boundary_candidate none~eval_local_e electrostatic_snapshot_type%eval_local_e proc~resolve_particle_boundary_candidate->none~eval_local_e none~eval_local_phi electrostatic_snapshot_type%eval_local_phi proc~resolve_particle_boundary_candidate->none~eval_local_phi none~eval_upper_panel_fourier_phi electrostatic_snapshot_type%eval_upper_panel_fourier_phi proc~resolve_particle_boundary_candidate->none~eval_upper_panel_fourier_phi proc~apply_escape_reflect_periodic_event apply_escape_reflect_periodic_event proc~resolve_particle_boundary_candidate->proc~apply_escape_reflect_periodic_event proc~build_particle_step_candidate build_particle_step_candidate proc~resolve_particle_boundary_candidate->proc~build_particle_step_candidate proc~find_first_boundary_event find_first_boundary_event proc~resolve_particle_boundary_candidate->proc~find_first_boundary_event proc~find_first_hit find_first_hit proc~resolve_particle_boundary_candidate->proc~find_first_hit proc~build_particle_step_candidate->none~eval_local_e none~eval_upper_panel_fourier_e electrostatic_snapshot_type%eval_upper_panel_fourier_e proc~build_particle_step_candidate->none~eval_upper_panel_fourier_e proc~boris_push boris_push proc~build_particle_step_candidate->proc~boris_push proc~find_first_hit_base find_first_hit_base proc~find_first_hit->proc~find_first_hit_base proc~find_first_hit_periodic2 find_first_hit_periodic2 proc~find_first_hit->proc~find_first_hit_periodic2 proc~initialize_hit initialize_hit proc~find_first_hit->proc~initialize_hit proc~resolve_periodic2_collision_config resolve_periodic2_collision_config proc~find_first_hit->proc~resolve_periodic2_collision_config proc~boris_update_velocity boris_update_velocity proc~boris_push->proc~boris_update_velocity proc~find_first_hit_base->proc~initialize_hit proc~find_first_hit_base_grid find_first_hit_base_grid proc~find_first_hit_base->proc~find_first_hit_base_grid proc~find_first_hit_base_linear find_first_hit_base_linear proc~find_first_hit_base->proc~find_first_hit_base_linear proc~resolve_box_filter_args resolve_box_filter_args proc~find_first_hit_base->proc~resolve_box_filter_args proc~find_first_hit_periodic2->proc~find_first_hit_base proc~find_first_hit_periodic2->proc~initialize_hit proc~find_first_hit_periodic2->proc~resolve_periodic2_collision_config proc~compute_periodic_shift_bounds compute_periodic_shift_bounds proc~find_first_hit_periodic2->proc~compute_periodic_shift_bounds proc~point_inside_box_periodic2 point_inside_box_periodic2 proc~find_first_hit_periodic2->proc~point_inside_box_periodic2 proc~prefer_periodic_candidate prefer_periodic_candidate proc~find_first_hit_periodic2->proc~prefer_periodic_candidate proc~find_first_hit_periodic2->proc~resolve_box_filter_args proc~wrap_periodic2_point wrap_periodic2_point proc~find_first_hit_periodic2->proc~wrap_periodic2_point proc~lower_ascii lower_ascii proc~resolve_periodic2_collision_config->proc~lower_ascii proc~cross~2 cross proc~boris_update_velocity->proc~cross~2 proc~find_first_hit_base_grid->proc~lower_ascii proc~bbox_inside_box bbox_inside_box proc~find_first_hit_base_grid->proc~bbox_inside_box proc~cell_id cell_id proc~find_first_hit_base_grid->proc~cell_id proc~coord_to_cell coord_to_cell proc~find_first_hit_base_grid->proc~coord_to_cell proc~point_inside_box point_inside_box proc~find_first_hit_base_grid->proc~point_inside_box proc~segment_aabb_intersection_t segment_aabb_intersection_t proc~find_first_hit_base_grid->proc~segment_aabb_intersection_t proc~segment_bbox_overlap_precomputed segment_bbox_overlap_precomputed proc~find_first_hit_base_grid->proc~segment_bbox_overlap_precomputed proc~segment_triangle_intersect segment_triangle_intersect proc~find_first_hit_base_grid->proc~segment_triangle_intersect proc~find_first_hit_base_linear->proc~bbox_inside_box proc~find_first_hit_base_linear->proc~point_inside_box proc~find_first_hit_base_linear->proc~segment_bbox_overlap_precomputed proc~find_first_hit_base_linear->proc~segment_triangle_intersect proc~cross cross proc~segment_triangle_intersect->proc~cross

Source Code

  subroutine resolve_particle_boundary_candidate( &
    mesh, sim, snapshot, bfield, x0, v0, q, m, dt, x_candidate, v_candidate, hit, result, boundary_contract, &
    boundary_rng_counter, sampled_electric_field &
    )
    type(mesh_type), intent(in) :: mesh
    type(sim_config), intent(in) :: sim
    type(electrostatic_snapshot_type), intent(inout) :: snapshot
    real(dp), intent(in) :: bfield(3), x0(3), v0(3), q, m, dt, x_candidate(3), v_candidate(3)
    type(hit_info), intent(in), optional :: hit
    type(particle_step_result), intent(out) :: result
    type(external_boundary_contract_type), intent(in), optional :: boundary_contract
    integer(i64), intent(in), optional :: boundary_rng_counter(4)
    real(dp), intent(in), optional :: sampled_electric_field(3)
    integer(i64) :: active_boundary_rng_counter(4)
    real(dp) :: active_electric_field(3), x_mid(3)
    logical :: has_boundary_rng_counter
    logical :: field_available

    result = particle_step_result()
    result%x = x0
    result%v = v0
    active_boundary_rng_counter = 0_i64
    has_boundary_rng_counter = present(boundary_rng_counter)
    if (has_boundary_rng_counter) active_boundary_rng_counter = boundary_rng_counter
    result%field_eval_count = 1_i32
    result%collision_query_count = merge(1_i32, 0_i32, present(hit))
    if (.not. valid_particle_step_input(x0, v0, bfield, q, m, dt) .or. &
        .not. all(ieee_is_finite(x_candidate)) .or. .not. all(ieee_is_finite(v_candidate))) then
      result%status = particle_step_invalid_boundary
      return
    end if
    if (present(sampled_electric_field)) then
      active_electric_field = sampled_electric_field
    else
      x_mid = x0 + 0.5_dp*v0*dt
      call project_field_sample_to_box(sim, x_mid)
      call snapshot%eval_local_e(mesh, x_mid, active_electric_field)
      result%field_eval_count = result%field_eval_count + 1_i32
    end if
    if (.not. all(ieee_is_finite(active_electric_field))) then
      result%status = particle_step_invalid_boundary
      return
    end if
    field_available = .true.
    call advance_particle_boundary_crossing( &
      mesh, sim, snapshot, bfield, x0, v0, q, m, dt, x_candidate, v_candidate, active_electric_field, hit, result, &
      boundary_contract, active_boundary_rng_counter, has_boundary_rng_counter, 0_i32, .false., field_available &
      )
  end subroutine resolve_particle_boundary_candidate