Init_AMRController3D Subroutine

public subroutine Init_AMRController3D(this, model, refineThreshold, coarsenThreshold, ivar, maxLevel, nHalo, relativeEnergyFloor, energyWeights, significantEnergyFloor)

Attach the controller to an initialized model. The model's current mesh becomes the forest's base mesh (level 0); its geometry interpolant drives the indicator and the solution transfer. Thresholds are the sigma = log10 modal-energy-ratio cut-offs of the refinement indicator (refineThreshold > coarsenThreshold; see SELF_RefinementIndicator_3D). ivar is the driving solution variable (or SELF_AMR_ALLVARS). maxLevel >= 0 caps the refinement depth; nHalo >= 0 sets the refine-flag halo width in elements.

relativeEnergyFloor tunes the indicator's amplitude gate: an element whose energy is below this fraction of the field's peak element energy is treated as quiescent (hence resolved) regardless of its modal shape, which is what allows the mesh to be released behind a passing front. It is an energy fraction, so the square of the corresponding amplitude fraction; 0 disables the gate. energyWeights optionally weights the per-variable energies that form the gate, e.g. from the model's entropy function - see RefinementIndicator3D%SetEnergyWeights. significantEnergyFloor opens a hysteresis band on the energy axis: elements between the two floors hold their mesh (SELF_AMR_KEEP) instead of flipping across a single hard cut. All three default to the indicator's own defaults.

Arguments

TypeIntentOptionalAttributesName
class(AMRController3D), intent(out) :: this
class(DGModel3D_t), intent(in) :: model
real(kind=prec), intent(in) :: refineThreshold
real(kind=prec), intent(in) :: coarsenThreshold
integer, intent(in) :: ivar
integer, intent(in) :: maxLevel
integer, intent(in) :: nHalo
real(kind=prec), intent(in), optional :: relativeEnergyFloor
real(kind=prec), intent(in), optional :: energyWeights(:)
real(kind=prec), intent(in), optional :: significantEnergyFloor

Calls

proc~~init_amrcontroller3d~~CallsGraph proc~init_amrcontroller3d Init_AMRController3D proc~initforestfromdecomposedmesh~2 InitForestFromDecomposedMesh proc~init_amrcontroller3d->proc~initforestfromdecomposedmesh~2 proc~allgatherperelemreals~2 AllgatherPerElemReals proc~initforestfromdecomposedmesh~2->proc~allgatherperelemreals~2 proc~allgatherperelemints~2 AllgatherPerElemInts proc~initforestfromdecomposedmesh~2->proc~allgatherperelemints~2 mpi_allgatherv mpi_allgatherv proc~allgatherperelemreals~2->mpi_allgatherv proc~allgatherperelemints~2->mpi_allgatherv

Contents

Source Code


Source Code

  subroutine Init_AMRController3D(this,model,refineThreshold,coarsenThreshold,ivar, &
                                  maxLevel,nHalo,relativeEnergyFloor,energyWeights, &
                                  significantEnergyFloor)
    !! Attach the controller to an initialized model. The model's current mesh becomes the
    !! forest's base mesh (level 0); its geometry interpolant drives the indicator and the
    !! solution transfer. Thresholds are the sigma = log10 modal-energy-ratio cut-offs of the
    !! refinement indicator (refineThreshold > coarsenThreshold; see
    !! SELF_RefinementIndicator_3D). ivar is the driving solution variable (or
    !! SELF_AMR_ALLVARS). maxLevel >= 0 caps the refinement depth; nHalo >= 0 sets the
    !! refine-flag halo width in elements.
    !!
    !! relativeEnergyFloor tunes the indicator's amplitude gate: an element whose energy is
    !! below this fraction of the field's peak element energy is treated as quiescent (hence
    !! resolved) regardless of its modal shape, which is what allows the mesh to be released
    !! behind a passing front. It is an energy fraction, so the square of the corresponding
    !! amplitude fraction; 0 disables the gate. energyWeights optionally weights the
    !! per-variable energies that form the gate, e.g. from the model's entropy function - see
    !! RefinementIndicator3D%SetEnergyWeights. significantEnergyFloor opens a hysteresis band
    !! on the energy axis: elements between the two floors hold their mesh (SELF_AMR_KEEP)
    !! instead of flipping across a single hard cut. All three default to the indicator's own
    !! defaults.
    implicit none
    class(AMRController3D),intent(out) :: this
    class(DGModel3D_t),intent(in) :: model
    real(prec),intent(in) :: refineThreshold
    real(prec),intent(in) :: coarsenThreshold
    integer,intent(in) :: ivar
    integer,intent(in) :: maxLevel
    integer,intent(in) :: nHalo
    real(prec),intent(in),optional :: relativeEnergyFloor
    real(prec),intent(in),optional :: energyWeights(:)
    real(prec),intent(in),optional :: significantEnergyFloor

    if(.not. associated(model%mesh)) then
      print*,__FILE__,':',__LINE__, &
        ' : Error : AMRController3D%Init requires an initialized model.'
      stop 1
    endif
    if(maxLevel < 0 .or. nHalo < 0) then
      print*,__FILE__,':',__LINE__, &
        ' : Error : AMRController3D%Init requires maxLevel >= 0 and nHalo >= 0.'
      stop 1
    endif

    this%baseMesh => model%mesh
    this%activeMesh => model%mesh
    this%activeGeom => model%geometry
    this%interp => model%geometry%x%interp
    this%ownsActive = .false.
    this%ivar = ivar
    this%maxLevel = maxLevel
    this%nHalo = nHalo
    this%refineThreshold = refineThreshold
    this%coarsenThreshold = coarsenThreshold
    if(present(relativeEnergyFloor)) then
      this%relativeEnergyFloor = relativeEnergyFloor
      this%significantEnergyFloor = relativeEnergyFloor
    endif
    if(present(significantEnergyFloor)) this%significantEnergyFloor = significantEnergyFloor
    if(present(energyWeights)) then
      allocate(this%energyWeights(1:size(energyWeights)))
      this%energyWeights = energyWeights
    endif

    ! Rank-replicated forest: on one rank, straight from the mesh; on several, from the
    ! allgathered global base tables (every rank builds the identical forest).
    if(model%mesh%decomp%nRanks > 1) then
      call InitForestFromDecomposedMesh(this%forest,model%mesh)
    else
      call this%forest%Init(model%mesh)
    endif
    call this%indicator%Init(this%interp,model%mesh%nElem,refineThreshold,coarsenThreshold)
    call this%ApplyIndicatorSettings()

  endsubroutine Init_AMRController3D