mesh_finalize Subroutine

public subroutine mesh_finalize(m)

Safely deallocates all heap-allocated arrays in the mesh structure.

This routine should be called during solver shutdown or mesh reload to prevent memory leaks. It nullifies all counts after deallocation.

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(inout) :: m

The mesh object to be cleared.


Called by

proc~~mesh_finalize~~CalledByGraph proc~mesh_finalize mod_mesh_types::mesh_finalize proc~read_native_mesh mod_mesh_io::read_native_mesh proc~read_native_mesh->proc~mesh_finalize program~lowmach_react_hex lowmach_react_hex program~lowmach_react_hex->proc~mesh_finalize program~lowmach_react_hex->proc~read_native_mesh

Source Code

   subroutine mesh_finalize(m)
      type(mesh_t), intent(inout) :: m

      integer :: p

      if (allocated(m%points)) deallocate(m%points)
      if (allocated(m%cells)) deallocate(m%cells)
      if (allocated(m%faces)) deallocate(m%faces)
      if (allocated(m%ncell_faces)) deallocate(m%ncell_faces)
      if (allocated(m%cell_faces)) deallocate(m%cell_faces)

      if (allocated(m%patches)) then
         do p = 1, size(m%patches)
            if (allocated(m%patches(p)%face_ids)) deallocate(m%patches(p)%face_ids)
         end do
         deallocate(m%patches)
      end if

      m%npoints = 0
      m%ncells = 0
      m%nfaces = 0
      m%npatches = 0
   end subroutine mesh_finalize