From 8ac1a766fdc47e4cf6b1d3b8afa5547fc55bda94 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 8 Feb 2010 11:35:07 +0000 Subject: [PATCH] Change setting of boundary conditions in prolongation matrix. git-svn-id: https://svn.dealii.org/trunk@20521 0785d39b-7218-0410-832d-ea1e28bc413d --- .../source/multigrid/mg_transfer_prebuilt.cc | 108 +++++++++--------- 1 file changed, 51 insertions(+), 57 deletions(-) diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc b/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc index fa7bcc0bab..a6baf26b5a 100644 --- a/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc +++ b/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc @@ -127,6 +127,7 @@ MGTransferPrebuilt::copy_to_mg ( for (IT i= copy_indices[level].begin(); i != copy_indices[level].end();++i) dst_level(i->second) = src(i->first); + // For non-DG: degrees of // freedom in the refinement // face may need special @@ -145,11 +146,10 @@ MGTransferPrebuilt::copy_to_mg ( template template void MGTransferPrebuilt::build_matrices ( - const MGDoFHandler &mg_dof, - const std::vector >&boundary_indices + const MGDoFHandler &mg_dof, + const std::vector > &boundary_indices ) { - //start building the matrices here const unsigned int n_levels = mg_dof.get_tria().n_levels(); const unsigned int dofs_per_cell = mg_dof.get_fe().dofs_per_cell; @@ -172,10 +172,10 @@ void MGTransferPrebuilt::build_matrices ( for (unsigned int i=0; i (new SparsityPattern)); - prolongation_matrices - .push_back (std_cxx1x::shared_ptr > (new SparseMatrix)); + prolongation_sparsities.push_back + (std_cxx1x::shared_ptr (new SparsityPattern)); + prolongation_matrices.push_back + (std_cxx1x::shared_ptr > (new SparseMatrix)); } // two fields which will store the @@ -220,7 +220,8 @@ void MGTransferPrebuilt::build_matrices ( // prolongation matrix for // this child const FullMatrix &prolongation - = mg_dof.get_fe().get_prolongation_matrix (child, cell->refinement_case()); + = mg_dof.get_fe().get_prolongation_matrix (child, + cell->refinement_case()); Assert (prolongation.n() != 0, ExcNoProlongation()); @@ -232,12 +233,11 @@ void MGTransferPrebuilt::build_matrices ( for (unsigned int i=0; iadd (dof_indices_child[i], - dof_indices_parent[j]); - }; - }; - }; + prolongation_sparsities[level]->add (dof_indices_child[i], + dof_indices_parent[j]); + } + } + prolongation_sparsities[level]->compress (); prolongation_matrices[level]->reinit (*prolongation_sparsities[level]); @@ -257,7 +257,8 @@ void MGTransferPrebuilt::build_matrices ( // prolongation matrix for // this child const FullMatrix &prolongation - = mg_dof.get_fe().get_prolongation_matrix (child, cell->refinement_case()); + = mg_dof.get_fe().get_prolongation_matrix (child, + cell->refinement_case()); cell->child(child)->get_mg_dof_indices (dof_indices_child); @@ -273,51 +274,44 @@ void MGTransferPrebuilt::build_matrices ( } } - // impose boundary conditions - // but only in the column of - // the prolongation matrix - if(boundary_indices.size() != 0) - { - std::vector constrain_indices; - for (int level=n_levels-2; level>=0; --level) -// for (unsigned int level=0; leveln(), 0); - std::set::const_iterator dof = boundary_indices[level].begin(), - endd = boundary_indices[level].end(); - for (; dof != endd; ++dof) - constrain_indices[*dof] = 1; - - const unsigned int n_dofs = prolongation_matrices[level]->m(); - for (unsigned int i=0; i::iterator start_row = prolongation_matrices[level]->begin(i), - end_row = prolongation_matrices[level]->end(i); - for(; start_row != end_row; ++start_row) - { - std::set::const_iterator dof = boundary_indices[level].begin(), - endd = boundary_indices[level].end(); - for (; dof != endd; ++dof) - { - const unsigned int column_number = start_row->column(); - const unsigned int dof_number = *dof; - if(dof_number == column_number) - prolongation_matrices[level]->set(i,dof_number,0); - } - } - } + std::vector constrain_indices; + for (int level=n_levels-2; level>=0; --level) + { + if (boundary_indices[level].size() == 0) + continue; + + // need to delete all the columns in the + // matrix that are on the boundary. to achive + // this, create an array as long as there are + // matrix columns, and find which columns we + // need to filter away. + constrain_indices.resize (0); + constrain_indices.resize (prolongation_matrices[level]->n(), 0); + std::set::const_iterator dof = boundary_indices[level].begin(), + endd = boundary_indices[level].end(); + for (; dof != endd; ++dof) + constrain_indices[*dof] = 1; + + const unsigned int n_dofs = prolongation_matrices[level]->m(); + for (unsigned int i=0; i::iterator + start_row = prolongation_matrices[level]->begin(i), + end_row = prolongation_matrices[level]->end(i); + for(; start_row != end_row; ++start_row) + { + if (constrain_indices[start_row->column()] == 1) + start_row->value() = 0; + } + } + } } - } // to find the indices that describe the // relation between global dofs and local -- 2.39.5