From: Daniel Arndt Date: Sat, 25 Apr 2020 17:05:43 +0000 (-0400) Subject: Fix calling TrilinosWrappers::BlockSparseMatrix::reinit with BlockSparseMatrix X-Git-Tag: v9.2.0-rc1~182^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9960%2Fhead;p=dealii.git Fix calling TrilinosWrappers::BlockSparseMatrix::reinit with BlockSparseMatrix --- diff --git a/include/deal.II/lac/trilinos_block_sparse_matrix.h b/include/deal.II/lac/trilinos_block_sparse_matrix.h index ef88d17c6a..3f44848982 100644 --- a/include/deal.II/lac/trilinos_block_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_block_sparse_matrix.h @@ -168,6 +168,19 @@ namespace TrilinosWrappers void reinit(const BlockSparsityPatternType &block_sparsity_pattern); + /** + * This function initializes the Trilinos matrix using the deal.II sparse + * matrix and the entries stored therein. It uses a threshold to copy only + * elements whose modulus is larger than the threshold (so zeros in the + * deal.II matrix can be filtered away). + */ + void + reinit( + const std::vector & parallel_partitioning, + const ::dealii::BlockSparseMatrix &dealii_block_sparse_matrix, + const MPI_Comm & communicator = MPI_COMM_WORLD, + const double drop_tolerance = 1e-13); + /** * This function initializes the Trilinos matrix using the deal.II sparse * matrix and the entries stored therein. It uses a threshold to copy only diff --git a/source/lac/trilinos_block_sparse_matrix.cc b/source/lac/trilinos_block_sparse_matrix.cc index c2a02b1cc4..70349aaa06 100644 --- a/source/lac/trilinos_block_sparse_matrix.cc +++ b/source/lac/trilinos_block_sparse_matrix.cc @@ -160,6 +160,43 @@ namespace TrilinosWrappers + void + BlockSparseMatrix::reinit( + const std::vector & parallel_partitioning, + const ::dealii::BlockSparseMatrix &dealii_block_sparse_matrix, + const MPI_Comm & communicator, + const double drop_tolerance) + { + const size_type n_block_rows = parallel_partitioning.size(); + + Assert(n_block_rows == dealii_block_sparse_matrix.n_block_rows(), + ExcDimensionMismatch(n_block_rows, + dealii_block_sparse_matrix.n_block_rows())); + Assert(n_block_rows == dealii_block_sparse_matrix.n_block_cols(), + ExcDimensionMismatch(n_block_rows, + dealii_block_sparse_matrix.n_block_cols())); + + // Call the other basic reinit function ... + reinit(n_block_rows, n_block_rows); + + // ... and then assign the correct + // data to the blocks. + for (size_type r = 0; r < this->n_block_rows(); ++r) + for (size_type c = 0; c < this->n_block_cols(); ++c) + { + this->sub_objects[r][c]->reinit(parallel_partitioning[r], + parallel_partitioning[c], + dealii_block_sparse_matrix.block(r, + c), + communicator, + drop_tolerance); + } + + collect_sizes(); + } + + + void BlockSparseMatrix::reinit( const ::dealii::BlockSparseMatrix &dealii_block_sparse_matrix,