Forked from
agnumpde / dune-tectonic
92 commits ahead of the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
linesearchsolver.hh 1.05 KiB
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_TECTONIC_LINESEARCHSOLVER_HH
#define DUNE_TECTONIC_LINESEARCHSOLVER_HH
#include <dune/tnnmg/problem-classes/bisection.hh>
#include "../../utils/almostequal.hh"
/**
* \brief A local solver for scalar quadratic obstacle problems with nonlinearity
* using bisection
*/
class LineSearchSolver
{
public:
template<class Vector, class Functional, class BitVector>
void operator()(Vector& x, const Functional& f, const BitVector& ignore) const {
x = 0;
if (ignore)
return;
/*Dune::Solvers::Interval<double> D;
D = f.subDifferential(0);
if (D[1] > 0) // NOTE: Numerical instability can actually get us here
return;
*/
if (almost_equal(f.domain()[0], f.domain()[1], 2)) {
x = f.domain()[0];
return;
}
int bisectionsteps = 0;
const Bisection globalBisection(0.0, 1.0, 0.0, 0.0);;
x = globalBisection.minimize(f, 0.0, 0.0, bisectionsteps);
//x = f.domain().projectIn(x);
}
};
#endif