Mercurial > repos > public > sbplib
annotate +scheme/+bc/verifyFormat.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 | 51cc7b05b4ab |
children |
rev | line source |
---|---|
872
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
1 % Errors with a more or less detailed error message if there is a problem with the bc specification |
869
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
2 function verifyBcFormat(bcs, diffOp) |
872
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
3 assertType(bcs, 'cell'); |
869
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
4 for i = 1:length(bcs) |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
5 assertType(bcs{i}, 'struct'); |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
6 assertStructFields(bcs{i}, {'type', 'boundary'}); |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
7 |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
8 if ~isfield(bcs{i}, 'data') || isempty(bcs{i}.data) |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
9 continue |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
10 end |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
11 |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
12 if ~isa(bcs{i}.data, 'function_handle') |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
13 error('bcs{%d}.data should be a function of time or a function of time and space',i); |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
14 end |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
15 |
872
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
16 % Find dimension of boundary |
869
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
17 b = diffOp.grid.getBoundary(bcs{i}.boundary); |
872
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
18 dim = size(b,2); |
869
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
19 |
872
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
20 % Assert that the data function has a valid number of input arguments |
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
21 if ~(nargin(bcs{i}.data) == 1 || nargin(bcs{i}.data) == 1 + dim) |
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
22 error('sbplib:scheme:bcSetup:DataWrongNumberOfArguments', 'bcs{%d}.data has the wrong number of input arguments. Must be either only time or time and space.', i); |
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
23 end |
869
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
24 |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
25 if nargin(bcs{i}.data) == 1 |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
26 % Grid data (only function of time) |
872
f190e35bb57a
Clean up verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
27 % Assert that the data has the correct dimension |
878
51cc7b05b4ab
Fix bugs in forcingSetup and verifyFormat
Jonatan Werpers <jonatan@werpers.com>
parents:
872
diff
changeset
|
28 assertSize(bcs{i}.data(0), 1, size(b,1)); |
869
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
29 end |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
30 end |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
31 end |