Kratos icon indicating copy to clipboard operation
Kratos copied to clipboard

Inconsistent ModelPart.GetProperties

Open miguelmaso opened this issue 3 years ago • 4 comments
trafficstars

Description

I've observed the following discrepancy in the ModelPart interface:

  • From the c++ interface, ModelPart.GetProperties(id) returns the property with the corresponding id from the mesh 0 (default value)
  • From the python interface, ModelPart.GetProperties(id) returns all the properties from the mesh with the corresponding id.

miguelmaso avatar Jan 14 '22 15:01 miguelmaso

I opened a discussion about this in the past, and I don't remember why we keep it (I think because it would break to much code)

loumalouomega avatar Jan 14 '22 15:01 loumalouomega

Recap

item container
Value Node Nodes
Element Elements
Condition Conditions
Properties Properties
Methods CreateNew(item)
Has(item)
Get(item)
Add(item)
Remove(item)
(container)
Set(container)
  • Properties means the item and also the container.
  • The Python interface adds Get(container). In general, this is not a problem, but it conflicts in the case of the properties. Consequently, there are multiple definitions of GetProperties in Python, returning the container or the item.
  • Furthermore, the properties Id may be confused with the mesh Id (legacy).

My proposal

  1. Remove the mesh Id from the python interface (#9774). This is a behavior change.
- GetProperties(mesh_id) -> Container
+ GetProperties(prop_id) -> Item
  1. Remove the GetProperties() (container), which can be confused with GetProperties(id) (item). This is an API breaker.

miguelmaso avatar Mar 16 '22 14:03 miguelmaso

NOTE: I'm not sure about the proposal 2 and I would like to hear opinions.

Pros:

  • Avoid confusion between properties item and properties container
  • Easy to replace

Cons:

  • There is a GetNodes etc, but not GetProperties (container)
  • ~1k of deprecation warnings

miguelmaso avatar Mar 16 '22 14:03 miguelmaso

In @KratosMultiphysics/implementation-committee we prefer only to remove the mesh id (option 1)

miguelmaso avatar Mar 22 '22 10:03 miguelmaso