From 922d410c1f4ec65a0374a081caa380c5459695d0 Mon Sep 17 00:00:00 2001 From: heister Date: Mon, 27 Oct 2008 15:39:00 +0000 Subject: [PATCH] Added MatrixTools::apply_boundary_values for PETScWrappers::MPI::BlockSparseMatrix and added CompressedSimpleSparsityPattern in doc/news/changes. git-svn-id: https://svn.dealii.org/trunk@17351 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/numerics/matrices.h | 13 ++++ .../numerics/matrices.all_dimensions.cc | 76 +++++++++++++++++++ deal.II/doc/news/changes.h | 17 +++++ 3 files changed, 106 insertions(+) diff --git a/deal.II/deal.II/include/numerics/matrices.h b/deal.II/deal.II/include/numerics/matrices.h index 540695fcd0..6f540a497f 100644 --- a/deal.II/deal.II/include/numerics/matrices.h +++ b/deal.II/deal.II/include/numerics/matrices.h @@ -55,7 +55,9 @@ namespace PETScWrappers namespace MPI { class SparseMatrix; + class BlockSparseMatrix; class Vector; + class BlockVector; } } #endif @@ -1109,6 +1111,17 @@ class MatrixTools : public MatrixCreator PETScWrappers::Vector &solution, PETScWrappers::MPI::Vector &right_hand_side, const bool eliminate_columns = true); + + /** + * Same as above but for BlockSparseMatrix. + */ + static void + apply_boundary_values (const std::map &boundary_values, + PETScWrappers::MPI::BlockSparseMatrix &matrix, + PETScWrappers::MPI::BlockVector &solution, + PETScWrappers::MPI::BlockVector &right_hand_side, + const bool eliminate_columns = true); + #endif #ifdef DEAL_II_USE_TRILINOS diff --git a/deal.II/deal.II/source/numerics/matrices.all_dimensions.cc b/deal.II/deal.II/source/numerics/matrices.all_dimensions.cc index 4366991f8e..910c8147f3 100644 --- a/deal.II/deal.II/source/numerics/matrices.all_dimensions.cc +++ b/deal.II/deal.II/source/numerics/matrices.all_dimensions.cc @@ -24,6 +24,7 @@ # include # include # include +# include #endif #ifdef DEAL_II_USE_TRILINOS @@ -681,6 +682,81 @@ apply_boundary_values (const std::map &boundary_values, } +void +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + PETScWrappers::MPI::BlockSparseMatrix &matrix, + PETScWrappers::MPI::BlockVector &solution, + PETScWrappers::MPI::BlockVector &right_hand_side, + const bool eliminate_columns) +{ + Assert (matrix.n() == right_hand_side.size(), + ExcDimensionMismatch(matrix.n(), right_hand_side.size())); + Assert (matrix.n() == solution.size(), + ExcDimensionMismatch(matrix.n(), solution.size())); + Assert (matrix.n_block_rows() == matrix.n_block_cols(), + ExcNotQuadratic()); + + const unsigned int n_blocks = matrix.n_block_rows(); + + matrix.compress(); + + // We need to find the subdivision + // into blocks for the boundary values. + // To this end, generate a vector of + // maps with the respective indices. + std::vector > block_boundary_values(n_blocks); + { + int offset = 0, block=0; + for (std::map::const_iterator + dof = boundary_values.begin(); + dof != boundary_values.end(); + ++dof) + { + if (dof->first >= matrix.block(block,0).m() + offset) + { + offset += matrix.block(block,0).m(); + block++; + } + const unsigned int index = dof->first - offset; + block_boundary_values[block].insert(std::pair (index,dof->second)); + } + } + + // Now call the non-block variants on + // the diagonal subblocks and the + // solution/rhs. + for (unsigned int block=0; block local_range + = matrix.block(block_m,0).local_range(); + + std::vector constrained_rows; + for (std::map::const_iterator + dof = block_boundary_values[block_m].begin(); + dof != block_boundary_values[block_m].end(); + ++dof) + if ((dof->first >= local_range.first) && + (dof->first < local_range.second)) + constrained_rows.push_back (dof->first); + + for (unsigned int block_n=0; block_n +
  • +

    + New: Added the CompressedSimpleSparsityPattern as an alternative to + CompressedSparsityPattern and CompressedSetSparsityPattern, which + should be faster in most cases but its memory usage is somewhere + inbetween. +
    + (Timo Heister 2008/09/03) +

    +
  • Improved: The CompressedSparsityPattern can now elide some operations @@ -353,6 +363,13 @@ inconvenience this causes.

    deal.II

      +
    1. +

      + New: MatrixTools::apply_boundary_values() also for PETScWrappers::MPI::BlockSparseMatrix. +
      + (Timo Heister 2008/10/27) +

      +
    2. New: When calling function DoFTools::make_sparsity_pattern with a ConstraintMatrix, it is now possible to set a bool argument keep_constrained_dofs. When this flag is set to false, constrained rows and columns will not be part of the sparsity pattern, which increases the performance of matrix operations and decrease memory consumption in case there are many constraints. -- 2.39.5