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

Use simpler initialization of std::set #13676

Merged
merged 3 commits into from May 6, 2022

Conversation

kronbichler
Copy link
Member

As suggested by #13674 (comment) - thanks @bangerth for the good hint for modernizing things.

@@ -172,8 +172,7 @@ test()
stokes_sub_blocks[dim] = 1;
DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks);

std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(1);
std::set<types::boundary_id> no_normal_flux_boundaries = {1};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::set<types::boundary_id> no_normal_flux_boundaries = {1};
const std::set<types::boundary_id> no_normal_flux_boundaries = {1};

I think const should work here, too.

It's just a test. I don't insist on this change :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. I widened my search and found some more appearances.

@marcfehling
Copy link
Member

/jenkins/workspace/dealii_PR-13676/tests/dofs/dof_tools_09.cc: In function ‘void check_this(const dealii::DoFHandler<dim>&)’:
/jenkins/workspace/dealii_PR-13676/tests/dofs/dof_tools_09.cc:45:24: error: no matching function for call to ‘std::set<unsigned int>::insert(int) const’
   boundary_ids.insert(1);
                        ^

Another id will be added after you initialize the container as const.

@@ -841,8 +841,7 @@ namespace Step37
const unsigned int nlevels = triangulation.n_global_levels();
mg_matrices.resize(0, nlevels - 1);

std::set<types::boundary_id> dirichlet_boundary;
dirichlet_boundary.insert(0);
const std::set<types::boundary_id> dirichlet_boundary = {0};
Copy link
Member

Choose a reason for hiding this comment

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

Since you're already in this patch, would you mind terribly changing the name for the variable to dirichlet_boundary_ids? Because it's really a set of ids, not of boundaries.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not at all - I fixed this here and in step-66.

@kronbichler
Copy link
Member Author

@marcfehling I fixed this problem - and I also updated the test, because it did not actually use that function with the particular boundary id as it was supposed to be from the test description. Now it should be fine.

Copy link
Member

@marcfehling marcfehling left a comment

Choose a reason for hiding this comment

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

CI is happy. Ready to merge.

@@ -44,7 +43,7 @@ check_this(const DoFHandler<dim> &dof_handler)

// check for boundary id 0 and 1
boundary_ids.insert(1);
DoFTools::map_dof_to_boundary_indices(dof_handler, map);
DoFTools::map_dof_to_boundary_indices(dof_handler, boundary_ids, map);
Copy link
Member

Choose a reason for hiding this comment

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

Good catch! :)

@marcfehling marcfehling merged commit 1857f60 into dealii:master May 6, 2022
@kronbichler kronbichler deleted the simplify_set_init branch May 6, 2022 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants