Mercurial > repos > public > sbplib
comparison +scheme/+bc/verifyFormat.m @ 872:f190e35bb57a bcSetupExperiment
Clean up verifyFormat
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 01 Nov 2018 12:02:25 +0100 |
parents | d356f1a22d4f |
children | 51cc7b05b4ab |
comparison
equal
deleted
inserted
replaced
871:526b039c0ecc | 872:f190e35bb57a |
---|---|
1 % Errors with a more or less detailed error message if there is a problem with the bc specification | |
1 function verifyBcFormat(bcs, diffOp) | 2 function verifyBcFormat(bcs, diffOp) |
3 assertType(bcs, 'cell'); | |
2 for i = 1:length(bcs) | 4 for i = 1:length(bcs) |
3 assertType(bcs{i}, 'struct'); | 5 assertType(bcs{i}, 'struct'); |
4 assertStructFields(bcs{i}, {'type', 'boundary'}); | 6 assertStructFields(bcs{i}, {'type', 'boundary'}); |
5 | 7 |
6 if ~isfield(bcs{i}, 'data') || isempty(bcs{i}.data) | 8 if ~isfield(bcs{i}, 'data') || isempty(bcs{i}.data) |
9 | 11 |
10 if ~isa(bcs{i}.data, 'function_handle') | 12 if ~isa(bcs{i}.data, 'function_handle') |
11 error('bcs{%d}.data should be a function of time or a function of time and space',i); | 13 error('bcs{%d}.data should be a function of time or a function of time and space',i); |
12 end | 14 end |
13 | 15 |
16 % Find dimension of boundary | |
14 b = diffOp.grid.getBoundary(bcs{i}.boundary); | 17 b = diffOp.grid.getBoundary(bcs{i}.boundary); |
18 dim = size(b,2); | |
15 | 19 |
16 dim = size(b,2); | 20 % Assert that the data function has a valid number of input arguments |
21 if ~(nargin(bcs{i}.data) == 1 || nargin(bcs{i}.data) == 1 + dim) | |
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); | |
23 end | |
17 | 24 |
18 if nargin(bcs{i}.data) == 1 | 25 if nargin(bcs{i}.data) == 1 |
19 % Grid data (only function of time) | 26 % Grid data (only function of time) |
27 % Assert that the data has the correct dimension | |
20 assertSize(bcs{i}.data(0), 1, size(b)); | 28 assertSize(bcs{i}.data(0), 1, size(b)); |
21 elseif nargin(bcs{i}.data) ~= 1+dim | |
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); | |
23 end | 29 end |
24 end | 30 end |
25 end | 31 end |