marker_set_CoM Function

private impure function marker_set_CoM(this) result(CoM)

Finds the center of area.

Type Bound

marker_set

Arguments

Type IntentOptional Attributes Name
class(marker_set), intent(inout) :: this

A collection of tessellation elements

Return Value real(kind=wp), (3)

Position of center of area


Calls

proc~~marker_set_com~~CallsGraph proc~marker_set_com marker_set%marker_set_CoM markers markers proc~marker_set_com->markers p p proc~marker_set_com->p

Source Code

    impure function marker_set_CoM(this) result(CoM)
      !> Finds the center of area.
      implicit none
      class(marker_set), intent(inout) :: this                                 !! A collection of tessellation elements
      real(wp)                         :: CoM(3)                               !! Position of center of area
      ! Work variables
      real(wp):: CoM_(3),SA_,SA

      SA_=0.0_wp
      CoM_=0.0_wp
      if (this%count_.gt.0) then
        select type(markers=>this%p)
        type is (marker_obj)
          SA_   = sum(markers(1:this%count_)%SA)
          CoM_(1)=sum(markers(1:this%count_)%SA*markers(1:this%count_)%p(1))
          CoM_(2)=sum(markers(1:this%count_)%SA*markers(1:this%count_)%p(2))
          CoM_(3)=sum(markers(1:this%count_)%SA*markers(1:this%count_)%p(3))
        end select
      end if
      call this%parallel%Sum(SA_    ,SA    )
      call this%parallel%Sum(CoM_(1),CoM(1))
      call this%parallel%Sum(CoM_(2),CoM(2))
      call this%parallel%Sum(CoM_(3),CoM(3))
      CoM=CoM/SA

      return
    end function marker_set_CoM