-
Elias Pipping authoredElias Pipping authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test-gradient-kinks.cc 1.28 KiB
/* Checks if the algorithm converges regardless of where it starts */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <cassert>
#include <dune/common/shared_ptr.hh>
#include <dune/tectonic/ellipticenergy.hh>
#include "test-gradient-method-nicefunction.hh"
#include "test-gradient-method-helper.hh"
int main() {
int const dim = 2;
typedef Dune::EllipticEnergy<dim> Functional;
typedef Functional::SmallMatrix SmallMatrix;
typedef Functional::SmallVector SmallVector;
SmallMatrix const A = { { 4, 1.5 }, { 1.5, 3 } };
SmallVector const b = { -8, 14 };
auto const f = Dune::make_shared<Dune::ThreeKinkFunction const>();
auto const phi = Dune::make_shared<Functional::NonlinearityType const>(f);
Functional const J(A, b, phi);
size_t runs = 5;
double ret1;
{
SmallVector start = { 17, 34 };
ret1 = functionTester(J, start, runs);
}
double ret2;
{
SmallVector start = { 1, 0 };
ret2 = functionTester(J, start, runs);
}
assert(std::abs(ret1 - ret2) < 1e-5);
double ret3;
{
SmallVector start = { 0, 1 };
ret3 = functionTester(J, start, runs);
}
assert(std::abs(ret1 - ret3) < 1e-5);
double ret4;
{
SmallVector start = { 0, 0 };
ret4 = functionTester(J, start, runs);
}
assert(std::abs(ret1 - ret4) < 1e-5);
}