ResolveEnergyScale Subroutine

public subroutine ResolveEnergyScale(this, energyScale, comm)

Determine the energy scale the relative floor is measured against: the pinned value when SetEnergyScale was used, otherwise the largest gate energy over the (rank-local) elements. When comm is present the maximum is taken over the communicator, so every rank applies the same floor and the flags - hence the adapted mesh - do not depend on the decomposition. One small collective per indicator evaluation, i.e. per adaptation epoch, never inside the time-stepping loop.

Arguments

TypeIntentOptionalAttributesName
class(RefinementIndicator3D_t), intent(in) :: this
real(kind=prec), intent(out) :: energyScale
integer, intent(in), optional :: comm

Calls

proc~~resolveenergyscale~~CallsGraph proc~resolveenergyscale ResolveEnergyScale mpi_allreduce mpi_allreduce proc~resolveenergyscale->mpi_allreduce

Called by

proc~~resolveenergyscale~~CalledByGraph proc~resolveenergyscale ResolveEnergyScale proc~estimate_refinementindicator3d_t Estimate_RefinementIndicator3D_t proc~estimate_refinementindicator3d_t->proc~resolveenergyscale proc~estimate_refinementindicator3d Estimate_RefinementIndicator3D proc~estimate_refinementindicator3d->proc~resolveenergyscale

Contents

Source Code


Source Code

  subroutine ResolveEnergyScale(this,energyScale,comm)
    !! Determine the energy scale the relative floor is measured against: the pinned value when
    !! SetEnergyScale was used, otherwise the largest gate energy over the (rank-local) elements.
    !! When comm is present the maximum is taken over the communicator, so every rank applies the
    !! same floor and the flags - hence the adapted mesh - do not depend on the decomposition.
    !! One small collective per indicator evaluation, i.e. per adaptation epoch, never inside the
    !! time-stepping loop.
    implicit none
    class(RefinementIndicator3D_t),intent(in) :: this
    real(prec),intent(out) :: energyScale
    integer,intent(in),optional :: comm
    ! Local
    integer :: iel,ierror,mpiPrec
    real(prec) :: gmax

    if(this%energyScaleIsSet) then
      energyScale = this%energyScale
      return
    endif

    gmax = 0.0_prec
    do iel = 1,this%nElem
      gmax = max(gmax,this%gate(iel))
    enddo

    if(present(comm)) then
      if(prec == real32) then
        mpiPrec = MPI_FLOAT
      else
        mpiPrec = MPI_DOUBLE
      endif
      call mpi_allreduce(gmax,energyScale,1,mpiPrec,MPI_MAX,comm,ierror)
    else
      energyScale = gmax
    endif

  endsubroutine ResolveEnergyScale