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

Add tests for local/global subdiff gap

parent 11602873
No related branches found
No related tags found
No related merge requests found
......@@ -358,6 +358,84 @@ void testSampleFunction2() {
assert(std::abs(ret1 - ret3) < 1e-5);
}
void testSampleFunctionSteep1() {
int const dim = 2;
typedef Dune::SampleFunctional<dim> Functional;
Functional::SmallMatrix A;
A[0][0] = 1;
A[0][1] = 0;
A[1][0] = 0;
A[1][1] = 1;
Functional::SmallVector b;
b[0] = 1;
b[1] = 2;
Dune::SampleFunction f;
Functional J(A, b, Dune::MyNonlinearity<dim>(f));
Functional::SmallVector start;
start[0] = 0;
start[1] = 1;
double const ret1 = functionTester(J, start, 7);
// Something random
start[0] = 279;
start[1] = -96;
double const ret2 = functionTester(J, start, 7);
assert(std::abs(ret1 - ret2) < 1e-5);
start[0] = 0;
start[1] = 0;
double const ret3 = functionTester(J, start, 2);
assert(std::abs(ret1 - ret3) < 1e-5);
}
void testSampleFunctionSteep2() {
int const dim = 2;
typedef Dune::SampleFunctional<dim> Functional;
Functional::SmallMatrix A;
A[0][0] = 1;
A[0][1] = 0;
A[1][0] = 0;
A[1][1] = 1;
Functional::SmallVector b;
b[0] = 1;
b[1] = 2.5;
Dune::SampleFunction f;
Functional J(A, b, Dune::MyNonlinearity<dim>(f));
Functional::SmallVector start;
start[0] = 0;
start[1] = 1;
double const ret1 = functionTester(J, start, 7);
// Something random
start[0] = 279;
start[1] = -96;
double const ret2 = functionTester(J, start, 7);
assert(std::abs(ret1 - ret2) < 1e-5);
start[0] = 0;
start[1] = 0;
start[0] = 0.4;
start[1] = 1.0;
start /= start.two_norm();
double const ret3 = functionTester(J, start, 3);
assert(std::abs(ret1 - ret3) < 1e-5);
}
int main() {
try {
testIdentity();
......@@ -375,6 +453,10 @@ int main() {
testSampleFunction2();
std::cout << std::endl << std::endl << std::endl;
testSampleFunction3D();
std::cout << std::endl << std::endl << std::endl;
testSampleFunctionSteep1();
std::cout << std::endl << std::endl << std::endl;
testSampleFunctionSteep2();
return 0;
}
catch (Dune::Exception &e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment