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

Fix hard-to-read code in dof_renumbering.cc. #15975

Closed
bangerth opened this issue Sep 8, 2023 · 0 comments · Fixed by #15990
Closed

Fix hard-to-read code in dof_renumbering.cc. #15975

bangerth opened this issue Sep 8, 2023 · 0 comments · Fixed by #15990
Assignees
Milestone

Comments

@bangerth
Copy link
Member

bangerth commented Sep 8, 2023

In looking at dof_renumbering.cc as part of #15966, I found this gem (in two places in the file):

    IndexSet        locally_relevant_dofs;
    const IndexSet &locally_owned_dofs = [&]() -> const IndexSet & {
      if (reorder_level_dofs == false)
        {
          DoFTools::extract_locally_relevant_dofs(dof_handler,
                                                  locally_relevant_dofs);
          return dof_handler.locally_owned_dofs();
        }
      else
        {
          Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index,
                 ExcDoFHandlerNotInitialized());
          DoFTools::extract_locally_relevant_level_dofs(dof_handler,
                                                        level,
                                                        locally_relevant_dofs);
          return dof_handler.locally_owned_mg_dofs(level);
        }
    }();

This is hard to read because the lambda function seems to compute a value to initialize locally_owned_dofs, but really it also initializes another variable. Surely this can be done in a way that is easier to read :-)

(In fact, after #15966, we can directly initialize both variables because we use versions of the extract_* functions that return the index set, rather than set an argument passed by reference.)

@bangerth bangerth added this to the Release 9.6 milestone Sep 8, 2023
@bangerth bangerth self-assigned this Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant