Skip to content

MOOSE storage-layout precondition not enforced in generated .C #10

Open

Description

@petlenz

Summary

MooseMaterialTarget::emit_compute_qp_body wraps MOOSE's _<name>[_qp].dataPointer() in tmech::adaptor assuming RankTwoTensor is 9 contiguous row-major doubles and RankFourTensor is 81. The assumption is mentioned only in a class-level comment. The actual adaptor sites have no static_assert, no is_standard_layout_v check, and no runtime check.

If a future MOOSE release changes the storage of RankTwoTensorTempl<Real> (padding, column-major, std::array wrapper), this codegen silently produces wrong stresses with no compile- or run-time signal.

Where

  • Adaptor construction: include/numsim_codegen/targets/moose_material.h:177-194

Fix

Emit a static_assert in the generated .C so the consuming MOOSE compiler verifies the invariant at MOOSE build time:

// In MooseMaterialTarget::emit_source, near the includes (or just inside the
// anonymous namespace):
"static_assert(sizeof(RankTwoTensor) == 9 * sizeof(Real),\n"
"              \"numsim-codegen: RankTwoTensor must be 9 contiguous Reals.\");\n"
"static_assert(sizeof(RankFourTensor) == 81 * sizeof(Real),\n"
"              \"numsim-codegen: RankFourTensor must be 81 contiguous Reals.\");\n"

Pair with the mock-MOOSE runtime parity test in the linked follow-up issue.

Refs

  • REVIEW.md → CORR-A5 (High), CORR-21
  • Severity: High
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions