Skip to content

[GeoMechanicsApplication] Improve self reference check in the neighbour finder#14299

Merged
rfaasse merged 4 commits intomasterfrom
geo/improve-self-reference-check-neighbour-finder
Mar 19, 2026
Merged

[GeoMechanicsApplication] Improve self reference check in the neighbour finder#14299
rfaasse merged 4 commits intomasterfrom
geo/improve-self-reference-check-neighbour-finder

Conversation

@rfaasse
Copy link
Contributor

@rfaasse rfaasse commented Mar 17, 2026

📝 Description
An issue was found where if an element and condition have the same geometry, they are not flagged as neighbours. The check is improved now to avoid this issue.

@rfaasse rfaasse self-assigned this Mar 17, 2026
@rfaasse rfaasse added GeoMechanics Issues related to the GeoMechanicsApplication FastPR This Pr is simple and / or has been already tested and the revision should be fast labels Mar 17, 2026
avdg81
avdg81 previously approved these changes Mar 17, 2026
Copy link
Contributor

@avdg81 avdg81 left a comment

Choose a reason for hiding this comment

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

Hi Richard,
Thanks a lot for resolving this bug. The change matches my expectation and the added unit test will ensure that the fix remains in place. To me, this PR is good to go. 👍

@rfaasse rfaasse requested a review from a team as a code owner March 17, 2026 12:42
@rfaasse rfaasse requested a review from avdg81 March 17, 2026 12:42
const auto& r_entities = it->second;
for (auto& rp_entity : r_entities) {
if (rp_entity->GetGeometry().Id() == pElement->GetGeometry().Id()) continue;
if (IsSameEntity(*pElement, *rp_entity)) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

a quick question, as far as I understand before this check skipped elements with the same geometry, now it skips the same type elements with the same geometry. Should it check for same element pointers? rp_entity.get() == pElement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before indeed we checked if the geometry (id) was the same, but we found that sometimes the geometries of a condition/element could be the same and we still would like them to be flagged as neighbours. Right now, we indeed check if the entities are of the same type and if they have the same id (the entity itself, so not the geometry).

A very good point about comparing the pointers, I hadn't thought about that possibility. I tested your suggestion and that also works (at least for the unit tests and python small suite) and I think it's slightly more neat, as it checks if the object is really the same. Assuming there are never copies of elements/conditions lying around (which I don't think is happening now), I think it's the cleaner option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The nightly and validation tests were also fine after implementing the simpler and cleaner check, thanks a lot for the suggestion!

Copy link
Contributor

@avdg81 avdg81 left a comment

Choose a reason for hiding this comment

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

I feel this PR is good to go 👍

@rfaasse rfaasse merged commit 531959e into master Mar 19, 2026
10 checks passed
@rfaasse rfaasse deleted the geo/improve-self-reference-check-neighbour-finder branch March 19, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FastPR This Pr is simple and / or has been already tested and the revision should be fast GeoMechanics Issues related to the GeoMechanicsApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants