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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Tensor2D_t), | intent(inout) | :: | this | |||
| type(Lagrange), | intent(in), | target | :: | interp | ||
| integer, | intent(in) | :: | nVar | |||
| integer, | intent(in) | :: | nElem |
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