From: David Wells Date: Sun, 30 Oct 2022 00:59:46 +0000 (-0400) Subject: Add BlockSparsityPatternBase::memory_consumption(). X-Git-Tag: v9.5.0-rc1~867^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d41b2ee73bd4be848bc085f9ba1992d6af06250;p=dealii.git Add BlockSparsityPatternBase::memory_consumption(). None of the inheriting classes add any class members so this should be here instead of in BlockSparsityPattern. --- diff --git a/include/deal.II/lac/block_sparsity_pattern.h b/include/deal.II/lac/block_sparsity_pattern.h index f1b9298a71..469c84bc45 100644 --- a/include/deal.II/lac/block_sparsity_pattern.h +++ b/include/deal.II/lac/block_sparsity_pattern.h @@ -310,6 +310,13 @@ public: void print_svg(std::ostream &out) const; + /** + * Determine an estimate for the memory consumption (in bytes) of this + * object. + */ + std::size_t + memory_consumption() const; + /** * @addtogroup Exceptions * @{ @@ -464,13 +471,6 @@ public: bool is_compressed() const; - /** - * Determine an estimate for the memory consumption (in bytes) of this - * object. - */ - std::size_t - memory_consumption() const; - /** * Copy data from an object of type BlockDynamicSparsityPattern, i.e. resize * this object to the size of the given argument, and copy over the contents diff --git a/source/lac/block_sparsity_pattern.cc b/source/lac/block_sparsity_pattern.cc index 0f4d67a4e9..676f9d5141 100644 --- a/source/lac/block_sparsity_pattern.cc +++ b/source/lac/block_sparsity_pattern.cc @@ -362,6 +362,25 @@ BlockSparsityPatternBase::print_svg( +template +std::size_t +BlockSparsityPatternBase::memory_consumption() const +{ + std::size_t mem = 0; + mem += (MemoryConsumption::memory_consumption(n_block_rows()) + + MemoryConsumption::memory_consumption(n_block_cols()) + + MemoryConsumption::memory_consumption(sub_objects) + + MemoryConsumption::memory_consumption(row_indices) + + MemoryConsumption::memory_consumption(column_indices)); + for (size_type r = 0; r < n_block_rows(); ++r) + for (size_type c = 0; c < n_block_cols(); ++c) + mem += MemoryConsumption::memory_consumption(*sub_objects[r][c]); + + return mem; +} + + + BlockSparsityPattern::BlockSparsityPattern(const size_type n_rows, const size_type n_columns) : BlockSparsityPatternBase(n_rows, n_columns) @@ -417,23 +436,6 @@ BlockSparsityPattern::is_compressed() const } -std::size_t -BlockSparsityPattern::memory_consumption() const -{ - std::size_t mem = 0; - mem += (MemoryConsumption::memory_consumption(n_block_rows()) + - MemoryConsumption::memory_consumption(n_block_cols()) + - MemoryConsumption::memory_consumption(sub_objects) + - MemoryConsumption::memory_consumption(row_indices) + - MemoryConsumption::memory_consumption(column_indices)); - for (size_type r = 0; r < n_block_rows(); ++r) - for (size_type c = 0; c < n_block_cols(); ++c) - mem += MemoryConsumption::memory_consumption(*sub_objects[r][c]); - - return mem; -} - - void BlockSparsityPattern::copy_from(const BlockDynamicSparsityPattern &dsp)