Skip to content

[Core] Replace geometry container with PVS #13377

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rickyaristio
Copy link
Contributor

@rickyaristio rickyaristio commented Apr 28, 2025

📝 Description
This PR serves two main goals:

  1. Replace GeometryContainer with PointerVectorSet:
    As discussed in GeometryContainer #11609 in order to have a standard interface.

  2. Fully remove GeometryContainer:
    Following up on [Core] Use PointerVectorSet as geometry container #12843, this PR fully removes the GeometryContainer and aliases it to the PointerVectorSet of the geometries.

@sunethwarna @matekelemen

@rickyaristio rickyaristio requested a review from a team April 28, 2025 15:24
@rickyaristio rickyaristio requested a review from a team as a code owner April 28, 2025 15:24
Copy link
Contributor

@matekelemen matekelemen left a comment

Choose a reason for hiding this comment

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

Awesome, thanks Ricky! This'll definitely need a peek from the TC though.

juancamarotti
juancamarotti previously approved these changes Apr 29, 2025
Copy link
Contributor

@juancamarotti juancamarotti 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 Ricky! All the CI Tests passed, so it's completely fine from my side. Thanks a lot

@rickyaristio
Copy link
Contributor Author

Nice work Ricky! All the CI Tests passed, so it's completely fine from my side. Thanks a lot

I will wait for the approval from the TC, as this involves changes in the core.

Copy link
Member

@RiccardoRossi RiccardoRossi left a comment

Choose a reason for hiding this comment

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

guys, who approved this? it should be approved by the @KratosMultiphysics/technical-committee

@matekelemen
Copy link
Contributor

guys, who approved this? it should be approved by the @KratosMultiphysics/technical-committee

That's what we're waiting for.

An approval is just that: someone expressing support for the PR. It doesn't mean the PR is merged.

The fact that the PR is mergable without approval from the technical committee is the fault of an improperly set up code owner file.

@matekelemen matekelemen requested a review from a team April 30, 2025 14:29
@sunethwarna sunethwarna moved this to 👀 Next meeting TODO in Technical Commiittee Apr 30, 2025
@sunethwarna
Copy link
Member

I would say this is a good opportunity to move the GeometryContainer to the Mesh and be consistent with all the other containers in ModelPart, unless there is a specific reason for it to be in ModelPart. @KratosMultiphysics/technical-committee ?

@sunethwarna sunethwarna moved this from 👀 Next meeting TODO to 👓 Check for the next meeting in Technical Commiittee May 8, 2025
// Check that the connectivities are the same
// note that we deliberately check the node ids and not the pointer adresses as there might be very rare situations

// (e.g., creating nodes bypassing the model part interface) with same connectivities but different pointer addresses
Copy link
Member

Choose a reason for hiding this comment

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

I didn't understand why pointer would fail. Nevertheless, checking the Id is ok for me.

Copy link
Member

@rubenzorrilla rubenzorrilla May 22, 2025

Choose a reason for hiding this comment

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

I think they're mimicking what we did for elements/conditions not many years ago (I remember discussing this in the @KratosMultiphysics/technical-committee). Am I wrong @rickyaristio?

Edit: well, I think I remember...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rubenzorrilla , you are right.

@loumalouomega
Copy link
Member

I am modifying these files, this is going to be a conflict :P

@@ -1812,7 +1810,7 @@ void ModelPartIO::ReadGeometriesBlock(NodesContainerType& rThisNodes, GeometryCo
temp_geometry_nodes.push_back( *(FindKey(rThisNodes, ReorderedNodeId(node_id), "Node").base()));
}

rThisGeometries.AddGeometry(r_clone_geometry.Create(ReorderedGeometryId(id), temp_geometry_nodes));
rThisGeometries.insert(r_clone_geometry.Create(ReorderedGeometryId(id), temp_geometry_nodes)); //TO DO!
Copy link
Member

Choose a reason for hiding this comment

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

What is exactly the remaining TODO?

Copy link
Contributor

@matekelemen matekelemen May 22, 2025

Choose a reason for hiding this comment

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

One remaining problem with geometries is their IDs.

It's not the straight and simple index-based ID we have on everything else, but a hash that encodes some unrelated data in the two most significant bits.

I imagine he tagged every place that uses geometry IDs.

Copy link
Member

Choose a reason for hiding this comment

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

well...this is NOT insignificant eh ... actually it is the reason for which we were using a special container

Copy link
Member

Choose a reason for hiding this comment

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

One remaining problem with geometries is their IDs.

It's not the straight and simple index-based ID we have on everything else, but a hash that encodes some unrelated data in the two most significant bits.

I imagine he tagged every place that uses geometry IDs.

guys this is a killer...

Copy link
Contributor

@matekelemen matekelemen May 24, 2025

Choose a reason for hiding this comment

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

guys this is a killer...

Why? The special container (a hash table) has been swapped out for PVS for over a year, and we never saw a performance regression.

The only reason for the hash-based IDs is the option to construct a Geometry without providing an ID (in that case, it gets automatically generated). The last two bits store information on how the ID was assigned: provided or generated.

I don't see why this ID auto-generation feature is necessary. On the other hand, it creates quite a few headaches:

  • the hash function does not guarantee uniqueness, so we're always running the risk of silent bugs
  • Geometry IDs are not consistent between runs (the hashing is unique to each run)
  • they are discontiguous, huge integers, terrible for debugging
  • bit-twiddling magic that is hard to read/understand/maintain

@RiccardoRossi why do you think auto-generated IDs are necessary? I don't see a valid use case.

Copy link
Member

Choose a reason for hiding this comment

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

well, the use case was to identify as given triangle (say) but its connectivity. If this is not any longer supported than my review does not make sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

If anything used that feature, it would have broken after merging #12843.

@@ -1,177 +0,0 @@
// | / |
Copy link
Member

Choose a reason for hiding this comment

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

Can't we reuse all these as tests for the PVS?

Copy link
Contributor Author

@rickyaristio rickyaristio May 30, 2025

Choose a reason for hiding this comment

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

Let me try it after we move the geometry container to mesh (so it is consistent with the elements/conditions). #13423

Copy link
Member

@rubenzorrilla rubenzorrilla left a comment

Choose a reason for hiding this comment

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

I only have a few minor observations. Aside of these, I don't see any error.

As a comment aside, I think that at some point we should consider doing a search&replace of all the GeometryName as these are very misleading. IMO, GeometryName in Kratos context means Triangle2D3, Line2D3, etc. What we have in here should be GeometryTextId or something of this sort.

Copy link
Member

@roigcarlo roigcarlo left a comment

Choose a reason for hiding this comment

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

👍 Looks good from my side as well

@RiccardoRossi RiccardoRossi dismissed their stale review May 29, 2025 10:47

not any longer valid

Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👓 Check for the next meeting
Development

Successfully merging this pull request may close these issues.

9 participants