Mercurial > repos > public > sbplib
annotate +multiblock/DiffOp.m @ 1344:b4e5e45bd239 feature/D2_boundary_opt
Remove round off zeros from D2Nonequidistant operators
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Sat, 15 Oct 2022 15:48:20 +0200 |
parents | 60c875c18de3 |
children |
rev | line source |
---|---|
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
1 classdef DiffOp < scheme.Scheme |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
2 properties |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
3 grid |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
4 order |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
5 diffOps |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
6 D |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
7 H |
210
39b7dcb2c724
multiblock: Implemented boundary conditions.
Jonatan Werpers <jonatan@werpers.com>
parents:
202
diff
changeset
|
8 |
39b7dcb2c724
multiblock: Implemented boundary conditions.
Jonatan Werpers <jonatan@werpers.com>
parents:
202
diff
changeset
|
9 blockmatrixDiv |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
10 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
11 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
12 methods |
943 | 13 function obj = DiffOp(doHand, g, order, doParam, intfTypes) |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
14 % doHand -- may either be a function handle or a cell array of |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
15 % function handles for each grid. The function handle(s) |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
16 % should be on the form do = doHand(grid, order, ...) |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
17 % Additional parameters for each doHand may be provided in |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
18 % the doParam input. |
721
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
19 % g -- a multiblock grid |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
20 % order -- integer specifying the order of accuracy |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
21 % doParam -- may either be a cell array or a cell array of cell arrays |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
22 % for each block. If it is a cell array with length equal |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
23 % to the number of blocks then each element is sent to the |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
24 % corresponding function handle as extra parameters: |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
25 % doHand(..., doParam{i}{:}) Otherwise doParam is sent as |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
26 % extra parameters to all doHand: doHand(..., doParam{:}) |
903
703183ed8c8b
Include interface type in multiblock.DiffOp, passed to all scheme.interface methods.
Martin Almquist <malmquist@stanford.edu>
parents:
618
diff
changeset
|
27 % |
928
1c61d8fa9903
Replace opts by type everywhere
Martin Almquist <malmquist@stanford.edu>
parents:
923
diff
changeset
|
28 % intfTypes (optional) -- nBlocks x nBlocks cell array of types for |
907
c0652621bd69
Add new class multiblock.InterfaceOptions whose instances are passed to multiblock.DiffOp.
Martin Almquist <malmquist@stanford.edu>
parents:
903
diff
changeset
|
29 % every interface. |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
30 default_arg('doParam', []) |
943 | 31 default_arg('intfTypes', cell(g.nBlocks(), g.nBlocks()) ); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
32 |
721
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
33 [getHand, getParam] = parseInput(doHand, g, doParam); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
34 |
907
c0652621bd69
Add new class multiblock.InterfaceOptions whose instances are passed to multiblock.DiffOp.
Martin Almquist <malmquist@stanford.edu>
parents:
903
diff
changeset
|
35 obj.order = order; |
721
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
36 nBlocks = g.nBlocks(); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
37 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
38 % Create the diffOps for each block |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
39 obj.diffOps = cell(1, nBlocks); |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
40 for i = 1:nBlocks |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
41 h = getHand(i); |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
42 p = getParam(i); |
343
ac30761d7bdb
Fixed bug in parameter parsing.
Jonatan Werpers <jonatan@werpers.com>
parents:
335
diff
changeset
|
43 if ~iscell(p) |
ac30761d7bdb
Fixed bug in parameter parsing.
Jonatan Werpers <jonatan@werpers.com>
parents:
335
diff
changeset
|
44 p = {p}; |
ac30761d7bdb
Fixed bug in parameter parsing.
Jonatan Werpers <jonatan@werpers.com>
parents:
335
diff
changeset
|
45 end |
721
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
46 obj.diffOps{i} = h(g.grids{i}, order, p{:}); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
47 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
48 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
49 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
50 % Build the norm matrix |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
51 H = cell(nBlocks, nBlocks); |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
52 for i = 1:nBlocks |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
53 H{i,i} = obj.diffOps{i}.H; |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
54 end |
210
39b7dcb2c724
multiblock: Implemented boundary conditions.
Jonatan Werpers <jonatan@werpers.com>
parents:
202
diff
changeset
|
55 obj.H = blockmatrix.toMatrix(H); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
56 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
57 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
58 % Build the differentiation matrix |
729
aa8cf3851de8
Update multiblock.DiffOp to work for systems.
Martin Almquist <malmquist@stanford.edu>
parents:
618
diff
changeset
|
59 Ns = zeros(nBlocks,1); |
aa8cf3851de8
Update multiblock.DiffOp to work for systems.
Martin Almquist <malmquist@stanford.edu>
parents:
618
diff
changeset
|
60 for i = 1:nBlocks |
aa8cf3851de8
Update multiblock.DiffOp to work for systems.
Martin Almquist <malmquist@stanford.edu>
parents:
618
diff
changeset
|
61 Ns(i) = length(obj.diffOps{i}.D); |
aa8cf3851de8
Update multiblock.DiffOp to work for systems.
Martin Almquist <malmquist@stanford.edu>
parents:
618
diff
changeset
|
62 end |
aa8cf3851de8
Update multiblock.DiffOp to work for systems.
Martin Almquist <malmquist@stanford.edu>
parents:
618
diff
changeset
|
63 obj.blockmatrixDiv = {Ns, Ns}; |
233
b8ee5212f651
multiblock: Added a function to return number of points in each block for a mbGrid. Fixed a bug in DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
220
diff
changeset
|
64 D = blockmatrix.zero(obj.blockmatrixDiv); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
65 for i = 1:nBlocks |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
66 D{i,i} = obj.diffOps{i}.D; |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
67 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
68 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
69 for i = 1:nBlocks |
237
0fc1de5cd85b
multigrid.DiffOp: Bug fix.
Jonatan Werpers <jonatan@werpers.com>
parents:
233
diff
changeset
|
70 for j = 1:nBlocks |
721
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
71 intf = g.connections{i,j}; |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
72 if isempty(intf) |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
73 continue |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
74 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
75 |
928
1c61d8fa9903
Replace opts by type everywhere
Martin Almquist <malmquist@stanford.edu>
parents:
923
diff
changeset
|
76 [ii, ij] = obj.diffOps{i}.interface(intf{1}, obj.diffOps{j}, intf{2}, intfTypes{i,j}); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
77 D{i,i} = D{i,i} + ii; |
233
b8ee5212f651
multiblock: Added a function to return number of points in each block for a mbGrid. Fixed a bug in DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
220
diff
changeset
|
78 D{i,j} = D{i,j} + ij; |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
79 |
928
1c61d8fa9903
Replace opts by type everywhere
Martin Almquist <malmquist@stanford.edu>
parents:
923
diff
changeset
|
80 [jj, ji] = obj.diffOps{j}.interface(intf{2}, obj.diffOps{i}, intf{1}, intfTypes{i,j}); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
81 D{j,j} = D{j,j} + jj; |
233
b8ee5212f651
multiblock: Added a function to return number of points in each block for a mbGrid. Fixed a bug in DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
220
diff
changeset
|
82 D{j,i} = D{j,i} + ji; |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
83 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
84 end |
210
39b7dcb2c724
multiblock: Implemented boundary conditions.
Jonatan Werpers <jonatan@werpers.com>
parents:
202
diff
changeset
|
85 obj.D = blockmatrix.toMatrix(D); |
722
89e14a85a2d0
Add missing assignment of obj.grid in multiblock.DiffOp
Jonatan Werpers <jonatan@werpers.com>
parents:
721
diff
changeset
|
86 obj.grid = g; |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
87 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
88 |
721
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
89 function [getHand, getParam] = parseInput(doHand, g, doParam) |
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
90 if ~isa(g, 'multiblock.Grid') |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
91 error('multiblock:DiffOp:DiffOp:InvalidGrid', 'Requires a multiblock grid.'); |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
92 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
93 |
721
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
94 if iscell(doHand) && length(doHand) == g.nBlocks() |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
95 getHand = @(i)doHand{i}; |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
96 elseif isa(doHand, 'function_handle') |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
97 getHand = @(i)doHand; |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
98 else |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
99 error('multiblock:DiffOp:DiffOp:InvalidGridDoHand', 'doHand must be a function handle or a cell array of length grid.nBlocks'); |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
100 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
101 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
102 if isempty(doParam) |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
103 getParam = @(i){}; |
392
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
104 return |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
105 end |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
106 |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
107 if ~iscell(doParam) |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
108 getParam = @(i)doParam; |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
109 return |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
110 end |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
111 |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
112 % doParam is a non-empty cell-array |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
113 |
721
c29eca357028
Change name of grid parameter in multiblock.DiffOp to avoid conflict with package
Jonatan Werpers <jonatan@werpers.com>
parents:
618
diff
changeset
|
114 if length(doParam) == g.nBlocks() && all(cellfun(@iscell, doParam)) |
392
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
115 % doParam is a cell-array of cell-arrays |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
116 getParam = @(i)doParam{i}; |
392
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
117 return |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
118 end |
392
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
119 |
30ff8879162e
Better input parsing for multiblock DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
346
diff
changeset
|
120 getParam = @(i)doParam; |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
121 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
122 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
123 |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
124 function ops = splitOp(obj, op) |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
125 % Splits a matrix operator into a cell-matrix of matrix operators for |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
126 % each grid. |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
127 ops = sparse2cell(op, obj.NNN); |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
128 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
129 |
532
b29f04ab5d99
Implement getBoundaryOperator for boundaryGroups in multiblock.DiffOp
Jonatan Werpers <jonatan@werpers.com>
parents:
529
diff
changeset
|
130 % Get a boundary operator specified by opName for the given boundary/BoundaryGroup |
b29f04ab5d99
Implement getBoundaryOperator for boundaryGroups in multiblock.DiffOp
Jonatan Werpers <jonatan@werpers.com>
parents:
529
diff
changeset
|
131 function op = getBoundaryOperator(obj, opName, boundary) |
969
adae8063ea2f
Remove silly getBoundaryOperator* methods in multiblock.DiffOp and make the getBoundaryOperator and getBoundaryQuadrature methods use the scheme.getBoundaryOperator/Quadrature methods instead of properties.
Martin Almquist <malmquist@stanford.edu>
parents:
968
diff
changeset
|
132 blockmatrixDiv = obj.blockmatrixDiv{1}; |
962
262b52c3f268
Bugfix in multiblock.DiffOp/getBoundaryOperatorWrapper
Martin Almquist <malmquist@stanford.edu>
parents:
958
diff
changeset
|
133 |
884
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
134 switch class(boundary) |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
135 case 'cell' |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
136 blockId = boundary{1}; |
969
adae8063ea2f
Remove silly getBoundaryOperator* methods in multiblock.DiffOp and make the getBoundaryOperator and getBoundaryQuadrature methods use the scheme.getBoundaryOperator/Quadrature methods instead of properties.
Martin Almquist <malmquist@stanford.edu>
parents:
968
diff
changeset
|
137 localOp = obj.diffOps{blockId}.getBoundaryOperator(opName, boundary{2}); |
884
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
138 |
962
262b52c3f268
Bugfix in multiblock.DiffOp/getBoundaryOperatorWrapper
Martin Almquist <malmquist@stanford.edu>
parents:
958
diff
changeset
|
139 div = {blockmatrixDiv, size(localOp,2)}; |
884
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
140 blockOp = blockmatrix.zero(div); |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
141 blockOp{blockId,1} = localOp; |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
142 op = blockmatrix.toMatrix(blockOp); |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
143 return |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
144 case 'multiblock.BoundaryGroup' |
964
99c2ef883dc6
Fix warning in getBoundaryWrapper methods
Martin Almquist <malmquist@stanford.edu>
parents:
962
diff
changeset
|
145 op = sparse(sum(blockmatrixDiv),0); |
884
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
146 for i = 1:length(boundary) |
969
adae8063ea2f
Remove silly getBoundaryOperator* methods in multiblock.DiffOp and make the getBoundaryOperator and getBoundaryQuadrature methods use the scheme.getBoundaryOperator/Quadrature methods instead of properties.
Martin Almquist <malmquist@stanford.edu>
parents:
968
diff
changeset
|
147 op = [op, obj.getBoundaryOperator(opName, boundary{i})]; |
884
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
148 end |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
149 otherwise |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
150 error('Unknown boundary indentifier') |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
151 end |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
152 end |
7d4f57725192
Add a getBoundaryOperator method in multiblock.DiffOp that uses the the diffop get_boundary_operator method rather than its properties. Werpers might not like this.
Martin Almquist <malmquist@stanford.edu>
parents:
797
diff
changeset
|
153 |
969
adae8063ea2f
Remove silly getBoundaryOperator* methods in multiblock.DiffOp and make the getBoundaryOperator and getBoundaryQuadrature methods use the scheme.getBoundaryOperator/Quadrature methods instead of properties.
Martin Almquist <malmquist@stanford.edu>
parents:
968
diff
changeset
|
154 function op = getBoundaryQuadrature(obj, boundary) |
958
72cd29107a9a
Temporary changes in multiblock.DiffOp. Change traction operators in Elastic2dvariable to be true boundary operators. But adjoint FD conv test fails for dirichlet BC so need to debug!
Martin Almquist <malmquist@stanford.edu>
parents:
884
diff
changeset
|
155 switch class(boundary) |
72cd29107a9a
Temporary changes in multiblock.DiffOp. Change traction operators in Elastic2dvariable to be true boundary operators. But adjoint FD conv test fails for dirichlet BC so need to debug!
Martin Almquist <malmquist@stanford.edu>
parents:
884
diff
changeset
|
156 case 'cell' |
72cd29107a9a
Temporary changes in multiblock.DiffOp. Change traction operators in Elastic2dvariable to be true boundary operators. But adjoint FD conv test fails for dirichlet BC so need to debug!
Martin Almquist <malmquist@stanford.edu>
parents:
884
diff
changeset
|
157 blockId = boundary{1}; |
969
adae8063ea2f
Remove silly getBoundaryOperator* methods in multiblock.DiffOp and make the getBoundaryOperator and getBoundaryQuadrature methods use the scheme.getBoundaryOperator/Quadrature methods instead of properties.
Martin Almquist <malmquist@stanford.edu>
parents:
968
diff
changeset
|
158 op = obj.diffOps{blockId}.getBoundaryQuadrature(boundary{2}); |
764
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
159 return |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
160 case 'multiblock.BoundaryGroup' |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
161 N = length(boundary); |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
162 H_bm = cell(N,N); |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
163 for i = 1:N |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
164 H_bm{i,i} = obj.getBoundaryQuadrature(boundary{i}); |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
165 end |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
166 op = blockmatrix.toMatrix(H_bm); |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
167 otherwise |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
168 error('Unknown boundary indentifier') |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
169 end |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
170 end |
e05465aa2e25
Add methods for getting boundary quadratures from multiblock.DiffOP
Jonatan Werpers <jonatan@werpers.com>
parents:
722
diff
changeset
|
171 |
335
2d48db7151cf
Bug fix in boundary condition.
Jonatan Werpers <jonatan@werpers.com>
parents:
237
diff
changeset
|
172 % Creates the closure and penalty matrix for a given boundary condition, |
346
33b2ef863519
Allowed muliple closure BCs in multiblock.DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
344
diff
changeset
|
173 % boundary -- the name of the boundary on the form {id,name} where |
202
e2fefb6f0746
multiblock.DiffOp: Fleshed out boundary_condition() a bit more
Jonatan Werpers <jonatan@werpers.com>
parents:
201
diff
changeset
|
174 % id is the number of a block and name is the name of a |
529
2ec8080027ab
Add some documentation and decide on public function signatures
Jonatan Werpers <jonatan@werpers.com>
parents:
522
diff
changeset
|
175 % boundary of that block example: {1,'s'} or {3,'w'}. It |
2ec8080027ab
Add some documentation and decide on public function signatures
Jonatan Werpers <jonatan@werpers.com>
parents:
522
diff
changeset
|
176 % can also be a boundary group |
335
2d48db7151cf
Bug fix in boundary condition.
Jonatan Werpers <jonatan@werpers.com>
parents:
237
diff
changeset
|
177 function [closure, penalty] = boundary_condition(obj, boundary, type) |
529
2ec8080027ab
Add some documentation and decide on public function signatures
Jonatan Werpers <jonatan@werpers.com>
parents:
522
diff
changeset
|
178 switch class(boundary) |
2ec8080027ab
Add some documentation and decide on public function signatures
Jonatan Werpers <jonatan@werpers.com>
parents:
522
diff
changeset
|
179 case 'cell' |
534
55a7777dfcd0
Implement boundary_condition for boundary groups
Jonatan Werpers <jonatan@werpers.com>
parents:
533
diff
changeset
|
180 [closure, penalty] = obj.singleBoundaryCondition(boundary, type); |
529
2ec8080027ab
Add some documentation and decide on public function signatures
Jonatan Werpers <jonatan@werpers.com>
parents:
522
diff
changeset
|
181 case 'multiblock.BoundaryGroup' |
534
55a7777dfcd0
Implement boundary_condition for boundary groups
Jonatan Werpers <jonatan@werpers.com>
parents:
533
diff
changeset
|
182 [n,m] = size(obj.D); |
55a7777dfcd0
Implement boundary_condition for boundary groups
Jonatan Werpers <jonatan@werpers.com>
parents:
533
diff
changeset
|
183 closure = sparse(n,m); |
584
b0386d2c180d
In case of empty grids, make grid functions with the correct dimensions
Jonatan Werpers <jonatan@werpers.com>
parents:
534
diff
changeset
|
184 penalty = sparse(n,0); |
534
55a7777dfcd0
Implement boundary_condition for boundary groups
Jonatan Werpers <jonatan@werpers.com>
parents:
533
diff
changeset
|
185 for i = 1:length(boundary) |
55a7777dfcd0
Implement boundary_condition for boundary groups
Jonatan Werpers <jonatan@werpers.com>
parents:
533
diff
changeset
|
186 [closurePart, penaltyPart] = obj.boundary_condition(boundary{i}, type); |
55a7777dfcd0
Implement boundary_condition for boundary groups
Jonatan Werpers <jonatan@werpers.com>
parents:
533
diff
changeset
|
187 closure = closure + closurePart; |
55a7777dfcd0
Implement boundary_condition for boundary groups
Jonatan Werpers <jonatan@werpers.com>
parents:
533
diff
changeset
|
188 penalty = [penalty, penaltyPart]; |
55a7777dfcd0
Implement boundary_condition for boundary groups
Jonatan Werpers <jonatan@werpers.com>
parents:
533
diff
changeset
|
189 end |
529
2ec8080027ab
Add some documentation and decide on public function signatures
Jonatan Werpers <jonatan@werpers.com>
parents:
522
diff
changeset
|
190 otherwise |
2ec8080027ab
Add some documentation and decide on public function signatures
Jonatan Werpers <jonatan@werpers.com>
parents:
522
diff
changeset
|
191 error('Unknown boundary indentifier') |
346
33b2ef863519
Allowed muliple closure BCs in multiblock.DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
344
diff
changeset
|
192 end |
210
39b7dcb2c724
multiblock: Implemented boundary conditions.
Jonatan Werpers <jonatan@werpers.com>
parents:
202
diff
changeset
|
193 |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
194 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
195 |
533
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
196 function [closure, penalty] = singleBoundaryCondition(obj, boundary, type) |
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
197 I = boundary{1}; |
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
198 name = boundary{2}; |
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
199 |
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
200 % Get the closure and penaly matrices |
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
201 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); |
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
202 |
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
203 % Expand to matrix for full domain. |
865
1cc5a0d26453
Use existing functions
Jonatan Werpers <jonatan@werpers.com>
parents:
862
diff
changeset
|
204 closure = multiblock.local2globalClosure(blockClosure, obj.blockmatrixDiv, I); |
1cc5a0d26453
Use existing functions
Jonatan Werpers <jonatan@werpers.com>
parents:
862
diff
changeset
|
205 penalty = multiblock.local2globalPenalty(blockPenalty, obj.blockmatrixDiv, I); |
533
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
206 end |
06d1606d6977
Factor out function for handling a single boundary condition
Jonatan Werpers <jonatan@werpers.com>
parents:
532
diff
changeset
|
207 |
202
e2fefb6f0746
multiblock.DiffOp: Fleshed out boundary_condition() a bit more
Jonatan Werpers <jonatan@werpers.com>
parents:
201
diff
changeset
|
208 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) |
522
68178e013868
Add not-implemented-error for interface method in multiblock.DiffOp
Jonatan Werpers <jonatan@werpers.com>
parents:
438
diff
changeset
|
209 error('not implemented') |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
210 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
211 |
1316
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
212 function penalties = interfaceForcing(obj, boundary, neighbour_boundary, type) |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
213 default_arg('type', []); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
214 switch class(boundary) |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
215 case 'cell' |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
216 penalties = obj.singleInterfaceForcing(boundary, neighbour_boundary, type); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
217 case 'multiblock.BoundaryGroup' |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
218 [n,m] = size(obj.D); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
219 penaltyZero = sparse(n,0); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
220 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
221 for i = 1:length(boundary) |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
222 penaltyParts = obj.interfaceForcing(boundary{i}, neighbour_boundary{i}, type); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
223 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
224 % Initalize if this is the first boundary |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
225 if i==1 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
226 penalties = cell(numel(penaltyParts), 1); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
227 for j = 1:numel(penaltyParts) |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
228 penalties{j} = penaltyZero; |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
229 end |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
230 end |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
231 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
232 for j = 1:numel(penaltyParts) |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
233 penalties{j} = [penalties{j}, penaltyParts{j}]; |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
234 end |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
235 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
236 end |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
237 otherwise |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
238 error('Unknown boundary indentifier') |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
239 end |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
240 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
241 end |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
242 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
243 function penalties = singleInterfaceForcing(obj, boundary, neighbour_boundary, type) |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
244 I = boundary{1}; |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
245 b1 = boundary{2}; |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
246 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
247 J = neighbour_boundary{1}; |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
248 b2 = neighbour_boundary{2}; |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
249 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
250 % Get local penalties |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
251 [~, ~, blockPenalties] = obj.diffOps{I}.interface(b1, obj.diffOps{J}, b2, type); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
252 % [~, ~, blockPenalties2] = obj.diffOps{J}.interface(b2, b1, obj.diffOps{I}); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
253 |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
254 % Expand to matrices for full domain. |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
255 n = numel(blockPenalties); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
256 penalties = cell(n, 1); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
257 for i = 1:n |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
258 penalties{i} = multiblock.local2globalPenalty(blockPenalties{i}, obj.blockmatrixDiv, I); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
259 % + multiblock.local2globalPenalty(blockPenalties2{i}, obj.blockmatrixDiv, J); |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
260 end |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
261 end |
bd8e607768ce
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
Martin Almquist <malmquist@stanford.edu>
parents:
969
diff
changeset
|
262 |
201
38f203f00f3a
Exeendend tests of multiblock.DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
186
diff
changeset
|
263 % Size returns the number of degrees of freedom |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
264 function N = size(obj) |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
265 N = 0; |
201
38f203f00f3a
Exeendend tests of multiblock.DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
186
diff
changeset
|
266 for i = 1:length(obj.diffOps) |
38f203f00f3a
Exeendend tests of multiblock.DiffOp.
Jonatan Werpers <jonatan@werpers.com>
parents:
186
diff
changeset
|
267 N = N + obj.diffOps{i}.size(); |
186
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
268 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
269 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
270 end |
1fc2eeb4f4e6
Moved multiblock grid to the multiblock package. Continued implementation. Added multiblock diffOp and removed some functions no longer needed.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
271 end |