Mercurial > repos > public > sbplib
changeset 786:18ce4b1ab3e1 bcSetupExperiment
Move verification to a separate function
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 24 Jul 2018 16:12:39 -0700 |
parents | c02b6d03c77c |
children | fef739088f20 |
files | +scheme/bcSetup.m |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
diff -r c02b6d03c77c -r 18ce4b1ab3e1 +scheme/bcSetup.m --- a/+scheme/bcSetup.m Tue Jul 24 15:55:45 2018 -0700 +++ b/+scheme/bcSetup.m Tue Jul 24 16:12:39 2018 -0700 @@ -16,6 +16,7 @@ assertType(bcs, 'cell'); assert(S_sign == 1 || S_sign == -1, 'S_sign must be either 1 or -1'); + verifyBcFormat(bcs); % Setup storage arrays closure = spzeros(size(diffOp)); @@ -27,7 +28,6 @@ % Collect closures, penalties and data for i = 1:length(bcs) - assertType(bcs{i}, 'struct'); [localClosure, penalty] = diffOp.boundary_condition(bcs{i}.boundary, bcs{i}.type); closure = closure + localClosure; @@ -35,7 +35,6 @@ % Skip to next loop if there is no data continue end - assertType(bcs{i}.data, 'function_handle'); % Find dimension dim = size(diffOp.grid.getBoundary(bcs{i}.boundary), 2); @@ -74,7 +73,17 @@ S = @S_fun; end -function parseData() +function verifyBcFormat(bcs) + for i = 1:length(bcs) + assertType(bcs{i}, 'struct'); + assertStructFields(bcs{i}, {'type', 'boundary'}); + if ~isfield(bcs{i}, 'data') || isempty(bcs{i}.data) + continue + end + + if ~isa(bcs{i}.data, 'function_handle') + error('bcs{%d}.data should be a function of time or a function of time and space',i); + end + end end -