Rebind to a new element count, reusing host pools and device buffers where they fit (AMR Stage 6b). Inherits the Vector2D resize (host pools plus the five device buffers) and adds this class's mortar buffers, which are sized by mesh%nMortars rather than nElem: nMortars changes with the mesh independently of the element count, so a stale buffer would silently under-size the next mortar exchange. They are invalidated here and lazily re-created at the correct size on next use.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(MappedVector2D), | intent(inout) | :: | this | |||
| type(Lagrange), | intent(in), | target | :: | interp | ||
| integer, | intent(in) | :: | nVar | |||
| integer, | intent(in) | :: | nElem |
subroutine Resize_MappedVector2D(this,interp,nVar,nElem)
!! Rebind to a new element count, reusing host pools and device buffers where they fit (AMR
!! Stage 6b). Inherits the Vector2D resize (host pools plus the five device buffers) and adds
!! this class's mortar buffers, which are sized by mesh%nMortars rather than nElem: nMortars
!! changes with the mesh independently of the element count, so a stale buffer would silently
!! under-size the next mortar exchange. They are invalidated here and lazily re-created at
!! the correct size on next use.
implicit none
class(MappedVector2D),intent(inout) :: this
type(Lagrange),target,intent(in) :: interp
integer,intent(in) :: nVar
integer,intent(in) :: nElem
call Resize_MappedVector2D_t(this,interp,nVar,nElem)
call EnsureDeviceBuffers_Vector2D(this)
if(c_associated(this%mortarBuff_gpu)) then
call gpuCheck(hipFree(this%mortarBuff_gpu))
this%mortarBuff_gpu = c_null_ptr
endif
! The packed halo-exchange buffers are sized by the mesh/partition's shared-side
! count, which changes with a regrid; free them so the next exchange rebuilds
! against the new mesh (see Resize_MappedScalar2D for the failure this prevents).
if(c_associated(this%halo_sendbuf_gpu)) call gpuCheck(hipFree(this%halo_sendbuf_gpu))
if(c_associated(this%halo_recvbuf_gpu)) call gpuCheck(hipFree(this%halo_recvbuf_gpu))
this%halo_sendbuf_gpu = c_null_ptr
this%halo_recvbuf_gpu = c_null_ptr
endsubroutine Resize_MappedVector2D