void Tvmult_add (VectorBase &dst,
const VectorBase &src) 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;
/**
* Compute the residual of an
# include <deal.II/lac/exceptions.h>
# include <deal.II/lac/petsc_matrix_base.h>
+# include <deal.II/lac/petsc_parallel_vector.h>
# include <vector>
DEAL_II_NAMESPACE_OPEN
namespace MPI
{
+
+
/**
* Implementation of a parallel sparse matrix class based on PETSC, with rows
* of the matrix distributed across an MPI network. All the functionality is
class SparseMatrix : public MatrixBase
{
public:
+
/**
* A structure that describes some of
* the traits of this class in terms
<< "The number of local rows " << arg1
<< " must be larger than the total number of rows " << arg2);
//@}
+
+ /**
+ * 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.
+ */
+ PetscScalar matrix_norm_square (const Vector &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.
+ */
+ PetscScalar matrix_scalar_product (const Vector &u,
+ const Vector &v) const;
+
private:
/**
class SparseMatrix : public MatrixBase
{
public:
+
/**
* A structure that describes some of
* the traits of this class in terms of
*/
virtual const MPI_Comm & get_mpi_communicator () 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.
+ */
+ 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.
+ */
+ PetscScalar matrix_scalar_product (const VectorBase &u,
+ const VectorBase &v) const;
+
private:
/**
}
-
- 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;
- }
-
-
-
PetscScalar
MatrixBase::residual (VectorBase &dst,
const VectorBase &x,
}
}
-
-
// explicit instantiations
//
template
const std::vector<unsigned int> &,
const unsigned int ,
const bool);
+
+
+ PetscScalar
+ SparseMatrix::matrix_norm_square (const Vector &v) const
+ {
+ Vector tmp (v);
+ vmult (tmp, v);
+ return tmp*v;
+ }
+
+ PetscScalar
+ SparseMatrix::matrix_scalar_product (const Vector &u,
+ const Vector &v) const
+ {
+ Vector tmp (v);
+ vmult (tmp, v);
+ return u*tmp;
+ }
+
}
}
namespace PETScWrappers
{
+
SparseMatrix::SparseMatrix ()
{
const int m=0, n=0, n_nonzero_per_row=0;
template void
SparseMatrix::do_reinit (const CompressedSimpleSparsityPattern &,
const bool);
+
+ PetscScalar
+ SparseMatrix::matrix_norm_square (const VectorBase &v) const
+ {
+ Vector tmp (v.size());
+ vmult (tmp, v);
+ return tmp*v;
+ }
+
+ PetscScalar
+ SparseMatrix::matrix_scalar_product (const VectorBase &u,
+ const VectorBase &v) const
+ {
+ Vector tmp (v.size());
+ vmult (tmp, v);
+ return u*tmp;
+ }
}