From: guido Date: Fri, 1 Feb 2002 13:57:30 +0000 (+0000) Subject: additional function exists in sparsity patterns X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c95ee72bcd056ac341533a326a530122003ab901;p=dealii-svn.git additional function exists in sparsity patterns git-svn-id: https://svn.dealii.org/trunk@5446 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/block_sparsity_pattern.h b/deal.II/lac/include/lac/block_sparsity_pattern.h index 5e9e43b3b5..25d324f568 100644 --- a/deal.II/lac/include/lac/block_sparsity_pattern.h +++ b/deal.II/lac/include/lac/block_sparsity_pattern.h @@ -283,6 +283,12 @@ class BlockSparsityPatternBase : public Subscriptor */ unsigned int n_cols () const; + /** + * Check if a value at a certain + * position may be non-zero. + */ + bool exists (const unsigned int i, const unsigned int j) const; + /** * Return the number of nonzero * elements of this @@ -557,6 +563,24 @@ BlockSparsityPatternBase::add (const unsigned int i, +template +inline +bool +BlockSparsityPatternBase::exists (const unsigned int i, + const unsigned int j) const +{ + // if you get an error here, are + // you sure you called + // @p{collect_sizes()} before? + const std::pair + row_index = row_indices.global_to_local (i), + col_index = column_indices.global_to_local (j); + return sub_objects[row_index.first][col_index.first]->exists (row_index.second, + col_index.second); +}; + + + template inline unsigned int diff --git a/deal.II/lac/include/lac/compressed_sparsity_pattern.h b/deal.II/lac/include/lac/compressed_sparsity_pattern.h index f629e00cf5..dcd3b1f706 100644 --- a/deal.II/lac/include/lac/compressed_sparsity_pattern.h +++ b/deal.II/lac/include/lac/compressed_sparsity_pattern.h @@ -217,6 +217,12 @@ class CompressedSparsityPattern : public Subscriptor const unsigned int j); /** + * Check if a value at a certain + * position may be non-zero. + */ + bool exists (const unsigned int i, const unsigned int j) const; + + /** * Make the sparsity pattern * symmetric by adding the * sparsity pattern of the diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index 221e316853..7998fb8c5d 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -661,7 +661,7 @@ SparseMatrix::residual (Vector &dst, Threads::encapsulate (&SparseMatrix:: template threaded_residual) .collect_args (this, dst, u, b, - std::make_pair + std::pair (n_rows * i / n_threads, n_rows * (i+1) / n_threads), &partial_norms[i])); diff --git a/deal.II/lac/include/lac/sparsity_pattern.h b/deal.II/lac/include/lac/sparsity_pattern.h index 0c16477b57..ba81481fd8 100644 --- a/deal.II/lac/include/lac/sparsity_pattern.h +++ b/deal.II/lac/include/lac/sparsity_pattern.h @@ -576,6 +576,13 @@ class SparsityPattern : public Subscriptor */ unsigned int n_cols () const; + /** + * Check if a value at a certain + * position may be non-zero. + */ + bool exists (const unsigned int i, const unsigned int j) const; + + /** * Number of entries in a specific row. */ diff --git a/deal.II/lac/source/compressed_sparsity_pattern.cc b/deal.II/lac/source/compressed_sparsity_pattern.cc index c628f1fd09..51c9d865bd 100644 --- a/deal.II/lac/source/compressed_sparsity_pattern.cc +++ b/deal.II/lac/source/compressed_sparsity_pattern.cc @@ -125,6 +125,18 @@ CompressedSparsityPattern::add (const unsigned int i, }; +bool +CompressedSparsityPattern::exists (const unsigned int i, + const unsigned int j) const +{ + Assert (i