Mercurial > repos > public > sbplib
annotate +multiblock/stitchSchemes.m @ 87:0a29a60e0b21
In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
author | Martin Almquist <martin.almquist@it.uu.se> |
---|---|
date | Sun, 29 Nov 2015 22:23:09 +0100 |
parents | 5c569cbef49e |
children | 8eb4e39df8a5 |
rev | line source |
---|---|
0 | 1 % Stitch schemes together given connection matrix and BC vector. |
2 % schmHand - function_handle to a Scheme constructor | |
3 % order - order of accuracy | |
4 % schmParam - cell array of extra parameters sent to each Scheme stored as cell arrays | |
5 % blocks - block definitions, On whatever form the scheme expects. | |
6 % ms - grid points in each direction for each block. Ex {[10,10], [10, 20]} | |
7 % conn - connection matrix | |
8 % bound - boundary condition vector, array of structs with fields w,e,s,n | |
9 % each field with a parameter array that is sent to schm.boundary_condition | |
10 % | |
11 % Output parameters are cell arrays and cell matrices. | |
76
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
12 % |
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
13 % Ex: [schms, D, H] = stitchSchemes(schmHand, order, schmParam, blocks, ms, conn, bound) |
0 | 14 function [schms, D, H] = stitchSchemes(schmHand, order, schmParam, blocks, ms, conn, bound) |
76
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
15 default_arg('schmParam',[]); |
0 | 16 |
17 n_blocks = numel(blocks); | |
18 | |
19 % Creating Schemes | |
20 for i = 1:n_blocks | |
76
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
21 if isempty(schmParam); |
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
22 schms{i} = schmHand(ms{i},blocks{i},order,[]); |
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
23 elseif ~iscell(schmParam) |
0 | 24 param = schmParam(i); |
76
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
25 schms{i} = schmHand(ms{i},blocks{i},order,param); |
0 | 26 else |
27 param = schmParam{i}; | |
76
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
28 if iscell(param) |
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
29 schms{i} = schmHand(ms{i},blocks{i},order,param{:}); |
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
30 else |
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
31 schms{i} = schmHand(ms{i},blocks{i},order,param); |
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
32 end |
0 | 33 end |
34 | |
35 % class(schmParam) | |
36 % class(ms) | |
37 % class(blocks) | |
38 % class(schmParam{i}) | |
39 % class(ms) | |
40 | |
76
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
41 |
0 | 42 end |
43 | |
44 | |
45 % Total norm | |
46 H = cell(n_blocks,n_blocks); | |
47 for i = 1:n_blocks | |
48 H{i,i} = schms{i}.H; | |
49 end | |
50 | |
51 %% Total system matrix | |
52 | |
53 % Differentiation terms | |
54 D = cell(n_blocks,n_blocks); | |
55 for i = 1:n_blocks | |
56 D{i,i} = schms{i}.D; | |
57 end | |
58 | |
59 % Boundary penalty terms | |
60 for i = 1:n_blocks | |
61 if ~isstruct(bound{i}) | |
62 continue | |
63 end | |
64 | |
65 fn = fieldnames(bound{i}); | |
66 for j = 1:length(fn); | |
67 bc = bound{i}.(fn{j}); | |
68 if isempty(bc) | |
69 continue | |
70 end | |
71 | |
72 t = schms{i}.boundary_condition(fn{j},bc{:}); | |
73 D{i,i} = D{i,i}+t; | |
74 end | |
75 end | |
76 | |
77 % Interface penalty terms | |
78 for i = 1:n_blocks | |
79 for j = 1:n_blocks | |
80 intf = conn{i,j}; | |
81 if isempty(intf) | |
82 continue | |
83 end | |
84 | |
76
5c569cbef49e
Added more input parameter handling and fixed some bugs.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
85 [uu,uv,vv,vu] = schms{i}.interface_coupling(schms{i},intf{1},schms{j},intf{2}); |
0 | 86 D{i,i} = D{i,i} + uu; |
87 D{i,j} = uv; | |
88 D{j,j} = D{j,j} + vv; | |
89 D{j,i} = vu; | |
90 end | |
91 end | |
92 end |