Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Early deprecate functions in DoFTools #13365

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/news/changes/incompatibilities/20220212Munch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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)
6 changes: 2 additions & 4 deletions examples/step-16/step-16.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,8 @@ namespace Step16
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));
Expand Down
3 changes: 2 additions & 1 deletion examples/step-18/step-18.cc
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ namespace Step18
{
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:
Expand Down
8 changes: 4 additions & 4 deletions examples/step-32/step-32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1864,16 +1864,16 @@ namespace Step32
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);
Comment on lines +1867 to +1868
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this place the regular RVO will probably not help the change will give rise to (very slightly) slower code than we had before, as we need to call the operator= here from the temporary object. This is different from the case in step-18 you made above where RVO eliminates the copy (on sane compilers).

I think this is justified for a cheap object like IndexSet given the interface uniformity it brings us. Furthermore, I believe we should at some point make the locally_relevant_dofs a member variable of the DoFHandler, given how often we set up and use these objects and how little memory they consume in the grand scheme of things. Then this gets even more clear that we should do it. But I do not think the case is necessarily as low for all functions that merely fill something, so we might need to make a case-by-case decision.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #11896.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separately, the cost of the move assignment is surely immeasurable compared to the cost of building the object. I'm very much in favor of the new interface.

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,
Expand Down
3 changes: 1 addition & 2 deletions examples/step-37/doc/results.dox
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ temporary vector and LinearAlgebra::distributed::Vector::copy_locally_owned_data
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,
Expand Down
10 changes: 4 additions & 6 deletions examples/step-37/step-37.cc
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,8 @@ namespace Step37
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);
Expand Down Expand Up @@ -852,10 +852,8 @@ namespace Step37

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(
Expand Down
3 changes: 2 additions & 1 deletion examples/step-40/step-40.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ namespace Step40
// 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
Expand Down
5 changes: 2 additions & 3 deletions examples/step-42/step-42.cc
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,8 @@ namespace Step42
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 */
Expand Down
5 changes: 2 additions & 3 deletions examples/step-45/step-45.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,8 @@ namespace Step45
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));
Expand Down
3 changes: 2 additions & 1 deletion examples/step-48/step-48.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ namespace Step48
// 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);
Expand Down
24 changes: 10 additions & 14 deletions examples/step-50/step-50.cc
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ void LaplaceProblem<dim, degree>::setup_system()

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);
Expand Down Expand Up @@ -594,10 +594,9 @@ void LaplaceProblem<dim, degree>::setup_multigrid()

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(
Expand Down Expand Up @@ -642,10 +641,9 @@ void LaplaceProblem<dim, degree>::setup_multigrid()

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
Expand Down Expand Up @@ -828,10 +826,8 @@ void LaplaceProblem<dim, degree>::assemble_multigrid()
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));
Expand Down
4 changes: 2 additions & 2 deletions examples/step-55/step-55.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ namespace Step55
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);
Expand Down
3 changes: 2 additions & 1 deletion examples/step-62/step-62.cc
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@ namespace step62
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,
Expand Down
5 changes: 2 additions & 3 deletions examples/step-63/step-63.cc
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,8 @@ namespace Step63
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));
Expand Down
3 changes: 2 additions & 1 deletion examples/step-64/step-64.cu
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ namespace Step64
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();
Expand Down
10 changes: 4 additions & 6 deletions examples/step-66/step-66.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ namespace Step66
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);
Expand Down Expand Up @@ -593,10 +593,8 @@ namespace Step66

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);
Expand Down
4 changes: 2 additions & 2 deletions examples/step-68/step-68.cc
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ namespace Step68
{
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,
Expand Down
2 changes: 1 addition & 1 deletion examples/step-69/step-69.cc
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ namespace Step69
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 =
Expand Down
4 changes: 2 additions & 2 deletions examples/step-70/step-70.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,8 @@ namespace Step70
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);
Expand Down
13 changes: 6 additions & 7 deletions examples/step-75/step-75.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,8 @@ namespace Step75
{
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,
Expand Down Expand Up @@ -777,9 +776,8 @@ namespace Step75
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);
Expand Down Expand Up @@ -1105,7 +1103,8 @@ namespace Step75
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,
Expand Down