init Subroutine

private pure subroutine init(self, particle, istart, iend)

初始化浮体的质量、质心、转动惯量、速度、角速度

Type Bound

float_object_type

Arguments

Type IntentOptional Attributes Name
class(float_object_type), intent(inout) :: self

浮体粒子集

type(particle_type), intent(in) :: particle

区域

integer, intent(in) :: istart

浮体粒子集的索引

integer, intent(in) :: iend

浮体粒子集的索引


Contents

Source Code


Source Code

    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