Skip to content
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

round-tripping a med file results in losing group names (tags) #1050

Open
Jesusbill opened this issue Mar 10, 2021 · 3 comments
Open

round-tripping a med file results in losing group names (tags) #1050

Jesusbill opened this issue Mar 10, 2021 · 3 comments
Labels

Comments

@Jesusbill
Copy link
Contributor

I would like to make sure that I can round-trip (read, modify and write) a med file without losing information.
Doing some tests I see that the names of the point tags and cell tags are not written (checked with older versions as well).

I am using this simple snippet

import meshio

file = meshio.read("path/to/med/file", file_format="med")

meshio.Mesh(
    file.points,
    file.cells_dict,
    # Optionally provide extra data on points, cells, etc.
    point_data=file.point_data,
    cell_data=file.cell_data,
    # field_data=file.field_data
).write(
    "path/to/new/med/file",
    file_format="med"
)

With the file attached for example I can get from the original file the correct point and cell tags

"point_tags": {
        "2": [
            "base_columns"
        ],
        "1": [
            "base_plates"
        ],
        "3": [
            "point_masses"
        ]
    }
"cell_tags": {
        "-1": [
            "base_plates"
        ],
        "-2": [
            "columns"
        ],
        "-3": [
            "plates"
        ],
        "-4": [
            "point_masses"
        ]
    }

but with the same med file written with meshio these tag dictionaries are empty, although the tag assignments to the elements are correctly done.

I am investigating, although not of high priority right now, but I would like to have it fixed soon.

PS: Nico can we have a med label for the issues? :)

reinforcement.zip

@nschloe nschloe added the med label Mar 10, 2021
@nschloe
Copy link
Owner

nschloe commented Mar 10, 2021

PS: Nico can we have a med label for the issues? :)

Added.

Jesusbill added a commit to Jesusbill/meshio that referenced this issue Apr 17, 2021
@Jesusbill
Copy link
Contributor Author

Jesusbill commented Apr 17, 2021

Hi @nschloe I have provided a commit for this issue here; I was thinking if you wanted to review before the PR.

I have the impression that the dictionaries that hold the tag values and the corresponding names were initially named point_tags and cell_tags but then they were renamed to point_sets and cell_sets.

However, they were never updated in the med implementation and instead two try/except statements were used to overcome the AttributeError. Does this train of thought makes sense?

I have tested it now and everything looks to work fine.

@nschloe
Copy link
Owner

nschloe commented Apr 17, 2021

Indeed, I think that might have happened. Just PR that, it's always easier to reason there. (No need for "pre-review", we can always close the PR without merging if we come up with something better in the process.)

Jesusbill added a commit to Jesusbill/meshio that referenced this issue Apr 17, 2021
Jesusbill added a commit to Jesusbill/meshio that referenced this issue Apr 17, 2021
Jesusbill added a commit to Jesusbill/meshio that referenced this issue Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants