{"action":"created","issue":{"url":"https://api.github.com/repos/nschloe/meshio/issues/619","repository_url":"https://api.github.com/repos/nschloe/meshio","labels_url":"https://api.github.com/repos/nschloe/meshio/issues/619/labels{/name}","comments_url":"https://api.github.com/repos/nschloe/meshio/issues/619/comments","events_url":"https://api.github.com/repos/nschloe/meshio/issues/619/events","html_url":"https://github.com/nschloe/meshio/issues/619","id":545395057,"node_id":"MDU6SXNzdWU1NDUzOTUwNTc=","number":619,"title":"Unification of point / cell sets among formats","user":{"login":"tianyikillua","id":4027283,"node_id":"MDQ6VXNlcjQwMjcyODM=","avatar_url":"https://avatars2.githubusercontent.com/u/4027283?v=4","gravatar_id":"","url":"https://api.github.com/users/tianyikillua","html_url":"https://github.com/tianyikillua","followers_url":"https://api.github.com/users/tianyikillua/followers","following_url":"https://api.github.com/users/tianyikillua/following{/other_user}","gists_url":"https://api.github.com/users/tianyikillua/gists{/gist_id}","starred_url":"https://api.github.com/users/tianyikillua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tianyikillua/subscriptions","organizations_url":"https://api.github.com/users/tianyikillua/orgs","repos_url":"https://api.github.com/users/tianyikillua/repos","events_url":"https://api.github.com/users/tianyikillua/events{/privacy}","received_events_url":"https://api.github.com/users/tianyikillua/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2020-01-05T09:39:41Z","updated_at":"2020-01-08T22:39:13Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## Objectives\r\n\r\nUnify the names (`gmsh:physical`, `medit:ref`, `flac3d:zone`...) and implementations of point / cell sets among formats.\r\n\r\n### Names\r\n\r\nCurrently these different names need to be hard-coded when the subsets are transferred among formats, like\r\n``` python\r\nif key in mesh.cell_data and \"medit:ref\" in mesh.cell_data[key]:\r\n    labels = mesh.cell_data[key][\"medit:ref\"]\r\nelif key in mesh.cell_data and \"gmsh:physical\" in mesh.cell_data[key]:\r\n    # Translating gmsh data to medit is an important case, so treat it\r\n    # explicitly here.\r\n    labels = mesh.cell_data[key][\"gmsh:physical\"]\r\nelif key in mesh.cell_data and \"flac3d:zone\" in mesh.cell_data[key]:\r\n    labels = mesh.cell_data[key][\"flac3d:zone\"]\r\nelse:\r\n    labels = numpy.ones(len(data), dtype=int)\r\n```\r\n\r\n**Two solutions**\r\n\r\n1. Either provide a list of these names like\r\n``` python\r\nCELL_SETS_NAMES = [\r\n    \"gmsh:physical\", \"medit:ref\", \"flac3d:zone\", ...\r\n]\r\n```\r\n\r\n2. Adopt a unified name and object for point / cell sets, like\r\n``` python\r\nmesh.point_sets = ...\r\nmesh.cell_sets = ...\r\n```\r\n\r\n### Implementations\r\n\r\nAn example of mesh composed of 5 line elements and 6 nodes. We have two point sets: \"Red\" and \"Green\", and two cell sets: \"Orange\" and \"Blue\".\r\n\r\n![subsets](https://user-images.githubusercontent.com/4027283/71777726-2b8ca100-2fa4-11ea-8bac-b0da3efee579.png)\r\n\r\n1. Use a `point_data` and `cell_data` as indicator functions. Using the current terminology for MED, we have\r\n``` python\r\nmesh.point_data[\"point_tags\"] = [0, 1, 1, 2, 1, 0]\r\nmesh.point_tags = {\r\n    1: [\"Red\"],\r\n    2: [\"Green\"],\r\n}\r\n\r\nmesh.cell_data[\"line\"][\"cell_tags\"] = [-1, -2, -1, 0, -2]\r\nmesh.cell_tags = {\r\n    -1: [\"Orange\"],\r\n    -2: [\"Blue\"],\r\n}\r\n```\r\nNote that with this implementation, we need two lists: the indicator function list that assigns a unique value to each point / cell, as well as a list that indicates the actual names corresponding to these unique values. This implementation is suited when we want to visualize point / cell sets in ParaView, since they are modeled as a `point_data` / `cell_data`.\r\n\r\nThis implementation is currently adopted by (to be completed)\r\n- gmsh\r\n- medit\r\n- med\r\n- flac3d\r\n\r\n2. Explicit enumerations of points / cell id's\r\n``` python\r\nmesh.point_sets = {\r\n    \"Red\": [1, 2, 4],\r\n    \"Green\": [3],\r\n}\r\nmesh.cell_sets = {\r\n    \"Orange\": {\"line\": [0, 2]},\r\n    \"Blue\": {\"line\": [1, 4]},\r\n}\r\n```\r\nThis implementation uses less memory and is more explicit. However it needs to be converted to the 1st method when visualizing them under ParaView. A universal conversion function can be provided in the `Mesh` class.\r\n\r\nThis method is already sketched (not yet exposed) in various formats\r\n- permas\r\n- abaqus\r\n\r\nQuestion: can this 2nd method adopted universally for all mesh formats, considering their own specificities?\r\n"},"comment":{"url":"https://api.github.com/repos/nschloe/meshio/issues/comments/572292258","html_url":"https://github.com/nschloe/meshio/issues/619#issuecomment-572292258","issue_url":"https://api.github.com/repos/nschloe/meshio/issues/619","id":572292258,"node_id":"MDEyOklzc3VlQ29tbWVudDU3MjI5MjI1OA==","user":{"login":"gdmcbain","id":1588947,"node_id":"MDQ6VXNlcjE1ODg5NDc=","avatar_url":"https://avatars3.githubusercontent.com/u/1588947?v=4","gravatar_id":"","url":"https://api.github.com/users/gdmcbain","html_url":"https://github.com/gdmcbain","followers_url":"https://api.github.com/users/gdmcbain/followers","following_url":"https://api.github.com/users/gdmcbain/following{/other_user}","gists_url":"https://api.github.com/users/gdmcbain/gists{/gist_id}","starred_url":"https://api.github.com/users/gdmcbain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gdmcbain/subscriptions","organizations_url":"https://api.github.com/users/gdmcbain/orgs","repos_url":"https://api.github.com/users/gdmcbain/repos","events_url":"https://api.github.com/users/gdmcbain/events{/privacy}","received_events_url":"https://api.github.com/users/gdmcbain/received_events","type":"User","site_admin":false},"created_at":"2020-01-08T22:39:13Z","updated_at":"2020-01-08T22:39:13Z","author_association":"CONTRIBUTOR","body":"> either specific for each format (in this case a list of these names could be provided), either a unique name\r\n\r\nI vote for a unique name.  That makes is trivial for meshio to convert cell-tags between any formats using the first representation, e.g. MSH2.2 and MEDIT, which it currently does not attempt.\r\n\r\nIt also means that any downstream program wanting to open a mesh and find the cell-tags (e.g. signifying subdomains or parts of the boundary in a mixed boundary value problem) can do so via meshio without worrying about whether the input mesh was written in MSH2.2 or MEDIT or whatever.  For a real code example, see: `skfem.importers.meshio.from_meshio` for [subdomains](https://github.com/kinnala/scikit-fem/blob/55bcfc71ca1fd307a07ee9a5e3f9f548eadc8620/skfem/importers/meshio.py#L77-L78) and [parts of boundaries](https://github.com/kinnala/scikit-fem/blob/55bcfc71ca1fd307a07ee9a5e3f9f548eadc8620/skfem/importers/meshio.py#L88-L90)."}}
{"actor":{"display_login":"gdmcbain"}}