compute centroid of a set of particles
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(particle_type), | intent(in), | dimension(:) | :: | particles |
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