template <typename> class ReinitHelper;
/**
- * A helper class internally used in linear_operator.h. Specialization for
+ * A helper class used internally in linear_operator.h. Specialization for
* BlockVector<number>.
*/
template<typename number>
void Tvmult (Vector &dst,
const Vector &src) const;
+ /**
+ * Return the partitioning of the domain space of this matrix, i.e., the
+ * partitioning of the vectors this matrix has to be multiplied with.
+ */
+ std::vector< size_type > locally_domain_sizes() const;
+
+ /**
+ * Return the partitioning of the range space of this matrix, i.e., the
+ * partitioning of the vectors that are result from matrix-vector
+ * products.
+ */
+ std::vector< size_type > locally_range_sizes() const;
+
/**
* Make the clear() function in the base class visible, though it is
* protected.
}
+namespace internal
+{
+ namespace LinearOperator
+ {
+ template <typename> class ReinitHelper;
+
+ /**
+ * A helper class used internally in linear_operator.h. Specialization for
+ * PETScWrappers::BlockVector.
+ */
+ template<>
+ class ReinitHelper<PETScWrappers::BlockVector>
+ {
+ public:
+ template <typename Matrix>
+ static
+ void reinit_range_vector (const Matrix &matrix,
+ PETScWrappers::BlockVector &v,
+ bool omit_zeroing_entries)
+ {
+ v.reinit(matrix.locally_range_sizes(), omit_zeroing_entries);
+ }
+
+ template <typename Matrix>
+ static
+ void reinit_domain_vector(const Matrix &matrix,
+ PETScWrappers::BlockVector &v,
+ bool omit_zeroing_entries)
+ {
+ v.reinit(matrix.locally_domain_sizes(), omit_zeroing_entries);
+ }
+ };
+
+ } /* namespace LinearOperator */
+} /* namespace internal */
+
DEAL_II_NAMESPACE_CLOSE
#endif // DEAL_II_WITH_PETSC
*/
void collect_sizes ();
+ /**
+ * Return the partitioning of the domain space of this matrix, i.e., the
+ * partitioning of the vectors this matrix has to be multiplied with.
+ */
+ std::vector< IndexSet > locally_owned_domain_indices() const;
+
+ /**
+ * Return the partitioning of the range space of this matrix, i.e., the
+ * partitioning of the vectors that are result from matrix-vector
+ * products.
+ */
+ std::vector< IndexSet > locally_owned_range_indices() const;
+
/**
* Return a reference to the MPI communicator object in use with this
* matrix.
}
+namespace internal
+{
+ namespace LinearOperator
+ {
+ template <typename> class ReinitHelper;
+
+ /**
+ * A helper class used internally in linear_operator.h. Specialization for
+ * PETScWrappers::MPI::BlockVector.
+ */
+ template<>
+ class ReinitHelper<PETScWrappers::MPI::BlockVector>
+ {
+ public:
+ template <typename Matrix>
+ static
+ void reinit_range_vector (const Matrix &matrix,
+ PETScWrappers::MPI::BlockVector &v,
+ bool omit_zeroing_entries)
+ {
+ v.reinit(matrix.locally_owned_range_indices(), matrix.get_mpi_communicator());
+ }
+
+ template <typename Matrix>
+ static
+ void reinit_domain_vector(const Matrix &matrix,
+ PETScWrappers::MPI::BlockVector &v,
+ bool omit_zeroing_entries)
+ {
+ v.reinit(matrix.locally_owned_domain_indices(), matrix.get_mpi_communicator());
+ }
+ };
+
+ } /* namespace LinearOperator */
+} /* namespace internal */
+
DEAL_II_NAMESPACE_CLOSE
#endif // DEAL_II_WITH_PETSC
/**
* Return the partitioning of the range space of this matrix, i.e., the
- * partitioning of the vectors that are result from matrix-vector
+ * partitioning of the vectors that result from matrix-vector
* products.
*/
IndexSet locally_owned_range_indices() const;
template <typename> class ReinitHelper;
/**
- * A helper class internally used in linear_operator.h. Specialization for
- * TrilinosWrappers::MPI::Vector.
+ * A helper class used internally in linear_operator.h. Specialization for
+ * PETScWrappers::MPI::Vector.
*/
template<>
class ReinitHelper<PETScWrappers::MPI::Vector>
template <typename> class ReinitHelper;
/**
- * A helper class internally used in linear_operator.h. Specialization for
+ * A helper class used internally in linear_operator.h. Specialization for
* PETScWrappers::Vector.
*/
template<>
template <typename> class ReinitHelper;
/**
- * A helper class internally used in linear_operator.h. Specialization for
+ * A helper class used internally in linear_operator.h. Specialization for
* TrilinosWrappers::BlockVector.
*/
template<>
template <typename> class ReinitHelper;
/**
- * A helper class internally used in linear_operator.h. Specialization for
+ * A helper class used internally in linear_operator.h. Specialization for
* TrilinosWrappers::MPI::BlockVector.
*/
template<>
template <typename> class ReinitHelper;
/**
- * A helper class internally used in linear_operator.h. Specialization for
+ * A helper class used internally in linear_operator.h. Specialization for
* TrilinosWrappers::MPI::Vector.
*/
template<>
};
/**
- * A helper class internally used in linear_operator.h. Specialization for
+ * A helper class used internally in linear_operator.h. Specialization for
* TrilinosWrappers::Vector.
*/
template<>
}
}
+ std::vector<BlockSparseMatrix::size_type >
+ BlockSparseMatrix::
+ locally_domain_sizes() const
+ {
+ std::vector< size_type > index_sets;
+
+ for ( unsigned int i=0; i<this->n_block_cols(); ++i)
+ index_sets.push_back(this->block(0,i).n());
+
+ return index_sets;
+ }
+ std::vector<BlockSparseMatrix::size_type >
+ BlockSparseMatrix::
+ locally_range_sizes() const
+ {
+ std::vector< size_type > index_sets;
+
+ for ( unsigned int i=0; i<this->n_block_rows(); ++i)
+ index_sets.push_back(this->block(i,0).m());
+
+ return index_sets;
+ }
void
BlockSparseMatrix::collect_sizes ()
BaseClass::collect_sizes ();
}
+ std::vector< IndexSet >
+ BlockSparseMatrix::locally_owned_domain_indices() const
+ {
+ std::vector< IndexSet > index_sets;
+
+ for ( unsigned int i=0; i<this->n_block_cols(); ++i)
+ index_sets.push_back(this->block(0,i).locally_owned_domain_indices());
+
+ return index_sets;
+ }
+ std::vector< IndexSet >
+ BlockSparseMatrix::locally_owned_range_indices() const
+ {
+ std::vector< IndexSet > index_sets;
+
+ for ( unsigned int i=0; i<this->n_block_rows(); ++i)
+ index_sets.push_back(this->block(i,0).locally_owned_range_indices());
+
+ return index_sets;
+ }
const MPI_Comm &
BlockSparseMatrix::get_mpi_communicator () const
IS *cols = nullptr;
ierr = MatGetSize (matrix, &n_rows, &n_cols);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
ierr = MatGetOwnershipIS(matrix, rows, cols);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
ierr = ISGetMinMax(*rows, &min, &max);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
IndexSet locally_owned_domain_indices(n_rows);
locally_owned_domain_indices.add_range(min, max);
IS *cols = nullptr;
ierr = MatGetSize (matrix, &n_rows, &n_cols);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
ierr = MatGetOwnershipIS(matrix, rows, cols);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
ierr = ISGetMinMax(*cols, &min, &max);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
IndexSet locally_owned_range_indices(n_cols);
locally_owned_range_indices.add_range(min, max);
{
PetscInt m,n;
PetscErrorCode ierr = MatGetSize(matrix, &m, &n);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
return m;
}
{
PetscInt m,n;
PetscErrorCode ierr = MatGetSize(matrix, &m, &n);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
return n;
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2015 by the deal.II authors
+// Copyright (C) 2016 by the deal.II authors
//
// This file is part of the deal.II library.
//
// ---------------------------------------------------------------------
// Test that it is possible to instantiate a LinearOperator object for all
-// different kinds of Trilinos matrices and vectors
+// different kinds of PETSc matrices and vectors
// TODO: A bit more tests...
#include "../tests.h"
#include <deal.II/lac/linear_operator.h>
+// Vectors:
#include <deal.II/lac/petsc_vector.h>
#include <deal.II/lac/petsc_sparse_matrix.h>
#include <deal.II/lac/petsc_parallel_vector.h>
#include <deal.II/lac/petsc_parallel_sparse_matrix.h>
+// Block Matrix and Vectors:
+#include <deal.II/lac/petsc_block_vector.h>
+#include <deal.II/lac/petsc_block_sparse_matrix.h>
+
+#include <deal.II/lac/petsc_parallel_block_vector.h>
+#include <deal.II/lac/petsc_parallel_block_sparse_matrix.h>
+
+
using namespace dealii;
int main(int argc, char *argv[])
auto op_a = linear_operator<PETScWrappers::MPI::Vector>(a);
}
+ {
+ PETScWrappers::BlockSparseMatrix a;
+ auto op_a = linear_operator<PETScWrappers::BlockVector>(a);
+ }
+
+ {
+ PETScWrappers::MPI::BlockSparseMatrix a;
+ auto op_a = linear_operator<PETScWrappers::MPI::BlockVector>(a);
+ }
deallog << "OK" << std::endl;