Integrate typed Newton strategies with checked trial gravity and feasibility
This commit is contained in:
@@ -19,6 +19,7 @@ export module mean_field:solver.newton;
|
||||
|
||||
export import :deformation.safe_newton_step;
|
||||
export import :solver.linear_backend;
|
||||
export import :solver.newton_numerics;
|
||||
|
||||
export namespace mean_field::solver::nonlinear {
|
||||
/*
|
||||
@@ -143,11 +144,12 @@ export namespace mean_field::solver::nonlinear {
|
||||
return {.residualNorm = residualNorm, .merit = 0.5 * residualNorm * residualNorm};
|
||||
}
|
||||
|
||||
template <typename Metric = NormalizedResidualMetric>
|
||||
template <typename Metric = NormalizedResidualMetric, NewtonNumericalConfiguration Numerics = NewtonNumerics<>>
|
||||
requires std::move_constructible<std::remove_cvref_t<Metric>>
|
||||
class Newton final {
|
||||
public:
|
||||
using MetricType = std::remove_cvref_t<Metric>;
|
||||
using NumericsType = std::remove_cvref_t<Numerics>;
|
||||
|
||||
Newton()
|
||||
requires std::default_initializable<MetricType>
|
||||
@@ -167,10 +169,12 @@ export namespace mean_field::solver::nonlinear {
|
||||
|
||||
Newton(
|
||||
NewtonOptions options,
|
||||
MetricType metric
|
||||
MetricType metric,
|
||||
NumericsType numerics = {}
|
||||
)
|
||||
: m_options(std::move(options)),
|
||||
m_metric(std::move(metric)) {
|
||||
m_metric(std::move(metric)),
|
||||
m_numerics(std::move(numerics)) {
|
||||
m_options.Validate();
|
||||
}
|
||||
|
||||
@@ -182,9 +186,12 @@ export namespace mean_field::solver::nonlinear {
|
||||
return m_metric;
|
||||
}
|
||||
|
||||
[[nodiscard]] const NumericsType &numerics() const noexcept { return m_numerics; }
|
||||
|
||||
private:
|
||||
NewtonOptions m_options;
|
||||
[[no_unique_address]] MetricType m_metric;
|
||||
[[no_unique_address]] NumericsType m_numerics;
|
||||
};
|
||||
|
||||
Newton() -> Newton<NormalizedResidualMetric>;
|
||||
@@ -196,9 +203,12 @@ export namespace mean_field::solver::nonlinear {
|
||||
Metric
|
||||
) -> Newton<std::remove_cvref_t<Metric>>;
|
||||
|
||||
template <typename Metric, typename Numerics>
|
||||
Newton(NewtonOptions, Metric, Numerics) -> Newton<std::remove_cvref_t<Metric>, std::remove_cvref_t<Numerics>>;
|
||||
|
||||
template <typename Candidate> struct IsNewtonConfiguration : std::false_type { };
|
||||
|
||||
template <typename Metric> struct IsNewtonConfiguration<Newton<Metric>> : std::true_type { };
|
||||
template <typename Metric, typename Numerics> struct IsNewtonConfiguration<Newton<Metric, Numerics>> : std::true_type { };
|
||||
|
||||
template <typename Candidate>
|
||||
concept NewtonConfiguration = IsNewtonConfiguration<std::remove_cvref_t<Candidate>>::value;
|
||||
@@ -237,7 +247,8 @@ export namespace mean_field::solver::nonlinear {
|
||||
inadmissible_state,
|
||||
non_finite_state,
|
||||
non_finite_residual,
|
||||
insufficient_decrease
|
||||
insufficient_decrease,
|
||||
auxiliary_solve_failure
|
||||
};
|
||||
|
||||
struct AfterLineSearchTrial final {
|
||||
|
||||
Reference in New Issue
Block a user