Resize_Tensor2D_t Subroutine

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

Rebind a live object to a new element count, reusing existing storage when it fits (AMR Stage 6b/6c). Unlike Init - which is intent(out), so it resets the object, reallocates, zeroes and reconstructs the 4*nVar equation parsers - this preserves metadata and parsers (neither depends on nElem) and touches storage only when it must grow.

All arrays are zeroed, exactly as Init leaves them. See Resize_Scalar2D_t for why that is required rather than merely tidy: a reused pool holds indeterminate values and the boundary arrays are not all rewritten before they are read.

Arguments

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

Called by

proc~~resize_tensor2d_t~~CalledByGraph proc~resize_tensor2d_t Resize_Tensor2D_t proc~resize_tensor2d Resize_Tensor2D proc~resize_tensor2d->proc~resize_tensor2d_t

Contents

Source Code


Source Code

  subroutine Resize_Tensor2D_t(this,interp,nVar,nElem)
    !! Rebind a live object to a new element count, reusing existing storage when it fits (AMR
    !! Stage 6b/6c). Unlike Init - which is intent(out), so it resets the object, reallocates,
    !! zeroes and reconstructs the 4*nVar equation parsers - this preserves metadata and parsers
    !! (neither depends on nElem) and touches storage only when it must grow.
    !!
    !! All arrays are zeroed, exactly as Init leaves them. See Resize_Scalar2D_t for why that is
    !! required rather than merely tidy: a reused pool holds indeterminate values and the boundary
    !! arrays are not all rewritten before they are read.
    implicit none
    class(Tensor2D_t),intent(inout) :: this
    type(Lagrange),target,intent(in) :: interp
    integer,intent(in) :: nVar
    integer,intent(in) :: nElem

    if(nVar /= this%nVar) then
      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

  endsubroutine Resize_Tensor2D_t