读取粒子二进制文件
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pif_h5part_type), | intent(inout) | :: | self | |||
| type(particle_type), | intent(inout), | target | :: | region |
subroutine read (self, region)
class(pif_h5part_type), intent(inout) :: self
type(particle_type), intent(inout), target :: region
real(rk), allocatable :: z(:, :)
integer(8) :: istat, fid
integer :: i
self%numbers => pnl_obj%numbers
self%float_objects => pnl_obj%float_objects
self%ptc => region ! 重定向粒子集
self%ptc%hsml = pnl_obj%hsml
self%nreal = self%numbers(1) + self%numbers(2)
fid = h5pt_openr(cli_obj%working_directory.join.ioc_obj%input_file)
if (fid == 0_8) then
call terminal_obj%error('open pif h5part file failed')
end if
allocate (self%ptc%loc(2, self%numbers(4)), &
self%ptc%vel(2, self%numbers(4)), &
self%ptc%acc(2, self%numbers(4)), &
self%ptc%rho(self%numbers(4)), &
self%ptc%p(self%numbers(4)), &
self%ptc%mass(self%numbers(4)), &
self%ptc%u(self%numbers(4)), &
self%ptc%drho(self%numbers(4)), &
self%ptc%du(self%numbers(4)), &
self%ptc%c(self%numbers(4)), &
source=0.0_rk)
allocate (self%ptc%itype(self%numbers(4)), source=0)
allocate (z(self%numbers(4), 2), source=0.0_rk)
! if (cfg_obj%is_go_on) then
! istat = h5pt_setstep(fid, int(cfg_obj%go_on_step, 8))
! else
istat = h5pt_setstep(fid, 1_8)
! end if
istat = h5pt_readdata(fid, "X", z(:, 1))
istat = h5pt_readdata(fid, "Y", z(:, 2))
do i = 1, self%numbers(4)
self%ptc%loc(:, i) = z(i, :)
end do
istat = h5pt_readdata(fid, "Vx", z(:, 1))
istat = h5pt_readdata(fid, "Vy", z(:, 2))
do i = 1, self%numbers(4)
self%ptc%vel(:, i) = z(i, :)
end do
self%ptc%acc = 0.0_rk
istat = h5pt_readdata(fid, "Mass", self%ptc%mass)
istat = h5pt_readdata(fid, "Rho", self%ptc%rho)
istat = h5pt_readdata(fid, "P", self%ptc%p)
istat = h5pt_readdata(fid, "U", self%ptc%u)
istat = h5pt_readdata(fid, "Itype", self%ptc%itype)
istat = h5pt_close(fid)
end subroutine read