Mercurial > repos > public > sbplib
changeset 877:7ceaea27d944 bcSetupExperiment
Clean up bc.forcingSetup
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 01 Nov 2018 16:01:33 +0100 |
parents | 93489ddb73e8 |
children | 51cc7b05b4ab |
files | +scheme/+bc/forcingSetup.m |
diffstat | 1 files changed, 22 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
diff -r 93489ddb73e8 -r 7ceaea27d944 +scheme/+bc/forcingSetup.m --- a/+scheme/+bc/forcingSetup.m Thu Nov 01 15:36:19 2018 +0100 +++ b/+scheme/+bc/forcingSetup.m Thu Nov 01 16:01:33 2018 +0100 @@ -1,3 +1,6 @@ +% Setup the forcing function for the given boundary conditions and data. +% S_sign allows changing the sign of the function to put on different sides in the system of ODEs. +% default is 1, which the same side as the diffOp. function S = forcingSetup(diffOp, penalties, bcs, S_sign) default_arg('S_sign', 1); @@ -6,27 +9,7 @@ scheme.bc.verifyFormat(bcs, diffOp); - % % Setup storage arrays - % closure = spzeros(size(diffOp)); - % gridData = {}; - % symbolicData = {}; - - % Loop over bcs and collect data - for i = 1:length(bcs) - % [ok, isSym, data] = parseData(bcs{i}, penalties{i}, diffOp.grid) - - % if ~ok - % % There was no data - % continue - % end - - % if isSym - % gridData{end+1} = data; - % else - % symbolicData{end+1} = data; - % end - end - + [gridData, symbolicData] = parseAndSortData(bcs, penalties, diffOp); % Setup penalty function O = spzeros(size(diffOp),1); @@ -45,6 +28,24 @@ S = @S_fun; end +% Go through a cell array of boundary condition specifications and return cell arrays +% of structs for grid and symbolic data. +function [gridData, symbolicData] = parseAndSortData(bcs, penalties, diffOp) + for i = 1:length(bcs) + [ok, isSymbolic, data] = parseData(bcs{i}, penalties{i}, diffOp.grid) + + if ~ok + continue % There was no data + end + + if isSymbolic + gridData{end+1} = data; + else + symbolicData{end+1} = data; + end + end +end + function [ok, isSymbolic, dataStruct] = parseData(bc, penalty, grid) if ~isfield(bc,'data') || isempty(bc.data) isSymbolic = [];