Mercurial > repos > public > sbplib
comparison +scheme/+bc/verifyFormat.m @ 920:386ef449df51 feature/d1_staggered
Merge with default.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Wed, 28 Nov 2018 17:35:19 -0800 |
parents | 51cc7b05b4ab |
children |
comparison
equal
deleted
inserted
replaced
890:c70131daaa6e | 920:386ef449df51 |
---|---|
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 |