]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Merge patches 21397, 21496, 21409 from mainline.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 Jun 2010 11:53:57 +0000 (11:53 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 Jun 2010 11:53:57 +0000 (11:53 +0000)
git-svn-id: https://svn.dealii.org/branches/releases/Branch-6-3@21411 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/lac/include/lac/trilinos_precondition.h
deal.II/lac/source/trilinos_precondition.cc

index 25736ff7ee68d0b7eed1b7327e0ac6a169a8fa66..985d008e36690eaa4ecb7ee20af9e6bc32e418a1 100644 (file)
@@ -57,6 +57,20 @@ inconvenience this causes.
 </ol>
 
 
+<a name="lac"></a>
+<h3>base</h3>
+
+<ol>
+  <li>
+  <p>
+  Fixed: deal.II release 6.3.0 did not compile with Trilinos versions 9.x and
+  10.0. This is now fixed.
+  <br>
+  (Martin Kronbichler, WB 2010/06/28)
+  </p>  
+</ol>
+
+
 <a name="deal.II"></a>
 <h3>deal.II</h3>
 
index 430203128aba7fee7071e01f58338ac527b063bb..b359254261da0c5063270968b4a5400b72d038c8 100644 (file)
@@ -30,7 +30,6 @@
 #  endif
 #  include <Epetra_Map.h>
 
-#  include <Teuchos_RCP.hpp>
 #  include <Teuchos_ParameterList.hpp>
 #  include <Epetra_Operator.h>
 #  include <Epetra_Vector.h>
@@ -103,6 +102,13 @@ namespace TrilinosWrappers
                                         */
       ~PreconditionBase ();
 
+                                      /**
+                                       * Destroys the preconditioner, leaving
+                                       * an object like just after having
+                                       * called the constructor.
+                                       */
+      void clear ();
+
                                       /**
                                        * Apply the preconditioner.
                                        */
@@ -139,7 +145,7 @@ namespace TrilinosWrappers
                                        * is used when applying the
                                        * preconditioner.
                                        */
-      Teuchos::RCP<const Epetra_Operator> preconditioner;
+      std_cxx1x::shared_ptr<Epetra_Operator> preconditioner;
 
                                        /**
                                        * Internal communication
@@ -250,14 +256,6 @@ namespace TrilinosWrappers
                                        */
       void initialize (const SparseMatrix   &matrix,
                       const AdditionalData &additional_data = AdditionalData());
-
-    private:
-                                      /**
-                                       * This is a pointer to the
-                                       * Ifpack data contained in
-                                       * this preconditioner.
-                                       */
-      Teuchos::RCP<Ifpack_Preconditioner> ifpack;
   };
 
 
@@ -386,14 +384,6 @@ namespace TrilinosWrappers
                                        */
       void initialize (const SparseMatrix   &matrix,
                       const AdditionalData &additional_data = AdditionalData());
-
-    private:
-                                      /**
-                                       * This is a pointer to the
-                                       * Ifpack data contained in
-                                       * this preconditioner.
-                                       */
-      Teuchos::RCP<Ifpack_Preconditioner> ifpack;
   };
 
 
@@ -522,14 +512,6 @@ namespace TrilinosWrappers
                                        */
       void initialize (const SparseMatrix   &matrix,
                       const AdditionalData &additional_data = AdditionalData());
-
-    private:
-                                      /**
-                                       * This is a pointer to the
-                                       * Ifpack data contained in
-                                       * this preconditioner.
-                                       */
-      Teuchos::RCP<Ifpack_Preconditioner> ifpack;
   };
 
 
@@ -699,14 +681,6 @@ namespace TrilinosWrappers
                                         */
       void initialize (const SparseMatrix   &matrix,
                       const AdditionalData &additional_data = AdditionalData());
-
-    private:
-                                      /**
-                                       * This is a pointer to the
-                                       * Ifpack data contained in
-                                       * this preconditioner.
-                                       */
-      Teuchos::RCP<Ifpack_Preconditioner> ifpack;
   };
 
 
@@ -875,14 +849,6 @@ namespace TrilinosWrappers
                                         */
       void initialize (const SparseMatrix   &matrix,
                       const AdditionalData &additional_data = AdditionalData());
-
-    private:
-                                      /**
-                                       * This is a pointer to the
-                                       * Ifpack data contained in
-                                       * this preconditioner.
-                                       */
-      Teuchos::RCP<Ifpack_Preconditioner> ifpack;
   };
 
 
@@ -1057,14 +1023,6 @@ namespace TrilinosWrappers
                                         */
       void initialize (const SparseMatrix   &matrix,
                       const AdditionalData &additional_data = AdditionalData());
-
-    private:
-                                      /**
-                                       * This is a pointer to the
-                                       * Ifpack data contained in
-                                       * this preconditioner.
-                                       */
-      Teuchos::RCP<Ifpack_Preconditioner> ifpack;
   };
 
 
@@ -1124,14 +1082,6 @@ namespace TrilinosWrappers
                                         */
       void initialize (const SparseMatrix   &matrix,
                       const AdditionalData &additional_data = AdditionalData());
-
-    private:
-                                      /**
-                                       * This is a pointer to the
-                                       * Ifpack data contained in
-                                       * this preconditioner.
-                                       */
-      Teuchos::RCP<Ifpack_Preconditioner> ifpack;
   };
 
 
@@ -1241,14 +1191,6 @@ namespace TrilinosWrappers
                                         */
       void initialize (const SparseMatrix   &matrix,
                       const AdditionalData &additional_data = AdditionalData());
-
-    private:
-                                      /**
-                                       * This is a pointer to the
-                                       * Ifpack data contained in
-                                       * this preconditioner.
-                                       */
-      Teuchos::RCP<Ifpack_Chebyshev> ifpack;
   };
 
 
@@ -1494,6 +1436,13 @@ namespace TrilinosWrappers
                                        */
       void reinit ();
 
+                                      /**
+                                       * Destroys the preconditioner, leaving
+                                       * an object like just after having
+                                       * called the constructor.
+                                       */
+      void clear ();
+
                                       /**
                                        * Prints an estimate of the memory
                                        * consumption of this class.
@@ -1501,18 +1450,11 @@ namespace TrilinosWrappers
       unsigned int memory_consumption () const;
 
     private:
-
-                                      /**
-                                       * A pointer to the preconditioner
-                                       * object.
-                                       */
-      Teuchos::RCP<ML_Epetra::MultiLevelPreconditioner> multilevel_operator;
-
                                       /**
                                        * A copy of the deal.II matrix into
                                        * Trilinos format.
                                        */
-      std_cxx1x::shared_ptr<SparseMatrix> Matrix;
+      std_cxx1x::shared_ptr<SparseMatrix> trilinos_matrix;
   };
 
 
index d6541721014f98d61defd78c73fd9f1a49cf45fa..34190d979ae6a8627ccfa633410aca009d1469b9 100644 (file)
@@ -55,8 +55,17 @@ namespace TrilinosWrappers
 
 
   PreconditionBase::~PreconditionBase()
+  {}
+
+
+
+  void PreconditionBase::clear ()
   {
-    preconditioner.release();
+    preconditioner.reset();
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+    communicator = MPI_COMM_SELF;
+#endif
+    vector_distributor.reset();
   }
 
 
@@ -77,16 +86,17 @@ namespace TrilinosWrappers
   PreconditionJacobi::initialize (const SparseMatrix   &matrix,
                                  const AdditionalData &additional_data)
   {
-    preconditioner.release();
-    ifpack.release();
-
-    ifpack = Teuchos::rcp (Ifpack().Create
-                          ("point relaxation",
-                           const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
-                           0));
+                               // release memory before reallocation
+    preconditioner.reset ();
+    preconditioner.reset (Ifpack().Create
+                         ("point relaxation",
+                          const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
+                          0));
 
-    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
-                                          "preconditioner"));
+    Ifpack_Preconditioner * ifpack = static_cast<Ifpack_Preconditioner*>
+      (preconditioner.get());
+    Assert (ifpack != 0, ExcMessage ("Trilinos could not create this "
+                                    "preconditioner"));
 
     int ierr;
 
@@ -105,8 +115,6 @@ namespace TrilinosWrappers
 
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
-
-    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -129,16 +137,16 @@ namespace TrilinosWrappers
   PreconditionSSOR::initialize (const SparseMatrix   &matrix,
                                const AdditionalData &additional_data)
   {
-    preconditioner.release();
-    ifpack.release();
-
-    ifpack = Teuchos::rcp (Ifpack().Create
-                          ("point relaxation",
-                           const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
-                           additional_data.overlap));
+    preconditioner.reset ();
+    preconditioner.reset (Ifpack().Create
+                         ("point relaxation",
+                          const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
+                          additional_data.overlap));
 
-    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
-                                          "preconditioner"));
+    Ifpack_Preconditioner * ifpack = static_cast<Ifpack_Preconditioner*>
+      (preconditioner.get());
+    Assert (ifpack != 0, ExcMessage ("Trilinos could not create this "
+                                    "preconditioner"));
 
     int ierr;
 
@@ -158,8 +166,6 @@ namespace TrilinosWrappers
 
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
-
-    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -182,16 +188,16 @@ namespace TrilinosWrappers
   PreconditionSOR::initialize (const SparseMatrix   &matrix,
                               const AdditionalData &additional_data)
   {
-    preconditioner.release();
-    ifpack.release();
-
-    ifpack = Teuchos::rcp (Ifpack().Create
-                          ("point relaxation",
-                           const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
-                           additional_data.overlap));
+    preconditioner.reset ();
+    preconditioner.reset (Ifpack().Create
+                         ("point relaxation",
+                          const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
+                          additional_data.overlap));
 
-    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
-                                          "preconditioner"));
+    Ifpack_Preconditioner * ifpack = static_cast<Ifpack_Preconditioner*>
+      (preconditioner.get());
+    Assert (ifpack != 0, ExcMessage ("Trilinos could not create this "
+                                    "preconditioner"));
 
     int ierr;
 
@@ -211,8 +217,6 @@ namespace TrilinosWrappers
 
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
-
-    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -237,16 +241,16 @@ namespace TrilinosWrappers
   PreconditionIC::initialize (const SparseMatrix   &matrix,
                              const AdditionalData &additional_data)
   {
-    preconditioner.release();
-    ifpack.release();
-
-    ifpack = Teuchos::rcp (Ifpack().Create
-                          ("IC",
-                           const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
-                           additional_data.overlap));
+    preconditioner.reset ();
+    preconditioner.reset (Ifpack().Create
+                         ("IC",
+                          const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
+                          additional_data.overlap));
 
-    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
-                                          "preconditioner"));
+    Ifpack_Preconditioner * ifpack = static_cast<Ifpack_Preconditioner*>
+      (preconditioner.get());
+    Assert (ifpack != 0, ExcMessage ("Trilinos could not create this "
+                                    "preconditioner"));
 
     int ierr;
 
@@ -264,8 +268,6 @@ namespace TrilinosWrappers
 
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
-
-    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -290,16 +292,16 @@ namespace TrilinosWrappers
   PreconditionILU::initialize (const SparseMatrix   &matrix,
                               const AdditionalData &additional_data)
   {
-    preconditioner.release();
-    ifpack.release();
-
-    ifpack = Teuchos::rcp (Ifpack().Create
-                          ("ILU",
-                           const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
-                           additional_data.overlap));
+    preconditioner.reset ();
+    preconditioner.reset (Ifpack().Create
+                         ("ILU",
+                          const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
+                          additional_data.overlap));
 
-    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
-                                          "preconditioner"));
+    Ifpack_Preconditioner * ifpack = static_cast<Ifpack_Preconditioner*>
+      (preconditioner.get());
+    Assert (ifpack != 0, ExcMessage ("Trilinos could not create this "
+                                    "preconditioner"));
 
     int ierr;
 
@@ -317,8 +319,6 @@ namespace TrilinosWrappers
 
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
-
-    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -345,16 +345,16 @@ namespace TrilinosWrappers
   PreconditionILUT::initialize (const SparseMatrix   &matrix,
                                const AdditionalData &additional_data)
   {
-    preconditioner.release();
-    ifpack.release();
-
-    ifpack = Teuchos::rcp (Ifpack().Create
-                          ("ILUT",
-                           const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
-                           additional_data.overlap));
+    preconditioner.reset ();
+    preconditioner.reset (Ifpack().Create
+                         ("ILUT",
+                          const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
+                          additional_data.overlap));
 
-    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
-                                          "preconditioner"));
+    Ifpack_Preconditioner * ifpack = static_cast<Ifpack_Preconditioner*>
+      (preconditioner.get());
+    Assert (ifpack != 0, ExcMessage ("Trilinos could not create this "
+                                    "preconditioner"));
 
     int ierr;
 
@@ -373,8 +373,6 @@ namespace TrilinosWrappers
 
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
-
-    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -393,15 +391,16 @@ namespace TrilinosWrappers
   PreconditionBlockwiseDirect::initialize (const SparseMatrix   &matrix,
                                           const AdditionalData &additional_data)
   {
-    preconditioner.release();
-    ifpack.release();
+    preconditioner.reset ();
+    preconditioner.reset (Ifpack().Create
+                         ("Amesos",
+                          const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
+                          additional_data.overlap));
 
-    ifpack = Teuchos::rcp (Ifpack().Create
-                          ("Amesos",
-                           const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
-                           additional_data.overlap));
-    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
-                                          "preconditioner"));
+    Ifpack_Preconditioner * ifpack = static_cast<Ifpack_Preconditioner*>
+      (preconditioner.get());
+    Assert (ifpack != 0, ExcMessage ("Trilinos could not create this "
+                                    "preconditioner"));
 
     int ierr;
 
@@ -416,8 +415,6 @@ namespace TrilinosWrappers
 
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
-
-    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -446,12 +443,13 @@ namespace TrilinosWrappers
   PreconditionChebyshev::initialize (const SparseMatrix   &matrix,
                                     const AdditionalData &additional_data)
   {
-    preconditioner.release();
-    ifpack.release();
+    preconditioner.reset ();
+    preconditioner.reset (new Ifpack_Chebyshev (&matrix.trilinos_matrix()));
 
-    ifpack = Teuchos::rcp (new Ifpack_Chebyshev (&matrix.trilinos_matrix()));
-    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
-                                          "preconditioner"));
+    Ifpack_Chebyshev * ifpack = static_cast<Ifpack_Chebyshev*>
+      (preconditioner.get());
+    Assert (ifpack != 0, ExcMessage ("Trilinos could not create this "
+                                    "preconditioner"));
 
     int ierr;
 
@@ -477,8 +475,6 @@ namespace TrilinosWrappers
 
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
-
-    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -513,9 +509,6 @@ namespace TrilinosWrappers
   PreconditionAMG:: initialize (const SparseMatrix   &matrix,
                                const AdditionalData &additional_data)
   {
-    preconditioner.reset ();
-    multilevel_operator.reset ();
-
     const unsigned int n_rows = matrix.m();
 
                                        // Build the AMG preconditioner.
@@ -609,8 +602,8 @@ namespace TrilinosWrappers
          for (unsigned int row=0; row<my_size; ++row)
            {
              int global_row_id = constant_modes_are_global ? domain_map.GID(row) : row;
-             distributed_constant_modes.ReplaceMyValue(row, d,
-               static_cast<double>(additional_data.constant_modes[d][global_row_id]));
+             distributed_constant_modes[d][row] = 
+               additional_data.constant_modes[d][global_row_id];
            }
 
        parameter_list.set("null space: type", "pre-computed");
@@ -623,7 +616,13 @@ namespace TrilinosWrappers
     initialize (matrix, parameter_list);
 
     if (additional_data.output_details)
-      multilevel_operator->PrintUnused(0);
+      {
+       ML_Epetra::MultiLevelPreconditioner * multilevel_operator = 
+         dynamic_cast<ML_Epetra::MultiLevelPreconditioner*> (preconditioner.get());
+       Assert (multilevel_operator != 0, 
+               ExcMessage ("Preconditioner setup failed."));
+       multilevel_operator->PrintUnused(0);
+      }
   }
 
 
@@ -632,9 +631,9 @@ namespace TrilinosWrappers
   PreconditionAMG::initialize (const SparseMatrix           &matrix,
                               const Teuchos::ParameterList &ml_parameters)
   {
-    multilevel_operator.reset (new ML_Epetra::MultiLevelPreconditioner
-                              (matrix.trilinos_matrix(), ml_parameters));
-    preconditioner.reset (multilevel_operator.get(), false);
+    preconditioner.reset ();
+    preconditioner.reset (new ML_Epetra::MultiLevelPreconditioner
+                         (matrix.trilinos_matrix(), ml_parameters));
   }
 
 
@@ -648,7 +647,6 @@ namespace TrilinosWrappers
              const ::dealii::SparsityPattern      *use_this_sparsity)
   {
     preconditioner.reset();
-    multilevel_operator.reset ();
     const unsigned int n_rows = deal_ii_sparse_matrix.m();
 
                                        // Init Epetra Matrix using an
@@ -657,32 +655,43 @@ namespace TrilinosWrappers
                                        // elements.
     vector_distributor.reset (new Epetra_Map(n_rows, 0, communicator));
 
-    if (Matrix.get() == 0)
-      Matrix.reset (new SparseMatrix());
+    if (trilinos_matrix.get() == 0)
+      trilinos_matrix.reset (new SparseMatrix());
 
-    Matrix->reinit (*vector_distributor, *vector_distributor,
-                   deal_ii_sparse_matrix, drop_tolerance, true,
-                   use_this_sparsity);
+    trilinos_matrix->reinit (*vector_distributor, *vector_distributor,
+                            deal_ii_sparse_matrix, drop_tolerance, true,
+                            use_this_sparsity);
 
-    initialize (*Matrix, additional_data);
+    initialize (*trilinos_matrix, additional_data);
   }
 
 
 
   void PreconditionAMG::reinit ()
   {
+    ML_Epetra::MultiLevelPreconditioner * multilevel_operator = 
+      dynamic_cast<ML_Epetra::MultiLevelPreconditioner*> (preconditioner.get());
     multilevel_operator->ReComputePreconditioner();
   }
 
 
+
+  void PreconditionAMG::clear ()
+  {
+    PreconditionBase::clear();
+    trilinos_matrix.reset();
+  }
+
+
+
   unsigned int PreconditionAMG::memory_consumption() const
   {
     unsigned int memory = sizeof(this);
 
                                // todo: find a way to read out ML's data
                                // sizes
-    if (Matrix.get() != 0)
-      memory += Matrix->memory_consumption();
+    if (trilinos_matrix.get() != 0)
+      memory += trilinos_matrix->memory_consumption();
     return memory;
   }
 

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.