From: Timo Heister Date: Wed, 5 Jun 2013 18:27:06 +0000 (+0000) Subject: merge from mainline X-Git-Tag: v8.0.0~120^2~47 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=941f4cd278b0c211e44e83f5a12490620d7dcd91;p=dealii.git merge from mainline git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@29764 0785d39b-7218-0410-832d-ea1e28bc413d --- 941f4cd278b0c211e44e83f5a12490620d7dcd91 diff --cc deal.II/examples/step-6/step-6.cc index 049bfcc3cd,75b32ce2e1..8217eb3aaa --- a/deal.II/examples/step-6/step-6.cc +++ b/deal.II/examples/step-6/step-6.cc @@@ -409,9 -395,9 +409,9 @@@ void Step6::assemble_system ( const unsigned int n_q_points = quadrature_formula.size(); FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); - Vector cell_rhs (dofs_per_cell); + LA::Vector cell_rhs (dofs_per_cell); - std::vector local_dof_indices (dofs_per_cell); + std::vector local_dof_indices (dofs_per_cell); const Coefficient coefficient; std::vector coefficient_values (n_q_points); diff --cc deal.II/include/deal.II/lac/compressed_simple_sparsity_pattern.h index fe2fcf94d3,9062e6cfa9..e7d37ac7bf --- a/deal.II/include/deal.II/lac/compressed_simple_sparsity_pattern.h +++ b/deal.II/include/deal.II/lac/compressed_simple_sparsity_pattern.h @@@ -136,16 -141,10 +141,16 @@@ public * default argument keeps all * entries. */ - CompressedSimpleSparsityPattern (const unsigned int m, - const unsigned int n, + CompressedSimpleSparsityPattern (const size_type m, + const size_type n, const IndexSet &rowset = IndexSet()); + /** + * Create a square matrix using + * the index set. + */ + CompressedSimpleSparsityPattern (const IndexSet &indexset); + /** * Initialize a square matrix of * dimension @p n. diff --cc deal.II/include/deal.II/lac/petsc_parallel_block_sparse_matrix.h index 1d0e1903b9,0bf1727fff..0c4ec05e75 --- a/deal.II/include/deal.II/lac/petsc_parallel_block_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/petsc_parallel_block_sparse_matrix.h @@@ -170,34 -169,9 +170,34 @@@ namespace PETScWrapper * user call whatever function * she desires. */ - void reinit (const unsigned int n_block_rows, - const unsigned int n_block_columns); + void reinit (const size_type n_block_rows, + const size_type n_block_columns); + + /** + * Efficiently reinit the block matrix for a parallel computation. + * Only the BlockSparsityPattern of the Simple type can efficiently + * store large sparsity patterns in parallel, so this is the only + * supported argument. + * The IndexSets describe the locally owned range of DoFs for each block. + * Note that each IndexSet needs to contiguous. For a symmetric structure + * hand in the same vector for the first two arguments. + */ + void reinit(const std::vector &rows, + const std::vector &cols, + const BlockCompressedSimpleSparsityPattern &bcsp, + const MPI_Comm &com); + + + /** + * Same as above but only for a symmetric structure only. + */ + void reinit(const std::vector &sizes, + const BlockCompressedSimpleSparsityPattern &bcsp, + const MPI_Comm &com); + + + /** * Matrix-vector multiplication: * let $dst = M*src$ with $M$ diff --cc deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h index 93c04f4371,2b963cb2ac..0cc526249c --- a/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h @@@ -368,25 -365,13 +372,25 @@@ namespace PETScWrapper * the start. */ template - void reinit (const MPI_Comm &communicator, - const SparsityType &sparsity_pattern, - const std::vector &local_rows_per_process, - const std::vector &local_columns_per_process, - const unsigned int this_process, - const bool preset_nonzero_locations = true); + void reinit (const MPI_Comm &communicator, + const SparsityType &sparsity_pattern, + const std::vector &local_rows_per_process, + const std::vector &local_columns_per_process, + const unsigned int this_process, + const bool preset_nonzero_locations = true); + /** + * Create a matrix where the size() of the IndexSets determine the global + * number of rows and columns and the entries of the IndexSet give + * the rows and columns for the calling processor. + * Note that only contiguous IndexSets are supported. + */ + template + void reinit (const IndexSet & local_rows, + const IndexSet & local_columns, + const SparsityType &sparsity_pattern, + const MPI_Comm &communicator); + /** * Return a reference to the MPI * communicator object in use with @@@ -485,20 -470,12 +489,20 @@@ * Same as previous functions. */ template - void do_reinit (const SparsityType &sparsity_pattern, - const std::vector &local_rows_per_process, - const std::vector &local_columns_per_process, - const unsigned int this_process, - const bool preset_nonzero_locations); + void do_reinit (const SparsityType &sparsity_pattern, + const std::vector &local_rows_per_process, + const std::vector &local_columns_per_process, + const unsigned int this_process, + const bool preset_nonzero_locations); + /** + * Same as previous functions. + */ + template + void do_reinit (const IndexSet & local_rows, + const IndexSet & local_columns, + const SparsityType &sparsity_pattern); + /** * To allow calling protected * prepare_add() and diff --cc deal.II/source/lac/compressed_simple_sparsity_pattern.cc index 6905fe21e1,07206370d9..c7bc7f7d39 --- a/deal.II/source/lac/compressed_simple_sparsity_pattern.cc +++ b/deal.II/source/lac/compressed_simple_sparsity_pattern.cc @@@ -249,17 -249,8 +249,17 @@@ CompressedSimpleSparsityPattern::Compre } +CompressedSimpleSparsityPattern::CompressedSimpleSparsityPattern (const IndexSet &rowset_) + : + rows(0), + cols(0), + rowset(0) +{ + reinit (rowset_.size(), rowset_.size(), rowset_); +} + - CompressedSimpleSparsityPattern::CompressedSimpleSparsityPattern (const unsigned int n) + CompressedSimpleSparsityPattern::CompressedSimpleSparsityPattern (const size_type n) : rows(0), cols(0), diff --cc deal.II/source/lac/petsc_parallel_sparse_matrix.cc index ecc5dac544,ffefdf851d..da6b5f1953 --- a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc +++ b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc @@@ -99,26 -99,16 +99,26 @@@ namespace PETScWrapper return *this; } + void + SparseMatrix::copy_from (const SparseMatrix &other) + { + if (&other == this) + return; + + this->communicator = other.communicator; + int ierr = MatCopy(other.matrix, matrix, SAME_NONZERO_PATTERN); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + } void - SparseMatrix::reinit (const MPI_Comm &communicator, - const unsigned int m, - const unsigned int n, - const unsigned int local_rows, - const unsigned int local_columns, - const unsigned int n_nonzero_per_row, - const bool is_symmetric) + SparseMatrix::reinit (const MPI_Comm &communicator, + const size_type m, + const size_type n, + const size_type local_rows, + const size_type local_columns, + const size_type n_nonzero_per_row, + const bool is_symmetric) { this->communicator = communicator; @@@ -188,35 -178,15 +188,35 @@@ preset_nonzero_locations); } + template + void + SparseMatrix:: + reinit (const IndexSet & local_rows, + const IndexSet & local_columns, + const SparsityType &sparsity_pattern, + const MPI_Comm &communicator) + { + this->communicator = communicator; + // get rid of old matrix and generate a + // new one +#if DEAL_II_PETSC_VERSION_LT(3,2,0) + const int ierr = MatDestroy (matrix); +#else + const int ierr = MatDestroy (&matrix); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + do_reinit (local_rows, local_columns, sparsity_pattern); + } void - SparseMatrix::do_reinit (const unsigned int m, - const unsigned int n, - const unsigned int local_rows, - const unsigned int local_columns, - const unsigned int n_nonzero_per_row, - const bool is_symmetric) + SparseMatrix::do_reinit (const size_type m, + const size_type n, + const size_type local_rows, + const size_type local_columns, + const size_type n_nonzero_per_row, + const bool is_symmetric) { Assert (local_rows <= m, ExcLocalRowsTooLarge (local_rows, m)); @@@ -791,17 -608,10 +791,17 @@@ const unsigned int, const bool); + template void + SparseMatrix:: + reinit (const IndexSet &, + const IndexSet &, + const CompressedSimpleSparsityPattern &, + const MPI_Comm &); + template void SparseMatrix::do_reinit (const SparsityPattern &, - const std::vector &, - const std::vector &, + const std::vector &, + const std::vector &, const unsigned int , const bool); template void diff --cc deal.II/source/lac/trilinos_vector_base.cc index 9df5d99651,c2695901ee..17e2b41c0c --- a/deal.II/source/lac/trilinos_vector_base.cc +++ b/deal.II/source/lac/trilinos_vector_base.cc @@@ -422,14 -446,10 +446,15 @@@ namespace TrilinosWrapper //one index and the value per local //entry. return sizeof(*this) - + this->local_size()*( sizeof(double)+sizeof(int) ); + + this->local_size()*( sizeof(double)+ + sizeof(TrilinosWrappers::types::int_type) ); } + void + VectorBase::update_ghost_values() const + { + } + } /* end of namespace TrilinosWrappers */