--- /dev/null
+Deprecated: We have introduced new versions of
+DoFTools::extract_locally_active_dofs(),
+DoFTools::extract_locally_active_level_dofs(),
+DoFTools::extract_locally_relevant_dofs(), and
+DoFTools::extract_locally_relevant_level_dofs().
+These versions return the index sets directly.
+The old versions have been early deprecated.
+<br>
+(Peter Munch, 2022/02/23)
std::vector<AffineConstraints<double>> boundary_constraints(n_levels);
for (unsigned int level = 0; level < n_levels; ++level)
{
- IndexSet dofset;
- DoFTools::extract_locally_relevant_level_dofs(dof_handler,
- level,
- dofset);
+ const IndexSet dofset =
+ DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
boundary_constraints[level].reinit(dofset);
boundary_constraints[level].add_lines(
mg_constrained_dofs.get_refinement_edge_indices(level));
{
dof_handler.distribute_dofs(fe);
locally_owned_dofs = dof_handler.locally_owned_dofs();
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
// The next step is to set up constraints due to hanging nodes. This has
// been handled many times before:
stokes_partitioning.push_back(stokes_index_set.get_view(0, n_u));
stokes_partitioning.push_back(stokes_index_set.get_view(n_u, n_u + n_p));
- DoFTools::extract_locally_relevant_dofs(stokes_dof_handler,
- stokes_relevant_set);
+ stokes_relevant_set =
+ DoFTools::extract_locally_relevant_dofs(stokes_dof_handler);
stokes_relevant_partitioning.push_back(
stokes_relevant_set.get_view(0, n_u));
stokes_relevant_partitioning.push_back(
stokes_relevant_set.get_view(n_u, n_u + n_p));
temperature_partitioning = temperature_dof_handler.locally_owned_dofs();
- DoFTools::extract_locally_relevant_dofs(
- temperature_dof_handler, temperature_relevant_partitioning);
+ temperature_relevant_partitioning =
+ DoFTools::extract_locally_relevant_dofs(temperature_dof_handler);
}
// Following this, we can compute constraints for the solution vectors,
as shown below.
@code
-IndexSet locally_relevant_dofs;
-DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+const IndexSet locally_relevant_dofs = DoFTools::extract_locally_relevant_dofs(dof_handler);
LinearAlgebra::distributed::Vector<double> copy_vec(solution);
solution.reinit(dof_handler.locally_owned_dofs(),
locally_relevant_dofs,
pcout << "Number of degrees of freedom: " << dof_handler.n_dofs()
<< std::endl;
- IndexSet locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ const IndexSet locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
constraints.clear();
constraints.reinit(locally_relevant_dofs);
for (unsigned int level = 0; level < nlevels; ++level)
{
- IndexSet relevant_dofs;
- DoFTools::extract_locally_relevant_level_dofs(dof_handler,
- level,
- relevant_dofs);
+ const IndexSet relevant_dofs =
+ DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
AffineConstraints<double> level_constraints;
level_constraints.reinit(relevant_dofs);
level_constraints.add_lines(
// around the locally owned cells; we need all of these degrees of
// freedom, for example, to estimate the error on the local cells).
locally_owned_dofs = dof_handler.locally_owned_dofs();
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
// Next, let us initialize the solution and right hand side vectors. As
// mentioned above, the solution vector we seek does not only store
dof_handler.distribute_dofs(fe);
locally_owned_dofs = dof_handler.locally_owned_dofs();
- locally_relevant_dofs.clear();
- DoFTools::extract_locally_relevant_dofs(dof_handler,
- locally_relevant_dofs);
+ locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
}
/* setup hanging nodes and Dirichlet constraints */
owned_partitioning.push_back(locally_owned_dofs.get_view(n_u, n_u + n_p));
relevant_partitioning.clear();
- IndexSet locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs(dof_handler,
- locally_relevant_dofs);
+ const IndexSet locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
relevant_partitioning.push_back(locally_relevant_dofs.get_view(0, n_u));
relevant_partitioning.push_back(
locally_relevant_dofs.get_view(n_u, n_u + n_p));
// access in MPI-local numbers that need to match between the vector and
// MatrixFree), so we just ask it to initialize the vectors to be sure the
// ghost exchange is properly handled.
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
constraints.clear();
constraints.reinit(locally_relevant_dofs);
DoFTools::make_hanging_node_constraints(dof_handler, constraints);
dof_handler.distribute_dofs(fe);
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
- locally_owned_dofs = dof_handler.locally_owned_dofs();
+ locally_relevant_dofs = DoFTools::extract_locally_relevant_dofs(dof_handler);
+ locally_owned_dofs = dof_handler.locally_owned_dofs();
solution.reinit(locally_owned_dofs, mpi_communicator);
right_hand_side.reinit(locally_owned_dofs, mpi_communicator);
for (unsigned int level = 0; level < n_levels; ++level)
{
- IndexSet relevant_dofs;
- DoFTools::extract_locally_relevant_level_dofs(dof_handler,
- level,
- relevant_dofs);
+ const IndexSet relevant_dofs =
+ DoFTools::extract_locally_relevant_level_dofs(dof_handler,
+ level);
AffineConstraints<double> level_constraints;
level_constraints.reinit(relevant_dofs);
level_constraints.add_lines(
for (unsigned int level = 0; level < n_levels; ++level)
{
- IndexSet dof_set;
- DoFTools::extract_locally_relevant_level_dofs(dof_handler,
- level,
- dof_set);
+ const IndexSet dof_set =
+ DoFTools::extract_locally_relevant_level_dofs(dof_handler,
+ level);
{
#ifdef USE_PETSC_LA
triangulation.n_global_levels());
for (unsigned int level = 0; level < triangulation.n_global_levels(); ++level)
{
- IndexSet dof_set;
- DoFTools::extract_locally_relevant_level_dofs(dof_handler,
- level,
- dof_set);
+ const IndexSet dof_set =
+ DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
boundary_constraints[level].reinit(dof_set);
boundary_constraints[level].add_lines(
mg_constrained_dofs.get_refinement_edge_indices(level));
owned_partitioning[1] =
dof_handler.locally_owned_dofs().get_view(n_u, n_u + n_p);
- IndexSet locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ const IndexSet locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
relevant_partitioning.resize(2);
relevant_partitioning[0] = locally_relevant_dofs.get_view(0, n_u);
relevant_partitioning[1] = locally_relevant_dofs.get_view(n_u, n_u + n_p);
dof_handler.distribute_dofs(fe);
locally_owned_dofs = dof_handler.locally_owned_dofs();
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
locally_relevant_solution.reinit(locally_owned_dofs,
locally_relevant_dofs,
for (unsigned int level = 0; level < triangulation.n_global_levels();
++level)
{
- IndexSet locally_owned_level_dof_indices;
- DoFTools::extract_locally_relevant_level_dofs(
- dof_handler, level, locally_owned_level_dof_indices);
+ const IndexSet locally_owned_level_dof_indices =
+ DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
boundary_constraints[level].reinit(locally_owned_level_dof_indices);
boundary_constraints[level].add_lines(
mg_constrained_dofs.get_refinement_edge_indices(level));
dof_handler.distribute_dofs(fe);
locally_owned_dofs = dof_handler.locally_owned_dofs();
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
system_rhs_dev.reinit(locally_owned_dofs, mpi_communicator);
constraints.clear();
dof_handler.distribute_dofs(fe);
dof_handler.distribute_mg_dofs();
- IndexSet locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ const IndexSet locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
constraints.clear();
constraints.reinit(locally_relevant_dofs);
for (unsigned int level = 0; level < nlevels; ++level)
{
- IndexSet relevant_dofs;
- DoFTools::extract_locally_relevant_level_dofs(dof_handler,
- level,
- relevant_dofs);
+ const IndexSet relevant_dofs =
+ DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
AffineConstraints<double> level_constraints;
level_constraints.reinit(relevant_dofs);
{
fluid_dh.distribute_dofs(fluid_fe);
const IndexSet locally_owned_dofs = fluid_dh.locally_owned_dofs();
- IndexSet locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs(fluid_dh, locally_relevant_dofs);
+ const IndexSet locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(fluid_dh);
velocity_field.reinit(locally_owned_dofs,
locally_relevant_dofs,
locally_owned = dof_handler.locally_owned_dofs();
n_locally_owned = locally_owned.n_elements();
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant);
+ locally_relevant = DoFTools::extract_locally_relevant_dofs(dof_handler);
n_locally_relevant = locally_relevant.n_elements();
partitioner =
fluid_owned_dofs[1] =
fluid_dh.locally_owned_dofs().get_view(n_u, n_u + n_p);
- IndexSet locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs(fluid_dh, locally_relevant_dofs);
+ const IndexSet locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(fluid_dh);
fluid_relevant_dofs.resize(2);
fluid_relevant_dofs[0] = locally_relevant_dofs.get_view(0, n_u);
fluid_relevant_dofs[1] = locally_relevant_dofs.get_view(n_u, n_u + n_p);
{
AffineConstraints<number> constraints_without_dbc;
- IndexSet locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs(dof_handler,
- locally_relevant_dofs);
+ const IndexSet locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
constraints_without_dbc.reinit(locally_relevant_dofs);
DoFTools::make_hanging_node_constraints(dof_handler,
const auto &dof_handler = dof_handlers[level];
auto & constraint = constraints[level];
- IndexSet locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs(dof_handler,
- locally_relevant_dofs);
+ const IndexSet locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
constraint.reinit(locally_relevant_dofs);
DoFTools::make_hanging_node_constraints(dof_handler, constraint);
dof_handler.distribute_dofs(fe_collection);
locally_owned_dofs = dof_handler.locally_owned_dofs();
- DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
+ locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(dof_handler);
locally_relevant_solution.reinit(locally_owned_dofs,
locally_relevant_dofs,
* with the locally owned subdomain id.
*/
template <int dim, int spacedim>
+ IndexSet
+ extract_locally_active_dofs(const DoFHandler<dim, spacedim> &dof_handler);
+
+ /**
+ * Extract the set of global DoF indices that are active on the current
+ * DoFHandler. For regular DoFHandlers, these are all DoF indices, but for
+ * DoFHandler objects built on parallel::distributed::Triangulation this set
+ * is a superset of DoFHandler::locally_owned_dofs() and contains all DoF
+ * indices that live on all locally owned cells (including on the interface
+ * to ghost cells). However, it does not contain the DoF indices that are
+ * exclusively defined on ghost or artificial cells (see
+ * @ref GlossArtificialCell "the glossary").
+ *
+ * The degrees of freedom identified by this function equal those obtained
+ * from the dof_indices_with_subdomain_association() function when called
+ * with the locally owned subdomain id.
+ *
+ * @deprecated Use the previous function instead.
+ */
+ template <int dim, int spacedim>
void
extract_locally_active_dofs(const DoFHandler<dim, spacedim> &dof_handler,
IndexSet & dof_set);
* given level.
*/
template <int dim, int spacedim>
+ IndexSet
+ extract_locally_active_level_dofs(
+ const DoFHandler<dim, spacedim> &dof_handler,
+ const unsigned int level);
+
+ /**
+ * Same function as above but for a certain (multigrid-)level.
+ * This function returns all DoF indices that live on
+ * all locally owned cells (including on the interface to ghost cells) on the
+ * given level.
+ *
+ * @deprecated Use the previous function instead.
+ */
+ template <int dim, int spacedim>
void
extract_locally_active_level_dofs(
const DoFHandler<dim, spacedim> &dof_handler,
* @ref GlossArtificialCell "the glossary").
*/
template <int dim, int spacedim>
+ IndexSet
+ extract_locally_relevant_dofs(const DoFHandler<dim, spacedim> &dof_handler);
+
+ /**
+ * Extract the set of global DoF indices that are active on the current
+ * DoFHandler. For regular DoFHandlers, these are all DoF indices, but for
+ * DoFHandler objects built on parallel::distributed::Triangulation this set
+ * is the union of DoFHandler::locally_owned_dofs() and the DoF indices on
+ * all ghost cells. In essence, it is the DoF indices on all cells that are
+ * not artificial (see
+ * @ref GlossArtificialCell "the glossary").
+ *
+ * @deprecated Use the previous function instead.
+ */
+ template <int dim, int spacedim>
void
extract_locally_relevant_dofs(const DoFHandler<dim, spacedim> &dof_handler,
IndexSet & dof_set);
-
/**
* Extract the set of locally owned DoF indices for each component within the
* mask that are owned by the current processor. For components disabled by
locally_relevant_dofs_per_subdomain(
const DoFHandler<dim, spacedim> &dof_handler);
+ /**
+ * Same as extract_locally_relevant_dofs() but for multigrid DoFs for the
+ * given @p level.
+ */
+ template <int dim, int spacedim>
+ IndexSet
+ extract_locally_relevant_level_dofs(
+ const DoFHandler<dim, spacedim> &dof_handler,
+ const unsigned int level);
/**
* Same as extract_locally_relevant_dofs() but for multigrid DoFs for the
* given @p level.
+ *
+ * @deprecated Use the previous function instead.
*/
template <int dim, int spacedim>
void
IndexSet locally_relevant_dofs;
if (comm)
{
- DoFTools::extract_locally_relevant_dofs(*dof_handler,
- locally_relevant_dofs);
+ locally_relevant_dofs =
+ DoFTools::extract_locally_relevant_dofs(*dof_handler);
partitioner = std::make_shared<Utilities::MPI::Partitioner>(
dof_handler->locally_owned_dofs(), locally_relevant_dofs, *comm);
}
}
else
{
- IndexSet relevant_dofs;
- DoFTools::extract_locally_relevant_level_dofs(dof, l, relevant_dofs);
+ const IndexSet relevant_dofs =
+ DoFTools::extract_locally_relevant_level_dofs(dof, l);
level_constraints[l].reinit(relevant_dofs);
}
template <int dim, int spacedim>
- void
- extract_locally_active_dofs(const DoFHandler<dim, spacedim> &dof_handler,
- IndexSet & dof_set)
+ IndexSet
+ extract_locally_active_dofs(const DoFHandler<dim, spacedim> &dof_handler)
{
// collect all the locally owned dofs
- dof_set = dof_handler.locally_owned_dofs();
+ IndexSet dof_set = dof_handler.locally_owned_dofs();
// 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
dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end());
dof_set.compress();
+
+ return dof_set;
}
template <int dim, int spacedim>
void
+ extract_locally_active_dofs(const DoFHandler<dim, spacedim> &dof_handler,
+ IndexSet & dof_set)
+ {
+ dof_set = extract_locally_active_dofs(dof_handler);
+ }
+
+
+
+ template <int dim, int spacedim>
+ IndexSet
extract_locally_active_level_dofs(
const DoFHandler<dim, spacedim> &dof_handler,
- IndexSet & dof_set,
const unsigned int level)
{
// collect all the locally owned dofs
- dof_set = dof_handler.locally_owned_mg_dofs(level);
+ IndexSet 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
dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end());
dof_set.compress();
+
+ return dof_set;
}
template <int dim, int spacedim>
void
- extract_locally_relevant_dofs(const DoFHandler<dim, spacedim> &dof_handler,
- IndexSet & dof_set)
+ extract_locally_active_level_dofs(
+ const DoFHandler<dim, spacedim> &dof_handler,
+ IndexSet & dof_set,
+ const unsigned int level)
+ {
+ dof_set = extract_locally_active_level_dofs(dof_handler, level);
+ }
+
+
+
+ template <int dim, int spacedim>
+ IndexSet
+ extract_locally_relevant_dofs(const DoFHandler<dim, spacedim> &dof_handler)
{
// collect all the locally owned dofs
- dof_set = dof_handler.locally_owned_dofs();
+ IndexSet dof_set = dof_handler.locally_owned_dofs();
// now add the DoF on the adjacent ghost cells to the IndexSet
std::unique(dofs_on_ghosts.begin(),
dofs_on_ghosts.end()));
dof_set.compress();
+
+ return dof_set;
}
template <int dim, int spacedim>
void
+ extract_locally_relevant_dofs(const DoFHandler<dim, spacedim> &dof_handler,
+ IndexSet & dof_set)
+ {
+ dof_set = extract_locally_relevant_dofs(dof_handler);
+ }
+
+
+
+ template <int dim, int spacedim>
+ IndexSet
extract_locally_relevant_level_dofs(
const DoFHandler<dim, spacedim> &dof_handler,
- const unsigned int level,
- IndexSet & dof_set)
+ const unsigned int level)
{
// collect all the locally owned dofs
- dof_set = dof_handler.locally_owned_mg_dofs(level);
+ IndexSet dof_set = dof_handler.locally_owned_mg_dofs(level);
// add the DoF on the adjacent ghost cells to the IndexSet
dofs_on_ghosts.end()));
dof_set.compress();
+
+ return dof_set;
+ }
+
+
+
+ template <int dim, int spacedim>
+ void
+ extract_locally_relevant_level_dofs(
+ const DoFHandler<dim, spacedim> &dof_handler,
+ const unsigned int level,
+ IndexSet & dof_set)
+ {
+ dof_set = extract_locally_relevant_level_dofs(dof_handler, level);
}
#if deal_II_dimension <= deal_II_space_dimension
namespace DoFTools
\{
+ template IndexSet
+ extract_locally_relevant_dofs<deal_II_dimension, deal_II_space_dimension>(
+ const DoFHandler<deal_II_dimension, deal_II_space_dimension>
+ &dof_handler);
+
template void
extract_locally_relevant_dofs<deal_II_dimension, deal_II_space_dimension>(
const DoFHandler<deal_II_dimension, deal_II_space_dimension>
& dof_handler,
IndexSet &dof_set);
+ template IndexSet
+ extract_locally_relevant_level_dofs<deal_II_dimension,
+ deal_II_space_dimension>(
+ const DoFHandler<deal_II_dimension, deal_II_space_dimension>
+ & dof_handler,
+ const unsigned int level);
+
template void
extract_locally_relevant_level_dofs<deal_II_dimension,
deal_II_space_dimension>(
const unsigned int level,
IndexSet & dof_set);
+ template IndexSet
+ extract_locally_active_dofs<deal_II_dimension, deal_II_space_dimension>(
+ const DoFHandler<deal_II_dimension, deal_II_space_dimension>
+ &dof_handler);
+
template void
extract_locally_active_dofs<deal_II_dimension, deal_II_space_dimension>(
const DoFHandler<deal_II_dimension, deal_II_space_dimension>
& dof_handler,
IndexSet &dof_set);
+ template IndexSet
+ extract_locally_active_level_dofs<deal_II_dimension,
+ deal_II_space_dimension>(
+ const DoFHandler<deal_II_dimension, deal_II_space_dimension>
+ & dof_handler,
+ const unsigned int level);
+
template void
extract_locally_active_level_dofs<deal_II_dimension,
deal_II_space_dimension>(