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

Compare with analytic solution

parent ee615ae3
No related branches found
No related tags found
No related merge requests found
/* Checks if the descent direction is computed correctly using the
analytic solution; also checks if the algorithm converges
regardless of where it starts */
to the right solution regardless of where it starts */
#ifdef HAVE_CONFIG_H
#include "config.h"
......@@ -27,6 +27,10 @@ int main() {
b[0] = 1;
b[1] = 2;
Functional::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);
......@@ -49,11 +53,18 @@ int main() {
assert(error.two_norm() < 1e-10);
double const ret1 = functionTester(J, start, 6);
error = solution;
error -= start;
assert(error.two_norm() < 1e-5);
// Something random
start[0] = 279;
start[1] = -96;
double const ret2 = functionTester(J, start, 16);
double const ret2 = functionTester(J, start, 25);
error = solution;
error -= start;
assert(error.two_norm() < 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