compute_periodic_shift_bounds Subroutine

public subroutine compute_periodic_shift_bounds(mesh, p0, p1, axis, period_len, nmin, nmax)

線分 AABB と canonical mesh AABB の重なりから必要な image shift 範囲を決める。

Arguments

Type IntentOptional Attributes Name
type(mesh_type), intent(in) :: mesh
real(kind=dp), intent(in) :: p0(3)
real(kind=dp), intent(in) :: p1(3)
integer(kind=i32), intent(in) :: axis
real(kind=dp), intent(in) :: period_len
integer(kind=i32), intent(out) :: nmin
integer(kind=i32), intent(out) :: nmax

Called by

proc~~compute_periodic_shift_bounds~~CalledByGraph proc~compute_periodic_shift_bounds compute_periodic_shift_bounds proc~find_first_hit_periodic2 find_first_hit_periodic2 proc~find_first_hit_periodic2->proc~compute_periodic_shift_bounds proc~find_first_hit find_first_hit proc~find_first_hit->proc~find_first_hit_periodic2 proc~sample_photo_raycast_particles sample_photo_raycast_particles proc~sample_photo_raycast_particles->proc~find_first_hit proc~sample_photo_species_state sample_photo_species_state proc~sample_photo_species_state->proc~sample_photo_raycast_particles proc~init_particle_batch_from_config init_particle_batch_from_config proc~init_particle_batch_from_config->proc~sample_photo_species_state

Source Code

  subroutine compute_periodic_shift_bounds(mesh, p0, p1, axis, period_len, nmin, nmax)
    type(mesh_type), intent(in) :: mesh
    real(dp), intent(in) :: p0(3), p1(3)
    integer(i32), intent(in) :: axis
    real(dp), intent(in) :: period_len
    integer(i32), intent(out) :: nmin, nmax

    real(dp) :: seg_min, seg_max, mesh_min, mesh_max, tol

    seg_min = min(p0(axis), p1(axis))
    seg_max = max(p0(axis), p1(axis))
    mesh_min = mesh%grid_bb_min(axis)
    mesh_max = mesh%grid_bb_max(axis)
    tol = 1.0d-12*max(1.0d0, abs(seg_min), abs(seg_max), abs(mesh_min), abs(mesh_max), period_len)

    nmin = int(ceiling((seg_min - mesh_max - tol)/period_len), kind=i32)
    nmax = int(floor((seg_max - mesh_min + tol)/period_len), kind=i32)
  end subroutine compute_periodic_shift_bounds