]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
additional function exists in sparsity patterns
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Feb 2002 13:57:30 +0000 (13:57 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Feb 2002 13:57:30 +0000 (13:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@5446 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_sparsity_pattern.h
deal.II/lac/include/lac/compressed_sparsity_pattern.h
deal.II/lac/include/lac/sparse_matrix.templates.h
deal.II/lac/include/lac/sparsity_pattern.h
deal.II/lac/source/compressed_sparsity_pattern.cc
deal.II/lac/source/sparsity_pattern.cc

index 5e9e43b3b527529e6224e3f940ecd0b40768ab73..25d324f5680a4a11e44643088784f363527a8cea 100644 (file)
@@ -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<SparsityPatternBase>::add (const unsigned int i,
 
 
 
+template <class SparsityPatternBase>
+inline
+bool
+BlockSparsityPatternBase<SparsityPatternBase>::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<unsigned int,unsigned int>
+    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 <class SparsityPatternBase>
 inline
 unsigned int
index f629e00cf5bcd15ae3fbf42149f1e350377e147d..dcd3b1f706ab0e75875ff4484e19e7c8f780e88d 100644 (file)
@@ -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
index 221e31685339eebf5b72dee33134241b2ac270df..7998fb8c5d62eaf948fd90cf4b0260823d8a6186 100644 (file)
@@ -661,7 +661,7 @@ SparseMatrix<number>::residual (Vector<somenumber>       &dst,
                        Threads::encapsulate (&SparseMatrix<number>::
                                              template threaded_residual<somenumber>)
                        .collect_args (this, dst, u, b,
-                                      std::make_pair<unsigned int,unsigned int>
+                                      std::pair<unsigned int,unsigned int>
                                       (n_rows * i / n_threads,
                                        n_rows * (i+1) / n_threads),
                                       &partial_norms[i]));
index 0c16477b579857525009c66069263e7345d6d2a0..ba81481fd810d1b42777f7fa9ce916cbf16ffc19 100644 (file)
@@ -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.
                                      */
index c628f1fd093e5f1bff93791bf949ea0174624bb3..51c9d865bd8a46f4f6cfe4aa8b966332289ff1ad 100644 (file)
@@ -125,6 +125,18 @@ CompressedSparsityPattern::add (const unsigned int i,
 };
 
 
+bool 
+CompressedSparsityPattern::exists (const unsigned int i,
+                                  const unsigned int j) const
+{
+  Assert (i<rows, ExcInvalidIndex(i,rows));
+  Assert (j<cols, ExcInvalidIndex(j,cols));
+//TODO: Ask Wolfgang on how to use column_indices
+  Assert(false, ExcNotImplemented());
+  return true;
+}
+
+
 
 void
 CompressedSparsityPattern::symmetrize () 
index 7d3486ccc9d7bee51cfcffdf988f8ec841c4dfb4..2e7e608c3c4d9cce2550120a7438ef4d14da449b 100644 (file)
@@ -620,6 +620,22 @@ SparsityPattern::add (const unsigned int i,
 };
 
 
+bool
+SparsityPattern::exists (const unsigned int i,
+                        const unsigned int j) const
+{
+  Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());  
+  Assert (i<rows, ExcIndexRange(i,0,rows));
+  Assert (j<cols, ExcIndexRange(j,0,cols));
+
+  for (unsigned int k=rowstart[i]; k<rowstart[i+1]; k++)
+    {
+                                      // entry already exists
+      if (colnums[k] == j) return true;
+    }
+  return false;
+}
+
 
 void
 SparsityPattern::symmetrize () 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.