Skip to content

Commit

Permalink
Merge pull request #62 from polyfem/line-search
Browse files Browse the repository at this point in the history
compute energy only if valid
  • Loading branch information
teseoch authored Jul 17, 2024
2 parents fdd346e + c9537da commit 1a6cae4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/polysolve/linear/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,15 @@ namespace polysolve::linear
#ifdef POLYSOLVE_WITH_PARDISO
return "Pardiso";
#else
#ifdef POLYSOLVE_WITH_ACCELERATE
return "Eigen::AccelerateLDLT";
#else
#ifdef POLYSOLVE_WITH_HYPRE
return "Hypre";
#else
return "Eigen::BiCGSTAB";
#endif
#endif
#endif
}

Expand Down
6 changes: 1 addition & 5 deletions src/polysolve/nonlinear/line_search/LineSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,7 @@ namespace polysolve::nonlinear::line_search
// Find step that does not result in nan or infinite energy
while (step_size > current_min_step_size() && cur_iter < current_max_step_size_iter())
{
// Compute the new energy value without contacts
const double energy = objFunc(new_x);
const bool is_step_valid = objFunc.is_step_valid(x, new_x);

if (!std::isfinite(energy) || !is_step_valid)
if (!objFunc.is_step_valid(x, new_x) || !std::isfinite(objFunc(new_x)))
{
step_size *= rate;
new_x = x + step_size * delta_x;
Expand Down

0 comments on commit 1a6cae4

Please sign in to comment.