annotate +scheme/elasticDilationVariable.m @ 675:90bf651abc7c feature/poroelastic

Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
author Martin Almquist <malmquist@stanford.edu>
date Thu, 18 Jan 2018 13:36:56 -0800
parents dd84b8862aa8
children 9926efb39330
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
1 classdef elasticDilationVariable < scheme.Scheme
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
2 properties
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
3 m % Number of points in each direction, possibly a vector
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4 h % Grid spacing
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
5
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6 grid
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7 dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9 order % Order accuracy for the approximation
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11 A % Variable coefficient lambda of the operator (as diagonal matrix here)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12 RHO % Density (as diagonal matrix here)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
14 D % Total operator
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
15 D1 % First derivatives
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
16 D2 % Second derivatives
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
17 Div % Divergence operator used for BC
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
18 H, Hi % Inner products
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
19 phi % Borrowing constant for (d1 - e^T*D1) from R
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20 H11 % First element of H
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
21 e_l, e_r
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22 d1_l, d1_r % Normal derivatives at the boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23 E % E{i}^T picks out component i
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 H_boundary % Boundary inner products
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 A_boundary_l % Variable coefficient at boundaries
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28 A_boundary_r %
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
30
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
31 methods
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
32 % Implements the shear part of the elastic wave equation, i.e.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33 % rho u_{i,tt} = d_i a d_j u_j + d_j a d_j u_i
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34 % where a = mu.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
35
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
36 function obj = elasticDilationVariable(g ,order, a_fun, rho_fun, opSet)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
37 default_arg('opSet',@sbp.D2Variable);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
38 default_arg('a_fun', @(x,y) 0*x+1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
39 default_arg('rho_fun', @(x,y) 0*x+1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
40 dim = 2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
41
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
42 assert(isa(g, 'grid.Cartesian'))
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
43
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
44 a = grid.evalOn(g, a_fun);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
45 rho = grid.evalOn(g, rho_fun);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
46 m = g.size();
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
47 m_tot = g.N();
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
48
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
49 h = g.scaling();
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
50 L = (m-1).*h;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
51
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
52 % 1D operators
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
53 ops = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
54 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
55 ops{i} = opSet(m(i), {0, L(i)}, order);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
56 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
57
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
58 % Borrowing constants
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
59 beta = ops{1}.borrowing.R.delta_D;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
60 obj.H11 = ops{1}.borrowing.H11;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
61 obj.phi = beta/obj.H11;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
62
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
63 I = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
64 D1 = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
65 D2 = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
66 H = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67 Hi = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
68 e_l = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
69 e_r = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
70 d1_l = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
71 d1_r = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
72
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
73 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
74 I{i} = speye(m(i));
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
75 D1{i} = ops{i}.D1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
76 D2{i} = ops{i}.D2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
77 H{i} = ops{i}.H;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
78 Hi{i} = ops{i}.HI;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
79 e_l{i} = ops{i}.e_l;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
80 e_r{i} = ops{i}.e_r;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
81 d1_l{i} = ops{i}.d1_l;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
82 d1_r{i} = ops{i}.d1_r;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
83 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
84
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
85 %====== Assemble full operators ========
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
86 A = spdiag(a);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
87 obj.A = A;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
88 RHO = spdiag(rho);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
89 obj.RHO = RHO;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
90
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
91
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
92 obj.D1 = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
93 obj.D2 = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
94 obj.e_l = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
95 obj.e_r = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
96 obj.d1_l = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
97 obj.d1_r = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
98
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
99 % D1
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
100 obj.D1{1} = kron(D1{1},I{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
101 obj.D1{2} = kron(I{1},D1{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
102
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
103 % Boundary operators
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
104 obj.e_l{1} = kron(e_l{1},I{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
105 obj.e_l{2} = kron(I{1},e_l{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
106 obj.e_r{1} = kron(e_r{1},I{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
107 obj.e_r{2} = kron(I{1},e_r{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
108
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
109 obj.d1_l{1} = kron(d1_l{1},I{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
110 obj.d1_l{2} = kron(I{1},d1_l{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
111 obj.d1_r{1} = kron(d1_r{1},I{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
112 obj.d1_r{2} = kron(I{1},d1_r{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
113
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
114 % D2
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
115 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
116 obj.D2{i} = sparse(m_tot);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
117 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
118 ind = grid.funcToMatrix(g, 1:m_tot);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
119
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
120 for i = 1:m(2)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
121 D = D2{1}(a(ind(:,i)));
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
122 p = ind(:,i);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
123 obj.D2{1}(p,p) = D;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
124 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
125
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
126 for i = 1:m(1)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
127 D = D2{2}(a(ind(i,:)));
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
128 p = ind(i,:);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
129 obj.D2{2}(p,p) = D;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
130 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
131
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
132 % Quadratures
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
133 obj.H = kron(H{1},H{2});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
134 obj.Hi = inv(obj.H);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
135 obj.H_boundary = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
136 obj.H_boundary{1} = H{2};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
137 obj.H_boundary{2} = H{1};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
138
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
139 % Boundary coefficient matrices and quadratures
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
140 obj.A_boundary_l = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
141 obj.A_boundary_r = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
142 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
143 obj.A_boundary_l{i} = obj.e_l{i}'*A*obj.e_l{i};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
144 obj.A_boundary_r{i} = obj.e_r{i}'*A*obj.e_r{i};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
145 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
146
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
147 % E{i}^T picks out component i.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
148 E = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
149 I = speye(m_tot,m_tot);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
150 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
151 e = sparse(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
152 e(i) = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
153 E{i} = kron(I,e);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
154 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
155 obj.E = E;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
156
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
157 % Differentiation matrix D (without SAT)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
158 D2 = obj.D2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
159 D1 = obj.D1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
160 D = sparse(dim*m_tot,dim*m_tot);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
161 d = @kroneckerDelta; % Kronecker delta
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
162 db = @(i,j) 1-d(i,j); % Logical not of Kronecker delta
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
163 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
164 for j = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
165 D = D + E{i}*inv(RHO)*( d(i,j)*D2{i}*E{j}' +...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
166 db(i,j)*D1{i}*A*D1{j}*E{j}' ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
167 );
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
168 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
169 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
170 obj.D = D;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
171 %=========================================%
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
172
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
173 % Divergence operator for BC
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
174 Div = cell(dim,1);
675
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
175 % Loop over boundaries
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
176 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
177 Div{i} = sparse(m_tot,dim*m_tot);
675
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
178 % Loop over components
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
179 for j = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
180 Div{i} = Div{i} + d(i,j)*(obj.e_l{i}*obj.d1_l{i}' + obj.e_r{i}*obj.d1_r{i}')*E{j}' ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
181 + db(i,j)*obj.D1{j}*E{j}';
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
182 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
183 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
184 obj.Div = Div;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
185
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
186 % Misc.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 obj.m = m;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
188 obj.h = h;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189 obj.order = order;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
190 obj.grid = g;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
191 obj.dim = dim;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
192
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
193 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
195
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
196 % Closure functions return the operators applied to the own domain to close the boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
197 % Penalty functions return the operators to force the solution. In the case of an interface it returns the operator applied to the other doamin.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
198 % Here penalty{i,j} enforces data component j on solution component i
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
199 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
200 % type is a string specifying the type of boundary condition if there are several.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201 % data is a function returning the data that should be applied at the boundary.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
202 % neighbour_scheme is an instance of Scheme that should be interfaced to.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
203 % neighbour_boundary is a string specifying which boundary to interface to.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204 function [closure, penalty] = boundary_condition(obj, boundary, type, parameter)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
205 default_arg('type','free');
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
206 default_arg('parameter', []);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
207
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
208 delta = @kroneckerDelta; % Kronecker delta
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
209 delta_b = @(i,j) 1-delta(i,j); % Logical not of Kronecker delta
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
210
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
211 % j is the coordinate direction of the boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
212 % nj: outward unit normal component.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
213 % nj = -1 for west, south, bottom boundaries
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
214 % nj = 1 for east, north, top boundaries
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
215 [j, nj] = obj.get_boundary_number(boundary);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
216 switch nj
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
217 case 1
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
218 e = obj.e_r;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
219 d = obj.d1_r;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
220 case -1
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
221 e = obj.e_l;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
222 d = obj.d1_l;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
223 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
224
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
225 E = obj.E;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
226 Hi = obj.Hi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
227 H_gamma = obj.H_boundary{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
228 A = obj.A;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
229 RHO = obj.RHO;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
230 D1 = obj.D1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
231
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
232 phi = obj.phi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
233 H11 = obj.H11;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
234 h = obj.h;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
235
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
236 switch type
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
237 % Dirichlet boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
238 case {'D','d','dirichlet'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
239 tuning = 1.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
240 phi = obj.phi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
241
675
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
242 % Initialize with zeros
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
243 m_tot = obj.grid.N();
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
244 closure = sparse(m_tot*obj.dim, m_tot*obj.dim);
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
245 penalty = 0*E{j}*e{j};
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
246
675
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
247 % Loop over components to put penalties on
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
248 for i = 1:obj.dim
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
249 sigma_i = tuning * obj.dim/(H11*h(j)) +...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
250 tuning * 1/(H11*h(j)*phi);
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
251
675
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
252 closure = closure + E{i}*inv(RHO)*nj*Hi*...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
253 ( ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
254 delta(i,j)*(e{j}*H_gamma*e{j}'*A*e{j}*d{j}')'*E{j}' ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
255 + delta_b(i,j)*(e{j}*H_gamma*e{j}'*A*D1{i})'*E{j}' ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
256 ) ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
257 - delta(i,j)*sigma_i*E{i}*inv(RHO)*Hi*A*e{j}*H_gamma*e{j}'*E{j}';
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
258
675
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
259 penalty = penalty - ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
260 E{i}*inv(RHO)*nj*Hi*...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
261 ( ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
262 delta(i,j)*(H_gamma*e{j}'*A*e{j}*d{j}')' ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
263 + delta_b(i,j)*(H_gamma*e{j}'*A*D1{i})' ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
264 ) ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
265 + delta(i,j)*sigma_i*E{i}*inv(RHO)*Hi*A*e{j}*H_gamma;
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
266
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
267 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
268
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
269 % Free boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
270 case {'F','f','Free','free'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
271 closures = cell(obj.dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
272 penalties = cell(obj.dim,obj.dim);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
273
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
274 % Divergence operator
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
275 Div = obj.Div{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
276
675
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
277 closure = -nj*E{j}*inv(RHO)*Hi*e{j} ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
278 *H_gamma*e{j}'*A*e{j}*e{j}'*Div;
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
279 penalty = nj*E{j}*inv(RHO)*Hi*e{j} ...
90bf651abc7c Add Dirichlet BC to dilation. Stable with variable coeff and conv study yields p+1/2 which probably is ok.
Martin Almquist <malmquist@stanford.edu>
parents: 674
diff changeset
280 *H_gamma*e{j}'*A*e{j};
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
281
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
282
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
283 % Unknown boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
284 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
285 error('No such boundary condition: type = %s',type);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
286 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
287 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
288
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
289 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
290 % u denotes the solution in the own domain
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
291 % v denotes the solution in the neighbour domain
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
292 tuning = 1.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
293 % tuning = 20.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
294 error('Interface not implemented');
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
295 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
296
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
297 % Returns the coordinate number and outward normal component for the boundary specified by the string boundary.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
298 function [j, nj] = get_boundary_number(obj, boundary)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
299
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
300 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
301 case {'w','W','west','West', 'e', 'E', 'east', 'East'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
302 j = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
303 case {'s','S','south','South', 'n', 'N', 'north', 'North'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
304 j = 2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
305 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
306 error('No such boundary: boundary = %s',boundary);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
307 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
308
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
309 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
310 case {'w','W','west','West','s','S','south','South'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
311 nj = -1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
312 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
313 nj = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
314 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
315 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
316
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
317 % Returns the coordinate number and outward normal component for the boundary specified by the string boundary.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
318 function [return_op] = get_boundary_operator(obj, op, boundary)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
319
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
320 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
321 case {'w','W','west','West', 'e', 'E', 'east', 'East'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
322 j = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
323 case {'s','S','south','South', 'n', 'N', 'north', 'North'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
324 j = 2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
325 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326 error('No such boundary: boundary = %s',boundary);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
327 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
328
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329 switch op
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
330 case 'e'
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
331 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332 case {'w','W','west','West','s','S','south','South'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
333 return_op = obj.e_l{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
334 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
335 return_op = obj.e_r{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
337 case 'd'
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
339 case {'w','W','west','West','s','S','south','South'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
340 return_op = obj.d_l{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
341 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
342 return_op = obj.d_r{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
343 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
344 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
345 error(['No such operator: operatr = ' op]);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
347
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
349
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350 function N = size(obj)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
351 N = prod(obj.m);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
352 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
353 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
354 end