初始化浮体的质量、质心、转动惯量、速度、角速度
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(float_object_type), | intent(inout) | :: | self |
浮体粒子集 |
||
| type(particle_type), | intent(in) | :: | particle |
区域 |
||
| integer, | intent(in) | :: | istart |
浮体粒子集的索引 |
||
| integer, | intent(in) | :: | iend |
浮体粒子集的索引 |
pure subroutine init(self, particle, istart, iend)
class(float_object_type), intent(inout) :: self !! 浮体粒子集
type(particle_type), intent(in) :: particle !! 区域
integer, intent(in) :: istart, iend !! 浮体粒子集的索引
integer :: i
self%istart = istart
self%iend = iend
associate (mass => particle%mass(self%istart:self%iend), &
loc => particle%loc(:, self%istart:self%iend))
self%mass(1) = sum(mass)
do i = 1, dim
self%loc(i) = sum(mass*loc(i, :))/self%mass(1)
end do
self%mass(2) = sum(mass*((loc(1, :) - self%loc(1))**2 + &
(loc(2, :) - self%loc(2))**2))
end associate
self%vel = 0.0_rk
self%ang_vel = 0.0_rk
end subroutine init