compute_centroid Function

public pure function compute_centroid(particles) result(centroid)

compute centroid of a set of particles

Arguments

TypeIntentOptionalAttributesName
class(particle_type), intent(in), dimension(:):: particles

Return Value real(kind=dp),dimension(3)


Contents

Source Code


Source Code

pure function compute_centroid(particles) result(centroid)

    class(particle_type), dimension(:), intent(in) :: particles

    integer :: i
    real(dp), dimension(3) :: centroid

    centroid = 0.0_dp
    do i = 1, size(particles)
        centroid = centroid + particles(i)%coordinate
    end do
    centroid = centroid / real(size(particles), dp)

end function compute_centroid