eulerian_obj_Norm2 Function

private impure function eulerian_obj_Norm2(this) result(val)

Computes norm2 of an Eulerian_obj.

Type Bound

eulerian_obj_base

Arguments

Type IntentOptional Attributes Name
class(eulerian_obj_base), intent(in) :: this

An Eulerian object

Return Value real(kind=wp)


Calls

proc~~eulerian_obj_norm2~~CallsGraph proc~eulerian_obj_norm2 eulerian_obj_base%eulerian_obj_Norm2 cell cell proc~eulerian_obj_norm2->cell

Source Code

    impure function eulerian_obj_Norm2(this) result (val)
      !> Computes norm2 of an Eulerian_obj.
      implicit none
      class(eulerian_obj_base), intent(in) :: this                             !! An Eulerian object
      real(wp) :: val
      ! Work variable
      real(wp) :: vol
      integer  :: i,j,k
      real(wp) :: buff_r

      associate (lo => this%block%lo,  hi => this%block%hi,         &
        dxm=>this%block%dxm,dym=>this%block%dym,dzm=>this%block%dzm)

        val = 0.0_wp; vol = 0.0_wp
        select type(this)
          type is (eulerian_obj_r)
            do k=lo(3),hi(3)
              do j=lo(2),hi(2)
                do i=lo(1),hi(1)
                  vol  = vol + dxm(i)*dym(j)*dzm(k)
                  val  = val + (this%cell(i,j,k)**2)*dxm(i)*dym(j)*dzm(k)
                end do
              end do
            end do
          type is (eulerian_obj_i)
            do k=lo(3),hi(3)
              do j=lo(2),hi(2)
                do i=lo(1),hi(1)
                  vol  = vol + dxm(i)*dym(j)*dzm(k)
                  val  = val + (real(this%cell(i,j,k),wp)**2)*dxm(i)*dym(j)*dzm(k)
                end do
              end do
            end do
          class default
            call this%parallel%Stop("Error encountered with Eulerian object")
        end select
        call this%parallel%Sum(vol,buff_r); vol=buff_r
        call this%parallel%Sum(val,buff_r); val=sqrt(buff_r/vol)
      end associate

      return
    end function eulerian_obj_Norm2