17 #include <deal.II/lac/chunk_sparsity_pattern.h> 18 #include <deal.II/lac/dynamic_sparsity_pattern.h> 19 #include <deal.II/lac/full_matrix.h> 22 DEAL_II_NAMESPACE_OPEN
39 "This constructor can only be called if the provided argument " 40 "is the sparsity pattern for an empty matrix. This constructor can " 41 "not be used to copy-construct a non-empty sparsity pattern."));
55 reinit(m, n, max_per_row, chunk_size);
63 const std::vector<size_type> &row_lengths,
68 reinit(m, n, row_lengths, chunk_size);
77 reinit(n, n, max_per_row, chunk_size);
84 const std::vector<size_type> &row_lengths,
89 reinit(m, m, row_lengths, chunk_size);
99 "This operator can only be called if the provided argument " 100 "is the sparsity pattern for an empty matrix. This operator can " 101 "not be used to copy a non-empty sparsity pattern."));
104 ExcMessage(
"This operator can only be called if the current object is " 124 const std::vector<size_type> row_lengths(m, max_per_row);
125 reinit(m, n, row_lengths, chunk_size);
134 const VectorSlice<
const std::vector<size_type>> &row_lengths,
149 const size_type m_chunks = (m + chunk_size - 1) / chunk_size,
158 std::vector<unsigned int> chunk_row_lengths(m_chunks, 0);
160 chunk_row_lengths[i / chunk_size] += row_lengths[i];
165 if (m != n && m_chunks == n_chunks)
166 for (
unsigned int i = 0; i < m_chunks; ++i)
167 ++chunk_row_lengths[i];
182 template <
typename SparsityPatternType>
202 const size_type m_chunks = (dsp.n_rows() + chunk_size - 1) / chunk_size,
203 n_chunks = (dsp.n_cols() + chunk_size - 1) / chunk_size;
206 for (
size_type row = 0; row < dsp.n_rows(); ++row)
213 for (
typename SparsityPatternType::iterator col_num = dsp.begin(row);
214 col_num != dsp.end(row);
216 temporary_sp.
add(reduced_row, col_num->column() /
chunk_size);
224 template <
typename number>
235 std::vector<size_type> entries_per_row(matrix.
m(), 0);
236 for (
size_type row = 0; row < matrix.
m(); ++row)
238 for (
size_type col = 0; col < matrix.
n(); ++col)
239 if (matrix(row, col) != 0)
240 ++entries_per_row[row];
242 if ((matrix.
m() == matrix.
n()) && (matrix(row, row) == 0))
243 ++entries_per_row[row];
249 for (
size_type row = 0; row < matrix.
m(); ++row)
250 for (
size_type col = 0; col < matrix.
n(); ++col)
251 if (matrix(row, col) != 0)
263 const std::vector<size_type> &row_lengths,
268 reinit(m, n, make_slice(row_lengths), chunk_size);
277 template <
typename SparsityPatternType>
294 template <
typename Sparsity>
297 const unsigned int n,
298 const Sparsity &sparsity_pattern_for_chunks,
299 const unsigned int chunk_size_in,
302 Assert(m > (sparsity_pattern_for_chunks.n_rows() - 1) * chunk_size_in &&
303 m <= sparsity_pattern_for_chunks.n_rows() * chunk_size_in,
304 ExcMessage(
"Number of rows m is not compatible with chunk size " 305 "and number of rows in sparsity pattern for the chunks."));
306 Assert(n > (sparsity_pattern_for_chunks.n_cols() - 1) * chunk_size_in &&
307 n <= sparsity_pattern_for_chunks.n_cols() * chunk_size_in,
309 "Number of columns m is not compatible with chunk size " 310 "and number of columns in sparsity pattern for the chunks."));
387 for (; p !=
end; ++p)
478 out <<
']' << std::endl;
513 << -static_cast<signed int>(i *
chunk_size + e) << std::endl;
598 ChunkSparsityPattern::copy_from<DynamicSparsityPattern>(
602 ChunkSparsityPattern::create_from<SparsityPattern>(
const unsigned int,
608 ChunkSparsityPattern::create_from<DynamicSparsityPattern>(
621 DEAL_II_NAMESPACE_CLOSE
void copy_from(const size_type n_rows, const size_type n_cols, const ForwardIterator begin, const ForwardIterator end, const size_type chunk_size)
void block_write(std::ostream &out) const
static::ExceptionBase & ExcEmptyObject()
std::size_t memory_consumption() const
static::ExceptionBase & ExcInvalidNumber(int arg1)
void print_gnuplot(std::ostream &out) const
static::ExceptionBase & ExcInvalidIndex(int arg1, int arg2)
std::size_t memory_consumption() const
static::ExceptionBase & ExcIO()
static const size_type invalid_entry
types::global_dof_index size_type
void add(const size_type i, const size_type j)
bool exists(const size_type i, const size_type j) const
void block_read(std::istream &in)
#define AssertThrow(cond, exc)
void add(const size_type i, const size_type j)
static::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
SparsityPattern sparsity_pattern
std::unique_ptr< size_type[]> colnums
bool stores_only_added_elements() const
static::ExceptionBase & ExcMessage(std::string arg1)
size_type max_entries_per_row() const
size_type max_entries_per_row() const
size_type bandwidth() const
void add(const size_type i, const size_type j)
void block_write(std::ostream &out) const
#define Assert(cond, exc)
size_type n_nonzero_elements() const
unsigned int row_length(const size_type row) const
void print(std::ostream &out) const
bool stores_only_added_elements() const
void copy_from(const size_type n_rows, const size_type n_cols, const ForwardIterator begin, const ForwardIterator end)
size_type bandwidth() const
size_type row_length(const size_type row) const
ChunkSparsityPattern & operator=(const ChunkSparsityPattern &)
void reinit(const size_type m, const size_type n, const unsigned int max_per_row)
static::ExceptionBase & ExcNotQuadratic()
std::unique_ptr< std::size_t[]> rowstart
void block_read(std::istream &in)
bool exists(const size_type i, const size_type j) const
void create_from(const unsigned int m, const unsigned int n, const Sparsity &sparsity_pattern_for_chunks, const unsigned int chunk_size, const bool optimize_diagonal=true)
std::size_t n_nonzero_elements() const
void reinit(const size_type m, const size_type n, const size_type max_per_row, const size_type chunk_size)