Mercurial > repos > public > sbplib
comparison +scheme/+bc/verifyFormat.m @ 1033:037f203b9bf5 feature/burgers1d
Merge with branch feature/advectioRV to utilize the +rv package
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 17 Jan 2019 10:44:12 +0100 |
parents | 51cc7b05b4ab |
children |
comparison
equal
deleted
inserted
replaced
854:18162a0a5bb5 | 1033:037f203b9bf5 |
---|---|
1 % Errors with a more or less detailed error message if there is a problem with the bc specification | |
2 function verifyBcFormat(bcs, diffOp) | |
3 assertType(bcs, 'cell'); | |
4 for i = 1:length(bcs) | |
5 assertType(bcs{i}, 'struct'); | |
6 assertStructFields(bcs{i}, {'type', 'boundary'}); | |
7 | |
8 if ~isfield(bcs{i}, 'data') || isempty(bcs{i}.data) | |
9 continue | |
10 end | |
11 | |
12 if ~isa(bcs{i}.data, 'function_handle') | |
13 error('bcs{%d}.data should be a function of time or a function of time and space',i); | |
14 end | |
15 | |
16 % Find dimension of boundary | |
17 b = diffOp.grid.getBoundary(bcs{i}.boundary); | |
18 dim = size(b,2); | |
19 | |
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 | |
24 | |
25 if nargin(bcs{i}.data) == 1 | |
26 % Grid data (only function of time) | |
27 % Assert that the data has the correct dimension | |
28 assertSize(bcs{i}.data(0), 1, size(b,1)); | |
29 end | |
30 end | |
31 end |