]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement the stores_only_added_elements function for all sparsity patterns.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 31 Jul 2008 12:33:50 +0000 (12:33 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 31 Jul 2008 12:33:50 +0000 (12:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@16462 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/chunk_sparsity_pattern.h
deal.II/lac/include/lac/compressed_set_sparsity_pattern.h
deal.II/lac/include/lac/compressed_sparsity_pattern.h
deal.II/lac/include/lac/sparsity_pattern.h
deal.II/lac/source/chunk_sparsity_pattern.cc

index a144707b7720e6e38bcdcc37b6185af9743f850f..c334af2500ee851c4d228fef74dc6fa8a6bb73d7 100644 (file)
@@ -591,6 +591,30 @@ class ChunkSparsityPattern : public Subscriptor
                                       */
     bool optimize_diagonal () const;
 
+                                    /**
+                                     * Return whether this object stores only
+                                     * those entries that have been added
+                                     * explicitly, or if the sparsity pattern
+                                     * contains elements that have been added
+                                     * through other means (implicitly) while
+                                     * building it. For the current class,
+                                     * the result is false because we store
+                                     * entire chunks, not individual
+                                     * elements, and adding one entry to the
+                                     * sparsity pattern requires also adding
+                                     * all the other elements of a chunk. The
+                                     * only exception is if
+                                     * <code>chunk_size==1</code>, the
+                                     * sparsity pattern is nonsymmetric or
+                                     * optimize_diag has been set to false.
+                                     *
+                                     * This function mainly serves the
+                                     * purpose of describing the current
+                                     * class in cases where several kinds of
+                                     * sparsity patterns can be passed as
+                                     * template arguments.
+                                     */
+    bool stores_only_added_elements () const;
     
                                     /**
                                      * Write the data of this object
index 7cbcccf0e490963910425567ee5569d2aa7ae4ea..1d6f79e251f98b138f34ca6501669050381b91cf 100644 (file)
@@ -304,10 +304,29 @@ class CompressedSetSparsityPattern : public Subscriptor
 
                                     /**
                                      * Return the number of nonzero elements
-                                     * allocated through this sparsity pattern.
+                                     * allocated through this sparsity
+                                     * pattern.
                                      */
     unsigned int n_nonzero_elements () const;
 
+                                    /**
+                                     * Return whether this object stores only
+                                     * those entries that have been added
+                                     * explicitly, or if the sparsity pattern
+                                     * contains elements that have been added
+                                     * through other means (implicitly) while
+                                     * building it. For the current class,
+                                     * the result is always true.
+                                     *
+                                     * This function mainly serves the
+                                     * purpose of describing the current
+                                     * class in cases where several kinds of
+                                     * sparsity patterns can be passed as
+                                     * template arguments.
+                                     */
+    static
+    bool stores_only_added_elements ();
+
   private:
                                     /**
                                      * Number of rows that this sparsity
@@ -429,6 +448,15 @@ CompressedSetSparsityPattern::row_end (const unsigned int row) const
 }
 
 
+
+inline
+bool
+CompressedSetSparsityPattern::stores_only_added_elements ()
+{
+  return true;
+}
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 #endif
index 85b90b4ae71a93255d71f9f3991525b972923ad4..0a4e6dba2cffe751eea8facfb6e05271debdd7e9 100644 (file)
@@ -275,10 +275,29 @@ class CompressedSparsityPattern : public Subscriptor
 
                                     /**
                                      * Return the number of nonzero elements
-                                     * allocated through this sparsity pattern.
+                                     * allocated through this sparsity
+                                     * pattern.
                                      */
     unsigned int n_nonzero_elements () const;
 
+                                    /**
+                                     * Return whether this object stores only
+                                     * those entries that have been added
+                                     * explicitly, or if the sparsity pattern
+                                     * contains elements that have been added
+                                     * through other means (implicitly) while
+                                     * building it. For the current class,
+                                     * the result is always true.
+                                     *
+                                     * This function mainly serves the
+                                     * purpose of describing the current
+                                     * class in cases where several kinds of
+                                     * sparsity patterns can be passed as
+                                     * template arguments.
+                                     */
+    static
+    bool stores_only_added_elements ();
+    
   private:
                                     /**
                                      * Number of rows that this sparsity
@@ -499,6 +518,15 @@ CompressedSparsityPattern::column_number (const unsigned int row,
 
 
 
+inline
+bool
+CompressedSparsityPattern::stores_only_added_elements ()
+{
+  return true;
+}
+
+
+
 
 DEAL_II_NAMESPACE_CLOSE
 
index 2209cdf516f703604d8dee2f3c9b24616d506979..a103d53abb87e86b7c0e005272c81cee0d79d6af 100644 (file)
@@ -1170,6 +1170,26 @@ class SparsityPattern : public Subscriptor
                                      * the diagonal storage optimization.
                                       */
     bool optimize_diagonal () const;
+
+                                    /**
+                                     * Return whether this object stores only
+                                     * those entries that have been added
+                                     * explicitly, or if the sparsity pattern
+                                     * contains elements that have been added
+                                     * through other means (implicitly) while
+                                     * building it. For the current class,
+                                     * the result is true iff optimize_diag
+                                     * in the constructor or reinit() calls
+                                     * has been set to false, or if the
+                                     * represented matrix is not square.
+                                     *
+                                     * This function mainly serves the
+                                     * purpose of describing the current
+                                     * class in cases where several kinds of
+                                     * sparsity patterns can be passed as
+                                     * template arguments.
+                                     */
+    bool stores_only_added_elements () const;
     
                                      /**
                                       * Use the METIS partitioner to generate
@@ -1903,6 +1923,19 @@ SparsityPattern::optimize_diagonal () const
 }
 
 
+inline
+bool
+SparsityPattern::stores_only_added_elements () const
+{
+  if ((diagonal_optimized == true)
+      &&
+      (n_cols() == n_rows()))
+    return false;
+  else
+    return true;
+}
+
+
 inline
 const std::size_t *
 SparsityPattern::get_rowstart_indices () const
index c2b1fae0f9b9dbea1175cbc9e0900c64a519e479..07dcf829ca27017bfa13b28e8fadf8eb67aa39e6 100644 (file)
@@ -436,6 +436,18 @@ ChunkSparsityPattern::bandwidth () const
 }
 
 
+
+bool
+ChunkSparsityPattern::stores_only_added_elements () const
+{
+  if (chunk_size == 1)
+    return sparsity_pattern.stores_only_added_elements ();
+  else
+    return false;
+}
+
+
+
 void
 ChunkSparsityPattern::block_write (std::ostream &out) const 
 {

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.