From: Timo Heister Date: Sun, 8 Jun 2014 23:23:56 +0000 (-0400) Subject: add extract_locally_relevant_mg_dofs X-Git-Tag: v8.4.0-rc2~277^2~48 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=837a2968003cdcda2ecf44811a75d7c1d000721f;p=dealii.git add extract_locally_relevant_mg_dofs --- diff --git a/include/deal.II/dofs/dof_tools.h b/include/deal.II/dofs/dof_tools.h index 10474e2865..30737de05d 100644 --- a/include/deal.II/dofs/dof_tools.h +++ b/include/deal.II/dofs/dof_tools.h @@ -1,5 +1,5 @@ // --------------------------------------------------------------------- -// $Id$ +// $Id: dof_tools.h 32722 2014-04-06 17:25:25Z kronbichler $ // // Copyright (C) 1999 - 2014 by the deal.II authors // @@ -1525,6 +1525,16 @@ namespace DoFTools extract_locally_relevant_dofs (const DH &dof_handler, IndexSet &dof_set); + /** + * Same as extract_locally_relevant_dofs() but for multigrid DoFs + * for the given @p level. + */ + template + void + extract_locally_relevant_mg_dofs (const DH &dof_handler, + IndexSet &dof_set, + unsigned int level); + /** * For each DoF, return in the output array to which subdomain (as * given by the cell->subdomain_id() function) it diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index 90967781b0..f5605b90d2 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -972,6 +972,46 @@ namespace DoFTools } + template + void + extract_locally_relevant_mg_dofs (const DH &dof_handler, + IndexSet &dof_set, + unsigned int level) + { + // collect all the locally owned dofs + dof_set = dof_handler.locally_owned_mg_dofs(level); + + // add the DoF on the adjacent ghost cells to the IndexSet, cache them + // in a set. need to check each dof manually because we can't be sure + // that the dof range of locally_owned_dofs is really contiguous. + std::vector dof_indices; + std::set global_dof_indices; + + typename DH::cell_iterator cell = dof_handler.begin(level), + endc = dof_handler.end(level); + for (; cell!=endc; ++cell) + { + types::subdomain_id id = cell->level_subdomain_id(); + + // skip artificial and own cells (only look at ghost cells) + if (id == dof_handler.get_tria().locally_owned_subdomain() + || id == numbers::artificial_subdomain_id) + continue; + + dof_indices.resize(cell->get_fe().dofs_per_cell); + cell->get_mg_dof_indices(dof_indices); + + for (std::vector::iterator it=dof_indices.begin(); + it!=dof_indices.end(); + ++it) + if (!dof_set.is_element(*it)) + global_dof_indices.insert(*it); + } + + dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end()); + + dof_set.compress(); + } template void diff --git a/source/dofs/dof_tools.inst.in b/source/dofs/dof_tools.inst.in index 05a94aaef9..f7695d7c0a 100644 --- a/source/dofs/dof_tools.inst.in +++ b/source/dofs/dof_tools.inst.in @@ -263,6 +263,12 @@ DoFTools::extract_locally_relevant_dofs > (const hp::DoFHandler & dof_handler, IndexSet & dof_set); +template +void +DoFTools::extract_locally_relevant_mg_dofs > +(const DoFHandler & dof_handler, + IndexSet & dof_set, unsigned int level); + template void DoFTools::extract_constant_modes >