get_volume_average Subroutine

public subroutine get_volume_average(power, mode, volume)

Uses

  • proc~~get_volume_average~~UsesGraph proc~get_volume_average get_volume_average module~mod_global_parameters mod_global_parameters proc~get_volume_average->module~mod_global_parameters module~mod_basic_types mod_basic_types module~mod_global_parameters->module~mod_basic_types module~mod_connectivity mod_connectivity module~mod_global_parameters->module~mod_connectivity module~mod_constants mod_constants module~mod_global_parameters->module~mod_constants module~mod_physicaldata mod_physicaldata module~mod_global_parameters->module~mod_physicaldata module~mod_variables mod_variables module~mod_global_parameters->module~mod_variables mpi mpi module~mod_global_parameters->mpi module~mod_variables->module~mod_basic_types

Compute mean(w**power) over the leaves of the grid. The first mode (power=1) corresponds to the mean, the second to the mean squared values and so on.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: power

Which mode to compute

double precision, intent(out) :: mode(nw)

The computed mode

double precision, intent(out) :: volume

The total grid volume


Calls

proc~~get_volume_average~~CallsGraph proc~get_volume_average get_volume_average mpi_allreduce mpi_allreduce proc~get_volume_average->mpi_allreduce

Called by

proc~~get_volume_average~~CalledByGraph proc~get_volume_average get_volume_average proc~printlog_default printlog_default proc~printlog_default->proc~get_volume_average proc~printlog_regression_test printlog_regression_test proc~printlog_regression_test->proc~get_volume_average proc~saveamrfile saveamrfile proc~saveamrfile->proc~printlog_default proc~saveamrfile->proc~printlog_regression_test proc~timeintegration timeintegration proc~timeintegration->proc~saveamrfile proc~main main proc~main->proc~timeintegration program~agile agile program~agile->proc~main

Source Code

  subroutine get_volume_average(power, mode, volume)
    use mod_global_parameters

    integer, intent(in)           :: power
    !< Which mode to compute
    double precision, intent(out) :: mode(nw)
    !< The computed mode
    double precision, intent(out) :: volume
    !< The total grid volume
    integer                       :: iigrid, igrid, iw
    integer                       :: ncells
    double precision              :: wsum(nw+1)
    double precision              :: dvol
    double precision              :: dsum_recv(1:nw+1)

    wsum(:) = 0
    ncells = (ixMhi1-ixMlo1+1)*(ixMhi2-ixMlo2+1)*(ixMhi3-ixMlo3+1)

    ! Loop over all the grids
    do iigrid = 1, igridstail
       igrid = igrids(iigrid)

       if (slab_uniform) then
          ! Every cell of the block has the same volume, and ps(igrid)%dvolume
          ! is not even allocated in a Cartesian build - take the one value
          ! from the block's spacing in rnode and factor it out of the sums.
          dvol = rnode(rpdx1_,igrid)*rnode(rpdx2_,igrid)*rnode(rpdx3_,igrid)

          wsum(nw+1) = wsum(nw+1) + dvol*dble(ncells)

          do iw = 1, nw
             wsum(iw) = wsum(iw) + dvol*sum(ps(igrid)%w(ixMlo1:ixMhi1,&
                ixMlo2:ixMhi2,ixMlo3:ixMhi3,iw)**power)
          end do
       else
          ! Read the metric out of bgeo directly rather than through the
          ! ps(igrid)%dvolume pointer view: bgeo is where the data actually
          ! lives, and the view is a bounds-remapped pointer into it.
          ! Store total volume in last element
          wsum(nw+1) = wsum(nw+1) + sum(bgeo%dvolume(ixMlo1:ixMhi1,&
             ixMlo2:ixMhi2,ixMlo3:ixMhi3,igrid))

          ! Compute the modes of the cell-centered variables, weighted by volume
          do iw = 1, nw
             wsum(iw) = wsum(iw) + sum(bgeo%dvolume(ixMlo1:ixMhi1,&
                ixMlo2:ixMhi2,ixMlo3:ixMhi3,igrid)*ps(igrid)%w(ixMlo1:ixMhi1,&
                ixMlo2:ixMhi2,ixMlo3:ixMhi3,iw)**power)
          end do
       end if
    end do

    ! Make the information available on all tasks
    call MPI_ALLREDUCE(wsum, dsum_recv, nw+1, MPI_DOUBLE_PRECISION, MPI_SUM,&
        icomm, ierrmpi)

    ! Set the volume and the average
    volume = dsum_recv(nw+1)
    mode   = dsum_recv(1:nw) / volume

  end subroutine get_volume_average