]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Revert patch 25771 - norms are required by tests/petsc/full_matrix_0{5,6}.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 21 Aug 2012 09:38:15 +0000 (09:38 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 21 Aug 2012 09:38:15 +0000 (09:38 +0000)
git-svn-id: https://svn.dealii.org/trunk@26045 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/petsc_matrix_base.h
deal.II/source/lac/petsc_matrix_base.cc

index f9b426ee9603e28815ca38159d049954f04efcc7..03d6f676ba901902ce4d4ba6884a96a4e867bc43 100644 (file)
@@ -838,6 +838,72 @@ namespace PETScWrappers
                                         */
       PetscReal frobenius_norm () const;
 
+
+                                       /**
+                                        * Return the square of the norm
+                                        * of the vector $v$ with respect
+                                        * to the norm induced by this
+                                        * matrix,
+                                        * i.e. $\left(v,Mv\right)$. This
+                                        * is useful, e.g. in the finite
+                                        * element context, where the
+                                        * $L_2$ norm of a function
+                                        * equals the matrix norm with
+                                        * respect to the mass matrix of
+                                        * the vector representing the
+                                        * nodal values of the finite
+                                        * element function.
+                                        *
+                                        * Obviously, the matrix needs to
+                                        * be quadratic for this operation.
+                                        *
+                                        * The implementation of this function
+                                        * is not as efficient as the one in
+                                        * the @p MatrixBase class used in
+                                        * deal.II (i.e. the original one, not
+                                        * the PETSc wrapper class) since PETSc
+                                        * doesn't support this operation and
+                                        * needs a temporary vector.
+                                        *
+                                        * Note that if the current object
+                                        * represents a parallel distributed
+                                        * matrix (of type
+                                        * PETScWrappers::MPI::SparseMatrix),
+                                        * then the given vector has to be
+                                        * a distributed vector as
+                                        * well. Conversely, if the matrix is
+                                        * not distributed, then neither
+                                        * may the vector be.
+                                        */
+      PetscScalar matrix_norm_square (const VectorBase &v) const;
+
+
+                                       /**
+                                        * Compute the matrix scalar
+                                        * product $\left(u,Mv\right)$.
+                                        *
+                                        * The implementation of this function
+                                        * is not as efficient as the one in
+                                        * the @p MatrixBase class used in
+                                        * deal.II (i.e. the original one, not
+                                        * the PETSc wrapper class) since PETSc
+                                        * doesn't support this operation and
+                                        * needs a temporary vector.
+                                        *
+                                        * Note that if the current object
+                                        * represents a parallel distributed
+                                        * matrix (of type
+                                        * PETScWrappers::MPI::SparseMatrix),
+                                        * then both vectors have to be
+                                        * distributed vectors as
+                                        * well. Conversely, if the matrix is
+                                        * not distributed, then neither of the
+                                        * vectors may be.
+                                        */
+      PetscScalar matrix_scalar_product (const VectorBase &u,
+                                        const VectorBase &v) const;
+
+
 #if DEAL_II_PETSC_VERSION_GTE(3,1,0)
                                        /**
                                         * Return the trace of the
index 271c4f90b97c587f7be9ff744b024fef87178440..1a04913d703af3b4c1363e418fb8fbe2fb22c84d 100644 (file)
@@ -420,6 +420,24 @@ namespace PETScWrappers
   }
 
 
+  PetscScalar
+  MatrixBase::matrix_norm_square (const VectorBase &v) const
+  {
+    Vector tmp(v.size());
+    vmult (tmp, v);
+    return tmp*v;
+  }
+
+  
+  PetscScalar
+  MatrixBase::matrix_scalar_product (const VectorBase &u,
+                                    const VectorBase &v) const
+  {
+    Vector tmp(v.size());
+    vmult (tmp, v);
+    return u*tmp;
+  }
+
 
 #if DEAL_II_PETSC_VERSION_GTE(3,1,0)
   PetscReal

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.