Mercurial > repos > public > sbplib
comparison +multiblock/nonConformingInterfaceOptions.m @ 908:ecfccf236af0 feature/utux2D
Add helper function nonConformingInterfaceOptions that creates an InterfaceOptions object that specifies which interpolation operators are used where.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Fri, 23 Nov 2018 20:14:16 -0800 |
parents | |
children | 95cd70f4b07d |
comparison
equal
deleted
inserted
replaced
907:c0652621bd69 | 908:ecfccf236af0 |
---|---|
1 % g: multiblock grid | |
2 % order: cell array of the orders of accuracy used in the different blocks, | |
3 % or a scalar for the same order everywhere. | |
4 % interpOpSet: string, e.g 'MC' or 'AWW' The same interpOpSet is used everywhere. | |
5 % | |
6 % Returns an InterfaceOptions object that can be used as the 'interfaceOptions' argument to multiblock.DiffOp | |
7 function options = nonConformingInterfaceOptions(g, orders, interpOpSet) | |
8 default_arg(interpOpSet, 'AWW'); | |
9 nBlocks = g.nBlocks; | |
10 conn = g.connections; | |
11 | |
12 % If order is a scalar, the same order is used in all blocks | |
13 if ~iscell(orders) | |
14 o = orders; | |
15 orders = cell(1,nBlocks); | |
16 for i = 1:nBlocks | |
17 orders{i} = o; | |
18 end | |
19 end | |
20 | |
21 interpOpts = cell(nBlocks, nBlocks); | |
22 for i = 1:nBlocks | |
23 for j = 1:nBlocks | |
24 intf = conn{i,j}; | |
25 if isempty(intf) | |
26 continue | |
27 end | |
28 | |
29 mi = length( g.getBoundary({i, intf{1}}) ) - 1; | |
30 mj = length( g.getBoundary({j, intf{2}}) ) - 1; | |
31 | |
32 if mi == mj | |
33 % Matching grids, no interpolation required (presumably) | |
34 continue; | |
35 elseif mi/mj == 2 | |
36 % Block i is finer | |
37 | |
38 switch interpOpSet | |
39 case 'MC' | |
40 interpOpSet = sbp.InterpMC(mi, mj, orders{i}, orders{j}); | |
41 I_i2j_good = interpOpSet.IF2C; | |
42 I_i2j_bad = interpOpSet.IF2C; | |
43 I_j2i_good = interpOpSet.IC2F; | |
44 I_j2i_bad = interpOpSet.IC2F; | |
45 | |
46 case 'AWW' | |
47 interpOpSetF2C = sbp.InterpAWW(mi+1, mj+1, orders{i}, orders{j}, 'F2C'); | |
48 interpOpSetC2F = sbp.InterpAWW(mi+1, mj+1, orders{i}, orders{j}, 'C2F'); | |
49 I_i2j_good = interpOpSetF2C.IF2C; | |
50 I_i2j_bad = interpOpSetC2F.IF2C; | |
51 I_j2i_good = interpOpSetC2F.IC2F; | |
52 I_j2i_bad = interpOpSetF2C.IC2F; | |
53 end | |
54 | |
55 elseif mj/mi == 2 | |
56 % Block j is finer | |
57 | |
58 switch interpOpSet | |
59 case 'MC' | |
60 interpOpSet = sbp.InterpMC(mi+1, mj+1, orders{i}, orders{j}); | |
61 I_i2j_good = interpOpSet.IC2F; | |
62 I_i2j_bad = interpOpSet.IC2F; | |
63 I_j2i_good = interpOpSet.IF2C; | |
64 I_j2i_bad = interpOpSet.IF2C; | |
65 | |
66 case 'AWW' | |
67 interpOpSetF2C = sbp.InterpAWW(mi+1, mj+1, orders{i}, orders{j}, 'F2C'); | |
68 interpOpSetC2F = sbp.InterpAWW(mi+1, mj+1, orders{i}, orders{j}, 'C2F'); | |
69 I_i2j_good = interpOpSetC2F.IC2F; | |
70 I_i2j_bad = interpOpSetF2C.IC2F; | |
71 I_j2i_good = interpOpSetF2C.IF2C; | |
72 I_j2i_bad = interpOpSetC2F.IF2C; | |
73 end | |
74 else | |
75 error(sprintf('Interpolation operators for grid ratio %f have not yet been constructed', mi/mj)); | |
76 end | |
77 | |
78 interpOpts{i,j} = cell(2,1); | |
79 interpOpts{i,j}{1}.I_local2neighbor.good = I_i2j_good; | |
80 interpOpts{i,j}{1}.I_local2neighbor.bad = I_i2j_bad; | |
81 interpOpts{i,j}{1}.I_neighbor2local.good = I_j2i_good; | |
82 interpOpts{i,j}{1}.I_neighbor2local.bad = I_j2i_bad; | |
83 | |
84 interpOpts{i,j}{2}.I_local2neighbor.good = I_j2i_good; | |
85 interpOpts{i,j}{2}.I_local2neighbor.bad = I_j2i_bad; | |
86 interpOpts{i,j}{2}.I_neighbor2local.good = I_i2j_good; | |
87 interpOpts{i,j}{2}.I_neighbor2local.bad = I_i2j_bad; | |
88 | |
89 options = multiblock.InterfaceOptions(g, interpOpts); | |
90 | |
91 end | |
92 end | |
93 |