From: David Wells Date: Sun, 30 Oct 2022 00:48:33 +0000 (-0400) Subject: BlockSparsityPatternBase: Convert rows/cols to block_rows/block_cols. X-Git-Tag: v9.5.0-rc1~867^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9972991d14c7df285c8745cdcabcf9acc4502cc4;p=dealii.git BlockSparsityPatternBase: Convert rows/cols to block_rows/block_cols. --- diff --git a/include/deal.II/lac/block_sparsity_pattern.h b/include/deal.II/lac/block_sparsity_pattern.h index d78bfa596f..f1b9298a71 100644 --- a/include/deal.II/lac/block_sparsity_pattern.h +++ b/include/deal.II/lac/block_sparsity_pattern.h @@ -350,12 +350,12 @@ protected: /** * Number of block rows. */ - size_type rows; + size_type block_rows; /** * Number of block columns. */ - size_type columns; + size_type block_columns; /** * Array of sparsity patterns. @@ -770,9 +770,9 @@ inline SparsityPatternType & BlockSparsityPatternBase::block(const size_type row, const size_type column) { - AssertIndexRange(row, rows); - AssertIndexRange(column, columns); - return *sub_objects[row][column]; + AssertIndexRange(row, n_block_rows()); + AssertIndexRange(column, n_block_cols()); + return *sub_objects(row, column); } @@ -783,9 +783,9 @@ BlockSparsityPatternBase::block( const size_type row, const size_type column) const { - AssertIndexRange(row, rows); - AssertIndexRange(column, columns); - return *sub_objects[row][column]; + AssertIndexRange(row, n_block_rows()); + AssertIndexRange(column, n_block_cols()); + return *sub_objects(row, column); } @@ -841,15 +841,15 @@ BlockSparsityPatternBase::add_entries( Assert(n_cols() == compute_n_cols(), ExcNeedsCollectSizes()); // Resize scratch arrays - if (block_column_indices.size() < this->n_block_cols()) + if (block_column_indices.size() < n_block_cols()) { - block_column_indices.resize(this->n_block_cols()); - counter_within_block.resize(this->n_block_cols()); + block_column_indices.resize(n_block_cols()); + counter_within_block.resize(n_block_cols()); } - const size_type n_cols = static_cast(end - begin); + const size_type n_added_cols = static_cast(end - begin); - // Resize sub-arrays to n_cols. This + // Resize sub-arrays to n_added_cols. This // is a bit wasteful, but we resize // only a few times (then the maximum // row length won't increase that @@ -859,9 +859,9 @@ BlockSparsityPatternBase::add_entries( // whether the size of one is large // enough before actually going // through all of them. - if (block_column_indices[0].size() < n_cols) + if (block_column_indices[0].size() < n_added_cols) for (size_type i = 0; i < this->n_block_cols(); ++i) - block_column_indices[i].resize(n_cols); + block_column_indices[i].resize(n_added_cols); // Reset the number of added elements // in each block to zero. @@ -893,9 +893,9 @@ BlockSparsityPatternBase::add_entries( // If in debug mode, do a check whether // the right length has been obtained. size_type length = 0; - for (size_type i = 0; i < this->n_block_cols(); ++i) + for (size_type i = 0; i < n_block_cols(); ++i) length += counter_within_block[i]; - Assert(length == n_cols, ExcInternalError()); + Assert(length == n_added_cols, ExcInternalError()); #endif // Now we found out about where the @@ -948,7 +948,7 @@ BlockSparsityPatternBase::row_length( unsigned int c = 0; - for (size_type b = 0; b < rows; ++b) + for (size_type b = 0; b < n_block_rows(); ++b) c += sub_objects[row_index.first][b]->row_length(row_index.second); return c; @@ -960,7 +960,7 @@ template inline typename BlockSparsityPatternBase::size_type BlockSparsityPatternBase::n_block_cols() const { - return columns; + return block_columns; } @@ -969,7 +969,7 @@ template inline typename BlockSparsityPatternBase::size_type BlockSparsityPatternBase::n_block_rows() const { - return rows; + return block_rows; } @@ -985,7 +985,7 @@ BlockDynamicSparsityPattern::column_number(const size_type row, size_type c = 0; size_type block_columns = 0; // sum of n_cols for all blocks to the left - for (unsigned int b = 0; b < columns; ++b) + for (unsigned int b = 0; b < this->n_block_cols(); ++b) { unsigned int rowlen = sub_objects[row_index.first][b]->row_length(row_index.second); @@ -1003,11 +1003,11 @@ BlockDynamicSparsityPattern::column_number(const size_type row, inline void -BlockSparsityPattern::reinit(const size_type n_block_rows, - const size_type n_block_columns) +BlockSparsityPattern::reinit(const size_type new_block_rows, + const size_type new_block_columns) { - BlockSparsityPatternBase::reinit(n_block_rows, - n_block_columns); + BlockSparsityPatternBase::reinit(new_block_rows, + new_block_columns); } diff --git a/source/lac/block_sparsity_pattern.cc b/source/lac/block_sparsity_pattern.cc index 9b712c13f0..0f4d67a4e9 100644 --- a/source/lac/block_sparsity_pattern.cc +++ b/source/lac/block_sparsity_pattern.cc @@ -23,19 +23,19 @@ DEAL_II_NAMESPACE_OPEN template BlockSparsityPatternBase::BlockSparsityPatternBase() - : rows(0) - , columns(0) + : block_rows(0) + , block_columns(0) {} template BlockSparsityPatternBase::BlockSparsityPatternBase( - const size_type n_block_rows, - const size_type n_block_columns) + const size_type block_rows, + const size_type block_columns) : BlockSparsityPatternBase() { - reinit(n_block_rows, n_block_columns); + reinit(block_rows, block_columns); } @@ -46,7 +46,7 @@ BlockSparsityPatternBase::BlockSparsityPatternBase( : BlockSparsityPatternBase() { (void)s; - Assert(s.rows == 0 && s.columns == 0, + Assert(s.n_block_rows() == 0 && s.n_block_cols() == 0, ExcMessage( "This constructor can only be called if the provided argument " "is the sparsity pattern for an empty matrix. This constructor can " @@ -58,17 +58,17 @@ BlockSparsityPatternBase::BlockSparsityPatternBase( template void BlockSparsityPatternBase::reinit( - const size_type n_block_rows, - const size_type n_block_columns) + const size_type new_block_rows, + const size_type new_block_columns) { sub_objects.reinit(0, 0); - rows = n_block_rows; - columns = n_block_columns; + block_rows = new_block_rows; + block_columns = new_block_columns; - sub_objects.reinit(rows, columns); - for (size_type i = 0; i < rows; ++i) - for (size_type j = 0; j < columns; ++j) + sub_objects.reinit(block_rows, block_columns); + for (size_type i = 0; i < n_block_rows(); ++i) + for (size_type j = 0; j < n_block_cols(); ++j) sub_objects[i][j] = std::make_unique(); } @@ -78,11 +78,11 @@ BlockSparsityPatternBase & BlockSparsityPatternBase::operator=( const BlockSparsityPatternBase &bsp) { - Assert(rows == bsp.rows, ExcDimensionMismatch(rows, bsp.rows)); - Assert(columns == bsp.columns, ExcDimensionMismatch(columns, bsp.columns)); + AssertDimension(n_block_rows(), bsp.n_block_rows()); + AssertDimension(n_block_cols(), bsp.n_block_cols()); // copy objects - for (size_type i = 0; i < rows; ++i) - for (size_type j = 0; j < columns; ++j) + for (size_type i = 0; i < n_block_rows(); ++i) + for (size_type j = 0; j < n_block_cols(); ++j) *sub_objects[i][j] = *bsp.sub_objects[i][j]; // update index objects collect_sizes(); @@ -99,7 +99,7 @@ BlockSparsityPatternBase::compute_n_rows() const // only count in first column, since // all rows should be equivalent size_type count = 0; - for (size_type r = 0; r < rows; ++r) + for (size_type r = 0; r < n_block_rows(); ++r) count += sub_objects[r][0]->n_rows(); return count; } @@ -113,7 +113,7 @@ BlockSparsityPatternBase::compute_n_cols() const // only count in first row, since // all rows should be equivalent size_type count = 0; - for (size_type c = 0; c < columns; ++c) + for (size_type c = 0; c < n_block_cols(); ++c) count += sub_objects[0][c]->n_cols(); return count; } @@ -124,18 +124,18 @@ template void BlockSparsityPatternBase::collect_sizes() { - std::vector row_sizes(rows); - std::vector col_sizes(columns); + std::vector row_sizes(n_block_rows()); + std::vector col_sizes(n_block_cols()); // first find out the row sizes // from the first block column - for (size_type r = 0; r < rows; ++r) + for (size_type r = 0; r < n_block_rows(); ++r) row_sizes[r] = sub_objects[r][0]->n_rows(); // then check that the following // block columns have the same // sizes - for (size_type c = 1; c < columns; ++c) - for (size_type r = 0; r < rows; ++r) + for (size_type c = 1; c < n_block_cols(); ++c) + for (size_type r = 0; r < n_block_rows(); ++r) Assert(row_sizes[r] == sub_objects[r][c]->n_rows(), ExcIncompatibleRowNumbers(r, 0, r, c)); @@ -145,10 +145,10 @@ BlockSparsityPatternBase::collect_sizes() // then do the same with the columns - for (size_type c = 0; c < columns; ++c) + for (size_type c = 0; c < n_block_cols(); ++c) col_sizes[c] = sub_objects[0][c]->n_cols(); - for (size_type r = 1; r < rows; ++r) - for (size_type c = 0; c < columns; ++c) + for (size_type r = 1; r < n_block_rows(); ++r) + for (size_type c = 0; c < n_block_cols(); ++c) Assert(col_sizes[c] == sub_objects[r][c]->n_cols(), ExcIncompatibleRowNumbers(0, c, r, c)); @@ -163,8 +163,8 @@ template void BlockSparsityPatternBase::compress() { - for (size_type i = 0; i < rows; ++i) - for (size_type j = 0; j < columns; ++j) + for (size_type i = 0; i < n_block_rows(); ++i) + for (size_type j = 0; j < n_block_cols(); ++j) sub_objects[i][j]->compress(); } @@ -174,8 +174,8 @@ template bool BlockSparsityPatternBase::empty() const { - for (size_type i = 0; i < rows; ++i) - for (size_type j = 0; j < columns; ++j) + for (size_type i = 0; i < n_block_rows(); ++i) + for (size_type j = 0; j < n_block_cols(); ++j) if (sub_objects[i][j]->empty() == false) return false; return true; @@ -188,10 +188,10 @@ typename BlockSparsityPatternBase::size_type BlockSparsityPatternBase::max_entries_per_row() const { size_type max_entries = 0; - for (size_type block_row = 0; block_row < rows; ++block_row) + for (size_type block_row = 0; block_row < n_block_rows(); ++block_row) { size_type this_row = 0; - for (size_type c = 0; c < columns; ++c) + for (size_type c = 0; c < n_block_cols(); ++c) this_row += sub_objects[block_row][c]->max_entries_per_row(); if (this_row > max_entries) @@ -229,8 +229,8 @@ typename BlockSparsityPatternBase::size_type BlockSparsityPatternBase::n_nonzero_elements() const { size_type count = 0; - for (size_type i = 0; i < rows; ++i) - for (size_type j = 0; j < columns; ++j) + for (size_type i = 0; i < n_block_rows(); ++i) + for (size_type j = 0; j < n_block_cols(); ++j) count += sub_objects[i][j]->n_nonzero_elements(); return count; } @@ -347,7 +347,7 @@ BlockSparsityPatternBase::print_svg( << "\" fill=\"rgb(255, 255, 255)\"/>\n\n"; for (unsigned int block_i = 0; block_i < n_block_rows(); ++block_i) - for (unsigned int block_j = 0; block_j < n_block_rows(); ++block_j) + for (unsigned int block_j = 0; block_j < n_block_cols(); ++block_j) for (const auto &entry : block(block_i, block_j)) { out << " is_compressed() == false) return false; return true; @@ -421,13 +421,13 @@ std::size_t BlockSparsityPattern::memory_consumption() const { std::size_t mem = 0; - mem += (MemoryConsumption::memory_consumption(rows) + - MemoryConsumption::memory_consumption(columns) + + 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 < rows; ++r) - for (size_type c = 0; c < columns; ++c) + 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;