]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Do not use the compress() function when using copy_from with CompressedSP since then...
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 6 Apr 2009 15:45:11 +0000 (15:45 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 6 Apr 2009 15:45:11 +0000 (15:45 +0000)
git-svn-id: https://svn.dealii.org/trunk@18557 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/sparsity_pattern.cc

index af42af27034d65675048ef8116d273fc00eac542..32a18e56876bd9e9739753477542973152ef82b6 100644 (file)
@@ -566,8 +566,15 @@ SparsityPattern::copy_from (const CompressedSparsityPattern &csp,
   const bool is_square = optimize_diag && (csp.n_rows() == csp.n_cols());
   std::vector<unsigned int> row_lengths (csp.n_rows());
   for (unsigned int i=0; i<csp.n_rows(); ++i)
-    row_lengths[i] = csp.row_length(i) +
-                     (is_square ? 1 : 0);
+    {
+      unsigned int additional_diagonal = 0;
+      if (is_square)
+       if (csp.exists(i,i) == false)
+         additional_diagonal = 1;
+
+      row_lengths[i] = csp.row_length(i) + additional_diagonal;
+    }
+
   reinit (csp.n_rows(), csp.n_cols(), row_lengths, is_square);
 
                                   // now enter all the elements into
@@ -588,10 +595,11 @@ SparsityPattern::copy_from (const CompressedSparsityPattern &csp,
        }
     }
 
-                                  // finally compress
-                                  // everything. this also sorts the
-                                  // entries within each row
-  compress ();
+                                  // do not need to compress the sparsity
+                                  // pattern since we already have
+                                  // allocated the right amount of data,
+                                  // and the CSP data is sorted, too.
+  compressed = true;
 }
 
 
@@ -613,8 +621,14 @@ SparsityPattern::copy_from (const CompressedSetSparsityPattern &csp,
   const bool is_square = optimize_diag && (csp.n_rows() == csp.n_cols());
   std::vector<unsigned int> row_lengths (csp.n_rows());
   for (unsigned int i=0; i<csp.n_rows(); ++i)
-    row_lengths[i] = csp.row_length(i) +
-                     (is_square ? 1 : 0);
+    {
+      unsigned int additional_diagonal = 0;
+      if (is_square)
+       if (csp.exists(i,i) == false)
+         additional_diagonal = 1;
+
+      row_lengths[i] = csp.row_length(i) + additional_diagonal;
+    }
   reinit (csp.n_rows(), csp.n_cols(), row_lengths, is_square);
 
                                   // now enter all the elements into
@@ -637,10 +651,12 @@ SparsityPattern::copy_from (const CompressedSetSparsityPattern &csp,
        }
     }
 
-                                  // finally compress
-                                  // everything. this also sorts the
-                                  // entries within each row
-  compress ();
+                                  // do not need to compress the sparsity
+                                  // pattern since we already have
+                                  // allocated the right amount of data,
+                                  // and the CSP data is sorted, too.
+  //compress ();
+  compressed = true;
 }
 
 void
@@ -660,8 +676,14 @@ SparsityPattern::copy_from (const CompressedSimpleSparsityPattern &csp,
   const bool is_square = optimize_diag && (csp.n_rows() == csp.n_cols());
   std::vector<unsigned int> row_lengths (csp.n_rows());
   for (unsigned int i=0; i<csp.n_rows(); ++i)
-    row_lengths[i] = csp.row_length(i) +
-                     (is_square ? 1 : 0);
+    {
+      unsigned int additional_diagonal = 0;
+      if (is_square)
+       if (csp.exists(i,i) == false)
+         additional_diagonal = 1;
+
+      row_lengths[i] = csp.row_length(i) + additional_diagonal;
+    }
   reinit (csp.n_rows(), csp.n_cols(), row_lengths, is_square);
 
                                    // now enter all the elements into
@@ -682,10 +704,11 @@ SparsityPattern::copy_from (const CompressedSimpleSparsityPattern &csp,
         }
     }
 
-                                   // finally compress
-                                   // everything. this also sorts the
-                                   // entries within each row
-  compress ();
+                                  // do not need to compress the sparsity
+                                  // pattern since we already have
+                                  // allocated the right amount of data,
+                                  // and the CSP data is sorted, too.
+  compressed = true;
 }
 
 

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.