Skip to content
Snippets Groups Projects
Commit d1bac0c4 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Cleanup

parent d4f38020
No related branches found
No related tags found
No related merge requests found
......@@ -28,32 +28,44 @@ int main() {
b[0] = 1;
b[1] = 2;
SmallVector solution; // Analytic solution
solution[0] = 4.0 / 39.0;
solution[1] = 6.0 / 13.0;
auto f = Dune::make_shared<Dune::TrivialFunction const>();
auto phi = Dune::make_shared<Functional::NonlinearityType const>(f);
Functional J(A, b, phi);
SmallVector start = b;
start *= 17;
SmallVector solution; // Analytic solution
solution[0] = 4.0 / 39.0;
solution[1] = 6.0 / 13.0;
double ret1;
{
SmallVector start = b;
start *= 17;
SmallVector analytic_descent = b;
A.mmv(start, analytic_descent);
SmallVector numerical_descent;
J.descentDirection(start, numerical_descent);
assert(two_distance<dim>(numerical_descent, analytic_descent) < 1e-10);
SmallVector analytic_descent = b;
A.mmv(start, analytic_descent);
SmallVector numerical_descent;
J.descentDirection(start, numerical_descent);
assert(two_distance<dim>(numerical_descent, analytic_descent) < 1e-10);
double const ret1 = functionTester(J, start, 6);
assert(two_distance<dim>(start, solution) < 1e-5);
ret1 = functionTester(J, start, 6);
assert(two_distance<dim>(start, solution) < 1e-5);
}
// Something random
start[0] = 279;
start[1] = -96;
double ret2;
{
// Something random
SmallVector start;
start[0] = 279;
start[1] = -96;
double const ret2 = functionTester(J, start, 25);
assert(two_distance<dim>(start, solution) < 1e-6);
SmallVector analytic_descent = b;
A.mmv(start, analytic_descent);
SmallVector numerical_descent;
J.descentDirection(start, numerical_descent);
assert(two_distance<dim>(numerical_descent, analytic_descent) < 1e-10);
ret2 = functionTester(J, start, 25);
assert(two_distance<dim>(start, solution) < 1e-6);
}
assert(std::abs(ret1 - ret2) < 1e-5);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment