Skip to content

Add tensor_to_scalar add_output overload (#142) - #157

Open
petlenz wants to merge 1 commit into
mainfrom
fix-142-t2s-outputs
Open

Add tensor_to_scalar add_output overload (#142)#157
petlenz wants to merge 1 commit into
mainfrom
fix-142-t2s-outputs

Conversation

@petlenz

@petlenz petlenz commented Aug 2, 2026

Copy link
Copy Markdown
Member

Closes #142.

Scalar-from-tensor outputs (von Mises, dissipation, trace) were inexpressible: OutputDecl::expr held only scalar/tensor alternatives while the t2s emitter sat fully wired but unreachable from outputs. This adds add_output(name, expression_holder<tensor_to_scalar_expression>, role) producing a Kind::Scalar OutputDecl (renders as double &<name>_out through the existing ScalarOutput path — no canonical_arguments/render changes needed).

  • Every OutputDecl::expr variant-visit site audited: SymbolValidationPass leaf sweep and the CodeEmitPass render arm gained t2s branches (LeafCollector/CodeEmitPipeline already had collect_t2s/.t2s()); NumSimMaterialTarget's two std::get sites now guard with holds_alternative and reject loudly ("does not support yet… add_output overload for tensor_to_scalar expressions (von Mises, dissipation) — scalar-from-tensor outputs are inexpressible #142") instead of bad_variant_access; AlgorithmicTangentPass is pre-guarded by its Kind::Tensor check.
  • Validation on the new overload: duplicate names, role attributes, plus a rejection of roles carrying expected_rank != 0 (a t2s output is scalar-valued; roles::Dissipation passes, roles::Stress throws).
  • Backends: standalone + MOOSE supported (MOOSE keys on Kind::Scalar → MaterialProperty<Real>); NumSimMaterialTarget rejects loudly pending its dual leaf-scoping/JSON work.

Tests (+7): signature/emission assertions, duplicate/role/leaf-validation negatives, NumSimMaterial rejection, and a compile-and-run gate (recipe T2sOutputCheck: tr_eps = trace(eps), vm_like = sqrt(w·(ε:ε))) numerically checked against hand-computed values.

Rebased onto current main. gcc-14 Debug (-Werror): ctest 328/328.

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.

add_output overload for tensor_to_scalar expressions (von Mises, dissipation) — scalar-from-tensor outputs are inexpressible

1 participant