Skip to content

Conversation

@tupek2
Copy link
Collaborator

@tupek2 tupek2 commented Nov 21, 2025

This adds gretl as a submodule and provides a first demo using FieldState (gretl-wrapped FiniteElementState and FiniteElementDual) for an explicit dynamics problem with dynamic checkpointing and back-propagation. Some minor differentiable_physics interface adjustments as well. Updating tribol to the latest develop branch to address a somewhat localized issue with builds that do not enable umpire.

tupek2 and others added 19 commits December 8, 2025 14:08
@tupek2 tupek2 requested a review from chapman39 December 11, 2025 22:07
Copy link
Member

@btalamini btalamini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integration looks very close to what I was expecting, so LGTM.


namespace smith {

/// @brief uses the constrained docs on the bc_manager to zero the corresponding dofs in FieldState s.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @brief uses the constrained docs on the bc_manager to zero the corresponding dofs in FieldState s.
/// @brief uses the constrained dofs on the bc_manager to zero the corresponding dofs in FieldState s.

Comment on lines 32 to 35
return smith::tuple{get<VALUE>(Rho), tensor<double, spatial_dim>{}};
} else {
auto ones = make_tensor<lumped_dim>([](int) { return 1.0; });
return smith::tuple{-get<VALUE>(Rho) * ones, tensor<double, lumped_dim, spatial_dim>{}};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that only the singleton case is negated is making me suspicious of a bug. Is this intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its been too long. Probably it wouldn't compile without it. I mean, the ranks of the tensors are different. Maybe there is some nicer way to handle it, but I can't see it looking at it now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, there was a bug, that was compensated for elsewhere. Fixed in an update.

namespace smith {

/// Evaluates a DoubleState using a provided ScalarObjective instance, and the input arguments to that objective. This
/// operation is tracked on the gretl graph. ScalarObjective must remain in scope for the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the last word of the comment got cut off.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing

DoubleState evaluateObjective(std::shared_ptr<ScalarObjective> objective, const TimeInfo& time_info,
const FieldState& shape_disp, const std::vector<FieldState>& inputs);

/// operation is tracked on the gretl graph.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comment looks cut off. Missing the "@brief"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

auto ke = 0.5 * rho * inner(v, v);
auto dx_dX = get<DERIVATIVE>(U) + Identity<dim>();
auto J = det(dx_dX);
return ke * J;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this multiplied by J? Rho is the density in the reference config, right? If so, no J.

Copy link
Collaborator Author

@tupek2 tupek2 Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, technically, this is not a shape-aware functional implementation (this is like a 10 months old implementation at this point). So, that argument is the shape-displacement (or the displacement if the current density is passed in, e.g., for updated Lagrange things). Perhaps in a follow up PR, I can convert this to using the new ScalarObjective interface which is shape-aware always.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is your tribol submodule out of date?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was an issue in tribol where if you didn't build with umpire, some part of its build would fail, so a patch was needed.

Copy link
Collaborator

@chapman39 chapman39 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know about the tribol issue, but was there something wrong with the axom and mfem submodules as well that required an update? that'd be useful to me to know so next time i update ill make sure those changes are included.

@tupek2
Copy link
Collaborator Author

tupek2 commented Dec 12, 2025

i know about the tribol issue, but was there something wrong with the axom and mfem submodules as well that required an update? that'd be useful to me to know so next time i update ill make sure those changes are included.

I had temporarily accidentally not merged the updated axom and mfem from dev, but I think that is fixed now? Unless I am not reading the diffs correctly?


if(SMITH_ENABLE_TESTS)
add_subdirectory(tests)
endif() No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
endif()
endif()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way our make style can just do this for us automatically? Its sort of time consuming for us to constantly check it in PRs and have to update file by file.

)

blt_add_library(
NAME smith_differentiable_numerics
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is differentiable_numerics something that would be better moved to a subdirectory of numerics?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my naming may have caused confusion here. The include dependencies make it clear that differentiable_numerics does not belong in numerics. It combines things in physics, numerics, gretl, etc. to create analogous structures as exist in numerics, but which will be differentiated on the gretl graph. Its not a perfect match to numerics, so perhaps a name change could avoid confusion. differentiable_utilities was another option I was considering. If people have suggestions, I'm happy to change it, but preferably in a follow on PR.

@chapman39
Copy link
Collaborator

@tupek2

I had temporarily accidentally not merged the updated axom and mfem from dev, but I think that is fixed now? Unless I am not reading the diffs correctly?

i see that now. ok, nevermind then! besides my other question lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Ready for active inspection by reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants