annotate +parametrization/TiTest.m @ 1031:2ef20d00b386 feature/advectionRV

For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 17 Jan 2019 10:25:06 +0100
parents 77ad5de4432e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
631
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
1 function tests = TiTest()
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
2 tests = functiontests(localfunctions);
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
3 end
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
4
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
5 function testScalarInput(testCase)
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
6 ti = getMinimumTi();
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
7
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
8 cases = {
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
9 % {u, v, out},
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
10 {0, 0, [1; 2]},
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
11 {0, 1, [1; 4]},
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
12 {1, 0, [3; 2]},
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
13 {1, 1, [3; 4]},
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
14 {0.5, 0.5, [2; 3]},
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
15 };
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
16
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
17 for i = 1:length(cases)
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
18 u = cases{i}{1};
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
19 v = cases{i}{2};
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
20 expected = cases{i}{3};
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
21
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
22 testCase.verifyEqual(ti.S(u,v), expected, sprintf('Case: %d',i));
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
23 end
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
24 end
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
25
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
26 function testRowVectorInput(testCase)
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
27 ti = getMinimumTi();
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
28
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
29 u = [0, 0.5, 1];
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
30 v = [0, 0, 0.5];
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
31 expected = [
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
32 1, 2, 3;
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
33 2, 2, 3;
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
34 ];
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
35
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
36 testCase.verifyEqual(ti.S(u,v), expected);
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
37 end
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
38
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
39 function testColumnvectorInput(testCase)
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
40 ti = getMinimumTi();
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
41
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
42 u = [0; 0.5; 1];
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
43 v = [0; 0; 0.5];
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
44 expected = [1; 2; 3; 2; 2; 3];
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
45
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
46 testCase.verifyEqual(ti.S(u,v), expected);
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
47 end
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
48
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
49
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
50 function ti = getMinimumTi()
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
51 ti = parametrization.Ti.rectangle([1; 2], [3; 4]);
77ad5de4432e Add tests to specify how a ti should respond to vector inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
52 end