]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Update block matrix residual.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 15 Oct 2008 14:36:39 +0000 (14:36 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 15 Oct 2008 14:36:39 +0000 (14:36 +0000)
git-svn-id: https://svn.dealii.org/trunk@17221 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/trilinos_block_sparse_matrix.h
deal.II/lac/source/trilinos_block_sparse_matrix.cc
deal.II/lac/source/trilinos_precondition_block.cc

index afb5e31cc33b73b37474f7c202103bfe296cbedd..661f6b6d98b75e902ef96818dad7ecb43a149215 100644 (file)
@@ -28,6 +28,8 @@
 
 #ifdef DEAL_II_USE_TRILINOS
 
+#  define TrilinosScalar double
+
 DEAL_II_NAMESPACE_OPEN
 
 
@@ -338,20 +340,8 @@ namespace TrilinosWrappers
                                         * applicable if the matrix has
                                         * only one block.
                                         */
-      void vmult (MPI::Vector       &dst,
-                  const MPI::Vector &src) const;
-
-                                       /**
-                                        * Matrix-vector
-                                        * multiplication. Just like the
-                                        * previous function, but only
-                                        * applicable if the matrix has
-                                        * only one block, now applied to
-                                        * localized vectors (works only
-                                        * when run on one processor).
-                                        */
-      void vmult (Vector       &dst,
-                 const Vector &src) const;
+      void vmult (VectorBase       &dst,
+                  const VectorBase &src) const;
 
                                        /**
                                         * Matrix-vector multiplication:
@@ -431,21 +421,156 @@ namespace TrilinosWrappers
                                         * applicable if the matrix has
                                         * only one block.
                                         */
-      void Tvmult (MPI::Vector       &dst,
-                   const MPI::Vector &src) const;
+      void Tvmult (VectorBase       &dst,
+                   const VectorBase &src) const;
 
                                        /**
-                                        * Matrix-vector
-                                        * multiplication. Just like the
+                                        * Compute the residual of an
+                                        * equation <i>Mx=b</i>, where
+                                        * the residual is defined to
+                                        * be <i>r=b-Mx</i>. Write the
+                                        * residual into @p dst. The
+                                        * <i>l<sub>2</sub></i> norm of
+                                        * the residual vector is
+                                        * returned.
+                                        *
+                                        * Source <i>x</i> and
+                                        * destination <i>dst</i> must
+                                        * not be the same vector.
+                                       *
+                                       * Note that both vectors have
+                                       * to be distributed vectors
+                                       * generated using the same Map
+                                       * as was used for the matrix
+                                       * in case you work on a
+                                       * distributed memory
+                                       * architecture, using the
+                                       * interface in the
+                                       * TrilinosWrappers::MPI::BlockVector
+                                       * class.
+                                        */
+      TrilinosScalar residual (MPI::BlockVector       &dst,
+                              const MPI::BlockVector &x,
+                              const MPI::BlockVector &b) const;
+
+                                       /**
+                                        * Compute the residual of an
+                                        * equation <i>Mx=b</i>, where
+                                        * the residual is defined to
+                                        * be <i>r=b-Mx</i>. Write the
+                                        * residual into @p dst. The
+                                        * <i>l<sub>2</sub></i> norm of
+                                        * the residual vector is
+                                        * returned.
+                                        *
+                                        * Source <i>x</i> and
+                                        * destination <i>dst</i> must
+                                        * not be the same vector.
+                                       *
+                                       * Note that both vectors have
+                                       * to be distributed vectors
+                                       * generated using the same Map
+                                       * as was used for the matrix
+                                       * in case you work on a
+                                       * distributed memory
+                                       * architecture, using the
+                                       * interface in the
+                                       * TrilinosWrappers::BlockVector
+                                       * class. Since the block
+                                       * matrix is in general
+                                       * distributed among processes,
+                                       * this function only works
+                                       * when running the program on
+                                       * one processor.
+                                        */
+      TrilinosScalar residual (BlockVector       &dst,
+                              const BlockVector &x,
+                              const BlockVector &b) const;
+
+                                       /**
+                                        * Compute the residual of an
+                                        * equation <i>Mx=b</i>, where
+                                        * the residual is defined to
+                                        * be <i>r=b-Mx</i>. Write the
+                                        * residual into @p dst. The
+                                        * <i>l<sub>2</sub></i> norm of
+                                        * the residual vector is
+                                        * returned. Just like the
                                         * previous function, but only
-                                        * applicable if the matrix has
-                                        * only one block, now applied to
-                                        * localized Trilinos vectors
-                                        * (works only when run on one
-                                        * processor).
+                                        * applicable if the matrix
+                                        * only has one block row.
                                         */
-      void Tvmult (Vector       &dst,
-                   const Vector &src) const;
+      TrilinosScalar residual (MPI::BlockVector       &dst,
+                              const MPI::Vector      &x,
+                              const MPI::BlockVector &b) const;
+
+                                       /**
+                                        * Compute the residual of an
+                                        * equation <i>Mx=b</i>, where
+                                        * the residual is defined to
+                                        * be <i>r=b-Mx</i>. Write the
+                                        * residual into @p dst. The
+                                        * <i>l<sub>2</sub></i> norm of
+                                        * the residual vector is
+                                        * returned. Just like the
+                                        * previous function, but only
+                                        * applicable if the matrix
+                                        * only has one block row.
+                                        */
+      TrilinosScalar residual (BlockVector       &dst,
+                              const Vector      &x,
+                              const BlockVector &b) const;
+
+                                       /**
+                                        * Compute the residual of an
+                                        * equation <i>Mx=b</i>, where
+                                        * the residual is defined to
+                                        * be <i>r=b-Mx</i>. Write the
+                                        * residual into @p dst. The
+                                        * <i>l<sub>2</sub></i> norm of
+                                        * the residual vector is
+                                        * returned. Just like the
+                                        * previous function, but only
+                                        * applicable if the matrix
+                                        * only has one block column.
+                                        */
+      TrilinosScalar residual (MPI::Vector            &dst,
+                              const MPI::BlockVector &x,
+                              const MPI::Vector      &b) const;
+
+                                       /**
+                                        * Compute the residual of an
+                                        * equation <i>Mx=b</i>, where
+                                        * the residual is defined to
+                                        * be <i>r=b-Mx</i>. Write the
+                                        * residual into @p dst. The
+                                        * <i>l<sub>2</sub></i> norm of
+                                        * the residual vector is
+                                        * returned. Just like the
+                                        * previous function, but only
+                                        * applicable if the matrix
+                                        * only has one block column.
+                                        */
+      TrilinosScalar residual (Vector            &dst,
+                              const BlockVector &x,
+                              const Vector      &b) const;
+
+                                       /**
+                                        * Compute the residual of an
+                                        * equation <i>Mx=b</i>, where
+                                        * the residual is defined to
+                                        * be <i>r=b-Mx</i>. Write the
+                                        * residual into @p dst. The
+                                        * <i>l<sub>2</sub></i> norm of
+                                        * the residual vector is
+                                        * returned. Just like the
+                                        * previous function, but only
+                                        * applicable if the matrix
+                                        * only has one block.
+                                        */
+      TrilinosScalar residual (VectorBase       &dst,
+                              const VectorBase &x,
+                              const VectorBase &b) const;
 
                                        /**
                                         * Make the clear() function in the
@@ -562,18 +687,8 @@ namespace TrilinosWrappers
 
   inline
   void
-  BlockSparseMatrix::vmult (MPI::Vector       &dst,
-                           const MPI::Vector &src) const
-  {
-    BaseClass::vmult_nonblock_nonblock (dst, src);
-  }
-
-
-
-  inline
-  void
-  BlockSparseMatrix::vmult (Vector       &dst,
-                            const Vector &src) const
+  BlockSparseMatrix::vmult (VectorBase       &dst,
+                           const VectorBase &src) const
   {
     BaseClass::vmult_nonblock_nonblock (dst, src);
   }
@@ -642,18 +757,8 @@ namespace TrilinosWrappers
 
   inline
   void
-  BlockSparseMatrix::Tvmult (MPI::Vector       &dst,
-                            const MPI::Vector &src) const
-  {
-    BaseClass::Tvmult_nonblock_nonblock (dst, src);
-  }
-
-
-
-  inline
-  void
-  BlockSparseMatrix::Tvmult (Vector       &dst,
-                            const Vector &src) const
+  BlockSparseMatrix::Tvmult (VectorBase       &dst,
+                            const VectorBase &src) const
   {
     BaseClass::Tvmult_nonblock_nonblock (dst, src);
   }
index 696845078da606e193b2617f278655be099a2e0f..0995b26e7bd9dbc95b262023e26e0fb41078ac98 100644 (file)
@@ -224,6 +224,108 @@ namespace TrilinosWrappers
     return n_nonzero;
   }
 
+
+
+  TrilinosScalar
+  BlockSparseMatrix::residual (MPI::BlockVector       &dst,
+                              const MPI::BlockVector &x,
+                              const MPI::BlockVector &b) const
+  {
+    vmult (dst, x);
+    dst -= b;
+    dst *= -1.;
+
+    return dst.l2_norm();
+  }
+
+
+
+                                       // TODO: In the following we
+                                       // use the same code as just
+                                       // above six more times. Use
+                                       // templates.
+  TrilinosScalar
+  BlockSparseMatrix::residual (BlockVector       &dst,
+                              const BlockVector &x,
+                              const BlockVector &b) const
+  {
+    vmult (dst, x);
+    dst -= b;
+    dst *= -1.;
+
+    return dst.l2_norm();
+  }
+
+
+
+  TrilinosScalar
+  BlockSparseMatrix::residual (MPI::BlockVector       &dst,
+                              const MPI::Vector      &x,
+                              const MPI::BlockVector &b) const
+  {
+    vmult (dst, x);
+    dst -= b;
+    dst *= -1.;
+
+    return dst.l2_norm();
+  }
+
+
+
+  TrilinosScalar
+  BlockSparseMatrix::residual (BlockVector       &dst,
+                              const Vector      &x,
+                              const BlockVector &b) const
+  {
+    vmult (dst, x);
+    dst -= b;
+    dst *= -1.;
+
+    return dst.l2_norm();
+  }
+
+
+
+  TrilinosScalar
+  BlockSparseMatrix::residual (MPI::Vector            &dst,
+                              const MPI::BlockVector &x,
+                              const MPI::Vector      &b) const
+  {
+    vmult (dst, x);
+    dst -= b;
+    dst *= -1.;
+
+    return dst.l2_norm();
+  }
+
+
+
+  TrilinosScalar
+  BlockSparseMatrix::residual (Vector            &dst,
+                              const BlockVector &x,
+                              const Vector      &b) const
+  {
+    vmult (dst, x);
+    dst -= b;
+    dst *= -1.;
+
+    return dst.l2_norm();
+  }
+
+
+
+  TrilinosScalar
+  BlockSparseMatrix::residual (VectorBase       &dst,
+                              const VectorBase &x,
+                              const VectorBase &b) const
+  {
+    vmult (dst, x);
+    dst -= b;
+    dst *= -1.;
+
+    return dst.l2_norm();
+  }
+
 }
 
 
index fe1c8a72fdc0b39f4c659c83ad380773ab3b45cb..3a4c8374006c4162bd26b95f4d16a5e26ac355af 100755 (executable)
@@ -87,7 +87,7 @@ namespace TrilinosWrappers
        *defaultPrec = &Teuchos::dyn_cast<Thyra::DefaultPreconditioner<double> >
                       (*PM);
 
-      (*defaultPrec).initializeRight(tmpP);
+      (*defaultPrec).initializeUnspecified(tmpP);
     }
 
                                        // Set up the solver.

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.