annotate +sbp/InterpOpsOP.m @ 1289:2fd2e2337b77 feature/boundary_optimized_grids

Add utility function for constructing a (possibly multidimensional) grid based on the grid points used by the boundary optimized SBP operators
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 01 Jul 2020 15:15:30 +0200
parents 27ce3f653aa7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
952
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
1 % Order-preserving (OP) interpolation operators, see
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
2 % Almquist, Wang, Werpers,
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
3 % "Order-Preserving Interpolation for Summation-by-Parts Operators
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
4 % at Non-Conforming Interfaces", https://arxiv.org/abs/1806.01931
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
5 %
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
6 % Let ^* denote the adjoint. These operators satsify
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
7 %
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
8 % Iuv2.good = Iv2u.bad^*
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
9 % Iv2u.good = Iu2v.bad^*
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
10 %
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
11 % The .bad operators have the same order of accuracy as the operators
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
12 % by Mattsson and Carpenter (MC) in InterpOpsMC, i.e. order p,
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
13 % if the interior stencil is order 2p. The .good operators are
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
14 % one order more accurate, i.e. order p+1.
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
15 %
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
16 % For PDEs of second order in space, the OP operators allow for the same
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
17 % convergence rate as with conforming interfaces, which is an improvement
27ce3f653aa7 Improve comments in InterpOpsXX
Martin Almquist <malmquist@stanford.edu>
parents: 937
diff changeset
18 % by one order compared what is possible with the MC operators.
927
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
19 classdef InterpOpsOP < sbp.InterpOps
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20 properties
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
21
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22 % Structs of interpolation operators, fields .good and .bad
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23 Iu2v
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24 Iv2u
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 end
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 methods
937
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
28 % m_u, m_v -- number of grid points along the interface
927
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29 % order_u, order_v -- order of accuracy in the different blocks
937
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
30 function obj = InterpOpsOP(m_u, m_v, order_u, order_v)
927
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
31
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
32 assert(order_u == order_v,...
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33 'InterpOpsOP: Different orders of accuracy not available');
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
35 switch order_u
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
36 case 2
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
37 intOpSet = @sbp.implementations.intOpOP_orders_2to2_ratio2to1;
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
38 case 4
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
39 intOpSet = @sbp.implementations.intOpOP_orders_4to4_ratio2to1;
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
40 case 6
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
41 intOpSet = @sbp.implementations.intOpOP_orders_6to6_ratio2to1;
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
42 case 8
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
43 intOpSet = @sbp.implementations.intOpOP_orders_8to8_ratio2to1;
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
44 otherwise
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
45 error('InterpOpsOP: Order of accuracy %d not available.', order_u);
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
46 end
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
47
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
48 Iu2v = struct;
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
49 Iv2u = struct;
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
50
937
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
51 if (m_u-1)/(m_v-1) == 2
927
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
52 % Block u is fine, v is coarse
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
53 m_C = m_v;
937
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
54 [Iv2u.good, Iu2v.bad] = intOpSet(m_C, 1, 'C2F');
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
55 [Iv2u.bad, Iu2v.good] = intOpSet(m_C, 1, 'F2C');
927
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
56
937
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
57 elseif (m_v-1)/(m_u-1) == 2
927
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
58 % Block v is fine, u is coarse
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
59 m_C = m_u;
937
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
60 [Iu2v.good, Iv2u.bad] = intOpSet(m_C, 1, 'C2F');
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
61 [Iu2v.bad, Iv2u.good] = intOpSet(m_C, 1, 'F2C');
927
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
62 else
937
ed8c98c4d479 Use only number of grid points as arguments in InterpOpsXX, instead of coordinates.
Martin Almquist <malmquist@stanford.edu>
parents: 927
diff changeset
63 error('InterpOpsOP: Interpolation operators for grid ratio %f have not yet been constructed', (m_u-1)/(m_v-1));
927
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
64 end
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
65
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
66 obj.Iu2v = Iu2v;
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67 obj.Iv2u = Iv2u;
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
68
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
69 end
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
70
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
71 function str = string(obj)
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
72 str = [class(obj)];
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
73 end
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
74
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
75 end
4291731570bb Rename AWW OP. Make Interpolation operator classes take grid points as arguments. Remove LaplCurv.interpolationOperators. Introduce default struct in LaplCurv.interface.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
76 end