-
Notifications
You must be signed in to change notification settings - Fork 295
Fix for overwriting nodesets #4121
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
base: devel
Are you sure you want to change the base?
Fix for overwriting nodesets #4121
Conversation
98c714a
to
1015024
Compare
- When creating sidesets from nodesets if the sideset shares an id with a nodeset they are combined - This checks first that the two are actually the same (same id and same nodes) - If they are not the same the instead of overwriting a new id is assigned to the new nodeset refs idaholab/moose#30085
- May need minor adjustments to work for when users manually rename sideset IDs
- Removed commented out code - Changed Map from nodeset to sideset id to a set of boundary IDs - Added function that allows MOOSE to add an id to this set
1015024
to
4ee955c
Compare
I checked the tests that failed and it looks like it was because it was tested on those three MOOSE tests I fixed in idaholab/moose#30291 before the PR made it to next. I invalidated them to run them again. Hopefully that should fix it. |
A timeout, so probably random, but I'm going to kick it again to be safe. |
And of course the MOOSE ARM mac failure is no more than the same civet breakage; we'll ignore that. |
That's what I figured. Those two tests weren't failing when I first opened the PR and they aren't failing when I run them locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need unit tests here, maybe before even bothering to rewrite the code that will address them. Come up with cases that should throw an error, and cases that shouldn't, and add a little test using each.
@@ -386,6 +386,14 @@ class BoundaryInfo : public ParallelObject | |||
*/ | |||
void renumber_id (boundary_id_type old_id, boundary_id_type new_id); | |||
|
|||
/** | |||
* Checks for existing nodeset that matches with this sideset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're going to need much more explanation here. What does "matches" mean? I'd have personally implemented this as return false;
, because nodesets and sidesets are two conceptually different things and thus any return true;
would be a category error. But since MOOSE has dived into that error too deep to fix, we're going to have to at least explain the new mishmashed category.
ElemSideBuilder side_builder; | ||
const Elem * new_side = &side_builder(*elem, side); | ||
if (has_equivalent_nodeset(new_side, id)) | ||
_sideset_to_nodeset_conversion.insert(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I give a side BCID 5, and then later I add an unrelated node with BCID 5, are those equivalent? They're definitely not, but here at the side addition we're already insisting that they must be.
const auto * n_list = side->get_nodes(); | ||
for (unsigned int i = 0; i < side->n_nodes(); i++) | ||
{ | ||
const auto node = n_list[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good way to iterate over an element's nodes. Try node_ref_range()
.
} | ||
else | ||
equivalent_nodeset = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop doesn't make sense to me. If I have sides a and b with nodes A, B, and C, A--a--B--b--C
, and I have BCID 3 on a, b, and A, would you say that sideset 3 is equivalent in any way to nodeset 3? I'd say it's definitely not, and unless I'm misunderstanding the code here has_equivalent_nodeset(b,3)
would agree with me, but has_equivalent_nodeset(a,3)
would disagree?
I honestly don't know what concept we're attempting to compute here.
// Add each node node on the side with the side's boundary id | ||
for (auto i : side->node_index_range()) | ||
{ | ||
const boundary_id_type bcid = id_pair.second; | ||
auto bcid_renum = bcid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're renumbering the bcid? But only ever to the same number? What is this variable for?
const boundary_id_type bcid = id_pair.second; | ||
auto bcid_renum = bcid; | ||
// If grouping by name check if nodeset id needs to be renumbered | ||
if (_node_boundary_ids.find(bcid) != _node_boundary_ids.end() && !has_equivalent_nodeset(side, bcid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If nothing about this test changes from node to node, then we don't want to call it inside the side->node_index_range()
loop.
// If grouping by name check if nodeset id needs to be renumbered | ||
if (_node_boundary_ids.find(bcid) != _node_boundary_ids.end() && !has_equivalent_nodeset(side, bcid)) | ||
// This sideset overlaps with a nodeset. Throw an error | ||
libmesh_error_msg("Sideset " << bcid << " has the same ID as a preexisting nodeset. Rename one in order to build a nodeset from this sideset"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this error checking in spirit. In practice we're not going to call it nearly as often as we should, right?
Consider again A--a--B--b--C
, with BCID 5 on node A
and on sides a
and b
.
Suppose our element loop hits side a first.
We try to build_node_list_from_side_list()
. On side a
, has_equivalent_nodeset()
returns true because it sees node A
, so it happily adds BCID 5 to node B
. Then on side b
, has_equivalent_nodeset()
returns true because it sees node B
, so it happily adds BCID 5 to node C
, and it finishes, having avoided emitting an error that IMHO it definitely should have.
Now suppose our loop takes us to b
before a
. On b
, has_equivalent_nodeset()
doesn't see any of the BCID 5 nodes that it knows exist, so it returns false, and now we emit the error.
But our results shouldn't depend on element numbering.
refs idaholab/moose#30085
Should be merged after idaholab/moose#30291