cmlibs / zinc

Source code repository for OpenCMISS-Zinc
Mozilla Public License 2.0
15 stars 18 forks source link

Simplify group fields and subdomains #263

Closed rchristie closed 1 year ago

rchristie commented 1 year ago

For the next major release, propose to simplify (and in the process break) group API by removing element and node groups as independent field types so there is only one FieldGroup type.

Benefits:

  1. Reduces number of fields, so client doesn't need to see a long list including group.mesh2d etc. which they don't understand.
  2. Simplifies coordination of related sub-object groups e.g. adding/removing faces, lines and nodes.
  3. Means all groups can be serialised in EX files; currently subobject groups can be created without an owner group, and these are not written to EX.
  4. Simplify group API. FieldGroup will have API to directly get/create/destroy MeshGroup and NodesetGroup objects, cutting out the need to get/create FieldElementGroup/FieldNodeGroup then calling getMeshGroup/getNodesetGroup. MeshGroup and NodesetGroup can also have getFieldGroup() method which is lacking the current API (and needed to pass to conditional functions).
  5. Simplifies client use; graphics subgroup Field should just be the group; currently confusing that it could be the group or the specific sub-element group for the in-use domain, or even the sub-element group for the wrong domain.
  6. Eliminates issue of renaming sub-object group fields when owner group is renamed, which has never been completed.

Example code:

group = fieldmodule.createFieldGroup()
meshGroup = group.createMeshGroup(mesh2d)
meshGroup.addElement(face1)

Issues:

  1. This is a full break. To keep the most common code working (albeit deprecated), we may maintain FieldElementGroup/FieldNodeGroup objects which are not Fields, but which have getMeshGroup/getNodesetGroup methods which work as now. Base field class API for evaluating real values could be offered in the C++/python APIs. [Aside: Field.evaluateBool() should probably be added to the Field class to support group and logical operators going forward.]
  2. Reading serialised json description files will require ongoing migration for names of non-existent sub-element groups to that of the group itself. When reading Fieldmodule serialisation, sub-element groups can be ignored. When reading graphics serialisation, field names ending in .mesh#d, .nodes and .datapoints can remove the suffix and find the group with the prefix name.