83 catch (
const std::runtime_error &e)
85 logger().set_level(level_before);
89 logger().set_level(level_before);
94 Eigen::VectorXd sol = solve_data.
nl_problem->reduced_to_full(reduced_sol);
100 const double local_energy_after = solve_data.
nl_problem->value(sol);
101 assert(std::isfinite(local_energy_before()));
102 assert(std::isfinite(local_energy_after));
103 const double abs_diff = local_energy_before() - local_energy_after;
113 const bool accept = abs_diff >= dt_sqr * acceptance_tolerance;
118 static int save_i = 0;
123 if (!is_converged_status(nl_solver->status()))
125 nl_solver->stop_criteria().iterations = 100;
127 const auto level_before =
logger().level();
128 logger().set_level(spdlog::level::warn);
132 nl_solver->minimize(*(solve_data.
nl_problem), reduced_sol);
134 catch (
const std::runtime_error &e)
136 logger().set_level(level_before);
140 logger().set_level(level_before);
145 sol = solve_data.
nl_problem->reduced_to_full(reduced_sol);
148 for (
const auto &[glob_vi, loc_vi] : local_mesh.global_to_local())
150 const auto u = sol.middleRows(this->
dim() * loc_vi, this->
dim());
151 const auto u_old = vertex_attrs[glob_vi].displacement();
152 vertex_attrs[glob_vi].position = vertex_attrs[glob_vi].rest_position + u;
159 static const std::string accept_str =
160 fmt::format(fmt::fg(fmt::terminal_color::green),
"accept");
161 static const std::string reject_str =
162 fmt::format(fmt::fg(fmt::terminal_color::yellow),
"reject");
164 "[{:s}] E0={:<10g} E1={:<10g} (E0-E1)={:<11g} tol={:g} local_ndof={:d} n_iters={:d}",
165 accept ? accept_str : reject_str, local_energy_before(),
166 local_energy_after, abs_diff, dt_sqr * acceptance_tolerance,
167 n_free_dof, nl_solver->current_criteria().iterations);