8#include <compile_time_options.h>
37 template <
typename Number>
38 DEAL_II_ALWAYS_INLINE
inline void
43 const Number dphi_p_1,
44 const Number dphi_p_2,
45 const Number sign = Number(1.0))
48 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
52 const auto scaling = ScalarNumber(1.) / (p_2 - p_1 + Number(eps));
54 const Number dd_11 = dphi_p_1;
55 const Number dd_12 = (phi_p_2 - phi_p_1) * scaling;
56 const Number dd_22 = dphi_p_2;
58 const Number dd_112 = (dd_12 - dd_11) * scaling;
59 const Number dd_122 = (dd_22 - dd_12) * scaling;
63 const auto discriminant_1 =
64 std::abs(dphi_p_1 * dphi_p_1 - ScalarNumber(4.) * phi_p_1 * dd_112);
65 const auto discriminant_2 =
66 std::abs(dphi_p_2 * dphi_p_2 - ScalarNumber(4.) * phi_p_2 * dd_122);
68 const auto denominator_1 = dphi_p_1 + sign * std::sqrt(discriminant_1);
69 const auto denominator_2 = dphi_p_2 + sign * std::sqrt(discriminant_2);
74 p_1 - dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
75 std::abs(denominator_1),
78 ScalarNumber(2.) * phi_p_1 / denominator_1);
81 p_2 - dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
82 std::abs(denominator_2),
85 ScalarNumber(2.) * phi_p_2 / denominator_2);
89 t_1 = std::max(p_1, t_1);
90 t_1 = std::min(p_2, t_1);
92 t_2 = std::max(p_1, t_2);
93 t_2 = std::min(p_2, t_2);
97 p_1 = std::min(t_1, t_2);
98 p_2 = std::max(t_1, t_2);
DEAL_II_ALWAYS_INLINE void quadratic_newton_step(Number &p_1, Number &p_2, const Number phi_p_1, const Number phi_p_2, const Number dphi_p_1, const Number dphi_p_2, const Number sign=Number(1.0))