From: wolf Date: Wed, 17 May 2000 20:24:57 +0000 (+0000) Subject: Further work on apply_boundary_values for block matrices; still not compilable, so... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb21e57faf2dbfd75737b84d8f2450ade3b365c4;p=dealii-svn.git Further work on apply_boundary_values for block matrices; still not compilable, so still commented out. git-svn-id: https://svn.dealii.org/trunk@2881 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index 168e7f2ee7..ebfba1cdb4 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include #include #include @@ -676,8 +678,8 @@ MatrixTools::apply_boundary_values (const map &boundar -/* +/* template template void @@ -693,7 +695,8 @@ MatrixTools::apply_boundary_values (const map &boundar ExcDimensionsDontMatch(matrix.n(), right_hand_side.size())); Assert (matrix.n() == solution.size(), ExcDimensionsDontMatch(matrix.n(), solution.size())); - Assert (matrix.get_row_indices() == matrix.get_column_indices(), + Assert (matrix.get_sparsity_pattern().get_row_indices() == + matrix.get_sparsity_pattern().get_column_indices(), ExcMatrixNotBlockSquare()); // if no boundary values are to be applied @@ -704,7 +707,9 @@ MatrixTools::apply_boundary_values (const map &boundar map::const_iterator dof = boundary_values.begin(), endd = boundary_values.end(); - const unsigned int n_dofs = matrix.m(); + const unsigned int n_dofs = matrix.m(); + const BlockSparsityPattern & + sparsity_pattern = matrix.get_sparsity_pattern(); // if a diagonal entry is zero // later, then we use another @@ -712,20 +717,45 @@ MatrixTools::apply_boundary_values (const map &boundar // the first nonzero diagonal // element of the matrix, or 1 if // there is no such thing - double first_nonzero_diagonal_entry = 1; - for (unsigned int i=0; i & + index_mapping = sparsity_pattern.get_column_indices(); + // now loop over all boundary dofs for (; dof != endd; ++dof) { Assert (dof->first < n_dofs, ExcInternalError()); const unsigned int dof_number = dof->first; + const pair + block_index = index_mapping.global_to_local (dof_number); + // for each boundary dof: // set entries of this line @@ -736,10 +766,33 @@ MatrixTools::apply_boundary_values (const map &boundar // 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::apply_boundary_values (const map &boundar // store the new rhs entry to make // the gauss step more efficient double new_rhs; - if (matrix.diag_element(dof_number) != 0.0) - new_rhs = right_hand_side(dof_number) - = dof->second * matrix.diag_element(dof_number); + if (matrix.block(block_index.first, block_index.first) + .diag_element(block_index.second) != 0.0) + new_rhs = dof->second * + matrix.block(block_index.first, block_index.first) + .diag_element(block_index.second); else { - matrix.set (dof_number, dof_number, - first_nonzero_diagonal_entry); - new_rhs = right_hand_side(dof_number) - = dof->second * first_nonzero_diagonal_entry; + matrix.block(block_index.first, block_index.first) + .set (block_index.second, + block_index.second, + first_nonzero_diagonal_entry); + new_rhs = dof->second * first_nonzero_diagonal_entry; }; + right_hand_side.block(block_index.first)(block_index.second) + = new_rhs; // if the user wants to have @@ -773,13 +831,17 @@ MatrixTools::apply_boundary_values (const map &boundar // sparsity pattern is // symmetric, then do a Gauss // elimination step with the - // present row + // present row. this is a + // little more complicated for + // block matrices. if (preserve_symmetry) { // store the only nonzero entry // of this line for the Gauss // elimination step - const double diagonal_entry = matrix.diag_element(dof_number); + const double diagonal_entry + = matrix.block(block_index.first,block_index.first) + .diag_element(block_index.second); // we have to loop over all // rows of the matrix which @@ -792,58 +854,78 @@ MatrixTools::apply_boundary_values (const map &boundar // these rows cheaply by // looking at the nonzero // column numbers of the - // present row. we need not - // look at the first entry, - // since that is the - // diagonal element and - // thus the present row - for (unsigned int j=sparsity_rowstart[dof_number]+1; jsecond; + solution.block(block_index.first)(block_index.second) = dof->second; }; }; - - */ - template MassMatrix::MassMatrix (const Function * const rhs, const Function * const a) : @@ -1256,3 +1338,23 @@ template class MatrixTools; template class MassMatrix; template class LaplaceMatrix; +/* +template +void +MatrixTools:: +apply_boundary_values (const map &, + BlockSparseMatrix &, + BlockVector<2,double> &, + BlockVector<2,double> &, + const bool); + +template +void +MatrixTools:: +apply_boundary_values (const map &, + BlockSparseMatrix &, + BlockVector<3,double> &, + BlockVector<3,double> &, + const bool); + +*/