Skip to content

required<T>/optional<T> helpers for parameter declarations (#74) - #92

Merged
petlenz merged 1 commit into
mainfrom
feature/parameter-helpers
Oct 18, 2026
Merged

petlenz merged 1 commit into
mainfrom
feature/parameter-helpers

Conversation

@petlenz

@petlenz petlenz commented Oct 15, 2026

Copy link
Copy Markdown
Member

What

core/parameter_helpers.h:

required<value_type>(para, "K");
optional<value_type>(para, "q", value_type{2.5});

These replace para.template insert<T>(key).template add<is_required>() / add<set_default>(v). They are additive (existing materials compile unchanged) and return the parameter, so checks or a description can be chained. They are also the place to attach check_data_type/range<> later (#65).

linear_isotropic_hardening and exponential_isotropic_hardening use them, as a demonstration. The other materials are not converted here: most of their files are touched by the open PRs #79–#86, so they can follow one at a time after those merge.

The reading side (base::template get_parameter<T>) is not changed; a helper for it needs material_base.h, which #86 changes.

Tests

ParameterHelpers.RequiredAndOptionalDeclareTheParameters (in test_set_parameter.cpp): a missing required parameter throws, defaults are applied, and a given value is kept. It failed to compile before. GCC 14 Debug with fetched dependencies: 622/622.

Closes #74

core/parameter_helpers.h: required<T>(para, key) and optional<T>(para, key,
default) replace para.template insert<T>(key).template add<...>().
linear_isotropic_hardening and exponential_isotropic_hardening use them;
other materials can follow one at a time.

Closes #74
@petlenz

petlenz commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Review findings (design, tmech expressions instead of component loops, modern C++, comments, tests, correctness). Severity: must = wrong result, hang, build break or unreachable feature; should = design, duplication, accuracy; nit = style.

required/optional helpers — ready

  • [should] optional collides with std::optional by name → with_default/optional_parameter; helpers are numsim-core material, consider upstreaming; 119 .template insert< sites remain — track the follow-up.

@petlenz
petlenz merged commit ce3b1f8 into main Oct 18, 2026
3 checks passed
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 a required<T>(para, key) helper to cut per-material parameter boilerplate

1 participant