From a49f4b9b941fa19853999fe961a9b11589c2bcbe Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 29 Oct 2022 19:44:39 -0400 Subject: [PATCH] BlockSparsityPatternBase: C++11 cleanups. --- include/deal.II/lac/block_sparsity_pattern.h | 11 +----- source/lac/block_sparsity_pattern.cc | 40 ++------------------ 2 files changed, 5 insertions(+), 46 deletions(-) diff --git a/include/deal.II/lac/block_sparsity_pattern.h b/include/deal.II/lac/block_sparsity_pattern.h index cfff498c88..48e89f0b44 100644 --- a/include/deal.II/lac/block_sparsity_pattern.h +++ b/include/deal.II/lac/block_sparsity_pattern.h @@ -117,11 +117,6 @@ public: */ BlockSparsityPatternBase(const BlockSparsityPatternBase &bsp); - /** - * Destructor. - */ - ~BlockSparsityPatternBase() override; - /** * Resize the matrix, by setting the number of block rows and columns. This * deletes all blocks and replaces them with uninitialized ones, i.e. ones @@ -161,7 +156,6 @@ public: SparsityPatternType & block(const size_type row, const size_type column); - /** * Access the block with the given coordinates. Version for constant * objects. @@ -357,10 +351,7 @@ protected: /** * Array of sparsity patterns. */ - Table<2, - SmartPointer>> - sub_objects; + Table<2, std::unique_ptr> sub_objects; /** * Object storing and managing the transformation of row indices to indices diff --git a/source/lac/block_sparsity_pattern.cc b/source/lac/block_sparsity_pattern.cc index 73ef42c281..e927b177dd 100644 --- a/source/lac/block_sparsity_pattern.cc +++ b/source/lac/block_sparsity_pattern.cc @@ -33,8 +33,7 @@ template BlockSparsityPatternBase::BlockSparsityPatternBase( const size_type n_block_rows, const size_type n_block_columns) - : rows(0) - , columns(0) + : BlockSparsityPatternBase() { reinit(n_block_rows, n_block_columns); } @@ -44,9 +43,7 @@ BlockSparsityPatternBase::BlockSparsityPatternBase( template BlockSparsityPatternBase::BlockSparsityPatternBase( const BlockSparsityPatternBase &s) - : Subscriptor() - , rows(0) - , columns(0) + : BlockSparsityPatternBase() { (void)s; Assert(s.rows == 0 && s.columns == 0, @@ -58,50 +55,21 @@ BlockSparsityPatternBase::BlockSparsityPatternBase( -template -BlockSparsityPatternBase::~BlockSparsityPatternBase() -{ - // clear all memory - try - { - reinit(0, 0); - } - catch (...) - {} -} - - - template void BlockSparsityPatternBase::reinit( const size_type n_block_rows, const size_type n_block_columns) { - // delete previous content and - // clean the sub_objects array - // completely - for (size_type i = 0; i < rows; ++i) - for (size_type j = 0; j < columns; ++j) - { - SparsityPatternType *sp = sub_objects[i][j]; - sub_objects[i][j] = nullptr; - delete sp; - } sub_objects.reinit(0, 0); - // then set new sizes rows = n_block_rows; columns = n_block_columns; - sub_objects.reinit(rows, columns); - // allocate new objects + sub_objects.reinit(rows, columns); for (size_type i = 0; i < rows; ++i) for (size_type j = 0; j < columns; ++j) - { - SparsityPatternType *p = new SparsityPatternType; - sub_objects[i][j] = p; - } + sub_objects[i][j] = std::make_unique(); } -- 2.39.5