const MPI_Comm & com);
+ /**
+ * This method associates the PETSc Mat to the instance of the class.
+ * Infers the number of blocks from A if it is of type MATNEST, otherwise
+ * the block operator will only have a single block.
+ */
+ void
+ reinit(Mat A);
+
/**
* Matrix-vector multiplication: let $dst = M*src$ with $M$ being this
Mat &
petsc_matrix();
- /**
- * This method assigns the PETSc Mat to the instance of the class.
- *
- * Note that the matrix is not copied: instead, the instance of this class
- * is initialized to use the given matrix. This is useful if you want to
- * interpret a PETSc Mat object as a deal.II BlockMatrix, and you already
- * have a BlockMatrix object that you want to use for this purpose.
- */
- void
- assign_petsc_matrix(Mat A);
-
private:
/**
* A PETSc Mat object that describes the entire block matrix.
inline BlockSparseMatrix::BlockSparseMatrix(const Mat &A)
: BlockSparseMatrix()
{
- this->assign_petsc_matrix(A);
+ this->reinit(A);
}
inline BlockSparseMatrix &
operator=(const BlockVector &V);
/**
- * This method assigns the given PETSc Vec to the instance of the class.
- *
- * Note that the vector is not copied: instead, the instance of this class
- * is initialized to use the given vector. This is useful if you want to
- * interpret a PETSc vector as a deal.II vector, and you already have a
- * BlockVector that you want to use for this purpose.
+ * This method associates the PETSc Vec to the instance of the class.
+ * Infers the number of blocks from v if it is of type VECNEST, otherwise
+ * the block vector will only have a single block.
*/
void
- assign_petsc_vector(Vec v);
+ reinit(Vec v);
/**
* Reinitialize the BlockVector to contain @p n_blocks of size @p
: BlockVectorBase<Vector>()
, petsc_nest_vector(nullptr)
{
- this->assign_petsc_vector(v);
+ this->reinit(v);
}
inline BlockVector &
virtual ~MatrixBase() override;
/**
- * This method assigns the PETSc Mat to the instance of the class.
- *
+ * This method associates the PETSc Mat to the instance of the class.
+ * This is particularly useful when performing PETSc to Deal.II operations
+ * since it allows to reuse the Deal.II MatrixBase and the PETSc Mat
+ * without incurring in memory copies.
*/
void
- assign_petsc_matrix(Mat A);
+ reinit(Mat A);
/**
* This operator assigns a scalar to a matrix. Since this does usually not
Vector &
operator=(const dealii::Vector<number> &v);
+ using VectorBase::reinit;
+
/**
* Change the dimension of the vector to @p N. It is unspecified how
* resizing the vector affects the memory allocation of this object;
operator=(const PetscScalar s);
/**
- * This method assigns the PETSc Vec to the instance of the class.
- * This is particularly useful when performing PETSc to deal.II operations
- * since it allows one to reuse the VectorBase and the PETSc Vec
+ * This method associates the PETSc Vec to the instance of the class.
+ * This is particularly useful when performing PETSc to Deal.II operations
+ * since it allows to reuse the Deal.II VectorBase and the PETSc Vec
* without incurring in memory copies.
*/
void
- assign_petsc_vector(Vec v);
+ reinit(Vec v);
/**
* Test for equality. This function assumes that the present vector and
}
void
- MatrixBase::assign_petsc_matrix(Mat A)
+ MatrixBase::reinit(Mat A)
{
AssertThrow(last_action == ::dealii::VectorOperation::unknown,
ExcMessage("Cannot assign a new Mat."));
}
void
- BlockSparseMatrix::assign_petsc_matrix(Mat A)
+ BlockSparseMatrix::reinit(Mat A)
{
clear();
}
void
- BlockVector::assign_petsc_vector(Vec v)
+ BlockVector::reinit(Vec v)
{
PetscBool isnest;
this->components.resize(nb);
for (unsigned int i = 0; i < nb; ++i)
{
- this->components[i].assign_petsc_vector(sv[i]);
+ this->components[i].reinit(sv[i]);
}
this->collect_sizes();
void
- VectorBase::assign_petsc_vector(Vec v)
+ VectorBase::reinit(Vec v)
{
/* TODO GHOSTED */
AssertThrow(last_action == ::dealii::VectorOperation::unknown,