Skip to content

Split element blocks by element type when writing exodus files - #4557

Open
GiudGiud wants to merge 2 commits into
libMesh:develfrom
GiudGiud:PR_exo_split
Open

GiudGiud wants to merge 2 commits into
libMesh:develfrom
GiudGiud:PR_exo_split

Conversation

@GiudGiud

@GiudGiud GiudGiud commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

refs #4019

I need this because when reading from VTK and outputting to exodus straight away (to keep my pipeline with exodus in MOOSE, maybe I don't need to though), I dont have a step in libmesh to fix the element block assignments. I only have that in moose

build_subdomain_map() grouped elements by subdomain id alone, so a subdomain containing more than one element type (e.g. a mix of C0POLYHEDRON and HEX8 cells) became a single Exodus block whose type was taken from its first element. That either errored ("all elements with a given subdomain ID [must] be the same type") or, when the first element was a standard type, crashed in ex_put_concat_all_blocks while writing the polyhedra as that type.

Group elements by (subdomain, element type): single-type subdomains keep their previous block id and behavior, while additional element types in a subdomain get synthesized block ids. Exodus requires a single element type per block, so this is what lets a mixed polyhedron/hex mesh be written and read back.

Adds test_write_and_read_mixed_poly_hex, which round-trips a mesh with a C0POLYHEDRON and a HEX8 in the same subdomain.

build_subdomain_map() grouped elements by subdomain id alone, so a
subdomain containing more than one element type (e.g. a mix of
C0POLYHEDRON and HEX8 cells) became a single Exodus block whose type was
taken from its first element.  That either errored ("all elements with a
given subdomain ID [must] be the same type") or, when the first element
was a standard type, crashed in ex_put_concat_all_blocks while writing
the polyhedra as that type.

Group elements by (subdomain, element type): single-type subdomains keep
their previous block id and behavior, while additional element types in a
subdomain get synthesized block ids.  Exodus requires a single element
type per block, so this is what lets a mixed polyhedron/hex mesh be
written and read back.

Adds test_write_and_read_mixed_poly_hex, which round-trips a mesh with a
C0POLYHEDRON and a HEX8 in the same subdomain.

Co-Authored-By: Claude <noreply@anthropic.com>
@GiudGiud
GiudGiud marked this pull request as ready for review September 17, 2026 13:33
Comment on lines +248 to +249
const subdomain_id_type block_id =
first_type ? sbd_id : next_synth_block_id++;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do we want a warning here? or just an info message

I m leaning info message, and adding the new entry into a subdomain name map

Comment on lines +3079 to +3080
// subdomain id. This block becomes its own subdomain when
// the file is read back in.

@GiudGiud GiudGiud Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that might be undesirable but also merging someone's random mesh same-name blocks (to try to recover the original subdomain assignments from subdomains names being the same and IDs being different) might also not work well

@GiudGiud

Copy link
Copy Markdown
Contributor Author

moose failures expected, patch here:
idaholab/moose#33792

@moosebuild

Copy link
Copy Markdown

Job Coverage, step Generate coverage on 17737b6 wanted to post the following:

Coverage

54e0d5 #4557 17737b
Total Total +/- New
Rate 65.99% 66.00% +0.01% 100.00%
Hits 79562 79591 +29 42
Misses 40996 40996 - 0

Diff coverage report

Full coverage report

This comment will be updated on new commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants