particles_per_batch_from_config Function

public function particles_per_batch_from_config(cfg) result(batch_n)

有効な粒子種の npcls_per_step を合計し、1バッチあたりの粒子数を返す。 1つ以上の粒子種が有効で、かつ合計が正でない場合は停止する。

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(in) :: cfg

粒子種設定を含むアプリ設定。

Return Value integer(kind=i32)


Called by

proc~~particles_per_batch_from_config~~CalledByGraph proc~particles_per_batch_from_config particles_per_batch_from_config proc~total_particles_from_config total_particles_from_config proc~total_particles_from_config->proc~particles_per_batch_from_config proc~init_particles_from_config init_particles_from_config proc~init_particles_from_config->proc~total_particles_from_config

Source Code

  integer(i32) function particles_per_batch_from_config(cfg) result(batch_n)
    type(app_config), intent(in) :: cfg
    integer(i32) :: s
    logical :: has_dynamic_source

    if (cfg%n_particle_species <= 0) then
      error stop 'At least one [[particles.species]] entry is required.'
    end if

    batch_n = 0_i32
    has_dynamic_source = .false.
    do s = 1, cfg%n_particle_species
      if (.not. cfg%particle_species(s)%enabled) cycle
      select case (trim(cfg%particle_species(s)%source_mode))
      case ('volume_seed')
        if (cfg%particle_species(s)%npcls_per_step < 0_i32) then
          error stop 'particles.species.npcls_per_step must be >= 0.'
        end if
        batch_n = batch_n + cfg%particle_species(s)%npcls_per_step
      case ('reservoir_face')
        has_dynamic_source = .true.
      case ('photo_raycast')
        has_dynamic_source = .true.
      case default
        error stop 'Unknown particles.species.source_mode.'
      end select
    end do

    if (batch_n <= 0_i32 .and. .not. has_dynamic_source) then
      error stop 'At least one enabled [[particles.species]] entry must have npcls_per_step > 0.'
    end if
  end function particles_per_batch_from_config