NextGeomBuffer_AMRController2D Subroutine

public subroutine NextGeomBuffer_AMRController2D(this, nElem, geom, slot)

Select the geometry buffer to fill this epoch: whichever of the two is not currently active, so the previous epoch's geometry stays intact and readable (AMR Stage 6c).

Each buffer is Init-ed the first time it is used and Resized on every subsequent epoch, so after the first two adaptations geometry performs no allocation at all - which is the point of the change. On the very first adaptation activeGeom is still the caller's geometry (geomSlot == 0); that object belongs to the caller and is never freed or reused here.

Arguments

TypeIntentOptionalAttributesName
class(AMRController2D), intent(inout) :: this
integer, intent(in) :: nElem
type(SEMQuad), intent(out), pointer:: geom
integer, intent(out) :: slot

Contents


Source Code

  subroutine NextGeomBuffer_AMRController2D(this,nElem,geom,slot)
    !! Select the geometry buffer to fill this epoch: whichever of the two is not currently
    !! active, so the previous epoch's geometry stays intact and readable (AMR Stage 6c).
    !!
    !! Each buffer is Init-ed the first time it is used and Resized on every subsequent epoch, so
    !! after the first two adaptations geometry performs no allocation at all - which is the point
    !! of the change. On the very first adaptation activeGeom is still the caller's geometry
    !! (geomSlot == 0); that object belongs to the caller and is never freed or reused here.
    implicit none
    class(AMRController2D),intent(inout) :: this
    integer,intent(in) :: nElem
    type(SEMQuad),pointer,intent(out) :: geom
    integer,intent(out) :: slot

    if(this%geomSlot == 1) then
      slot = 2
    else
      slot = 1
    endif

    if(slot == 1) then
      if(.not. associated(this%geomA)) allocate(this%geomA)
      geom => this%geomA
    else
      if(.not. associated(this%geomB)) allocate(this%geomB)
      geom => this%geomB
    endif

    if(geom%nElem == 0) then
      call geom%Init(this%interp,nElem)
    else
      call geom%Resize(this%interp,nElem)
    endif

  endsubroutine NextGeomBuffer_AMRController2D