From b41b6cee9dfacdbd17f2f4c396738ceb1bfd8d62 Mon Sep 17 00:00:00 2001 From: heister Date: Sat, 4 Jan 2014 23:24:03 +0000 Subject: [PATCH] rework MGConstrainedDofs to use IndexSet as the datastructure git-svn-id: https://svn.dealii.org/trunk@32167 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/multigrid/mg_constrained_dofs.h | 104 ++++++++++++++---- deal.II/include/deal.II/multigrid/mg_tools.h | 15 ++- deal.II/source/multigrid/mg_tools.cc | 56 ++++++---- deal.II/source/multigrid/mg_tools.inst.in | 9 +- 4 files changed, 133 insertions(+), 51 deletions(-) diff --git a/deal.II/include/deal.II/multigrid/mg_constrained_dofs.h b/deal.II/include/deal.II/multigrid/mg_constrained_dofs.h index bf736c9883..917dc33771 100644 --- a/deal.II/include/deal.II/multigrid/mg_constrained_dofs.h +++ b/deal.II/include/deal.II/multigrid/mg_constrained_dofs.h @@ -106,7 +106,6 @@ public: * Return the indices of dofs for each level that lie on the * boundary of the domain. */ -// TODO: remove const std::vector > & get_boundary_indices () const; @@ -115,23 +114,35 @@ public: * refinement edge (i.e. are on faces between cells of this level * and cells on the level below). */ - // TODO: remove const std::vector > & - get_refinement_edge_indices () const; + 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) + */ + const IndexSet & + get_refinement_edge_indices (unsigned int level) const; /** * 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(). */ - // TODO: remove const std::vector > & - get_refinement_edge_boundary_indices () const; + get_refinement_edge_boundary_indices () const DEAL_II_DEPRECATED; /** - * Return if boundary_indices need to be set or not. + * Return indices of all dofs that are on boundary faces on the given level + * if the cell has refinement edge indices (i.e. has a coarser neighbor). */ + const IndexSet & + get_refinement_edge_boundary_indices (unsigned int level) const; + /** + * Return if boundary_indices need to be set or not. + */ +//TODO: remove? bool set_boundary_values () const; private: @@ -145,7 +156,7 @@ private: * The degrees of freedom on the refinement edge between a level and * coarser cells. */ - std::vector > refinement_edge_indices; + std::vector refinement_edge_indices; /** * The degrees of freedom on the refinement edge between a level and @@ -153,7 +164,17 @@ private: * * This is a subset of #refinement_edge_indices. */ - std::vector > refinement_edge_boundary_indices; + std::vector refinement_edge_boundary_indices; + + /** + * old data structure only filled on demand + */ + mutable std::vector > refinement_edge_boundary_indices_old; + + /** + * old data structure only filled on demand + */ + mutable std::vector > refinement_edge_indices_old; }; @@ -165,10 +186,12 @@ MGConstrainedDoFs::initialize(const DoFHandler &dof) const unsigned int nlevels = dof.get_tria().n_global_levels(); refinement_edge_indices.resize(nlevels); refinement_edge_boundary_indices.resize(nlevels); + refinement_edge_indices_old.clear(); + refinement_edge_boundary_indices_old.clear(); for (unsigned int l=0; l > & MGConstrainedDoFs::get_refinement_edge_indices () const { - return refinement_edge_indices; + 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 { - return refinement_edge_boundary_indices; + if (refinement_edge_boundary_indices_old.size()!=refinement_edge_boundary_indices.size()) + { + unsigned int n_levels = refinement_edge_boundary_indices.size(); + refinement_edge_boundary_indices_old.resize(n_levels); + for (unsigned int l=0;l void extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, - std::vector > &interface_dofs, - std::vector > &boundary_interface_dofs); + std::vector &interface_dofs, + std::vector &boundary_interface_dofs); /** * Does the same as the function above, @@ -302,7 +302,16 @@ namespace MGTools template void extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, - std::vector > &interface_dofs); + std::vector &interface_dofs); + + /** + * As above but with a deprecated data structure. This makes one additional copy. + */ + template + void + extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, + std::vector > &interface_dofs) DEAL_II_DEPRECATED; + template void diff --git a/deal.II/source/multigrid/mg_tools.cc b/deal.II/source/multigrid/mg_tools.cc index 0bf94ebb10..85bf569a4f 100644 --- a/deal.II/source/multigrid/mg_tools.cc +++ b/deal.II/source/multigrid/mg_tools.cc @@ -1416,7 +1416,7 @@ namespace MGTools template void extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, - std::vector > &interface_dofs) + std::vector &interface_dofs) { Assert (interface_dofs.size() == mg_dof_handler.get_tria().n_global_levels(), ExcDimensionMismatch (interface_dofs.size(), @@ -1427,10 +1427,7 @@ namespace MGTools Assert (interface_dofs[l].size() == mg_dof_handler.n_dofs(l), ExcDimensionMismatch (interface_dofs[l].size(), mg_dof_handler.n_dofs(l))); - - std::fill (interface_dofs[l].begin(), - interface_dofs[l].end(), - false); + interface_dofs[l].clear(); } const FiniteElement &fe = mg_dof_handler.get_fe(); @@ -1475,7 +1472,29 @@ namespace MGTools for (unsigned int i=0; i + void + extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, + std::vector > &interface_dofs) + { + std::vector temp; + temp.resize(interface_dofs.size()); + for (unsigned int l=0;l void extract_non_interface_dofs (const DoFHandler &mg_dof_handler, - std::vector > &non_interface_dofs) + std::vector > &non_interface_dofs) { Assert (non_interface_dofs.size() == mg_dof_handler.get_tria().n_global_levels(), ExcDimensionMismatch (non_interface_dofs.size(), @@ -1552,8 +1571,8 @@ namespace MGTools template void extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, - std::vector > &interface_dofs, - std::vector > &boundary_interface_dofs) + std::vector &interface_dofs, + std::vector &boundary_interface_dofs) { Assert (interface_dofs.size() == mg_dof_handler.get_tria().n_global_levels(), ExcDimensionMismatch (interface_dofs.size(), @@ -1564,19 +1583,8 @@ namespace MGTools for (unsigned int l=0; l &fe = mg_dof_handler.get_fe(); @@ -1639,10 +1647,10 @@ namespace MGTools for (unsigned int i=0; i &mg_dof_handler, - std::vector > &interface_dofs, - std::vector > &boundary_interface_dofs); + std::vector &interface_dofs, + std::vector &boundary_interface_dofs); + template + void + extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, + std::vector &interface_dofs); template void extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, std::vector > &interface_dofs); + template void extract_non_interface_dofs (const DoFHandler & mg_dof_handler, -- 2.39.5