Mercurial > repos > public > sbplib
comparison diracDiscrCurve.m @ 1251:6424745e1b58 feature/volcano
Merge in latest changes from default
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 20 Nov 2019 14:26:57 -0800 |
parents | 25efceb0c392 |
children | 663eb90a4559 |
comparison
equal
deleted
inserted
replaced
1248:10881b234f77 | 1251:6424745e1b58 |
---|---|
1 % 2-dimensional delta function for single-block curvilinear grid | |
2 % x_s: source point coordinate vector, e.g. [x; y] or [x; y; z]. | |
3 % g: single-block grid containing the source | |
4 % m_order: Number of moment conditions | |
5 % s_order: Number of smoothness conditions | |
6 % order: Order of SBP derivative approximations | |
7 % opSet: Cell array of function handle to opSet generator | |
8 function d = diracDiscrCurve(x_s, g, m_order, s_order, order, opSet) | |
9 default_arg('order', m_order); | |
10 default_arg('opSet', {@sbp.D2Variable, @sbp.D2Variable}); | |
11 | |
12 dim = length(x_s); | |
13 assert(dim == 2, 'diracDiscrCurve: Only implemented for 2d.'); | |
14 assertType(g, 'grid.Curvilinear'); | |
15 | |
16 % Compute Jacobian | |
17 J = jacobian(g, opSet, order); | |
18 | |
19 % Find approximate logical coordinates of point source | |
20 X = g.points(); | |
21 U = g.logic.points(); | |
22 U_interp = scatteredInterpolant(X, U(:,1)); | |
23 V_interp = scatteredInterpolant(X, U(:,2)); | |
24 uS = U_interp(x_s); | |
25 vS = V_interp(x_s); | |
26 | |
27 % Get quadrature matrices for moment conditions | |
28 m = g.size(); | |
29 ops_u = opSet{1}(m(1), {0, 1}, order); | |
30 ops_v = opSet{2}(m(2), {0, 1}, order); | |
31 H_u = ops_u.H; | |
32 H_v = ops_v.H; | |
33 | |
34 % Get delta function for logical grid and scale by Jacobian | |
35 d = (1./J).*diracDiscr(g, [uS; vS], m_order, s_order, {H_u, H_v}); | |
36 end | |
37 | |
38 function J = jacobian(g, opSet, order) | |
39 m = g.size(); | |
40 m_u = m(1); | |
41 m_v = m(2); | |
42 ops_u = opSet{1}(m_u, {0, 1}, order); | |
43 ops_v = opSet{2}(m_v, {0, 1}, order); | |
44 I_u = speye(m_u); | |
45 I_v = speye(m_v); | |
46 | |
47 D1_u = ops_u.D1; | |
48 D1_v = ops_v.D1; | |
49 | |
50 Du = kr(D1_u,I_v); | |
51 Dv = kr(I_u,D1_v); | |
52 | |
53 coords = g.points(); | |
54 x = coords(:,1); | |
55 y = coords(:,2); | |
56 | |
57 x_u = Du*x; | |
58 x_v = Dv*x; | |
59 y_u = Du*y; | |
60 y_v = Dv*y; | |
61 | |
62 J = x_u.*y_v - x_v.*y_u; | |
63 end |