comparison +scheme/bcSetup.m @ 735:eac5fb4b63db feature/poroelastic

Make bcSetup work for cell penalties and data from several BC per boundary. Should probably be changed before merge.
author Martin Almquist <malmquist@stanford.edu>
date Wed, 25 Apr 2018 14:47:54 -0700
parents 9dd49d622a4c
children 1f6b2fb69225
comparison
equal deleted inserted replaced
734:eebe24a636c7 735:eac5fb4b63db
23 closure = closure + localClosure; 23 closure = closure + localClosure;
24 24
25 if isempty(bc{i}.data) 25 if isempty(bc{i}.data)
26 continue 26 continue
27 end 27 end
28 assertType(bc{i}.data, 'function_handle');
29 28
30 coord = diffOp.grid.getBoundary(bc{i}.boundary); 29 coord = diffOp.grid.getBoundary(bc{i}.boundary);
31 assertNumberOfArguments(bc{i}.data, 1+size(coord,2)); 30 if iscell(bc{i}.data)
31 for j = 1:length(bc{i}.data)
32 assertType(bc{i}.data{j}, 'function_handle');
33 assertNumberOfArguments(bc{i}.data{j}, 1+size(coord,2));
34 end
35 else
36 assertType(bc{i}.data, 'function_handle');
37 assertNumberOfArguments(bc{i}.data, 1+size(coord,2));
38 end
32 39
33 penalties{end+1} = penalty; 40 penalties{end+1} = penalty;
34 dataFunctions{end+1} = bc{i}.data; 41 dataFunctions{end+1} = bc{i}.data;
35 dataParams{end+1} = num2cell(coord ,1); 42 dataParams{end+1} = num2cell(coord ,1);
36 end 43 end
37 44
38 O = spzeros(size(diffOp),1); 45 O = spzeros(size(diffOp),1);
39 function v = S_fun(t) 46 function v = S_fun(t)
40 v = O; 47 v = O;
41 for i = 1:length(dataFunctions) 48 for i = 1:length(dataFunctions)
42 v = v + penalties{i}*dataFunctions{i}(t, dataParams{i}{:}); 49 if iscell(penalties{i})
50 for j = 1:length(penalties{i})
51 v = v + penalties{i}{j}*dataFunctions{i}{j}(t, dataParams{i}{:});
52 end
53 else
54 v = v + penalties{i}*dataFunctions{i}(t, dataParams{i}{:});
55 end
43 end 56 end
44 57
45 v = S_sign * v; 58 v = S_sign * v;
46 end 59 end
47 S = @S_fun; 60 S = @S_fun;