From 9b736ff37c3be60475b6c410b6c0202bffe5ebdb Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Mon, 21 Dec 2015 12:34:41 -0500 Subject: [PATCH] remove deprecated stuff in MGConstrainedDoFs Also introduce the replacement have_boundary_indices() for set_boundary_values() and make sure it works correctly. --- .../deal.II/multigrid/mg_constrained_dofs.h | 143 ++---------------- source/multigrid/mg_transfer_block.cc | 91 ++++++----- source/multigrid/mg_transfer_prebuilt.cc | 2 +- tests/mpi/multigrid_adaptive.cc | 13 +- tests/mpi/multigrid_uniform.cc | 19 ++- tests/multigrid/constrained_dofs_01.cc | 16 -- tests/multigrid/step-16-02.cc | 23 +-- tests/multigrid/step-16-bdry1.cc | 11 +- tests/multigrid/step-16.cc | 11 +- 9 files changed, 95 insertions(+), 234 deletions(-) diff --git a/include/deal.II/multigrid/mg_constrained_dofs.h b/include/deal.II/multigrid/mg_constrained_dofs.h index 0718e0e5ac..39530bd35d 100644 --- a/include/deal.II/multigrid/mg_constrained_dofs.h +++ b/include/deal.II/multigrid/mg_constrained_dofs.h @@ -84,15 +84,6 @@ public: bool at_refinement_edge (const unsigned int level, const types::global_dof_index index) const; - /** - * Return the indices of dofs for each level that are subject to boundary - * constraints. - * - * @deprecated: use get_boundary_indices(const unsigned int) instead. - */ - const std::vector > & - get_boundary_indices () const DEAL_II_DEPRECATED; - /** * Return the indices of level dofs on the given level that are subject to * Dirichlet boundary conditions (as set by the @p function_map parameter in @@ -102,42 +93,19 @@ public: const IndexSet & get_boundary_indices (const unsigned int level) const; - /** - * @deprecated Use at_refinement_edge() if possible, else - * get_refinement_edge_indices(unsigned int). - * - * Return the indices of dofs for each level that lie on the refinement edge - * (i.e. are on faces between cells of this level and cells on the level - * below). - */ - const std::vector > & - get_refinement_edge_indices () const DEAL_II_DEPRECATED; /** * Return the indices of dofs on the given level that lie on an refinement - * edge (dofs on faces to neighbors that are coarser) + * edge (dofs on faces to neighbors that are coarser). */ const IndexSet & get_refinement_edge_indices (unsigned int level) const; - /** - * @deprecated Use at_refinement_edge_boundary() if possible, else use - * get_refinement_edge_boundary_indices(). - * - * Return the indices of dofs for each level that are in the intersection of - * the sets returned by get_boundary_indices() and - * get_refinement_edge_indices(). - */ - const std::vector > & - get_refinement_edge_boundary_indices () const DEAL_II_DEPRECATED; /** - * @deprecated The function is_boundary_index() now returns false if no - * boundary values are set. - * - * Return if boundary_indices need to be set or not. + * Return if Dirichlet boundary indices are set in initialize(). */ - bool set_boundary_values () const DEAL_II_DEPRECATED; + bool have_boundary_indices () const; private: @@ -146,29 +114,11 @@ private: */ std::vector boundary_indices; - /** - * Old data structure that is only filled on demand from @p boundary_indices - * for deprecated get_boundary_indices(). - */ - mutable std::vector > boundary_indices_old; - /** * The degrees of freedom on a given level that live on the refinement edge * between the level and cells on a coarser level. */ std::vector refinement_edge_indices; - - /** - * Old data structure that is only filled on demand for deprecated - * get_refinement_edge_boundary_indices(). - */ - mutable std::vector > refinement_edge_boundary_indices_old; - - /** - * Old data structure that is only filled on demand for deprecated - * get_refinement_edge_indices(). - */ - mutable std::vector > refinement_edge_indices_old; }; @@ -177,19 +127,13 @@ inline void MGConstrainedDoFs::initialize(const DoFHandler &dof) { - const unsigned int nlevels = dof.get_triangulation().n_global_levels(); + boundary_indices.clear(); - boundary_indices.resize(nlevels); + const unsigned int nlevels = dof.get_triangulation().n_global_levels(); refinement_edge_indices.resize(nlevels); - refinement_edge_indices_old.clear(); - refinement_edge_boundary_indices_old.clear(); for (unsigned int l=0; l &dof, { initialize (dof); + // allocate an IndexSet for each global level. Contents will be + // overwritten inside make_boundary_list. + const unsigned int n_levels = dof.get_triangulation().n_global_levels(); + boundary_indices.resize(n_levels); + MGTools::make_boundary_list (dof, function_map, boundary_indices, @@ -215,15 +164,8 @@ inline void MGConstrainedDoFs::clear() { - for (unsigned int l=0; l > & -MGConstrainedDoFs::get_boundary_indices () const -{ - if (boundary_indices_old.size()!=boundary_indices.size()) - { - boundary_indices_old.resize(boundary_indices.size()); - for (unsigned int l=0; l tmp; - boundary_indices[l].fill_index_vector(tmp); - boundary_indices_old[l].insert(tmp.begin(), tmp.end()); - } - } - return boundary_indices_old; -} inline @@ -277,23 +203,6 @@ MGConstrainedDoFs::get_boundary_indices (const unsigned int level) const } -inline -const std::vector > & -MGConstrainedDoFs::get_refinement_edge_indices () const -{ - if (refinement_edge_indices_old.size()!=refinement_edge_indices.size()) - { - unsigned int n_levels = refinement_edge_indices.size(); - refinement_edge_indices_old.resize(n_levels); - for (unsigned int l=0; l > & -MGConstrainedDoFs::get_refinement_edge_boundary_indices () const -{ - if (refinement_edge_boundary_indices_old.size()==0) - { - unsigned int n_levels = refinement_edge_indices.size(); - refinement_edge_boundary_indices_old.resize(n_levels); - for (unsigned int l=0; lis_boundary_index(l, *it); - } - } - - return refinement_edge_boundary_indices_old; -} inline bool -MGConstrainedDoFs::set_boundary_values () const +MGConstrainedDoFs::have_boundary_indices () const { - const bool boundary_values_need_to_be_set - = boundary_indices.size()!=0; - return boundary_values_need_to_be_set; + return boundary_indices.size()!=0; } diff --git a/source/multigrid/mg_transfer_block.cc b/source/multigrid/mg_transfer_block.cc index 673594da84..67a97e29de 100644 --- a/source/multigrid/mg_transfer_block.cc +++ b/source/multigrid/mg_transfer_block.cc @@ -410,52 +410,51 @@ void MGTransferBlockBase::build_matrices ( // impose boundary conditions // but only in the column of // the prolongation matrix - if (mg_constrained_dofs != 0) - if (mg_constrained_dofs->set_boundary_values()) - { - std::vector constrain_indices; - std::vector > constraints_per_block (n_blocks); - for (int level=n_levels-2; level>=0; --level) - { - if (mg_constrained_dofs->get_boundary_indices()[level].size() == 0) - continue; - - // need to delete all the columns in the - // matrix that are on the boundary. to achieve - // 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 - = mg_constrained_dofs->get_boundary_indices()[level].begin(), - endd = mg_constrained_dofs->get_boundary_indices()[level].end(); - for (; dof != endd; ++dof) - constrain_indices[*dof] = 1; - - unsigned int index = 0; - for (unsigned int block=0; blockblock(block, block).m(); - constraints_per_block[block].resize(0); - constraints_per_block[block].resize(n_dofs, 0); - for (types::global_dof_index i=0; i::iterator - start_row = prolongation_matrices[level]->block(block, block).begin(i), - end_row = prolongation_matrices[level]->block(block, block).end(i); - for (; start_row != end_row; ++start_row) - { - if (constraints_per_block[block][start_row->column()]) - start_row->value() = 0.; - } - } - } - } - } + if (mg_constrained_dofs != 0 && mg_constrained_dofs->have_boundary_indices()) + { + std::vector constrain_indices; + std::vector > constraints_per_block (n_blocks); + for (int level=n_levels-2; level>=0; --level) + { + if (mg_constrained_dofs->get_boundary_indices(level).n_elements() == 0) + continue; + + // need to delete all the columns in the + // matrix that are on the boundary. to achieve + // 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); + IndexSet::ElementIterator dof + = mg_constrained_dofs->get_boundary_indices(level).begin(), + endd = mg_constrained_dofs->get_boundary_indices(level).end(); + for (; dof != endd; ++dof) + constrain_indices[*dof] = 1; + + unsigned int index = 0; + for (unsigned int block=0; blockblock(block, block).m(); + constraints_per_block[block].resize(0); + constraints_per_block[block].resize(n_dofs, 0); + for (types::global_dof_index i=0; i::iterator + start_row = prolongation_matrices[level]->block(block, block).begin(i), + end_row = prolongation_matrices[level]->block(block, block).end(i); + for (; start_row != end_row; ++start_row) + { + if (constraints_per_block[block][start_row->column()]) + start_row->value() = 0.; + } + } + } + } + } } diff --git a/source/multigrid/mg_transfer_prebuilt.cc b/source/multigrid/mg_transfer_prebuilt.cc index 9e82e15632..f7f7c08d00 100644 --- a/source/multigrid/mg_transfer_prebuilt.cc +++ b/source/multigrid/mg_transfer_prebuilt.cc @@ -235,7 +235,7 @@ void MGTransferPrebuilt::build_matrices = mg_dof.get_fe().get_prolongation_matrix (child, cell->refinement_case()); - if (mg_constrained_dofs != 0 && mg_constrained_dofs->set_boundary_values()) + if (mg_constrained_dofs != 0 && mg_constrained_dofs->have_boundary_indices()) for (unsigned int j=0; jis_boundary_index(level, dof_indices_parent[j])) for (unsigned int i=0; i coefficient; std::vector coefficient_values (n_q_points); - std::vector > interface_dofs - = mg_constrained_dofs.get_refinement_edge_indices (); - std::vector > boundary_interface_dofs - = mg_constrained_dofs.get_refinement_edge_boundary_indices (); - std::vector boundary_constraints (triangulation.n_levels()); ConstraintMatrix empty_constraints; for (unsigned int level=0; level coefficient; std::vector coefficient_values (n_q_points); - std::vector > interface_dofs - = mg_constrained_dofs.get_refinement_edge_indices (); - std::vector > boundary_interface_dofs - = mg_constrained_dofs.get_refinement_edge_boundary_indices (); - std::vector boundary_constraints (triangulation.n_levels()); std::vector boundary_interface_constraints (triangulation.n_levels()); for (unsigned int level=0; levellevel()][local_dof_indices[i]]==true && - interface_dofs[cell->level()][local_dof_indices[j]]==false)) + if ( + !mg_constrained_dofs.at_refinement_edge(cell->level(), + local_dof_indices[i]) + || mg_constrained_dofs.at_refinement_edge(cell->level(), + local_dof_indices[j]) + ) cell_matrix(i,j) = 0; boundary_interface_constraints[cell->level()] diff --git a/tests/multigrid/constrained_dofs_01.cc b/tests/multigrid/constrained_dofs_01.cc index 77464a83f8..062d4be507 100644 --- a/tests/multigrid/constrained_dofs_01.cc +++ b/tests/multigrid/constrained_dofs_01.cc @@ -140,22 +140,6 @@ void check_fe(FiniteElement &fe) deallog << "get_boundary_indices:" << std::endl; bi.print(deallog); - { - // check that refinement_edge_boundary_indices (deprecated) is really - // the intersection of the sets above: - IndexSet intersect = rei & bi; - std::vector ref = mg_constrained_dofs.get_refinement_edge_boundary_indices()[level]; - - unsigned int idx = 0; - for (std::vector::iterator it = ref.begin(); it != ref.end(); ++it, ++idx) - { - if ((*it == true) != intersect.is_element(idx)) - deallog << "mismatch idx=" << idx << " " - << (*it == true) << " " << intersect.is_element(idx) << std::endl; - } - } - - IndexSet relevant; DoFTools::extract_locally_relevant_level_dofs (dofh, level, diff --git a/tests/multigrid/step-16-02.cc b/tests/multigrid/step-16-02.cc index f6939b2da1..6bd45e9ef4 100644 --- a/tests/multigrid/step-16-02.cc +++ b/tests/multigrid/step-16-02.cc @@ -389,21 +389,20 @@ void LaplaceProblem::assemble_multigrid (const bool &use_mw) const Coefficient coefficient; std::vector coefficient_values (n_q_points); - std::vector > interface_dofs - = mg_constrained_dofs.get_refinement_edge_indices (); - std::vector > boundary_interface_dofs - = mg_constrained_dofs.get_refinement_edge_boundary_indices (); - std::vector boundary_constraints (triangulation.n_levels()); std::vector boundary_interface_constraints (triangulation.n_levels()); for (unsigned int level=0; level::assemble_multigrid (const bool &use_mw) for (unsigned int i=0; ilevel()][local_dof_indices[i]]==true && - interface_dofs[cell->level()][local_dof_indices[j]]==false)) + if ( + !mg_constrained_dofs.at_refinement_edge(cell->level(), + local_dof_indices[i]) + || mg_constrained_dofs.at_refinement_edge(cell->level(), + local_dof_indices[j]) + ) cell_matrix(i,j) = 0; boundary_interface_constraints[cell->level()] diff --git a/tests/multigrid/step-16-bdry1.cc b/tests/multigrid/step-16-bdry1.cc index 56197d9c2b..7bc563b425 100644 --- a/tests/multigrid/step-16-bdry1.cc +++ b/tests/multigrid/step-16-bdry1.cc @@ -394,16 +394,13 @@ void LaplaceProblem::assemble_multigrid (bool use_mw) const Coefficient coefficient; std::vector coefficient_values (n_q_points); - std::vector > interface_dofs - = mg_constrained_dofs.get_refinement_edge_indices (); - std::vector boundary_constraints (triangulation.n_levels()); ConstraintMatrix empty_constraints; for (unsigned int level=0; level::assemble_multigrid (bool use_mw) for (unsigned int i=0; i::assemble_multigrid () const Coefficient coefficient; std::vector coefficient_values (n_q_points); - std::vector > interface_dofs - = mg_constrained_dofs.get_refinement_edge_indices (); - std::vector boundary_constraints (triangulation.n_levels()); ConstraintMatrix empty_constraints; for (unsigned int level=0; level::assemble_multigrid () for (unsigned int i=0; i