ResolveEnergyWeights Subroutine

public subroutine ResolveEnergyWeights(this, nVar, ivar)

Ensure energyWeight is associated and sized to nVar. Weights supplied by SetEnergyWeights must match nVar; otherwise the default weights are regenerated: unit weight on the driving variable, or on every variable when ivar is SELF_AMR_ALLVARS. Resolved here rather than at Init because the variable count belongs to the solution field, not to the indicator.

Arguments

TypeIntentOptionalAttributesName
class(RefinementIndicator3D_t), intent(inout) :: this
integer, intent(in) :: nVar
integer, intent(in) :: ivar

Called by

proc~~resolveenergyweights~~CalledByGraph proc~resolveenergyweights ResolveEnergyWeights proc~estimate_refinementindicator3d_t Estimate_RefinementIndicator3D_t proc~estimate_refinementindicator3d_t->proc~resolveenergyweights proc~estimate_refinementindicator3d Estimate_RefinementIndicator3D proc~estimate_refinementindicator3d->proc~resolveenergyweights

Contents

Source Code


Source Code

  subroutine ResolveEnergyWeights(this,nVar,ivar)
    !! Ensure energyWeight is associated and sized to nVar. Weights supplied by SetEnergyWeights
    !! must match nVar; otherwise the default weights are regenerated: unit weight on the driving
    !! variable, or on every variable when ivar is SELF_AMR_ALLVARS. Resolved here rather than at
    !! Init because the variable count belongs to the solution field, not to the indicator.
    implicit none
    class(RefinementIndicator3D_t),intent(inout) :: this
    integer,intent(in) :: nVar
    integer,intent(in) :: ivar
    ! Local
    integer :: v

    if(this%energyWeightsSet) then
      if(this%nVarWeights /= nVar) then
        print*,__FILE__,':',__LINE__, &
          ' : Error : energy weights were set for a different variable count.'
        stop 1
      endif
      return
    endif

    if(this%nVarWeights /= nVar) then
      if(associated(this%energyWeight)) deallocate(this%energyWeight)
      allocate(this%energyWeight(1:nVar))
      this%nVarWeights = nVar
    endif
    do v = 1,nVar
      if(ivar == SELF_AMR_ALLVARS .or. v == ivar) then
        this%energyWeight(v) = 1.0_prec
      else
        this%energyWeight(v) = 0.0_prec
      endif
    enddo

  endsubroutine ResolveEnergyWeights