From 17dc9e127519726fbe3a55787d4bb36718d130d4 Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Mon, 4 Nov 2024 22:37:13 -0800 Subject: [PATCH] reset -> reset_memory --- include/numerics/petsc_matrix.h | 2 ++ include/numerics/petsc_matrix_base.h | 4 ---- include/numerics/sparse_matrix.h | 7 ++----- src/numerics/petsc_matrix.C | 15 +++++++++++++++ src/numerics/petsc_matrix_base.C | 13 ------------- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/include/numerics/petsc_matrix.h b/include/numerics/petsc_matrix.h index 6bafd0acc60..07ef0094847 100644 --- a/include/numerics/petsc_matrix.h +++ b/include/numerics/petsc_matrix.h @@ -291,6 +291,8 @@ class PetscMatrix final : public PetscMatrixBase virtual bool supports_hash_table() const override { return true; } + virtual void reset_memory() override; + protected: /** * Perform matrix initialization steps sans preallocation diff --git a/include/numerics/petsc_matrix_base.h b/include/numerics/petsc_matrix_base.h index c236fcdbf58..61124433132 100644 --- a/include/numerics/petsc_matrix_base.h +++ b/include/numerics/petsc_matrix_base.h @@ -171,10 +171,6 @@ class PetscMatrixBase : public SparseMatrix virtual bool closed() const override; -#if PETSC_RELEASE_GREATER_EQUALS(3,23,0) - virtual void reset () override; -#endif - protected: /** diff --git a/include/numerics/sparse_matrix.h b/include/numerics/sparse_matrix.h index 3735055ea01..f9f10e7013e 100644 --- a/include/numerics/sparse_matrix.h +++ b/include/numerics/sparse_matrix.h @@ -605,12 +605,9 @@ class SparseMatrix : public ReferenceCountedObject>, bool use_hash_table() const { return _use_hash_table; } /** - * Reset the state of the matrix. The default implementation calls \p clear() but this is meant to - * be more nuanced in that it can reset the state of the matrix without deallocating core data - * structures. As an example, this would not destroy the \p Mat data member for PETSc matrix - * derived classes + * Reset the memory storage of the matrix */ - virtual void reset() { this->clear(); } + virtual void reset_memory() { libmesh_not_implemented(); } protected: /** diff --git a/src/numerics/petsc_matrix.C b/src/numerics/petsc_matrix.C index 521a94f62d3..ef8a2e8e729 100644 --- a/src/numerics/petsc_matrix.C +++ b/src/numerics/petsc_matrix.C @@ -1284,6 +1284,21 @@ PetscMatrix::copy_from_hash () } #endif +template +void +PetscMatrix::reset_memory() +{ + if (this->_use_hash_table) +#if PETSC_RELEASE_GREATER_EQUALS(3, 23, 0) + // This performs MatReset plus re-establishes the hash table + LibmeshPetscCall(MatResetHash(this->_mat)); +#else + libmesh_error_msg("Hash tables not fully supported until PETSc version 3.23"); +#endif + else + this->reset_preallocation(); +} + //------------------------------------------------------------------ // Explicit instantiations template class LIBMESH_EXPORT PetscMatrix; diff --git a/src/numerics/petsc_matrix_base.C b/src/numerics/petsc_matrix_base.C index b894f809782..df4d8acaa08 100644 --- a/src/numerics/petsc_matrix_base.C +++ b/src/numerics/petsc_matrix_base.C @@ -249,19 +249,6 @@ bool PetscMatrixBase::closed() const return (assembled == PETSC_TRUE); } -#if PETSC_RELEASE_GREATER_EQUALS(3,23,0) -template -void -PetscMatrixBase::reset() -{ - if (this->_use_hash_table) - // This performs MatReset plus re-establishes the hash table - LibmeshPetscCall(MatResetHash(this->_mat)); - else - LibmeshPetscCall(MatReset(this->_mat)); -} -#endif - //------------------------------------------------------------------ // Explicit instantiations template class LIBMESH_EXPORT PetscMatrixBase;