From bae7c85f204d4b9a21caaa5ac36f4373177258e0 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 19 May 2000 15:33:30 +0000 Subject: [PATCH] Implement more functions for block matrices as well. git-svn-id: https://svn.dealii.org/trunk@2902 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/dofs/dof_constraints.templates.h | 314 +++++++++++------- .../deal.II/source/dofs/dof_constraints.cc | 2 +- 2 files changed, 197 insertions(+), 119 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_constraints.templates.h b/deal.II/deal.II/include/dofs/dof_constraints.templates.h index 0bc781c646..f39cb8877e 100644 --- a/deal.II/deal.II/include/dofs/dof_constraints.templates.h +++ b/deal.II/deal.II/include/dofs/dof_constraints.templates.h @@ -21,8 +21,6 @@ template void ConstraintMatrix::condense (BlockSparsityPattern &sparsity) const { - Assert (false, ExcInternalError()); -/* Assert (sorted == true, ExcMatrixNotClosed()); Assert (sparsity.is_compressed() == false, ExcMatrixIsClosed()); Assert (sparsity.n_rows() == sparsity.n_cols(), @@ -30,76 +28,132 @@ void ConstraintMatrix::condense (BlockSparsityPattern &sparsity) Assert (sparsity.get_column_indices() == sparsity.get_row_indices(), ExcMatrixNotSquare()); + const BlockIndices & + index_mapping = sparsity.get_column_indices(); + // store for each index whether it // must be distributed or not. If entry // is -1, no distribution is necessary. // otherwise, the number states which // line in the constraint matrix handles // this index - vector distribute(sparsity.n_rows(), -1); + vector distribute (sparsity.n_rows(), -1); for (unsigned int c=0; c(c); - int n_rows = sparsity.n_rows(); - for (int row=0; row + block_index = index_mapping.global_to_local(row); + const unsigned int block_row = block_index.first; + if (distribute[row] == -1) - // regular line. loop over cols - for (unsigned int j=sparsity.get_rowstart_indices()[row]; - j &uncondensed, vector::const_iterator next_constraint = lines.begin(); unsigned int shift = 0; - unsigned int n_rows = uncondensed_struct.n_rows(); + const unsigned int n_rows = uncondensed_struct.n_rows(); if (next_constraint == lines.end()) // if no constraint is to be handled @@ -378,21 +432,29 @@ ConstraintMatrix::condense (BlockSparseMatrix &uncondensed const unsigned int n_rows = sparsity.n_rows(); for (unsigned int row=0; row + block_index = index_mapping.global_to_local(row); + const unsigned int block_row = block_index.first; + if (distribute[row] == -1) + // regular line. loop over + // all columns and see + // whether this column must + // be distributed { - // get index of this row - // within the blocks - const pair - block_index = index_mapping.global_to_local(row); - - // regular line. loop over - // all columns and see - // whether this column must - // be distributed + + // to loop over all entries + // in this row, we have to + // loop over all blocks in + // this blockrow and the + // corresponding row + // therein for (unsigned int block_col=0; block_col &uncondensed else { const unsigned int global_col - =index_mapping.local_to_global(block_col, - block_sparsity.get_column_numbers()[j]); + = index_mapping.local_to_global(block_col, + block_sparsity.get_column_numbers()[j]); if (distribute[global_col] != -1) // distribute entry at regular @@ -420,7 +482,7 @@ ConstraintMatrix::condense (BlockSparseMatrix &uncondensed // set old entry to zero { const double old_value = - uncondensed.block(block_index.first,block_col).global_entry(j); + uncondensed.block(block_row,block_col).global_entry(j); for (unsigned int q=0; q!=lines[distribute[global_col]] @@ -430,7 +492,7 @@ ConstraintMatrix::condense (BlockSparseMatrix &uncondensed old_value * lines[distribute[global_col]].entries[q].second); - uncondensed.block(block_index.first,block_col).global_entry(j) + uncondensed.block(block_row,block_col).global_entry(j) = 0.; }; }; @@ -438,61 +500,77 @@ ConstraintMatrix::condense (BlockSparseMatrix &uncondensed } else { - Assert (false, ExcInternalError()); -/* - // row must be distributed - for (unsigned int j=sparsity.get_rowstart_indices()[row]; - j(c); - unsigned int n_rows = sparsity.n_rows(); + const unsigned int n_rows = sparsity.n_rows(); for (unsigned int row=0; row