EnsureScratch_SEMQuad Subroutine

public subroutine EnsureScratch_SEMQuad(myGeom, nGeo, quadrature, nElem)

Prepare the cached GenerateFromMesh scratch for a mesh with nGeo/quadrature and nElem elements (AMR Stage 6c). The nGeo -> N interpolant is built once and reused; the node coordinate staging is resized, so an adapting run stops rebuilding either one per epoch.

The interpolant is rebuilt only if nGeo or the quadrature actually changes, which does not happen across adaptation but is handled so that reusing one SEMQuad against a different mesh family stays correct.

Arguments

TypeIntentOptionalAttributesName
class(SEMQuad), intent(inout) :: myGeom
integer, intent(in) :: nGeo
integer, intent(in) :: quadrature
integer, intent(in) :: nElem

Contents

Source Code


Source Code

  subroutine EnsureScratch_SEMQuad(myGeom,nGeo,quadrature,nElem)
    !! Prepare the cached GenerateFromMesh scratch for a mesh with nGeo/quadrature and nElem
    !! elements (AMR Stage 6c). The nGeo -> N interpolant is built once and reused; the node
    !! coordinate staging is resized, so an adapting run stops rebuilding either one per epoch.
    !!
    !! The interpolant is rebuilt only if nGeo or the quadrature actually changes, which does not
    !! happen across adaptation but is handled so that reusing one SEMQuad against a different
    !! mesh family stays correct.
    implicit none
    class(SEMQuad),intent(inout) :: myGeom
    integer,intent(in) :: nGeo
    integer,intent(in) :: quadrature
    integer,intent(in) :: nElem

    if(myGeom%scratchReady) then
      if(myGeom%scratchNGeo /= nGeo .or. myGeom%meshToModel%controlNodeType /= quadrature) then
        call myGeom%xMesh%Free()
        call myGeom%meshToModel%Free()
        deallocate(myGeom%meshToModel)
        myGeom%meshToModel => null()
        myGeom%scratchReady = .false.
      endif
    endif

    if(.not. myGeom%scratchReady) then
      allocate(myGeom%meshToModel)
      call myGeom%meshToModel%Init(nGeo, &
                                   quadrature, &
                                   myGeom%x%interp%N, &
                                   myGeom%x%interp%controlNodeType)
      call myGeom%xMesh%Init(myGeom%meshToModel,1,nElem)
      myGeom%scratchReady = .true.
      myGeom%scratchNGeo = nGeo
    elseif(myGeom%xMesh%nElem /= nElem) then
      call myGeom%xMesh%Resize(myGeom%meshToModel,1,nElem)
    endif

  endsubroutine EnsureScratch_SEMQuad