Skip to content

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

Merged
roystgnr merged 9 commits into
libMesh:develfrom
GiudGiud:PR_exo_split
Oct 17, 2026
Merged

roystgnr merged 9 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.

@GiudGiud
GiudGiud marked this pull request as ready for review September 17, 2026 13:33
Comment thread src/mesh/exodusII_io_helper.C
Comment thread src/mesh/exodusII_io_helper.C
@GiudGiud

GiudGiud commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

moose failures expected, patch here:
idaholab/moose#33792
EDIT patched is merged. moose test failures are unrelated

@moosebuild

moosebuild commented Sep 17, 2026 •

Copy link
Copy Markdown

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

Coverage

8c3130 #4557 f07a27
Total Total +/- New
Rate 66.47% 66.49% +0.02% 100.00%
Hits 80271 80330 +59 86
Misses 40494 40491 -3 0

Diff coverage report

Full coverage report

This comment will be updated on new commits.

Comment thread src/mesh/exodusII_io_helper.C
Comment thread src/mesh/exodusII_io_helper.C Outdated
Comment thread src/mesh/exodusII_io_helper.C Outdated
@@ -206,50 +206,87 @@ const std::vector<int> prism_inverse_face_map = {4, 1, 2, 3, 5};
subdomain_id_type & subdomain_id_end,
int & next_block_id)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's throw a libmesh_assert(mesh.is_serial()) in here, since we're making that assumption implicitly so many places below?

Right now of course the mesh is serial, because in NemesisIO_Helper we override the functions that would have called this, but at some point soon we're going to want to extend these features to Nemesis too.

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.

ok had to reorder some code because we are calling this with a serial on rank 0 only mesh

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.

added a test for writing a distributed mesh. essentially we were gathering an incomplete subdomain map on rank > 0 and then promptly returning from the caller for rank != 0

if we have the assert we can't do that.

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.

seems we are hitting this in moose still. I ll keep looking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, sorry! The most we can assert here is is_serial_on_zero(), I suppose?

GiudGiud and others added 6 commits October 13, 2026 08:43
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>
- fix the comment
Move logic on getting ID for polyhedra outside the routine
GiudGiud and others added 3 commits October 13, 2026 10:53
due to run_only_on_proc0 = false use in moose
Add a run_only_on_proc0 option to the mixed HEX8/TET4 round-trip test.
With run_only_on_proc0=false each rank writes its own file through an
ExodusII_IO_Helper, which exercises the reduction in
build_subdomain_map(), including the add_sides side-block counts.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread src/mesh/exodusII_io_helper.C

@roystgnr roystgnr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel like we're still certain to run into some kind of problems with this that we're not hitting in test coverage yet, but since I can no longer think of any specific examples, I think we're good to merge. Unless @jwpeterson wants a look first I'll merge tomorrow or this weekend.

@roystgnr
roystgnr merged commit e17a3d3 into libMesh:devel Oct 17, 2026
23 checks passed
@jwpeterson

Copy link
Copy Markdown
Member

FYI @GiudGiud and @roystgnr, we seem to be consistently failing all the distributed mesh make check sweeps on the devel->master merge since this PR went in.

https://civet.inl.gov/branch/14145/

distributed_make_check_sweep

@GiudGiud

Copy link
Copy Markdown
Contributor Author

thanks for reaching out. From checking two recipes it's example 5. I ll take a look

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.

4 participants