Skip to content

Tupek/system solver extended#1609

Open
tupek2 wants to merge 81 commits into
developfrom
tupek/system_solver_extended
Open

Tupek/system solver extended#1609
tupek2 wants to merge 81 commits into
developfrom
tupek/system_solver_extended

Conversation

@tupek2

@tupek2 tupek2 commented May 20, 2026

Copy link
Copy Markdown
Collaborator

This introduces a new interface for constructing multiphysics systems of equations, their boundary conditions, time integration rules, and solving them using potentially customized staggered or coupled algorithms.

mrtupek2 and others added 30 commits April 11, 2026 15:46
… we go along. workout some stress output details.
weak_form_->AddDomainIntegral(
Dimension<spatial_dim>{}, DependsOn<all_params...>{},
[dt, cycle, mode, integrand](double time, auto X, auto... inputs) {
return integrand(TimeInfo(time, *dt, *cycle, *mode), X, inputs...);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think reconstructing time_info here will also result in double adding dt, as we observed in time_discretized_weak_form. Since we are already storing dt_, cycle_, and mode_, can we store time_info_ = time_info when we invoke residual() and jacobian()?

Then the lambda injected for these add integral functions would be

[time_info, integrand] (double /* time */, auto X, auto... inputs) {
  return integrand(time_info, X, inputs...);
}

Comment on lines +275 to +290
return applyTimeRuleToPrefix(
rule, t_info,
[&](auto... self_states_and_tail) {
constexpr std::size_t n_self = sizeof...(self_states_and_tail) - tail_count;
auto all = std::forward_as_tuple(self_states_and_tail...);
return [&]<std::size_t... Si, std::size_t... Ti>(std::index_sequence<Si...>, std::index_sequence<Ti...>) {
return applyCouplingTimeRules(
coupling, t_info,
[&](auto... interpolated_coupling) {
return std::forward<Callback>(callback)(std::get<Si>(all)..., interpolated_coupling...);
},
std::get<n_self + Ti>(all)...);
}(std::make_index_sequence<n_self>{}, std::make_index_sequence<tail_count>{});
},
raw_args...);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The nested return here is not very human-readable. Can we simplify this method?

smith::TimeInfo(physics->time(), dt, static_cast<size_t>(physics->cycle())));
}

std::cout << "reaction norm: " << physics->getReactionStates().front().get()->Norml2() << '\n';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd prefer SLIC_INFO + std::format, easier to read imo.

int main(int argc, char* argv[])
{
// _init_start
smith::ApplicationManager application_manager(argc, argv);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These examples are user facing so should have some inline comments

#include "smith/differentiable_numerics/nonlinear_solve.hpp"
#include "smith/differentiable_numerics/make_time_info_material.hpp"
#include "smith/physics/functional_objective.hpp"
#include "gretl/wang_checkpoint_strategy.hpp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is a larger problem than this PR but we have gretl as an optional TPL guarded by the CMake option SMITH_ENABLE_GRETL. This will fail if someone turns that off, which I don't think anyone has tried.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's a good point. Gretl really isn't optional, core functionality (differentiability) depends on it. Unless I'm mistaken? If not, the CMake option should be removed IMO.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Issue created. we can handle it outside of this PR #1630

@btalamini btalamini left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Creating multi-physics is very nice with this!


/// @brief evaluate value of the ode state as used by the integration rule
template <typename T1>
/// @brief Return the static field value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like the agent added a second set of doxygen comments, (one before the template, the other after. Delete one set. The new set seems more specific then the old, maybe delete the old ones.

/// @c h = 1e-4 * max(1,|t|).
///
/// Rebuilt on each call from current value-level essentials, so late additions are reflected.
const smith::BoundaryConditionManager& getSecondDerivativeManager() const;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the purpose of this? It doesn't seem to be used. Is this to enable acceleration BCs?

Strumpack, /**< Strumpack MPI-enabled direct frontal solver*/
PetscCG, /**< PETSc MPI-enabled conjugate gradient solver */
PetscGMRES, /**< PETSc MPI-enabled generalize minimal residual solver */
None /**< Preconditioner application only, No linear solver Krylov iterations */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe the intent would be clearer to call this one PrecondOnly or something like that?

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.

5 participants