Skip to content

[MDPA] Improve support for Kratos Multiphysics mdpa support - #1553

Closed
loumalouomega wants to merge 21 commits into
nschloe:mainfrom
loumalouomega:improve-mdpa-format-support
Closed

[MDPA] Improve support for Kratos Multiphysics mdpa support#1553
loumalouomega wants to merge 21 commits into
nschloe:mainfrom
loumalouomega:improve-mdpa-format-support

Conversation

@loumalouomega

Copy link
Copy Markdown

This Pull Request significantly expands and robustifies the support for the Kratos Multiphysics MDPA format. It transforms the MDPA module from a basic reader/writer into a comprehensive tool capable of handling complex simulation setups with high fidelity.

Key Enhancements

1. Expanded Entity Mapping

  • Implemented specialized mapping dictionaries for Kratos Geometries, Elements, and Conditions.
  • Added support for a wide range of standard Kratos types (e.g., Element3D4N, Element2D3N, SurfaceCondition3D3N, LineCondition2D2N).
  • Improved type identification logic to prioritize exact matches and handle legacy/common naming conventions robustly.

2. High-Fidelity Round-Trips via misc_data

  • Utilized mesh.misc_data to preserve MDPA-specific metadata that doesn't fit the standard meshio model:
    • Original IDs: Preserves original Kratos IDs for nodes, elements, conditions, and geometries.
    • SubModelParts: Maintains the full hierarchical structure of SubModelParts, including their local data and tables.
    • Mesh Blocks: Supports multi-level solver mesh representations.
  • The writer now prioritizes this metadata, allowing for near-identical reconstruction of MDPA files.

3. Hierarchical SubModelPart Support

  • Completely refactored the SubModelPart parser to correctly handle nested Begin/End blocks.
  • The writer now reconstructs the hierarchical tree structure in the output file, ensuring compatibility with Kratos's model part hierarchy.

4. Corrected Node Ordering (Permutations)

  • Fixed node index permutations for higher-order elements (hexahedron20 and hexahedron27).
  • Correctly converts between Kratos-specific ordering and meshio's standard VTK-based ordering during both read and write operations.

5. Robust Parser Improvements

  • Enhanced block parsing to handle tab characters and comments in headers (e.g., Begin Elements Element3D4N // comment).
  • Improved error handling and warnings for malformed or unsupported blocks.

Testing Improvements

  • Increased Coverage: Added a comprehensive suite of new tests covering:
    • Elemental and conditional data blocks.
    • Hierarchical SubModelPart round-trips.
    • Higher-order element permutations.
    • Geometries and complex mesh block structures.
  • Reference Meshes: Included several new reference .mdpa files in tests/meshes/mdpa/ to verify real-world scenarios.
  • Standardized Naming: Renamed test files to follow the project's test_*.mdpa convention.

Code Quality

  • Applied isort and black styling to all modified files.
  • Resolved all relevant flake8 linting issues.
  • Optimized internal helper functions with enhanced inline documentation.

@loumalouomega

Copy link
Copy Markdown
Author

Looks like some tests in the main are failing, I will try to fix them, and cherry-pick in an independent branch

@loumalouomega

Copy link
Copy Markdown
Author

Includes #1554

Vicente Mataix Ferrándiz added 15 commits April 8, 2026 15:27
- Replace | with Union in type hints for compatibility with Python < 3.10
- Add missing topological_dimension import in meshio/__init__.py
- Update tox.ini and CI to explicitly use py38 and py312 environments
- Ensure tox uses the correct environment version in GitHub Actions
- Use math.prod in VTK writers (as suggested in code)
- Fix argparse subparser compatibility
- Refine __about__.py version discovery
- General cleanup of type hints and imports
@loumalouomega

Copy link
Copy Markdown
Author

Okay, now passes

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.

1 participant