From 102bd0c2009c24dcea29ae2431edaf2d0206cc45 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 22 May 2000 09:09:31 +0000 Subject: [PATCH] Fix a bug with non-square/square block matrices. git-svn-id: https://svn.dealii.org/trunk@2917 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/numerics/matrices.cc | 38 ++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index 0c1017352f..be9eeb19a0 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -922,10 +922,32 @@ MatrixTools::apply_boundary_values (const map &boundar // (row,dof_number) // in this block // (not in the - // transpose one) - const unsigned int * + // transpose + // one). note that + // we have to take + // care of special + // cases with + // square + // sub-matrices + const unsigned int *p = 0; + if (this_sparsity.n_rows() == this_sparsity.n_cols()) + { + if (this_sparsity.get_column_numbers() + [this_sparsity.get_rowstart_indices()[row]] + == + block_index.second) + p = &this_sparsity.get_column_numbers() + [this_sparsity.get_rowstart_indices()[row]]; + else + p = lower_bound(&this_sparsity.get_column_numbers() + [this_sparsity.get_rowstart_indices()[row]+1], + &this_sparsity.get_column_numbers() + [this_sparsity.get_rowstart_indices()[row+1]], + block_index.second); + } + else p = lower_bound(&this_sparsity.get_column_numbers() - [this_sparsity.get_rowstart_indices()[row]+1], + [this_sparsity.get_rowstart_indices()[row]], &this_sparsity.get_column_numbers() [this_sparsity.get_rowstart_indices()[row+1]], block_index.second); @@ -938,7 +960,15 @@ MatrixTools::apply_boundary_values (const map &boundar // past-the-end pointer but points // to dof_number anyway...) // - // there should be such an entry! + // there should be + // such an entry! + // note, however, + // that this + // assertion will + // fail sometimes + // if the sparsity + // pattern is not + // symmetric! Assert ((*p == block_index.second) && (p != &this_sparsity.get_column_numbers() [this_sparsity.get_rowstart_indices()[row+1]]), -- 2.39.5