]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add TrilinosWrappers::PreconditionIdentity, i.e., identity preconditioner for Trilinos.
authorBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 13 Aug 2013 17:30:01 +0000 (17:30 +0000)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 13 Aug 2013 17:30:01 +0000 (17:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@30302 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/trilinos_precondition.h
deal.II/source/lac/trilinos_precondition.cc
deal.II/source/lac/trilinos_solver.cc

index 34a6017f4f17b97e648d89b84b15e11a1bfdddd8..3936118d50082ba63ed9326329249e2159f5df69 100644 (file)
@@ -121,13 +121,13 @@ namespace TrilinosWrappers
     /**
      * Apply the preconditioner.
      */
-    void vmult (VectorBase       &dst,
-                const VectorBase &src) const;
+    virtual void vmult (VectorBase       &dst,
+                        const VectorBase &src) const;
 
     /**
      * Apply the transpose preconditioner.
      */
-    void Tvmult (VectorBase       &dst,
+    virtual void Tvmult (VectorBase       &dst,
                  const VectorBase &src) const;
 
     /**
@@ -137,8 +137,8 @@ namespace TrilinosWrappers
      * in the Trilinos wrapper
      * class.
      */
-    void vmult (dealii::Vector<double>       &dst,
-                const dealii::Vector<double> &src) const;
+    virtual void vmult (dealii::Vector<double>       &dst,
+                        const dealii::Vector<double> &src) const;
 
     /**
      * Apply the transpose preconditioner on
@@ -147,8 +147,8 @@ namespace TrilinosWrappers
      * in the Trilinos wrapper
      * class.
      */
-    void Tvmult (dealii::Vector<double>       &dst,
-                 const dealii::Vector<double> &src) const;
+    virtual void Tvmult (dealii::Vector<double>       &dst,
+                         const dealii::Vector<double> &src) const;
 
     /**
      * Apply the preconditioner on deal.II
@@ -156,8 +156,8 @@ namespace TrilinosWrappers
      * the ones provided in the Trilinos
      * wrapper class.
      */
-    void vmult (dealii::parallel::distributed::Vector<double>       &dst,
-                const dealii::parallel::distributed::Vector<double> &src) const;
+    virtual void vmult (dealii::parallel::distributed::Vector<double>       &dst,
+                        const dealii::parallel::distributed::Vector<double> &src) const;
 
     /**
      * Apply the transpose preconditioner on deal.II
@@ -165,8 +165,8 @@ namespace TrilinosWrappers
      * the ones provided in the Trilinos
      * wrapper class.
      */
-    void Tvmult (dealii::parallel::distributed::Vector<double>       &dst,
-                 const dealii::parallel::distributed::Vector<double> &src) const;
+    virtual void Tvmult (dealii::parallel::distributed::Vector<double>       &dst,
+                         const dealii::parallel::distributed::Vector<double> &src) const;
 
     /**
      * Exception.
@@ -1508,6 +1508,64 @@ namespace TrilinosWrappers
 
 
 
+  /**
+   * A wrapper class for an identity preconditioner for Trilinos matrices.
+   *
+   * @ingroup TrilinosWrappers
+   * @ingroup Preconditioners
+   * @author Bruno Turcksin, 2013
+   */
+  class PreconditionIdentity : public PreconditionBase
+  {
+  public:
+
+    /**
+     * Apply the preconditioner, i.e., dst = src.
+     */
+    void vmult (VectorBase       &dst,
+                const VectorBase &src) const;
+
+    /**
+     * Apply the transport conditioner, i.e., dst = src.
+     */
+    void Tvmult (VectorBase       &dst,
+                 const VectorBase &src) const;
+
+    /**
+     * Apply the preconditioner on deal.II data structures 
+     * instead of the ones provided in the Trilinos wrapper class, 
+     * i.e., dst = src.
+     */
+    void vmult (dealii::Vector<double>       &dst,
+                const dealii::Vector<double> &src) const;
+
+    /**
+     * Apply the transpose preconditioner on deal.II data structures 
+     * instead of the ones provided in the Trilinos wrapper class,
+     * i.e. dst = src.
+     */
+    void Tvmult (dealii::Vector<double>       &dst,
+                 const dealii::Vector<double> &src) const;
+
+    /**
+     * Apply the preconditioner on deal.II parallel data structures 
+     * instead of the ones provided in the Trilinos wrapper class,
+     * i.e., dst = src.
+     */
+    void vmult (parallel::distributed::Vector<double>       &dst,
+                const dealii::parallel::distributed::Vector<double> &src) const;
+
+    /**
+     * Apply the transpose preconditioner on deal.II parallel data structures 
+     * instead of the ones provided in the Trilinos wrapper class,
+     * i.e., dst = src.
+     */
+    void Tvmult (parallel::distributed::Vector<double>       &dst,
+                 const dealii::parallel::distributed::Vector<double> &src) const;
+  };
+
+
+
 // -------------------------- inline and template functions ----------------------
 
 
index d8342f04d2e7bd9153996b4e68cea27baacfded5..a014bdd2f346c56ffc6ab0f8d8484ff1c6fa3d33 100644 (file)
@@ -745,6 +745,52 @@ namespace TrilinosWrappers
                                              const AdditionalData &, const double,
                                              const ::dealii::SparsityPattern *);
 
+
+
+
+  /* -------------------------- PreconditionAMG -------------------------- */
+
+  void 
+  PreconditionIdentity::vmult(VectorBase       &dst,
+                              const VectorBase &src) const
+  {
+    dst = src;
+  }
+
+  void
+  PreconditionIdentity::Tvmult(VectorBase       &dst,
+                               const VectorBase &src) const
+  {
+    dst = src;
+  }
+
+  void 
+  PreconditionIdentity::vmult(dealii::Vector<double>       &dst,
+                              const dealii::Vector<double> &src) const
+  {
+    dst = src;
+  }
+
+  void
+  PreconditionIdentity::Tvmult(dealii::Vector<double>       &dst,
+                               const dealii::Vector<double> &src) const
+  {
+    dst = src;
+  }
+
+  void
+  PreconditionIdentity::vmult(parallel::distributed::Vector<double>       &dst,
+                              const parallel::distributed::Vector<double> &src) const
+  {
+    dst = src;
+  }
+
+  void
+  PreconditionIdentity::Tvmult(parallel::distributed::Vector<double>       &dst,
+                               const parallel::distributed::Vector<double> &src) const
+  {
+    dst = src;
+  }
 }
 
 DEAL_II_NAMESPACE_CLOSE
index f04ca39f85986d85602ee4d8ad41d2f9ffd9a8f8..896d5d8499073eeda7c3480a84b5ab0d9b5c7cb5 100644 (file)
@@ -208,11 +208,14 @@ namespace TrilinosWrappers
         Assert (false, ExcNotImplemented());
       }
 
-    // Introduce the
-    // preconditioner, ...
-    ierr = solver.SetPrecOperator (const_cast<Epetra_Operator *>
-                                   (preconditioner.preconditioner.get()));
-    AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+    // Introduce the preconditioner, 
+    // if not the identity preconditioner ...
+    if (preconditioner.preconditioner.use_count()!=0)
+    {
+      ierr = solver.SetPrecOperator (const_cast<Epetra_Operator *>
+                                     (preconditioner.preconditioner.get()));
+      AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+    }
 
     // ... set some options, ...
     solver.SetAztecOption (AZ_output, additional_data.output_solver_details ?

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.