Support inhomogenous element blocks (in input only) - #2123
Open
rjoussen wants to merge 4 commits into
Open
Conversation
Inhomogenous element blocks are converted to homogenous element blocks internally. All homogenous blocks specified jointly in the input have the same group_id and name (if applicable). - internal element blocks are no longer uniquely identified by id, so all corresponding mappings are gone. Element blocks are instead stored in a vector. - filter_by_cell_block_id is replaced by filtering cell block references directly. - external mesh readers are adapted to no longer reject inhomogenous blocks - element_data_spec uses all_of instead of one_of for the cell type. Only the grid generator uses old one_of
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the mesh input pipeline to accept inhomogeneous external element blocks (mixed cell types) for VTU and Gmsh by splitting them into homogeneous internal CellBlocks that share a common logical group_id / optional group_name, and updates downstream mesh filtering, element creation, and tests accordingly.
Changes:
- Update VTU/Gmsh/Exodus mesh readers and
MeshInputdata structures to support multiple homogeneous cell blocks per logical group (group_id). - Update mesh reader input parsing to select logical blocks (by
ID/NAME) and apply per-cell-type element definitions within a logical group. - Add regression tests and new test meshes/input files for mixed-cell logical blocks (VTU + Gmsh), plus test utilities.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/list_of_tests.cmake | Registers new integration tests for mixed element blocks (VTU/Gmsh). |
| tests/input_files/vtu/solid_vtu_mixed_element_block.vtu | Adds VTU mesh fixture containing mixed cell types in a shared logical block id. |
| tests/input_files/solid_vtu_mixed_element_block.4C.yaml | Adds 4C input using per-cell-type definitions within one referenced block id. |
| tests/input_files/solid_gmsh_mixed_element_block.msh | Adds Gmsh mesh fixture with a mixed physical group. |
| tests/input_files/solid_gmsh_mixed_element_block.4C.yaml | Adds 4C input referencing a mixed physical group by name with per-cell-type definitions. |
| src/core/io/tests/test_files/vtu/mixed_hex8_tet4_same_block.vtu | Adds small VTU unit-test mesh for mixed hex/tet in same block id. |
| src/core/io/tests/test_files/gmsh/mixed_hex8_tet4.msh.test | Adds small Gmsh unit-test mesh for mixed hex/tet in one physical group. |
| src/core/io/tests/4C_io_vtu_test.cpp | Updates VTU tests to use group-id lookup helpers and adds mixed-block splitting test. |
| src/core/io/tests/4C_io_mesh_test.cpp | Updates mesh filtering test to use new filter_by_cell_blocks API. |
| src/core/io/tests/4C_io_mesh_test_utils_test.hpp | Adds test helpers for retrieving cell blocks by group id/name and by (group id, cell type). |
| src/core/io/tests/4C_io_gmsh_test.cpp | Updates Gmsh tests to use group-id lookup helpers and adds mixed-group splitting test. |
| src/core/io/tests/4C_io_exodus_test.cpp | Updates Exodus tests to reflect group id/name semantics. |
| src/core/io/src/4C_io_vtu_reader.hpp | Updates VTU reader doc to remove “homogeneous-only” constraint for block_id. |
| src/core/io/src/4C_io_vtu_reader.cpp | Splits VTU logical block ids into multiple homogeneous internal cell blocks keyed by (group id, cell type). |
| src/core/io/src/4C_io_meshreader.cpp | Updates element-block selection and element creation to handle multiple cell blocks per logical block and per-cell-type definitions. |
| src/core/io/src/4C_io_mesh.hpp | Refactors RawMesh::cell_blocks to a vector, introduces group_id/group_name, updates CellBlockReference, and adds filter_by_cell_blocks. |
| src/core/io/src/4C_io_mesh.cpp | Updates lookup tables and filtering logic to operate on cell-block pointers / group ids. |
| src/core/io/src/4C_io_gridgenerator.cpp | Keeps grid generator restricted to one cell type group via input spec and adds a runtime assertion. |
| src/core/io/src/4C_io_gmsh_reader.hpp | Updates Gmsh reader docs to reflect mixed-cell physical group handling. |
| src/core/io/src/4C_io_gmsh_reader.cpp | Emits one homogeneous internal cell block per element type while preserving the physical-group tag/name as the logical group. |
| src/core/io/src/4C_io_exodus.cpp | Updates Exodus reader to populate group_id and group_name and uses vector-based storage. |
| src/core/fem/src/general/element/4C_fem_general_element_definition.hpp | Extends element definition parsing/spec to support multiple cell-type groups (map keyed by CellType). |
| src/core/fem/src/general/element/4C_fem_general_element_definition.cpp | Implements multi-cell-type unpacking and configurable one-of vs all-of grouping in the input spec. |
| src/core/fem/src/discretization/4C_fem_discretization.cpp | Updates assertion message to reference element block label/cell type (but currently contains a small typo). |
| src/core/fem/src/discretization/4C_fem_discretization_builder.cpp | Updates auto-clustered block creation to populate group id/name with new CellBlock constructor. |
rjoussen
force-pushed
the
allow-multiple-element-types-per-block
branch
from
August 2, 2026 17:20
121ab0d to
81613dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description and Context
Motivation: Most mesh generators do not offer a simple interface to create strictly homogeneous meshes, e.g. when transitioning from a tet to a hex region or for unstructured hex/quad-dominated meshes. 4C so far requires strictly homogeneous mesh blocks, i.e., one cell type per block, which often requires post-processing such meshes with meshio or something.
This PR add support for inhomogenous mesh blocks. External meshes with inhomogenous blocks (only vtu and gmsh) are no longer rejected, but their inhomogenous blocks are internally converted to homogenous blocks, which all share the same
group_idand (if specified)group_name. The internal id used for element blocks so far (which needed to be unique) is removed.An inhomogenous external mesh block can be referenced in the input file as follows:
The user must ensure that they define every cell type present in the external block, otherwise an error is thrown. We then pick the right definition for each cell type. Currently, it is possible to define more cell types than present in the external block. The additional cell types are simply ignored. The idea behind this is that it will make it much easier to switch between different meshes by just defining all the cell types your mesh could have. Providing no cell type definition at all throws an error.
The grid generator retains its old mode where only one cell type is allowed.
Note: this is not a breaking change, since specifying only one cell type per element block works perfectly fine still.
AI usage:
Parts of the code AI assisted with:
filter_by_cell_block_idbyfilter_by_cell_block4C_io_mesh_test_utils_test.hpp