53 {
54 using Problem = ComputeNaturalCoordsRootFindingProblem<ShapeFunction>;
55 using LJM = typename Problem::LocalJacobianMatrix;
56 using LRV = typename Problem::LocalResidualVector;
57
58 Problem problem(e, Eigen::Map<const LRV>(real_coords.data()));
59
60 Eigen::PartialPivLU<LJM> linear_solver(
ElementDim);
61 LJM jacobian;
62
63 const double increment_tolerance = 0;
65 linear_solver,
66 [&problem](LJM& J) { problem.updateJacobian(J); },
67 [&problem](LRV& res) { problem.updateResidual(res); },
68 [&problem](auto& delta_r) { problem.updateSolution(delta_r); },
69 {max_iter, real_coords_tolerance, increment_tolerance});
70
71 auto const opt_iter = newton_solver.solve(jacobian);
72
73 if (opt_iter)
74 {
75 DBUG(
"Newton solver succeeded after {} iterations", *opt_iter);
76
77 Eigen::Vector3d natural_coords = Eigen::Vector3d::Zero();
78 natural_coords.head<
ElementDim>() = problem.getNaturalCoordinates();
79 return natural_coords;
80 }
81
83 "Newton solver failed. Please consider increasing the error "
84 "tolerance or the max. number of Newton iterations.");
85 }
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
static constexpr int ElementDim
NewtonRaphson< LinearSolver, JacobianMatrixUpdate, ResidualUpdate, SolutionUpdate > makeNewtonRaphson(LinearSolver &linear_solver, JacobianMatrixUpdate &&jacobian_update, ResidualUpdate &&residual_update, SolutionUpdate &&solution_update, NewtonRaphsonSolverParameters const &solver_parameters)