From bb64b4cd16067b61a2534950c9f7ff242b12d63c Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 31 Jul 2008 13:30:54 +0000 Subject: [PATCH] Fix a few functions. Implement some missing functionality. git-svn-id: https://svn.dealii.org/trunk@16464 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/include/lac/chunk_sparsity_pattern.h | 10 -- deal.II/lac/source/chunk_sparsity_pattern.cc | 111 ++++++++++++++++-- 2 files changed, 99 insertions(+), 22 deletions(-) diff --git a/deal.II/lac/include/lac/chunk_sparsity_pattern.h b/deal.II/lac/include/lac/chunk_sparsity_pattern.h index c334af2500..0d383b451c 100644 --- a/deal.II/lac/include/lac/chunk_sparsity_pattern.h +++ b/deal.II/lac/include/lac/chunk_sparsity_pattern.h @@ -850,16 +850,6 @@ ChunkSparsityPattern::optimize_diagonal () const } -inline -unsigned int -ChunkSparsityPattern::n_nonzero_elements () const -{ - return (sparsity_pattern.n_nonzero_elements() * - chunk_size * - chunk_size); -} - - template void diff --git a/deal.II/lac/source/chunk_sparsity_pattern.cc b/deal.II/lac/source/chunk_sparsity_pattern.cc index 8d86337a45..8593f7608c 100644 --- a/deal.II/lac/source/chunk_sparsity_pattern.cc +++ b/deal.II/lac/source/chunk_sparsity_pattern.cc @@ -155,15 +155,18 @@ ChunkSparsityPattern::reinit ( // compute the maximum number of chunks in // each row. the passed array denotes the - // number of entries in each row -- in the - // worst case, these are all in independent - // chunks, so we have to calculate it as - // follows: + // number of entries in each row of the big + // matrix -- in the worst case, these are + // all in independent chunks, so we have to + // calculate it as follows (as an example: + // let chunk_size==2, + // row_lengths={2,2,...}, and entries in + // row zero at columns {0,2} and for row + // one at {4,6} --> we'll need 4 chunks for + // the first chunk row!) : std::vector chunk_row_lengths (m_chunks, 0); for (unsigned int i=0; irow() != sparsity_pattern.n_rows() - 1) + && + (p->column() != sparsity_pattern.n_cols() - 1)) + n += chunk_size * chunk_size; + else + if ((p->row() == sparsity_pattern.n_rows() - 1) + && + (p->column() != sparsity_pattern.n_cols() - 1)) + // last chunk row, but not + // last chunk column. only a + // smaller number (n_rows % + // chunk_size) of rows + // actually exist + n += (n_rows() % chunk_size) * chunk_size; + else + if ((p->row() != sparsity_pattern.n_rows() - 1) + && + (p->column() == sparsity_pattern.n_cols() - 1)) + // last chunk column, but + // not row + n += (n_cols() % chunk_size) * chunk_size; + else + // bottom right chunk + n += (n_cols() % chunk_size) * + (n_rows() % chunk_size); + + return n; + } + } +} + + + void ChunkSparsityPattern::print (std::ostream &out) const { @@ -370,13 +445,18 @@ ChunkSparsityPattern::print (std::ostream &out) const AssertThrow (out, ExcIO()); for (unsigned int i=0; i> c; AssertThrow (c == '[', ExcIO()); in >> rows - >> cols; + >> cols + >> chunk_size; in >> c; AssertThrow (c == ']', ExcIO()); -- 2.39.5