Generalize the temperature scalar type for forward-mode AD - #35
Open
Samm-Py wants to merge 7 commits into
Open
Conversation
Finch's field type was fixed to double. This threads a Scalar template parameter (defaulting to double) through Grid, Boundary, Solver, Layer and SolidificationData, so the temperature field can carry a user-supplied arithmetic type. With double the generated code and temperature fields are unchanged; verified bit-identical temperature output and identical solidification records on the single_line case. The differentiated material and source inputs move into a MaterialProperties struct so a caller can supply values of the field scalar type rather than plain doubles read from the input deck. Quantities that only select a branch (solidus, liquidus) and all mesh geometry stay double. Finch_Scalar.hpp adds exp/fmin/fmax dispatch: arithmetic types forward to Kokkos as before, anything else resolves by ADL into the scalar type's own namespace. Finch therefore carries no dependency on any AD library. The optional finch_sensitivity application demonstrates the result with cpp_oti_lib, obtaining d(QoI)/dp for six material and source parameters from a single solve and validating each against central finite differences. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PNkQTS2g7P6dNDybhWRkwz
Author
|
@Rombur The PR is open and ready for review. |
streeve
reviewed
Aug 5, 2026
Rombur
reviewed
Aug 6, 2026
Co-authored-by: Bruno Turcksin <bruno.turcksin@gmail.com>
Co-authored-by: Bruno Turcksin <bruno.turcksin@gmail.com>
Closed
Rombur
reviewed
Aug 10, 2026
Rombur
reviewed
Aug 10, 2026
Replace the ad hoc spike run directories with an example under examples/single_line_sensitivity, laid out like the existing single_line example. run_example.sh performs the reference double solve and then four sensitivity configurations: the default finite difference step, a refined step, latent heat removed, and four MPI ranks. The four rank stage now reuses inputs.json Drop the spike specific .gitignore entries, which belong in a local exclude file rather than in the repository.
Samm-Py
force-pushed
the
scalar-template-ad
branch
from
August 10, 2026 19:22
fe75f43 to
aaca526
Compare
Rombur
approved these changes
Aug 10, 2026
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.
Summary
Grid,Boundary,Layer, andSolidificationData, while retainingdoubleas the default.material/source properties plus ADL-based math and value customization
points. Finch core remains independent of any AD library.
finch_sensitivityapplication usingcpp_oti_libtocompute first-order sensitivities for six material and source parameters in
one solve and compare them with central finite differences.
Compatibility
doublewithout source changes.storage remain
double.cpp_oti_libis found; thestandard Finch build has no new dependency.
Validation
clang-format14.0.6 check passed for every changed C++ file.-Wall -Wextra -pedantic -Werror, bothwith and without
cpp_oti_libavailable.single_linetemperature outputs are bit-for-bit identical to upstreammain; solidification records are identical (their parallel emission orderis nondeterministic).
matched the ordinary
doublesolve, and all six derivatives were validatedagainst central finite differences using
FINCH_FD_STEP=1e-8.