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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(RefinementIndicator3D_t), | intent(in) | :: | this | |||
| real(kind=prec), | intent(out) | :: | energyScale | |||
| integer, | intent(in), | optional | :: | comm |
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