Mercurial > repos > public > sbplib
comparison +scheme/bcSetup.m @ 785:c02b6d03c77c bcSetupExperiment
Change name from bc to bcs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 24 Jul 2018 15:55:45 -0700 |
parents | 0776fa4754ff |
children | 18ce4b1ab3e1 |
comparison
equal
deleted
inserted
replaced
777:0776fa4754ff | 785:c02b6d03c77c |
---|---|
9 % | 9 % |
10 % The boundary data function can either be a function of time or a function of time and space coordinates. | 10 % The boundary data function can either be a function of time or a function of time and space coordinates. |
11 % In the case where it only depends on time it should return the data as grid function for the boundary. | 11 % In the case where it only depends on time it should return the data as grid function for the boundary. |
12 % In the case where it also takes space coordinates the number of space coordinates should match the number of dimensions of the problem domain. | 12 % In the case where it also takes space coordinates the number of space coordinates should match the number of dimensions of the problem domain. |
13 % For example in the 2D case: f(t,x,y). | 13 % For example in the 2D case: f(t,x,y). |
14 function [closure, S] = bcSetup(diffOp, bc, S_sign) | 14 function [closure, S] = bcSetup(diffOp, bcs, S_sign) |
15 default_arg('S_sign', 1); | 15 default_arg('S_sign', 1); |
16 assertType(bc, 'cell'); | 16 assertType(bcs, 'cell'); |
17 assert(S_sign == 1 || S_sign == -1, 'S_sign must be either 1 or -1'); | 17 assert(S_sign == 1 || S_sign == -1, 'S_sign must be either 1 or -1'); |
18 | 18 |
19 | 19 |
20 % Setup storage arrays | 20 % Setup storage arrays |
21 closure = spzeros(size(diffOp)); | 21 closure = spzeros(size(diffOp)); |
24 symbolicDataPenalties = {}; | 24 symbolicDataPenalties = {}; |
25 symbolicDataFunctions = {}; | 25 symbolicDataFunctions = {}; |
26 symbolicDataCoords = {}; | 26 symbolicDataCoords = {}; |
27 | 27 |
28 % Collect closures, penalties and data | 28 % Collect closures, penalties and data |
29 for i = 1:length(bc) | 29 for i = 1:length(bcs) |
30 assertType(bc{i}, 'struct'); | 30 assertType(bcs{i}, 'struct'); |
31 [localClosure, penalty] = diffOp.boundary_condition(bc{i}.boundary, bc{i}.type); | 31 [localClosure, penalty] = diffOp.boundary_condition(bcs{i}.boundary, bcs{i}.type); |
32 closure = closure + localClosure; | 32 closure = closure + localClosure; |
33 | 33 |
34 if ~isfield(bc{i},'data') || isempty(bc{i}.data) | 34 if ~isfield(bcs{i},'data') || isempty(bcs{i}.data) |
35 % Skip to next loop if there is no data | 35 % Skip to next loop if there is no data |
36 continue | 36 continue |
37 end | 37 end |
38 assertType(bc{i}.data, 'function_handle'); | 38 assertType(bcs{i}.data, 'function_handle'); |
39 | 39 |
40 % Find dimension | 40 % Find dimension |
41 dim = size(diffOp.grid.getBoundary(bc{i}.boundary), 2); | 41 dim = size(diffOp.grid.getBoundary(bcs{i}.boundary), 2); |
42 | 42 |
43 if nargin(bc{i}.data) == 1 | 43 if nargin(bcs{i}.data) == 1 |
44 % Grid data | 44 % Grid data |
45 boundarySize = [size(diffOp.grid.getBoundary(bc{i}.boundary),1),1]; | 45 boundarySize = [size(diffOp.grid.getBoundary(bcs{i}.boundary),1),1]; |
46 assertSize(bc{i}.data(0), boundarySize); % Eval for t = 0 and make sure the function returns a grid vector of the correct size. | 46 assertSize(bcs{i}.data(0), boundarySize); % Eval for t = 0 and make sure the function returns a grid vector of the correct size. |
47 gridDataPenalties{end+1} = penalty; | 47 gridDataPenalties{end+1} = penalty; |
48 gridDataFunctions{end+1} = bc{i}.data; | 48 gridDataFunctions{end+1} = bcs{i}.data; |
49 elseif nargin(bc{i}.data) == 1+dim | 49 elseif nargin(bcs{i}.data) == 1+dim |
50 % Symbolic data | 50 % Symbolic data |
51 coord = diffOp.grid.getBoundary(bc{i}.boundary); | 51 coord = diffOp.grid.getBoundary(bcs{i}.boundary); |
52 symbolicDataPenalties{end+1} = penalty; | 52 symbolicDataPenalties{end+1} = penalty; |
53 symbolicDataFunctions{end+1} = bc{i}.data; | 53 symbolicDataFunctions{end+1} = bcs{i}.data; |
54 symbolicDataCoords{end+1} = num2cell(coord ,1); | 54 symbolicDataCoords{end+1} = num2cell(coord ,1); |
55 else | 55 else |
56 error('sbplib:scheme:bcSetup:DataWrongNumberOfArguments', 'bc{%d}.data has the wrong number of input arguments. Must be either only time or time and space.', i); | 56 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); |
57 end | 57 end |
58 end | 58 end |
59 | 59 |
60 % Setup penalty function | 60 % Setup penalty function |
61 O = spzeros(size(diffOp),1); | 61 O = spzeros(size(diffOp),1); |
71 | 71 |
72 v = S_sign * v; | 72 v = S_sign * v; |
73 end | 73 end |
74 S = @S_fun; | 74 S = @S_fun; |
75 end | 75 end |
76 | |
77 function parseData() | |
78 | |
79 end | |
80 |