Resize_Scalar2D_t Subroutine

public subroutine Resize_Scalar2D_t(this, interp, nVar, nElem)

Rebind a live object to a new element count, reusing the existing storage when it fits (AMR Stage 6b). Unlike Init - which is intent(out) and therefore resets the whole object, reallocates, zeroes and, on GPU builds, uploads those zeros - this preserves metadata and equation parsers (neither depends on nElem) and touches storage only when it must grow.

All arrays are zeroed, exactly as Init leaves them. This is not optional: a pool that has been reused (or freshly allocated at a larger capacity) holds indeterminate values, and the boundary arrays are not all fully rewritten before they are read - leaving them alone produced NaN entropy on the first step after an adaptation. The saving over Free + Init is the allocation itself, the device upload of zeros, and the metadata and equation-parser reconstruction; the zeroing is required for correctness and is kept.

Arguments

TypeIntentOptionalAttributesName
class(Scalar2D_t), intent(inout) :: this
type(Lagrange), intent(in), target:: interp
integer, intent(in) :: nVar
integer, intent(in) :: nElem

Called by

proc~~resize_scalar2d_t~~CalledByGraph proc~resize_scalar2d_t Resize_Scalar2D_t proc~resize_mappedscalar2d_t Resize_MappedScalar2D_t proc~resize_mappedscalar2d_t->proc~resize_scalar2d_t proc~resize_scalar2d Resize_Scalar2D proc~resize_scalar2d->proc~resize_scalar2d_t proc~resize_mappedscalar2d Resize_MappedScalar2D proc~resize_mappedscalar2d->proc~resize_mappedscalar2d_t

Contents

Source Code


Source Code

  subroutine Resize_Scalar2D_t(this,interp,nVar,nElem)
    !! Rebind a live object to a new element count, reusing the existing storage when it fits
    !! (AMR Stage 6b). Unlike Init - which is intent(out) and therefore resets the whole object,
    !! reallocates, zeroes and, on GPU builds, uploads those zeros - this preserves metadata and
    !! equation parsers (neither depends on nElem) and touches storage only when it must grow.
    !!
    !! All arrays are zeroed, exactly as Init leaves them. This is not optional: a pool that has
    !! been reused (or freshly allocated at a larger capacity) holds indeterminate values, and
    !! the boundary arrays are not all fully rewritten before they are read - leaving them alone
    !! produced NaN entropy on the first step after an adaptation. The saving over Free + Init is
    !! the allocation itself, the device upload of zeros, and the metadata and equation-parser
    !! reconstruction; the zeroing is required for correctness and is kept.
    implicit none
    class(Scalar2D_t),intent(inout) :: this
    type(Lagrange),intent(in),target :: interp
    integer,intent(in) :: nVar
    integer,intent(in) :: nElem

    if(nVar /= this%nVar) then
      ! Metadata and equation parsers are sized by nVar; a change means this is not a regrid.
      print*,__FILE__,':',__LINE__, &
        ' : Error : Resize cannot change nVar. Use Free followed by Init.'
      stop 1
    endif

    this%interp => interp
    this%nElem = nElem
    this%N = interp%N
    this%M = interp%M

    call this%MapArrays(interp%N+1,nVar,nElem)

    this%interior = 0.0_prec
    this%boundary = 0.0_prec
    this%extBoundary = 0.0_prec
    this%avgBoundary = 0.0_prec
    this%boundarynormal = 0.0_prec

  endsubroutine Resize_Scalar2D_t