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 ConstraintLine rather than redefining data structures #14967

Merged
merged 2 commits into from Mar 24, 2023

Conversation

kronbichler
Copy link
Member

While looking at #14905, @bergbauer and I observed some weird std::tuple data structures in the code for AffineConstraints::make_consistent_in_parallel that duplicates the content of AffineConstraints::ConstraintLine. I see no reason not to use this field, and it in fact leads to much more understandable code. For the record, this was introduced in #12430, and I couldn't find a discussion there about the type. Note that also is_consistent_in_parallel uses the more straight-forward type,

// Helper to return a ConstraintLine object that belongs to row @p row.
// If @p row is not constrained or not stored locally, return an empty
// constraint object that would correspond to a zero constraints
auto get_line = [&](const size_type line_n) -> ConstraintLine {
const size_type line_index = calculate_line_index(line_n);
if (line_index >= lines_cache.size() ||
lines_cache[line_index] == numbers::invalid_size_type)
{
const ConstraintLine empty = {line_n, {}, 0.0};
return empty;
}
else
return lines[lines_cache[line_index]];
};
// identify non-owned rows and send to owner:
std::map<unsigned int, std::vector<ConstraintLine>> to_send;

@kronbichler
Copy link
Member Author

Note that this will conflict with #14905, so we need to take care when the first of the two PRs is merged.

Copy link
Member

@peterrum peterrum left a comment

Choose a reason for hiding this comment

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

observed some weird std::tuple data structures in the code for AffineConstraints::make_consistent_in_parallel that duplicates the content of AffineConstraints::ConstraintLine.

The reason is that the author did not know ConstraintLine^^

Note that this will conflict with #14905, so we need to take care when the first of the two PRs is merged.

I would suggest to merge this one first. The other one will still take some time.

@bergbauer
Copy link
Contributor

I would suggest to merge this one first. The other one will still take some time.

Fine with me. This will make #14905 much easier to read and understand! Thanks @kronbichler

@peterrum peterrum merged commit f1cc0ea into dealii:master Mar 24, 2023
11 checks passed
@kronbichler kronbichler deleted the fix_datatype branch March 24, 2023 14:06
Copy link
Member

@bangerth bangerth left a comment

Choose a reason for hiding this comment

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

Nice work!

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

4 participants