From 756c54b30c9745be729557d147634c75645e6682 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 22 Apr 2020 22:56:01 -0400 Subject: [PATCH] Remove deprecated TrilinosWrappers constructors and reinitializations --- include/deal.II/lac/block_sparsity_pattern.h | 24 -- .../lac/trilinos_block_sparse_matrix.h | 25 -- include/deal.II/lac/trilinos_sparse_matrix.h | 185 +---------- .../deal.II/lac/trilinos_sparsity_pattern.h | 232 -------------- source/lac/block_sparsity_pattern.cc | 29 -- source/lac/trilinos_block_sparse_matrix.cc | 110 ++----- source/lac/trilinos_precondition_ml.cc | 18 +- source/lac/trilinos_precondition_muelu.cc | 18 +- source/lac/trilinos_sparse_matrix.cc | 288 ++++-------------- source/lac/trilinos_sparse_matrix.inst.in | 13 - source/lac/trilinos_sparsity_pattern.cc | 180 ----------- tests/trilinos/64.cc | 14 +- tests/trilinos/parallel_sparse_matrix_01.cc | 13 +- tests/trilinos/sparse_matrix_02.cc | 7 +- tests/trilinos/sparse_matrix_03.cc | 7 +- tests/trilinos/sparse_matrix_04.cc | 8 +- tests/trilinos/sparse_matrix_05.cc | 8 +- tests/trilinos/sparse_matrix_07.cc | 9 +- tests/trilinos/sparse_matrix_07_rectangle.cc | 14 +- tests/trilinos/sparse_matrix_copy_from_01.cc | 3 +- 20 files changed, 140 insertions(+), 1065 deletions(-) diff --git a/include/deal.II/lac/block_sparsity_pattern.h b/include/deal.II/lac/block_sparsity_pattern.h index 71484356a4..6f91649033 100644 --- a/include/deal.II/lac/block_sparsity_pattern.h +++ b/include/deal.II/lac/block_sparsity_pattern.h @@ -650,19 +650,6 @@ namespace TrilinosWrappers BlockSparsityPattern(const std::vector &row_block_sizes, const std::vector &col_block_sizes); - /** - * Initialize the pattern with an array Epetra_Map that specifies both - * rows and columns of the matrix (so the final matrix will be a square - * matrix), where the Epetra_Map specifies the parallel distribution of - * the degrees of freedom on the individual block. This function is - * equivalent to calling the second constructor with the length of the - * mapping vector and then entering the index values. - * - * @deprecated Use the respective method with IndexSet arguments instead. - */ - DEAL_II_DEPRECATED - BlockSparsityPattern(const std::vector ¶llel_partitioning); - /** * Initialize the pattern with an array of index sets that specifies both * rows and columns of the matrix (so the final matrix will be a square @@ -703,17 +690,6 @@ namespace TrilinosWrappers reinit(const std::vector &row_block_sizes, const std::vector &col_block_sizes); - /** - * Resize the matrix to a square tensor product of matrices with parallel - * distribution according to the specifications in the array of - * Epetra_Maps. - * - * @deprecated Use the respective method with IndexSet arguments instead. - */ - DEAL_II_DEPRECATED - void - reinit(const std::vector ¶llel_partitioning); - /** * Resize the matrix to a square tensor product of matrices. See the * constructor that takes a vector of IndexSets for details. diff --git a/include/deal.II/lac/trilinos_block_sparse_matrix.h b/include/deal.II/lac/trilinos_block_sparse_matrix.h index ab8d8a3f27..a3dd36d2b2 100644 --- a/include/deal.II/lac/trilinos_block_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_block_sparse_matrix.h @@ -147,17 +147,6 @@ namespace TrilinosWrappers void reinit(const size_type n_block_rows, const size_type n_block_columns); - /** - * Resize the matrix, by using an array of Epetra maps to determine the - * %parallel distribution of the individual matrices. This function - * assumes that a quadratic block matrix is generated. - */ - template - void - reinit(const std::vector & input_maps, - const BlockSparsityPatternType &block_sparsity_pattern, - const bool exchange_data = false); - /** * Resize the matrix, by using an array of index sets to determine the * %parallel distribution of the individual matrices. This function @@ -179,20 +168,6 @@ 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). - * - * @deprecated Use the respective method with IndexSet arguments instead. - */ - DEAL_II_DEPRECATED - void - reinit(const std::vector & input_maps, - const ::dealii::BlockSparseMatrix &deal_ii_sparse_matrix, - 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/include/deal.II/lac/trilinos_sparse_matrix.h b/include/deal.II/lac/trilinos_sparse_matrix.h index 7c864504d3..4d2513bbb8 100644 --- a/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_sparse_matrix.h @@ -699,188 +699,7 @@ namespace TrilinosWrappers void reinit(const Epetra_CrsMatrix &input_matrix, const bool copy_values = true); //@} - /** - * @name Constructors and initialization using an Epetra_Map description - */ - //@{ - /** - * Constructor using an Epetra_Map to describe the %parallel partitioning. - * The parameter @p n_max_entries_per_row sets the number of nonzero - * entries in each row that will be allocated. Note that this number does - * not need to be exact, and it is even allowed that the actual matrix - * structure has more nonzero entries than specified in the constructor. - * However it is still advantageous to provide good estimates here since - * this will considerably increase the performance of the matrix setup. - * However, there is no effect in the performance of matrix-vector - * products, since Trilinos reorganizes the matrix memory prior to use (in - * the compress() step). - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - SparseMatrix(const Epetra_Map ¶llel_partitioning, - const size_type n_max_entries_per_row = 0); - - /** - * Same as before, but now set a value of nonzeros for each matrix row. - * Since we know the number of elements in the matrix exactly in this - * case, we can already allocate the right amount of memory, which makes - * the creation process including the insertion of nonzero elements by the - * respective SparseMatrix::reinit call considerably faster. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - SparseMatrix(const Epetra_Map & parallel_partitioning, - const std::vector &n_entries_per_row); - - /** - * This constructor is similar to the one above, but it now takes two - * different Epetra maps for rows and columns. This interface is meant to - * be used for generating rectangular matrices, where one map describes - * the %parallel partitioning of the dofs associated with the matrix rows - * and the other one the partitioning of dofs in the matrix columns. Note - * that there is no real parallelism along the columns – the - * processor that owns a certain row always owns all the column elements, - * no matter how far they might be spread out. The second Epetra_Map is - * only used to specify the number of columns and for internal - * arrangements when doing matrix-vector products with vectors based on - * that column map. - * - * The integer input @p n_max_entries_per_row defines the number of - * columns entries per row that will be allocated. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - SparseMatrix(const Epetra_Map &row_parallel_partitioning, - const Epetra_Map &col_parallel_partitioning, - const size_type n_max_entries_per_row = 0); - - /** - * This constructor is similar to the one above, but it now takes two - * different Epetra maps for rows and columns. This interface is meant to - * be used for generating rectangular matrices, where one map specifies - * the %parallel distribution of degrees of freedom associated with matrix - * rows and the second one specifies the %parallel distribution the dofs - * associated with columns in the matrix. The second map also provides - * information for the internal arrangement in matrix vector products - * (i.e., the distribution of vector this matrix is to be multiplied - * with), but is not used for the distribution of the columns – - * rather, all column elements of a row are stored on the same processor - * in any case. The vector n_entries_per_row specifies the number - * of entries in each row of the newly generated matrix. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - SparseMatrix(const Epetra_Map & row_parallel_partitioning, - const Epetra_Map & col_parallel_partitioning, - const std::vector &n_entries_per_row); - - /** - * This function is initializes the Trilinos Epetra matrix according to - * the specified sparsity_pattern, and also reassigns the matrix rows to - * different processes according to a user-supplied Epetra map. In - * programs following the style of the tutorial programs, this function - * (and the respective call for a rectangular matrix) are the natural way - * to initialize the matrix size, its distribution among the MPI processes - * (if run in %parallel) as well as the location of non-zero elements. - * Trilinos stores the sparsity pattern internally, so it won't be needed - * any more after this call, in contrast to the deal.II own object. The - * optional argument @p exchange_data can be used for reinitialization - * with a sparsity pattern that is not fully constructed. This feature is - * only implemented for input sparsity patterns of type - * DynamicSparsityPattern. If the flag is not set, each processor just - * sets the elements in the sparsity pattern that belong to its rows. - * - * If the sparsity pattern given to this function is of type - * DynamicSparsity pattern, then a matrix will be created that allows - * several threads to write into different rows of the matrix at the same - * also with MPI, as opposed to most other reinit() methods. - * - * This is a collective operation that needs to be called on all - * processors in order to avoid a dead lock. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - template - DEAL_II_DEPRECATED void - reinit(const Epetra_Map & parallel_partitioning, - const SparsityPatternType &sparsity_pattern, - const bool exchange_data = false); - - /** - * This function is similar to the other initialization function above, - * but now also reassigns the matrix rows and columns according to two - * user-supplied Epetra maps. To be used for rectangular matrices. The - * optional argument @p exchange_data can be used for reinitialization - * with a sparsity pattern that is not fully constructed. This feature is - * only implemented for input sparsity patterns of type - * DynamicSparsityPattern. - * - * This is a collective operation that needs to be called on all - * processors in order to avoid a dead lock. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - template - DEAL_II_DEPRECATED void - reinit(const Epetra_Map & row_parallel_partitioning, - const Epetra_Map & col_parallel_partitioning, - const SparsityPatternType &sparsity_pattern, - const bool exchange_data = false); - /** - * 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 with modulus larger than the threshold (so zeros in the - * deal.II matrix can be filtered away). In contrast to the other reinit - * function with deal.II sparse matrix argument, this function takes a - * %parallel partitioning specified by the user instead of internally - * generating it. - * - * The optional parameter copy_values decides whether only the - * sparsity structure of the input matrix should be used or the matrix - * entries should be copied, too. - * - * This is a collective operation that needs to be called on all - * processors in order to avoid a dead lock. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - template - DEAL_II_DEPRECATED void - reinit(const Epetra_Map & parallel_partitioning, - const ::dealii::SparseMatrix &dealii_sparse_matrix, - const double drop_tolerance = 1e-13, - const bool copy_values = true, - const ::dealii::SparsityPattern * use_this_sparsity = nullptr); - - /** - * This function is similar to the other initialization function with - * deal.II sparse matrix input above, but now takes Epetra maps for both - * the rows and the columns of the matrix. Chosen for rectangular - * matrices. - * - * The optional parameter copy_values decides whether only the - * sparsity structure of the input matrix should be used or the matrix - * entries should be copied, too. - * - * This is a collective operation that needs to be called on all - * processors in order to avoid a dead lock. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - template - DEAL_II_DEPRECATED void - reinit(const Epetra_Map & row_parallel_partitioning, - const Epetra_Map & col_parallel_partitioning, - const ::dealii::SparseMatrix &dealii_sparse_matrix, - const double drop_tolerance = 1e-13, - const bool copy_values = true, - const ::dealii::SparsityPattern * use_this_sparsity = nullptr); - //@} /** * @name Constructors and initialization using an IndexSet description */ @@ -990,7 +809,9 @@ namespace TrilinosWrappers * processors in order to avoid a dead lock. */ template - void + typename std::enable_if< + !std::is_same>::value>::type reinit(const IndexSet & row_parallel_partitioning, const IndexSet & col_parallel_partitioning, const SparsityPatternType &sparsity_pattern, diff --git a/include/deal.II/lac/trilinos_sparsity_pattern.h b/include/deal.II/lac/trilinos_sparsity_pattern.h index 47f3b7d445..bf956ea9b1 100644 --- a/include/deal.II/lac/trilinos_sparsity_pattern.h +++ b/include/deal.II/lac/trilinos_sparsity_pattern.h @@ -421,200 +421,7 @@ namespace TrilinosWrappers void compress(); //@} - /** - * @name Constructors and initialization using an Epetra_Map description - */ - //@{ - - /** - * Constructor for a square sparsity pattern using an Epetra_map for the - * description of the %parallel partitioning. Moreover, the number of - * nonzero entries in the rows of the sparsity pattern can be specified. - * Note that this number does not need to be exact, and it is allowed that - * the actual sparsity structure has more nonzero entries than specified - * in the constructor (the usual case when the function - * DoFTools::make_sparsity_pattern() is called). However it is still - * advantageous to provide good estimates here since a good value will - * avoid repeated allocation of memory, which considerably increases the - * performance when creating the sparsity pattern. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - SparsityPattern(const Epetra_Map ¶llel_partitioning, - const size_type n_entries_per_row = 0); - - /** - * Same as before, but now use the exact number of nonzeros in each m row. - * Since we know the number of elements in the sparsity pattern exactly in - * this case, we can already allocate the right amount of memory, which - * makes the creation process by the respective SparsityPattern::reinit - * call considerably faster. However, this is a rather unusual situation, - * since knowing the number of entries in each row is usually connected to - * knowing the indices of nonzero entries, which the sparsity pattern is - * designed to describe. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - SparsityPattern(const Epetra_Map & parallel_partitioning, - const std::vector &n_entries_per_row); - - /** - * This constructor is similar to the one above, but it now takes two - * different Epetra maps for rows and columns. This interface is meant to - * be used for generating rectangular sparsity pattern, where one map - * describes the %parallel partitioning of the dofs associated with the - * sparsity pattern rows and the other one of the sparsity pattern - * columns. Note that there is no real parallelism along the columns - * – the processor that owns a certain row always owns all the - * column elements, no matter how far they might be spread out. The second - * Epetra_Map is only used to specify the number of columns and for - * specifying the correct domain space when performing matrix-vector - * products with vectors based on the same column map. - * - * The number of columns entries per row is specified as the maximum - * number of entries argument. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - SparsityPattern(const Epetra_Map &row_parallel_partitioning, - const Epetra_Map &col_parallel_partitioning, - const size_type n_entries_per_row = 0); - - /** - * This constructor is similar to the one above, but it now takes two - * different Epetra maps for rows and columns. This interface is meant to - * be used for generating rectangular matrices, where one map specifies - * the %parallel distribution of rows and the second one specifies the - * distribution of degrees of freedom associated with matrix columns. This - * second map is however not used for the distribution of the columns - * themselves – rather, all column elements of a row are stored on - * the same processor. The vector n_entries_per_row specifies the - * number of entries in each row of the newly generated matrix. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - SparsityPattern(const Epetra_Map & row_parallel_partitioning, - const Epetra_Map & col_parallel_partitioning, - const std::vector &n_entries_per_row); - - /** - * Reinitialization function for generating a square sparsity pattern - * using an Epetra_Map for the description of the %parallel partitioning - * and the number of nonzero entries in the rows of the sparsity pattern. - * Note that this number does not need to be exact, and it is even allowed - * that the actual sparsity structure has more nonzero entries than - * specified in the constructor. However it is still advantageous to - * provide good estimates here since this will considerably increase the - * performance when creating the sparsity pattern. - * - * This function does not create any entries by itself, but provides the - * correct data structures that can be used by the respective add() - * function. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - void - reinit(const Epetra_Map ¶llel_partitioning, - const size_type n_entries_per_row = 0); - - /** - * Same as before, but now use the exact number of nonzeros in each m row. - * Since we know the number of elements in the sparsity pattern exactly in - * this case, we can already allocate the right amount of memory, which - * makes process of adding entries to the sparsity pattern considerably - * faster. However, this is a rather unusual situation, since knowing the - * number of entries in each row is usually connected to knowing the - * indices of nonzero entries, which the sparsity pattern is designed to - * describe. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - void - reinit(const Epetra_Map & parallel_partitioning, - const std::vector &n_entries_per_row); - - /** - * This reinit function is similar to the one above, but it now takes two - * different Epetra maps for rows and columns. This interface is meant to - * be used for generating rectangular sparsity pattern, where one map - * describes the %parallel partitioning of the dofs associated with the - * sparsity pattern rows and the other one of the sparsity pattern - * columns. Note that there is no real parallelism along the columns - * – the processor that owns a certain row always owns all the - * column elements, no matter how far they might be spread out. The second - * Epetra_Map is only used to specify the number of columns and for - * internal arrangements when doing matrix-vector products with vectors - * based on that column map. - * - * The number of columns entries per row is specified by the argument - * n_entries_per_row. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - void - reinit(const Epetra_Map &row_parallel_partitioning, - const Epetra_Map &col_parallel_partitioning, - const size_type n_entries_per_row = 0); - - /** - * This reinit function is similar to the one above, but it now takes two - * different Epetra maps for rows and columns. This interface is meant to - * be used for generating rectangular matrices, where one map specifies - * the %parallel distribution of rows and the second one specifies the - * distribution of degrees of freedom associated with matrix columns. This - * second map is however not used for the distribution of the columns - * themselves – rather, all column elements of a row are stored on - * the same processor. The vector n_entries_per_row specifies the - * number of entries in each row of the newly generated matrix. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - DEAL_II_DEPRECATED - void - reinit(const Epetra_Map & row_parallel_partitioning, - const Epetra_Map & col_parallel_partitioning, - const std::vector &n_entries_per_row); - - /** - * Reinit function. Takes one of the deal.II sparsity patterns and a - * %parallel partitioning of the rows and columns for initializing the - * current Trilinos sparsity pattern. The optional argument @p - * exchange_data can be used for reinitialization with a sparsity pattern - * that is not fully constructed. This feature is only implemented for - * input sparsity patterns of type DynamicSparsityPattern. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - template - DEAL_II_DEPRECATED void - reinit(const Epetra_Map & row_parallel_partitioning, - const Epetra_Map & col_parallel_partitioning, - const SparsityPatternType &nontrilinos_sparsity_pattern, - const bool exchange_data = false); - /** - * Reinit function. Takes one of the deal.II sparsity patterns and a - * %parallel partitioning of the rows and columns for initializing the - * current Trilinos sparsity pattern. The optional argument @p - * exchange_data can be used for reinitialization with a sparsity pattern - * that is not fully constructed. This feature is only implemented for - * input sparsity patterns of type DynamicSparsityPattern. - * - * @deprecated Use the respective method with IndexSet argument instead. - */ - template - DEAL_II_DEPRECATED void - reinit(const Epetra_Map & parallel_partitioning, - const SparsityPatternType &nontrilinos_sparsity_pattern, - const bool exchange_data = false); - //@} /** * @name Constructors and initialization using an IndexSet description */ @@ -1000,10 +807,7 @@ namespace TrilinosWrappers * sets the parallel partitioning of the domain space of this sparsity * pattern, i.e., the partitioning of the vectors matrices based on this * sparsity pattern are multiplied with. - * - * @deprecated Use locally_owned_domain_indices() instead. */ - DEAL_II_DEPRECATED const Epetra_Map & domain_partitioner() const; @@ -1012,46 +816,10 @@ namespace TrilinosWrappers * sets the partitioning of the range space of this sparsity pattern, * i.e., the partitioning of the vectors that are result from matrix- * vector products. - * - * @deprecated Use locally_owned_range_indices() instead. */ - DEAL_II_DEPRECATED const Epetra_Map & range_partitioner() const; - /** - * Return a const reference to the underlying Trilinos Epetra_Map that - * sets the partitioning of the sparsity pattern rows. Equal to the - * partitioning of the range. - * - * @deprecated Use locally_owned_range_indices() instead. - */ - DEAL_II_DEPRECATED - const Epetra_Map & - row_partitioner() const; - - /** - * Return a const reference to the underlying Trilinos Epetra_Map that - * sets the partitioning of the sparsity pattern columns. This is in - * general not equal to the partitioner Epetra_Map for the domain because - * of overlap in the matrix. - * - * @deprecated Usually not necessary. If desired, access via the - * Epetra_FECrsGraph. - */ - DEAL_II_DEPRECATED - const Epetra_Map & - col_partitioner() const; - - /** - * Return a const reference to the communicator used for this object. - * - * @deprecated Use get_mpi_communicator instead. - */ - DEAL_II_DEPRECATED - const Epetra_Comm & - trilinos_communicator() const; - /** * Return the MPI communicator object in use with this matrix. */ diff --git a/source/lac/block_sparsity_pattern.cc b/source/lac/block_sparsity_pattern.cc index 2ffc8a7c23..edb74ccaec 100644 --- a/source/lac/block_sparsity_pattern.cc +++ b/source/lac/block_sparsity_pattern.cc @@ -529,20 +529,6 @@ namespace TrilinosWrappers - BlockSparsityPattern::BlockSparsityPattern( - const std::vector ¶llel_partitioning) - : BlockSparsityPatternBase(parallel_partitioning.size(), - parallel_partitioning.size()) - { - for (size_type i = 0; i < parallel_partitioning.size(); ++i) - for (size_type j = 0; j < parallel_partitioning.size(); ++j) - this->block(i, j).reinit(parallel_partitioning[i], - parallel_partitioning[j]); - this->collect_sizes(); - } - - - BlockSparsityPattern::BlockSparsityPattern( const std::vector ¶llel_partitioning, const MPI_Comm & communicator) @@ -593,21 +579,6 @@ namespace TrilinosWrappers - void - BlockSparsityPattern::reinit( - const std::vector ¶llel_partitioning) - { - dealii::BlockSparsityPatternBase::reinit( - parallel_partitioning.size(), parallel_partitioning.size()); - for (size_type i = 0; i < parallel_partitioning.size(); ++i) - for (size_type j = 0; j < parallel_partitioning.size(); ++j) - this->block(i, j).reinit(parallel_partitioning[i], - parallel_partitioning[j]); - this->collect_sizes(); - } - - - void BlockSparsityPattern::reinit( const std::vector ¶llel_partitioning, diff --git a/source/lac/trilinos_block_sparse_matrix.cc b/source/lac/trilinos_block_sparse_matrix.cc index 6c0f5b55ac..ea80153982 100644 --- a/source/lac/trilinos_block_sparse_matrix.cc +++ b/source/lac/trilinos_block_sparse_matrix.cc @@ -71,20 +71,24 @@ namespace TrilinosWrappers template void BlockSparseMatrix::reinit( - const std::vector & parallel_partitioning, + const std::vector & parallel_partitioning, const BlockSparsityPatternType &block_sparsity_pattern, + const MPI_Comm & communicator, const bool exchange_data) { - Assert(parallel_partitioning.size() == - block_sparsity_pattern.n_block_rows(), - ExcDimensionMismatch(parallel_partitioning.size(), + std::vector epetra_maps; + for (size_type i = 0; i < block_sparsity_pattern.n_block_rows(); ++i) + epetra_maps.push_back( + parallel_partitioning[i].make_trilinos_map(communicator, false)); + + Assert(epetra_maps.size() == block_sparsity_pattern.n_block_rows(), + ExcDimensionMismatch(epetra_maps.size(), block_sparsity_pattern.n_block_rows())); - Assert(parallel_partitioning.size() == - block_sparsity_pattern.n_block_cols(), - ExcDimensionMismatch(parallel_partitioning.size(), + Assert(epetra_maps.size() == block_sparsity_pattern.n_block_cols(), + ExcDimensionMismatch(epetra_maps.size(), block_sparsity_pattern.n_block_cols())); - const size_type n_block_rows = parallel_partitioning.size(); + const size_type n_block_rows = epetra_maps.size(); (void)n_block_rows; Assert(n_block_rows == block_sparsity_pattern.n_block_rows(), @@ -111,42 +115,22 @@ namespace TrilinosWrappers this->sub_objects[r][c]->reinit(parallel_partitioning[r], parallel_partitioning[c], block_sparsity_pattern.block(r, c), + communicator, exchange_data); } } - template - void - BlockSparseMatrix::reinit( - const std::vector & parallel_partitioning, - const BlockSparsityPatternType &block_sparsity_pattern, - const MPI_Comm & communicator, - const bool exchange_data) - { - std::vector epetra_maps; - for (size_type i = 0; i < block_sparsity_pattern.n_block_rows(); ++i) - epetra_maps.push_back( - parallel_partitioning[i].make_trilinos_map(communicator, false)); - - reinit(epetra_maps, block_sparsity_pattern, exchange_data); - } - - - template void BlockSparseMatrix::reinit( const BlockSparsityPatternType &block_sparsity_pattern) { - std::vector parallel_partitioning; + std::vector parallel_partitioning; for (size_type i = 0; i < block_sparsity_pattern.n_block_rows(); ++i) parallel_partitioning.emplace_back( - static_cast( - block_sparsity_pattern.block(i, 0).n_rows()), - 0, - Utilities::Trilinos::comm_self()); + complete_index_set(block_sparsity_pattern.block(i, 0).n_rows())); reinit(parallel_partitioning, block_sparsity_pattern); } @@ -176,41 +160,6 @@ namespace TrilinosWrappers - void - BlockSparseMatrix::reinit( - const std::vector & parallel_partitioning, - const ::dealii::BlockSparseMatrix &dealii_block_sparse_matrix, - 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), - drop_tolerance); - } - - collect_sizes(); - } - - - void BlockSparseMatrix::reinit( const ::dealii::BlockSparseMatrix &dealii_block_sparse_matrix, @@ -224,23 +173,15 @@ namespace TrilinosWrappers ExcDimensionMismatch(dealii_block_sparse_matrix.m(), dealii_block_sparse_matrix.n())); - // produce a dummy local map and pass it - // off to the other function -# ifdef DEAL_II_WITH_MPI - Epetra_MpiComm trilinos_communicator(MPI_COMM_SELF); -# else - Epetra_SerialComm trilinos_communicator; -# endif - - std::vector parallel_partitioning; + std::vector parallel_partitioning; for (size_type i = 0; i < dealii_block_sparse_matrix.n_block_rows(); ++i) parallel_partitioning.emplace_back( - static_cast( - dealii_block_sparse_matrix.block(i, 0).m()), - 0, - trilinos_communicator); + complete_index_set(dealii_block_sparse_matrix.block(i, 0).m())); - reinit(parallel_partitioning, dealii_block_sparse_matrix, drop_tolerance); + reinit(parallel_partitioning, + dealii_block_sparse_matrix, + MPI_COMM_SELF, + drop_tolerance); } @@ -376,15 +317,6 @@ namespace TrilinosWrappers template void BlockSparseMatrix::reinit(const dealii::BlockDynamicSparsityPattern &); - template void - BlockSparseMatrix::reinit(const std::vector &, - const dealii::BlockSparsityPattern &, - const bool); - template void - BlockSparseMatrix::reinit(const std::vector &, - const dealii::BlockDynamicSparsityPattern &, - const bool); - template void BlockSparseMatrix::reinit(const std::vector &, const dealii::BlockDynamicSparsityPattern &, diff --git a/source/lac/trilinos_precondition_ml.cc b/source/lac/trilinos_precondition_ml.cc index 435ea9f848..2a5ea5305e 100644 --- a/source/lac/trilinos_precondition_ml.cc +++ b/source/lac/trilinos_precondition_ml.cc @@ -284,19 +284,21 @@ namespace TrilinosWrappers preconditioner.reset(); const size_type n_rows = deal_ii_sparse_matrix.m(); - // Init Epetra Matrix using an - // equidistributed map; avoid - // storing the nonzero - // elements. - vector_distributor = std::make_shared( - static_cast(n_rows), 0, communicator); + // Init Epetra Matrix using an equidistributed map; avoid storing the + // nonzero elements. + IndexSet distributor(n_rows); + const unsigned int n_mpi_processes = communicator.NumProc(); + const unsigned int my_id = communicator.MyPID(); + distributor.add_range(my_id * n_rows / n_mpi_processes, + (my_id + 1) * n_rows / n_mpi_processes); if (trilinos_matrix.get() == nullptr) trilinos_matrix = std::make_shared(); - trilinos_matrix->reinit(*vector_distributor, - *vector_distributor, + trilinos_matrix->reinit(distributor, + distributor, deal_ii_sparse_matrix, + communicator.Comm(), drop_tolerance, true, use_this_sparsity); diff --git a/source/lac/trilinos_precondition_muelu.cc b/source/lac/trilinos_precondition_muelu.cc index ed1ae4ee58..fd10f6a781 100644 --- a/source/lac/trilinos_precondition_muelu.cc +++ b/source/lac/trilinos_precondition_muelu.cc @@ -214,19 +214,21 @@ namespace TrilinosWrappers preconditioner.reset(); const size_type n_rows = deal_ii_sparse_matrix.m(); - // Init Epetra Matrix using an - // equidistributed map; avoid - // storing the nonzero - // elements. - vector_distributor = std::make_shared( - static_cast(n_rows), 0, communicator); + // Init Epetra Matrix using an equidistributed map; avoid storing the + // nonzero elements. + IndexSet distributor(n_rows); + const unsigned int n_mpi_processes = communicator.NumProc(); + const unsigned int my_id = communicator.MyPID(); + distributor.add_range(my_id * n_rows / n_mpi_processes, + (my_id + 1) * n_rows / n_mpi_processes); if (trilinos_matrix.get() == nullptr) trilinos_matrix = std::make_shared(); - trilinos_matrix->reinit(*vector_distributor, - *vector_distributor, + trilinos_matrix->reinit(distributor, + distributor, deal_ii_sparse_matrix, + communicator.Comm(), drop_tolerance, true, use_this_sparsity); diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index bd04d29cc6..2d8031a1b0 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -218,66 +218,6 @@ namespace TrilinosWrappers - SparseMatrix::SparseMatrix(const Epetra_Map &input_map, - const size_type n_max_entries_per_row) - : column_space_map(new Epetra_Map(input_map)) - , matrix(new Epetra_FECrsMatrix(Copy, - *column_space_map, - TrilinosWrappers::types::int_type( - n_max_entries_per_row), - false)) - , last_action(Zero) - , compressed(false) - {} - - - - SparseMatrix::SparseMatrix(const Epetra_Map & input_map, - const std::vector &n_entries_per_row) - : column_space_map(new Epetra_Map(input_map)) - , matrix(new Epetra_FECrsMatrix(Copy, - *column_space_map, - reinterpret_cast( - const_cast( - n_entries_per_row.data())), - false)) - , last_action(Zero) - , compressed(false) - {} - - - - SparseMatrix::SparseMatrix(const Epetra_Map &input_row_map, - const Epetra_Map &input_col_map, - const size_type n_max_entries_per_row) - : column_space_map(new Epetra_Map(input_col_map)) - , matrix(new Epetra_FECrsMatrix(Copy, - input_row_map, - TrilinosWrappers::types::int_type( - n_max_entries_per_row), - false)) - , last_action(Zero) - , compressed(false) - {} - - - - SparseMatrix::SparseMatrix(const Epetra_Map & input_row_map, - const Epetra_Map & input_col_map, - const std::vector &n_entries_per_row) - : column_space_map(new Epetra_Map(input_col_map)) - , matrix(new Epetra_FECrsMatrix(Copy, - input_row_map, - reinterpret_cast( - const_cast( - n_entries_per_row.data())), - false)) - , last_action(Zero) - , compressed(false) - {} - - - SparseMatrix::SparseMatrix(const size_type m, const size_type n, const unsigned int n_max_entries_per_row) @@ -512,11 +452,12 @@ namespace TrilinosWrappers template void - reinit_matrix(const Epetra_Map & input_row_map, - const Epetra_Map & input_col_map, - const SparsityPatternType & sparsity_pattern, - const bool exchange_data, - std::unique_ptr & column_space_map, + reinit_matrix(const IndexSet & row_parallel_partitioning, + const IndexSet & column_parallel_partitioning, + const SparsityPatternType & sparsity_pattern, + const bool exchange_data, + const MPI_Comm & communicator, + std::unique_ptr &column_space_map, std::unique_ptr &matrix, std::unique_ptr & nonlocal_matrix, std::unique_ptr & nonlocal_matrix_exporter) @@ -526,15 +467,19 @@ namespace TrilinosWrappers nonlocal_matrix.reset(); nonlocal_matrix_exporter.reset(); - if (input_row_map.Comm().MyPID() == 0) + column_space_map = std_cxx14::make_unique( + column_parallel_partitioning.make_trilinos_map(communicator, false)); + + if (column_space_map->Comm().MyPID() == 0) { AssertDimension(sparsity_pattern.n_rows(), - TrilinosWrappers::n_global_elements(input_row_map)); + row_parallel_partitioning.size()); AssertDimension(sparsity_pattern.n_cols(), - TrilinosWrappers::n_global_elements(input_col_map)); + column_parallel_partitioning.size()); } - column_space_map = std_cxx14::make_unique(input_col_map); + Epetra_Map row_space_map = + row_parallel_partitioning.make_trilinos_map(communicator, false); // if we want to exchange data, build a usual Trilinos sparsity pattern // and let that handle the exchange. otherwise, manually create a @@ -543,9 +488,10 @@ namespace TrilinosWrappers if (exchange_data) { SparsityPattern trilinos_sparsity; - trilinos_sparsity.reinit(input_row_map, - input_col_map, + trilinos_sparsity.reinit(row_parallel_partitioning, + column_parallel_partitioning, sparsity_pattern, + communicator, exchange_data); matrix = std_cxx14::make_unique( Copy, trilinos_sparsity.trilinos_sparsity_pattern(), false); @@ -553,9 +499,9 @@ namespace TrilinosWrappers return; } - const size_type first_row = TrilinosWrappers::min_my_gid(input_row_map), + const size_type first_row = TrilinosWrappers::min_my_gid(row_space_map), last_row = - TrilinosWrappers::max_my_gid(input_row_map) + 1; + TrilinosWrappers::max_my_gid(row_space_map) + 1; std::vector n_entries_per_row(last_row - first_row); for (size_type row = first_row; row < last_row; ++row) @@ -576,12 +522,16 @@ namespace TrilinosWrappers // distributed). for only one processor, we can directly assign the // columns as well. Compare this with bug # 4123 in the Sandia Bugzilla. std::unique_ptr graph; - if (input_row_map.Comm().NumProc() > 1) + if (row_space_map.Comm().NumProc() > 1) graph = std_cxx14::make_unique( - Copy, input_row_map, n_entries_per_row.data(), true); + Copy, row_space_map, n_entries_per_row.data(), true); else - graph = std_cxx14::make_unique( - Copy, input_row_map, input_col_map, n_entries_per_row.data(), true); + graph = + std_cxx14::make_unique(Copy, + row_space_map, + *column_space_map, + n_entries_per_row.data(), + true); // This functions assumes that the sparsity pattern sits on all // processors (completely). The parallel version uses an Epetra graph @@ -612,7 +562,7 @@ namespace TrilinosWrappers // contiguous, etc). note that the documentation of the function indeed // states that we first need to provide the column (domain) map and then // the row (range) map - graph->FillComplete(input_col_map, input_row_map); + graph->FillComplete(*column_space_map, row_space_map); graph->OptimizeStorage(); // check whether we got the number of columns right. @@ -649,15 +599,17 @@ namespace TrilinosWrappers }; + // specialization for DynamicSparsityPattern which can provide us with // more information about the non-locally owned rows template <> void - reinit_matrix(const Epetra_Map & input_row_map, - const Epetra_Map & input_col_map, - const DynamicSparsityPattern & sparsity_pattern, - const bool exchange_data, - std::unique_ptr & column_space_map, + reinit_matrix(const IndexSet & row_parallel_partitioning, + const IndexSet & column_parallel_partitioning, + const DynamicSparsityPattern &sparsity_pattern, + const bool exchange_data, + const MPI_Comm & communicator, + std::unique_ptr & column_space_map, std::unique_ptr &matrix, std::unique_ptr & nonlocal_matrix, std::unique_ptr & nonlocal_matrix_exporter) @@ -666,25 +618,29 @@ namespace TrilinosWrappers nonlocal_matrix.reset(); nonlocal_matrix_exporter.reset(); + column_space_map = std_cxx14::make_unique( + column_parallel_partitioning.make_trilinos_map(communicator, false)); + AssertDimension(sparsity_pattern.n_rows(), - TrilinosWrappers::n_global_elements(input_row_map)); + row_parallel_partitioning.size()); AssertDimension(sparsity_pattern.n_cols(), - TrilinosWrappers::n_global_elements(input_col_map)); + column_parallel_partitioning.size()); - column_space_map = std_cxx14::make_unique(input_col_map); + Epetra_Map row_space_map = + row_parallel_partitioning.make_trilinos_map(communicator, false); IndexSet relevant_rows(sparsity_pattern.row_index_set()); // serial case if (relevant_rows.size() == 0) { relevant_rows.set_size( - TrilinosWrappers::n_global_elements(input_row_map)); + TrilinosWrappers::n_global_elements(row_space_map)); relevant_rows.add_range( - 0, TrilinosWrappers::n_global_elements(input_row_map)); + 0, TrilinosWrappers::n_global_elements(row_space_map)); } relevant_rows.compress(); Assert(relevant_rows.n_elements() >= - static_cast(input_row_map.NumMyElements()), + static_cast(row_space_map.NumMyElements()), ExcMessage( "Locally relevant rows of sparsity pattern must contain " "all locally owned rows")); @@ -704,8 +660,8 @@ namespace TrilinosWrappers reinterpret_cast( indices.data())), 0, - input_row_map.Comm()); - if (relevant_map.SameAs(input_row_map)) + row_space_map.Comm()); + if (relevant_map.SameAs(row_space_map)) have_ghost_rows = false; else have_ghost_rows = true; @@ -713,13 +669,13 @@ namespace TrilinosWrappers const unsigned int n_rows = relevant_rows.n_elements(); std::vector ghost_rows; - std::vector n_entries_per_row(input_row_map.NumMyElements()); + std::vector n_entries_per_row(row_space_map.NumMyElements()); std::vector n_entries_per_ghost_row; for (unsigned int i = 0, own = 0; i < n_rows; ++i) { const TrilinosWrappers::types::int_type global_row = relevant_rows.nth_index_in_set(i); - if (input_row_map.MyGID(global_row)) + if (row_space_map.MyGID(global_row)) n_entries_per_row[own++] = sparsity_pattern.row_length(global_row); else if (sparsity_pattern.row_length(global_row) > 0) { @@ -735,15 +691,15 @@ namespace TrilinosWrappers (ghost_rows.data()) : nullptr, 0, - input_row_map.Comm()); + row_space_map.Comm()); std::unique_ptr graph; std::unique_ptr nonlocal_graph; - if (input_row_map.Comm().NumProc() > 1) + if (row_space_map.Comm().NumProc() > 1) { graph = std_cxx14::make_unique( Copy, - input_row_map, + row_space_map, (n_entries_per_row.size() > 0) ? (n_entries_per_row.data()) : nullptr, exchange_data ? false : true); @@ -754,8 +710,8 @@ namespace TrilinosWrappers else graph = std_cxx14::make_unique( Copy, - input_row_map, - input_col_map, + row_space_map, + *column_space_map, (n_entries_per_row.size() > 0) ? (n_entries_per_row.data()) : nullptr, true); @@ -774,7 +730,7 @@ namespace TrilinosWrappers for (int col = 0; col < row_length; ++col) row_indices[col] = sparsity_pattern.column_number(global_row, col); - if (input_row_map.MyGID(global_row)) + if (row_space_map.MyGID(global_row)) graph->InsertGlobalIndices(global_row, row_length, row_indices.data()); @@ -797,13 +753,13 @@ namespace TrilinosWrappers nonlocal_graph->SetIndicesAreGlobal(); Assert(nonlocal_graph->IndicesAreGlobal() == true, ExcInternalError()); - nonlocal_graph->FillComplete(input_col_map, input_row_map); + nonlocal_graph->FillComplete(*column_space_map, row_space_map); nonlocal_graph->OptimizeStorage(); // insert data from nonlocal graph into the final sparsity pattern if (exchange_data) { - Epetra_Export exporter(nonlocal_graph->RowMap(), input_row_map); + Epetra_Export exporter(nonlocal_graph->RowMap(), row_space_map); int ierr = graph->Export(*nonlocal_graph, exporter, Add); (void)ierr; Assert(ierr == 0, ExcTrilinosError(ierr)); @@ -813,7 +769,7 @@ namespace TrilinosWrappers std_cxx14::make_unique(Copy, *nonlocal_graph); } - graph->FillComplete(input_col_map, input_row_map); + graph->FillComplete(*column_space_map, row_space_map); graph->OptimizeStorage(); AssertDimension(sparsity_pattern.n_cols(), @@ -829,19 +785,11 @@ namespace TrilinosWrappers void SparseMatrix::reinit(const SparsityPatternType &sparsity_pattern) { - const Epetra_Map rows(static_cast( - sparsity_pattern.n_rows()), - 0, - Utilities::Trilinos::comm_self()); - const Epetra_Map columns(static_cast( - sparsity_pattern.n_cols()), - 0, - Utilities::Trilinos::comm_self()); - - reinit_matrix(rows, - columns, + reinit_matrix(complete_index_set(sparsity_pattern.n_rows()), + complete_index_set(sparsity_pattern.n_cols()), sparsity_pattern, false, + MPI_COMM_SELF, column_space_map, matrix, nonlocal_matrix, @@ -851,63 +799,20 @@ namespace TrilinosWrappers template - void - SparseMatrix::reinit(const Epetra_Map & input_map, - const SparsityPatternType &sparsity_pattern, - const bool exchange_data) - { - reinit_matrix(input_map, - input_map, - sparsity_pattern, - exchange_data, - column_space_map, - matrix, - nonlocal_matrix, - nonlocal_matrix_exporter); - } - - - - template - inline void + inline typename std::enable_if< + !std::is_same>::value>::type SparseMatrix::reinit(const IndexSet & row_parallel_partitioning, const IndexSet & col_parallel_partitioning, const SparsityPatternType &sparsity_pattern, const MPI_Comm & communicator, const bool exchange_data) { - Epetra_Map row_map = - row_parallel_partitioning.make_trilinos_map(communicator, false); - Epetra_Map col_map = - col_parallel_partitioning.make_trilinos_map(communicator, false); - reinit_matrix(row_map, - col_map, - sparsity_pattern, - exchange_data, - column_space_map, - matrix, - nonlocal_matrix, - nonlocal_matrix_exporter); - - // In the end, the matrix needs to be compressed in order to be really - // ready. - last_action = Zero; - compress(VectorOperation::insert); - } - - - - template - inline void - SparseMatrix::reinit(const Epetra_Map & row_map, - const Epetra_Map & col_map, - const SparsityPatternType &sparsity_pattern, - const bool exchange_data) - { - reinit_matrix(row_map, - col_map, + reinit_matrix(row_parallel_partitioning, + col_parallel_partitioning, sparsity_pattern, exchange_data, + communicator, column_space_map, matrix, nonlocal_matrix, @@ -1101,47 +1006,6 @@ namespace TrilinosWrappers - template - void - SparseMatrix::reinit( - const Epetra_Map & input_map, - const ::dealii::SparseMatrix &dealii_sparse_matrix, - const double drop_tolerance, - const bool copy_values, - const ::dealii::SparsityPattern * use_this_sparsity) - { - reinit(IndexSet(input_map), - IndexSet(input_map), - dealii_sparse_matrix, - MPI_COMM_SELF, - drop_tolerance, - copy_values, - use_this_sparsity); - } - - - - template - void - SparseMatrix::reinit( - const Epetra_Map & input_row_map, - const Epetra_Map & input_col_map, - const ::dealii::SparseMatrix &dealii_sparse_matrix, - const double drop_tolerance, - const bool copy_values, - const ::dealii::SparsityPattern * use_this_sparsity) - { - reinit(IndexSet(input_row_map), - IndexSet(input_col_map), - dealii_sparse_matrix, - MPI_COMM_SELF, - drop_tolerance, - copy_values, - use_this_sparsity); - } - - - void SparseMatrix::reinit(const Epetra_CrsMatrix &input_matrix, const bool copy_values) @@ -3471,24 +3335,6 @@ namespace TrilinosWrappers template void SparseMatrix::reinit(const DynamicSparsityPattern &); - template void - SparseMatrix::reinit(const Epetra_Map &, - const dealii::SparsityPattern &, - const bool); - template void - SparseMatrix::reinit(const Epetra_Map &, - const DynamicSparsityPattern &, - const bool); - template void - SparseMatrix::reinit(const Epetra_Map &, - const Epetra_Map &, - const dealii::SparsityPattern &, - const bool); - template void - SparseMatrix::reinit(const Epetra_Map &, - const Epetra_Map &, - const DynamicSparsityPattern &, - const bool); template void SparseMatrix::reinit(const IndexSet &, const IndexSet &, diff --git a/source/lac/trilinos_sparse_matrix.inst.in b/source/lac/trilinos_sparse_matrix.inst.in index dfa1ccbc4f..1518885796 100644 --- a/source/lac/trilinos_sparse_matrix.inst.in +++ b/source/lac/trilinos_sparse_matrix.inst.in @@ -25,19 +25,6 @@ for (S : REAL_SCALARS) const bool, const dealii::SparsityPattern *); template void - SparseMatrix::reinit(const Epetra_Map &, - const dealii::SparseMatrix &, - const double, - const bool, - const dealii::SparsityPattern *); - template void - SparseMatrix::reinit(const Epetra_Map &, - const Epetra_Map &, - const dealii::SparseMatrix &, - const double, - const bool, - const dealii::SparsityPattern *); - template void SparseMatrix::reinit(const IndexSet &, const IndexSet &, const dealii::SparseMatrix &, diff --git a/source/lac/trilinos_sparsity_pattern.cc b/source/lac/trilinos_sparsity_pattern.cc index 290bfa848e..08c9e3e6eb 100644 --- a/source/lac/trilinos_sparsity_pattern.cc +++ b/source/lac/trilinos_sparsity_pattern.cc @@ -95,41 +95,6 @@ namespace TrilinosWrappers } - SparsityPattern::SparsityPattern(const Epetra_Map &input_map, - const size_type n_entries_per_row) - { - reinit(input_map, input_map, n_entries_per_row); - } - - - - SparsityPattern::SparsityPattern( - const Epetra_Map & input_map, - const std::vector &n_entries_per_row) - { - reinit(input_map, input_map, n_entries_per_row); - } - - - - SparsityPattern::SparsityPattern(const Epetra_Map &input_row_map, - const Epetra_Map &input_col_map, - const size_type n_entries_per_row) - { - reinit(input_row_map, input_col_map, n_entries_per_row); - } - - - - SparsityPattern::SparsityPattern( - const Epetra_Map & input_row_map, - const Epetra_Map & input_col_map, - const std::vector &n_entries_per_row) - { - reinit(input_row_map, input_col_map, n_entries_per_row); - } - - SparsityPattern::SparsityPattern(const size_type m, const size_type n, @@ -472,63 +437,6 @@ namespace TrilinosWrappers } // namespace - void - SparsityPattern::reinit(const Epetra_Map &input_map, - const size_type n_entries_per_row) - { - reinit_sp(input_map, - input_map, - n_entries_per_row, - column_space_map, - graph, - nonlocal_graph); - } - - - - void - SparsityPattern::reinit(const Epetra_Map &input_row_map, - const Epetra_Map &input_col_map, - const size_type n_entries_per_row) - { - reinit_sp(input_row_map, - input_col_map, - n_entries_per_row, - column_space_map, - graph, - nonlocal_graph); - } - - - - void - SparsityPattern::reinit(const Epetra_Map & input_map, - const std::vector &n_entries_per_row) - { - reinit_sp(input_map, - input_map, - n_entries_per_row, - column_space_map, - graph, - nonlocal_graph); - } - - - - void - SparsityPattern::reinit(const Epetra_Map & input_row_map, - const Epetra_Map & input_col_map, - const std::vector &n_entries_per_row) - { - reinit_sp(input_row_map, - input_col_map, - n_entries_per_row, - column_space_map, - graph, - nonlocal_graph); - } - - void SparsityPattern::reinit(const IndexSet ¶llel_partitioning, @@ -685,42 +593,6 @@ namespace TrilinosWrappers - template - void - SparsityPattern::reinit(const Epetra_Map & input_map, - const SparsityPatternType &sp, - const bool exchange_data) - { - reinit_sp(input_map, - input_map, - sp, - exchange_data, - column_space_map, - graph, - nonlocal_graph); - } - - - - template - void - SparsityPattern::reinit(const Epetra_Map & input_row_map, - const Epetra_Map & input_col_map, - const SparsityPatternType &sp, - const bool exchange_data) - { - reinit_sp(input_row_map, - input_col_map, - sp, - exchange_data, - column_space_map, - graph, - nonlocal_graph); - compress(); - } - - - SparsityPattern & SparsityPattern::operator=(const SparsityPattern &) { @@ -1067,36 +939,6 @@ namespace TrilinosWrappers - const Epetra_Map & - SparsityPattern::row_partitioner() const - { - // TODO A dynamic_cast fails here, this is suspicious. - const auto &row_map = - static_cast(graph->RowMap()); // NOLINT - return row_map; - } - - - - const Epetra_Map & - SparsityPattern::col_partitioner() const - { - // TODO A dynamic_cast fails here, this is suspicious. - const auto &col_map = - static_cast(graph->ColMap()); // NOLINT - return col_map; - } - - - - const Epetra_Comm & - SparsityPattern::trilinos_communicator() const - { - return graph->RangeMap().Comm(); - } - - - MPI_Comm SparsityPattern::get_mpi_communicator() const { @@ -1200,28 +1042,6 @@ namespace TrilinosWrappers template void SparsityPattern::copy_from(const dealii::DynamicSparsityPattern &); - - template void - SparsityPattern::reinit(const Epetra_Map &, - const dealii::SparsityPattern &, - bool); - template void - SparsityPattern::reinit(const Epetra_Map &, - const dealii::DynamicSparsityPattern &, - bool); - - template void - SparsityPattern::reinit(const Epetra_Map &, - const Epetra_Map &, - const dealii::SparsityPattern &, - bool); - template void - SparsityPattern::reinit(const Epetra_Map &, - const Epetra_Map &, - const dealii::DynamicSparsityPattern &, - bool); - - template void SparsityPattern::reinit(const IndexSet &, const dealii::SparsityPattern &, diff --git a/tests/trilinos/64.cc b/tests/trilinos/64.cc index e49c6373e4..e49bb0878e 100644 --- a/tests/trilinos/64.cc +++ b/tests/trilinos/64.cc @@ -68,15 +68,15 @@ main(int argc, char **argv) // check // TrilinosWrappers::SparseMatrix - const unsigned int n_jobs = Utilities::Trilinos::get_n_mpi_processes( - Utilities::Trilinos::comm_world()); + const unsigned int n_jobs = + Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + const unsigned int my_id = + Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); Assert(n_dofs % n_jobs == 0, ExcInternalError()); const unsigned int n_local_dofs = n_dofs / n_jobs; - Epetra_Map map(static_cast(n_dofs), - static_cast( - n_local_dofs), - Utilities::Trilinos::comm_world()); - TrilinosWrappers::SparseMatrix v2(map, 5); + IndexSet local_rows(n_dofs); + local_rows.add_range(n_local_dofs * my_id, n_local_dofs * (my_id + 1)); + TrilinosWrappers::SparseMatrix v2(local_rows, MPI_COMM_WORLD, 5); test(v2); } } diff --git a/tests/trilinos/parallel_sparse_matrix_01.cc b/tests/trilinos/parallel_sparse_matrix_01.cc index cc061bc9e5..8c95c9228c 100644 --- a/tests/trilinos/parallel_sparse_matrix_01.cc +++ b/tests/trilinos/parallel_sparse_matrix_01.cc @@ -81,19 +81,14 @@ test() // start_row[bj] + (i+2*k) % local_rows_per_process[bj]); - // now create a matrix with this sparsity // pattern - Epetra_Map map( - TrilinosWrappers::types::int_type(-1), - TrilinosWrappers::types::int_type( - local_rows_per_process[Utilities::Trilinos::get_this_mpi_process( - Utilities::Trilinos::comm_world())]), - 0, - Utilities::Trilinos::comm_world()); + const unsigned int my_id = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + IndexSet locally_owned_dofs(N); + locally_owned_dofs.add_range(start_row[my_id], local_rows_per_process[my_id]); TrilinosWrappers::SparseMatrix m; - m.reinit(map, csp); + m.reinit(locally_owned_dofs, locally_owned_dofs, csp, MPI_COMM_WORLD); // now write into the exact same matrix // entries as have been created by the // sparsity pattern above diff --git a/tests/trilinos/sparse_matrix_02.cc b/tests/trilinos/sparse_matrix_02.cc index 6b0464dcb6..3184ccb499 100644 --- a/tests/trilinos/sparse_matrix_02.cc +++ b/tests/trilinos/sparse_matrix_02.cc @@ -54,12 +54,9 @@ main(int argc, char **argv) matrix.print_formatted(deallog.get_file_stream()); // now copy everything into a Trilinos matrix - Epetra_Map map(TrilinosWrappers::types::int_type(5), - TrilinosWrappers::types::int_type(5), - 0, - Utilities::Trilinos::comm_world()); + const auto local_rows = complete_index_set(5); TrilinosWrappers::SparseMatrix tmatrix; - tmatrix.reinit(map, map, matrix); + tmatrix.reinit(local_rows, local_rows, matrix, MPI_COMM_SELF); deallog << "Copy with all values:" << std::endl; tmatrix.print(deallog.get_file_stream()); diff --git a/tests/trilinos/sparse_matrix_03.cc b/tests/trilinos/sparse_matrix_03.cc index 17a80fe082..17eae9a1f8 100644 --- a/tests/trilinos/sparse_matrix_03.cc +++ b/tests/trilinos/sparse_matrix_03.cc @@ -54,12 +54,9 @@ main(int argc, char **argv) matrix.print_formatted(deallog.get_file_stream()); // now copy everything into a Trilinos matrix - Epetra_Map map(TrilinosWrappers::types::int_type(5), - 5, - 0, - Utilities::Trilinos::comm_world()); + const auto local_rows = complete_index_set(5); TrilinosWrappers::SparseMatrix tmatrix; - tmatrix.reinit(map, map, matrix, 4.); + tmatrix.reinit(local_rows, local_rows, matrix, MPI_COMM_SELF, 4.); deallog << "Copy with a drop tolerance of 4:" << std::endl; tmatrix.print(deallog.get_file_stream()); diff --git a/tests/trilinos/sparse_matrix_04.cc b/tests/trilinos/sparse_matrix_04.cc index 53768bb2c9..03ed5a978b 100644 --- a/tests/trilinos/sparse_matrix_04.cc +++ b/tests/trilinos/sparse_matrix_04.cc @@ -54,13 +54,9 @@ main(int argc, char **argv) matrix.print_formatted(deallog.get_file_stream()); // now copy everything into a Trilinos matrix - Epetra_Map map(TrilinosWrappers::types::int_type(5), - TrilinosWrappers::types::int_type(5), - 0, - Utilities::Trilinos::comm_world()); - + const auto local_rows = complete_index_set(5); TrilinosWrappers::SparseMatrix tmatrix; - tmatrix.reinit(map, map, matrix, 0, false); + tmatrix.reinit(local_rows, local_rows, matrix, MPI_COMM_SELF, 0, false); deallog << "Copy structure only:" << std::endl; tmatrix.print(deallog.get_file_stream()); diff --git a/tests/trilinos/sparse_matrix_05.cc b/tests/trilinos/sparse_matrix_05.cc index 5349978c86..5b1ce6abf3 100644 --- a/tests/trilinos/sparse_matrix_05.cc +++ b/tests/trilinos/sparse_matrix_05.cc @@ -61,12 +61,10 @@ main(int argc, char **argv) // now copy everything into a Trilinos matrix - Epetra_Map map(TrilinosWrappers::types::int_type(5), - 5, - 0, - Utilities::Trilinos::comm_world()); + const auto local_rows = complete_index_set(5); TrilinosWrappers::SparseMatrix tmatrix; - tmatrix.reinit(map, map, matrix, 0, true, &xsparsity); + tmatrix.reinit( + local_rows, local_rows, matrix, MPI_COMM_SELF, 0, true, &xsparsity); deallog << "Copy structure only:" << std::endl; tmatrix.print(deallog.get_file_stream()); diff --git a/tests/trilinos/sparse_matrix_07.cc b/tests/trilinos/sparse_matrix_07.cc index bff2672103..66d2b41632 100644 --- a/tests/trilinos/sparse_matrix_07.cc +++ b/tests/trilinos/sparse_matrix_07.cc @@ -63,14 +63,11 @@ main(int argc, char **argv) xsparsity.add(2, 1); xsparsity.compress(); - // now copy everything into a Trilinos matrix - Epetra_Map map(TrilinosWrappers::types::int_type(5), - 5, - 0, - Utilities::Trilinos::comm_world()); + const auto local_rows = complete_index_set(5); TrilinosWrappers::SparseMatrix tmatrix; - tmatrix.reinit(map, map, matrix, 0, true, &xsparsity); + tmatrix.reinit( + local_rows, local_rows, matrix, MPI_COMM_SELF, 0, true, &xsparsity); deallog << "Copy structure only:" << std::endl; tmatrix.print(deallog.get_file_stream()); diff --git a/tests/trilinos/sparse_matrix_07_rectangle.cc b/tests/trilinos/sparse_matrix_07_rectangle.cc index 0e33341dd8..ba74436c5a 100644 --- a/tests/trilinos/sparse_matrix_07_rectangle.cc +++ b/tests/trilinos/sparse_matrix_07_rectangle.cc @@ -63,17 +63,11 @@ main(int argc, char **argv) // now copy everything into a Trilinos matrix - Epetra_Map rowmap(TrilinosWrappers::types::int_type(4), - 4, - 0, - Utilities::Trilinos::comm_world()); - Epetra_Map colmap(TrilinosWrappers::types::int_type(5), - 5, - 0, - Utilities::Trilinos::comm_world()); - + const auto local_rows = complete_index_set(4); + const auto local_cols = complete_index_set(5); TrilinosWrappers::SparseMatrix tmatrix; - tmatrix.reinit(rowmap, colmap, matrix, 0, true, &xsparsity); + tmatrix.reinit( + local_rows, local_cols, matrix, MPI_COMM_SELF, 0, true, &xsparsity); deallog << "Copy structure only:" << std::endl; tmatrix.print(deallog.get_file_stream()); diff --git a/tests/trilinos/sparse_matrix_copy_from_01.cc b/tests/trilinos/sparse_matrix_copy_from_01.cc index 8ce1589f45..9de742b122 100644 --- a/tests/trilinos/sparse_matrix_copy_from_01.cc +++ b/tests/trilinos/sparse_matrix_copy_from_01.cc @@ -60,7 +60,8 @@ main(int argc, char **argv) 0, Utilities::Trilinos::comm_world()); TrilinosWrappers::SparseMatrix tmatrix; - tmatrix.reinit(map, map, matrix); + const auto local_rows = complete_index_set(5); + tmatrix.reinit(local_rows, local_rows, matrix, MPI_COMM_SELF); // now copy things back into a SparseMatrix SparseMatrix copy(sparsity); -- 2.39.5