batch_injection_layout_type Derived Type

type, public :: batch_injection_layout_type

1 バッチの注入 layout。全 rank で同じ global 粒子数と面ごとの速度補正を持ち、 static の rank 分割と shared の slot pool の両方がこれを基に粒子を作る。 segment は species 順に source(volume_seed または photo ray)、次に面 1..6 の reservoir が並ぶ。


Components

Type Visibility Attributes Name Initial
logical, public :: ready = .false.
integer(kind=i32), public :: batch_idx = 0_i32
integer(kind=i32), public :: nspecies = 0_i32
integer(kind=i32), public, allocatable :: source_kind(:)
integer(kind=i32), public, allocatable :: source_global_count(:)
integer(kind=i32), public, allocatable :: boundary_global_count(:,:)
real(kind=dp), public, allocatable :: boundary_vmin(:,:)
real(kind=dp), public, allocatable :: boundary_barrier(:,:)
real(kind=dp), public, allocatable :: weight(:)
real(kind=dp), public, allocatable :: temperature_k(:)
real(kind=dp), public, allocatable :: drift_velocity(:,:)
real(kind=dp), public, allocatable :: photo_emit_current_density(:)
real(kind=dp), public, allocatable :: photo_normal_drift_speed(:)
real(kind=dp), public, allocatable :: photo_ray_weight(:)

1 本の ray が当たったときのマクロ粒子重み(全 rank 合計の ray 数で分担)。

integer(kind=i32), public :: nsegments = 0_i32
integer(kind=i32), public :: total_slots = 0_i32
integer(kind=i32), public, allocatable :: segment_species(:)
integer(kind=i32), public, allocatable :: segment_kind(:)
integer(kind=i32), public, allocatable :: segment_face(:)
integer(kind=i32), public, allocatable :: segment_begin(:)
integer(kind=i32), public, allocatable :: segment_end(:)
integer(kind=i32), public :: nbands = 0_i32

slot は segment を round-robin に回って並ぶ(segment 内 index k の周回で、長さが k 以上の segment を順に取る)。 取り合う順に種が混ざり、static の round-robin 組み立てと同じ処理順になる。slot ごとの表は持たず、 segment 長の相異なる値ごとの帯で locate_slot が (segment, segment 内 index) を求める。 帯 b は segment 内 index が band_length(b-1)+1 .. band_length(b) の周回で、band_length(0)=0。

integer(kind=i32), public, allocatable :: band_length(:)
integer(kind=i32), public, allocatable :: band_last_slot(:)

帯 b の最後の global slot(band_last_slot(0)=0)。


Type-Bound Procedures

procedure, public :: locate_slot => locate_batch_slot

  • public pure subroutine locate_batch_slot(self, slot, segment, local_index)

    global slot から (segment, segment 内 index) を求める。O(nsegments) で、slot ごとの表を持たない。

    Arguments

    Type IntentOptional Attributes Name
    class(batch_injection_layout_type), intent(in) :: self
    integer(kind=i32), intent(in) :: slot

    1..total_slots の global slot。

    integer(kind=i32), intent(out) :: segment

    slot が属する segment。

    integer(kind=i32), intent(out) :: local_index

    slot が属する segment。 segment 内の 1 始まり index。

Source Code

  type, public :: batch_injection_layout_type
    logical :: ready = .false.
    integer(i32) :: batch_idx = 0_i32
    integer(i32) :: nspecies = 0_i32
    integer(i32), allocatable :: source_kind(:)
    integer(i32), allocatable :: source_global_count(:)
    integer(i32), allocatable :: boundary_global_count(:, :)
    real(dp), allocatable :: boundary_vmin(:, :)
    real(dp), allocatable :: boundary_barrier(:, :)
    real(dp), allocatable :: weight(:)
    real(dp), allocatable :: temperature_k(:)
    real(dp), allocatable :: drift_velocity(:, :)
    real(dp), allocatable :: photo_emit_current_density(:)
    real(dp), allocatable :: photo_normal_drift_speed(:)
    !> 1 本の ray が当たったときのマクロ粒子重み(全 rank 合計の ray 数で分担)。
    real(dp), allocatable :: photo_ray_weight(:)
    integer(i32) :: nsegments = 0_i32
    integer(i32) :: total_slots = 0_i32
    integer(i32), allocatable :: segment_species(:)
    integer(i32), allocatable :: segment_kind(:)
    integer(i32), allocatable :: segment_face(:)
    integer(i32), allocatable :: segment_begin(:)
    integer(i32), allocatable :: segment_end(:)
    !> slot は segment を round-robin に回って並ぶ(segment 内 index k の周回で、長さが k 以上の segment を順に取る)。
    !! 取り合う順に種が混ざり、static の round-robin 組み立てと同じ処理順になる。slot ごとの表は持たず、
    !! segment 長の相異なる値ごとの帯で `locate_slot` が (segment, segment 内 index) を求める。
    !! 帯 b は segment 内 index が `band_length(b-1)+1 .. band_length(b)` の周回で、`band_length(0)=0`。
    integer(i32) :: nbands = 0_i32
    integer(i32), allocatable :: band_length(:)
    !> 帯 b の最後の global slot(`band_last_slot(0)=0`)。
    integer(i32), allocatable :: band_last_slot(:)
  contains
    procedure :: locate_slot => locate_batch_slot
  end type batch_injection_layout_type