]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
No longer try to call PETScWrappers::MatrixBase::compress() automatically, but instea...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 30 Aug 2011 19:14:51 +0000 (19:14 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 30 Aug 2011 19:14:51 +0000 (19:14 +0000)
git-svn-id: https://svn.dealii.org/trunk@24219 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/lac/petsc_matrix_base.h
deal.II/source/lac/petsc_matrix_base.cc
tests/mpi/petsc_02.cc
tests/mpi/petsc_02/ncpu_1/cmp/generic
tests/mpi/petsc_02/ncpu_10/cmp/generic
tests/mpi/petsc_02/ncpu_4/cmp/generic

index 2e10cc328d8ed707c9f6f7e6920512af65a117e9..5ca92752991c8cd85eaa713aa2c51825be092ac6 100644 (file)
@@ -21,18 +21,20 @@ inconvenience this causes.
 </p>
 
 <ol>
-<li> Changed: The PETScWrapper::VectorBase class tried to keep track of
+<li> Changed: The PETScWrapper::VectorBase and PETScWrapper::MatrixBase
+classes tried to keep track of
 whether the last operation done on a vector was to add to an element or to
 write into one. If the previous such operation was of a different kind
 than the current one, we would flush buffers (see the description in
 @ref GlossCompress). However, trying to do this automatically turned
 out to be an endless source of hard-to-find bugs in %parallel programs.
-The scheme has therefore now been changed to the following: the class
-keeps track of the previous operation and if it differs from the
+The scheme has therefore now been changed to the following: the classes
+keep track of the previous operation and if it differs from the
 current one, reports an error stating that the user needs to call
-PETScWrapper::VectorBase::compress() instead.
+PETScWrapper::VectorBase::compress() or
+PETScWrapper::MatrixBase::compress() instead.
 <br>
-(Wolfgang Bangerth, 2011/08/03)
+(Wolfgang Bangerth, 2011/08/03, 2011/08/30)
 
 <li> Changed: The classes Tensor, SymmetricTensor and Point now have an
 additional template argument for the number type. While a default template
index 2d55c9dc8357e8f7c50d478621eb8809db40e471..2cb99594b0d72939d259bcd0712a21565b9b9656 100644 (file)
@@ -1148,7 +1148,24 @@ namespace PETScWrappers
                                         * Exception
                                         */
       DeclException0 (ExcSourceEqualsDestination);
-
+      
+      /**
+        * Exception.
+       */
+      DeclException2 (ExcWrongMode,
+                     int, int,
+                     << "You tried to do a "
+                     << (arg1 == 1 ?
+                         "'set'" :
+                         (arg1 == 2 ?
+                          "'add'" : "???"))
+                     << " operation but the vector is currently in "
+                     << (arg2 == 1 ?
+                         "'set'" :
+                         (arg2 == 2 ?
+                          "'add'" : "???"))
+                     << " mode. You first have to call 'compress()'.");
+       
     protected:
                                        /**
                                         * A generic matrix object in
@@ -1190,9 +1207,10 @@ namespace PETScWrappers
       LastAction::Values last_action;
 
                                       /**
-                                       * Flush buffers on all CPUs when
-                                       * switching between inserting and
-                                       * adding to elements, no-op otherwise.
+                                       * Ensure that the add/set mode that
+                                       * is required for actions following
+                                       * this call is compatible with the
+                                       * current mode.
                                        * Should be called from all internal
                                        * functions accessing matrix elements.
                                        */
@@ -1433,7 +1451,6 @@ namespace PETScWrappers
                   const unsigned int j,
                   const PetscScalar  value)
   {
-
     Assert (numbers::is_finite(value), ExcNumberNotFinite());
 
     set (i, 1, &j, &value, false);
@@ -1793,18 +1810,12 @@ namespace PETScWrappers
   void
   MatrixBase::prepare_action(const LastAction::Values new_action)
   {
-                                    // flush PETSc buffers when switching
-                                    // actions, otherwise just return.
-    if (last_action == new_action) return;
-
-    int ierr;
-    ierr = MatAssemblyBegin(matrix, MAT_FLUSH_ASSEMBLY);
-    AssertThrow (ierr == 0, ExcPETScError(ierr));
-
-    ierr = MatAssemblyEnd(matrix, MAT_FLUSH_ASSEMBLY);
-    AssertThrow (ierr == 0, ExcPETScError(ierr));
-
-    last_action = new_action;
+    if (last_action == new_action) 
+      ;
+    else if (last_action == LastAction::none)
+      last_action = new_action;
+    else
+      Assert (false, ExcWrongMode (last_action, new_action));
   }
 
 
index b8195a433850f03e836fc09f3f06ff61d0441481..e07373baf2d93bf8e8e8bb22028348841c6d54d6 100644 (file)
@@ -247,6 +247,8 @@ namespace PETScWrappers
 
     ierr = MatAssemblyEnd (matrix,MAT_FINAL_ASSEMBLY);
     AssertThrow (ierr == 0, ExcPETScError(ierr));
+    
+    last_action == LastAction::none;
   }
 
 
index 401600b3ecf552ff8805a2a1af9dc9422278f2c4..52ceeda37a554cea779958f95a999b6fee07a8b8 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id: simple_mpi_01.cc 23327 2011-02-11 03:19:07Z bangerth $
 //    Version: $Name$
 //
-//    Copyright (C) 2009 by the deal.II authors
+//    Copyright (C) 2009, 2011 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -19,8 +19,8 @@
 #include "../tests.h"
 
 #include <deal.II/lac/compressed_simple_sparsity_pattern.h>
-#include <deal.II/lac/petsc_sparse_matrix.h>    
-#include <deal.II/lac/petsc_parallel_sparse_matrix.h>    
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_parallel_sparse_matrix.h>
 #include <deal.II/base/logstream.h>
 #include <deal.II/base/utilities.h>
 
@@ -39,18 +39,17 @@ void test()
   CompressedSimpleSparsityPattern csp(2);
   csp.add(0,0);
   csp.add(1,1);
-  
+
   PETScWrappers::MPI::SparseMatrix mat;
   std::vector< unsigned int > local_rows(numprocs, 0);
   local_rows[0]=2;
-  
+
   mat.reinit(MPI_COMM_WORLD, csp, local_rows, local_rows, myid);
 
-#warning this here hangs, so it is uncommented until bug is fixed
-  //if (myid == 0 )
-       mat.add(0, 0, 1.0);
+  if (myid == 0 )
+    mat.add(0, 0, 1.0);
+
 
-  
   mat.compress();
 
   if (myid==0)
index 76a3add3842bc150741eed689cbe64512ec6e151..721906ea793ea42684b543fdcd98a8de46db827d 100644 (file)
@@ -1,4 +1,3 @@
 
 DEAL::Running on 1 CPU(s).
-DEAL::2nd try
 DEAL::done
index 729abc0fba7903ff33b6d8369b612510315158b3..7430da69645a8dba59b69d8928d30b86dfb0c1fa 100644 (file)
@@ -1,4 +1,3 @@
 
 DEAL::Running on 10 CPU(s).
-DEAL::2nd try
 DEAL::done
index 25e315071a008ae0e56fb59ebef6fe37c9ca1da8..befd3970452e1ad34ec33af193fad87fd3047a1b 100644 (file)
@@ -1,4 +1,3 @@
 
 DEAL::Running on 4 CPU(s).
-DEAL::2nd try
 DEAL::done

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.