From 79a1be0b7e1c67e844e4cd44a9e777efa1ec8887 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 8 Jan 2013 21:19:57 +0000 Subject: [PATCH] Replace two untested and undocumented functions by a call to MatrixTools::apply_boundary_values. git-svn-id: https://svn.dealii.org/trunk@27982 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/multigrid/mg_tools.cc | 405 +++------------------------ 1 file changed, 36 insertions(+), 369 deletions(-) diff --git a/deal.II/source/multigrid/mg_tools.cc b/deal.II/source/multigrid/mg_tools.cc index ce14f7e9fd..bd45b98853 100644 --- a/deal.II/source/multigrid/mg_tools.cc +++ b/deal.II/source/multigrid/mg_tools.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -1625,131 +1626,23 @@ namespace MGTools const std::set &boundary_dofs, SparseMatrix &matrix, const bool preserve_symmetry, - const bool ignore_zeros) + const bool /*ignore_zeros*/) { - // if no boundary values are to be applied - // simply return - if (boundary_dofs.size() == 0) - return; - - - const unsigned int n_dofs = matrix.m(); - - // if a diagonal entry is zero - // later, then we use another - // number instead. take it to be - // the first nonzero diagonal - // element of the matrix, or 1 if - // there is no such thing - number first_nonzero_diagonal_entry = 1; - for (unsigned int i=0; i::const_iterator dof = boundary_dofs.begin(), - endd = boundary_dofs.end(); - const SparsityPattern &sparsity = matrix.get_sparsity_pattern(); - const std::size_t *sparsity_rowstart = sparsity.get_rowstart_indices(); - const unsigned int *sparsity_colnums = sparsity.get_column_numbers(); - for (; dof != endd; ++dof) - { - Assert (*dof < n_dofs, ExcInternalError()); - - const unsigned int dof_number = *dof; - // for each boundary dof: - - // set entries of this line - // to zero except for the diagonal - // entry. Note that the diagonal - // entry is always the first one - // for square matrices, i.e. - // we shall not set - // matrix.global_entry( - // sparsity_rowstart[dof.first]) - const unsigned int last = sparsity_rowstart[dof_number+1]; - for (unsigned int j=sparsity_rowstart[dof_number]+1; j boundary_values; + for (std::set::const_iterator p=boundary_dofs.begin(); + p != boundary_dofs.end(); ++p) + boundary_values[*p] = 0; + + Vector dummy(matrix.m()); + MatrixTools::apply_boundary_values (boundary_values, + matrix, dummy, dummy, + preserve_symmetry); } @@ -1773,251 +1666,25 @@ namespace MGTools Assert (matrix.block(i,i).get_sparsity_pattern().optimize_diagonal(), SparsityPattern::ExcDiagonalNotOptimized()); - - // if no boundary values are to be applied - // simply return - if (boundary_dofs.size() == 0) - return; - - - const unsigned int n_dofs = matrix.m(); - - // if a diagonal entry is zero - // later, then we use another - // number instead. take it to be - // the first nonzero diagonal - // element of the matrix, or 1 if - // there is no such thing - number first_nonzero_diagonal_entry = 0; - for (unsigned int diag_block=0; diag_block::const_iterator dof = boundary_dofs.begin(), - endd = boundary_dofs.end(); - const BlockSparsityPattern & - sparsity_pattern = matrix.get_sparsity_pattern(); - - // pointer to the mapping between - // global and block indices. since - // the row and column mappings are - // equal, store a pointer on only - // one of them - const BlockIndices & - index_mapping = sparsity_pattern.get_column_indices(); - - // now loop over all boundary dofs - for (; dof != endd; ++dof) - { - Assert (*dof < n_dofs, ExcInternalError()); - - // get global index and index - // in the block in which this - // dof is located - const unsigned int dof_number = *dof; - const std::pair - block_index = index_mapping.global_to_local (dof_number); - - // for each boundary dof: - - // set entries of this line - // to zero except for the diagonal - // entry. Note that the diagonal - // entry is always the first one - // for square matrices, i.e. - // we shall not set - // matrix.global_entry( - // sparsity_rowstart[dof.first]) - // of the diagonal block - for (unsigned int block_col=0; block_col boundary_values; + for (std::set::const_iterator p=boundary_dofs.begin(); + p != boundary_dofs.end(); ++p) + boundary_values[*p] = 0; + + BlockVector dummy(matrix.n_block_rows()); + for (unsigned int i=0; i