annotate +scheme/elasticDilationVariable.m @ 678:06676c40e77f feature/poroelastic

Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
author Martin Almquist <malmquist@stanford.edu>
date Mon, 05 Feb 2018 11:06:15 -0800
parents 9926efb39330
children
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)
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
12 RHO, RHOi % Density (as diagonal matrix here)
674
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 %
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
29
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
30 % Kroneckered norms and coefficients
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
31 RHOi_kron
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
32 Hi_kron
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
35 methods
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
36 % 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
37 % 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
38 % where a = mu.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
39
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
40 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
41 default_arg('opSet',@sbp.D2Variable);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
42 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
43 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
44 dim = 2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
45
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
46 assert(isa(g, 'grid.Cartesian'))
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
47
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
48 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
49 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
50 m = g.size();
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
51 m_tot = g.N();
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
52
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
53 h = g.scaling();
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
54 L = (m-1).*h;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
55
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
56 % 1D operators
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
57 ops = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
58 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
59 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
60 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
61
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
62 % Borrowing constants
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
63 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
64 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
65 obj.phi = beta/obj.H11;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
66
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67 I = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
68 D1 = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
69 D2 = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
70 H = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
71 Hi = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
72 e_l = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
73 e_r = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
74 d1_l = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
75 d1_r = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
76
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
77 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
78 I{i} = speye(m(i));
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
79 D1{i} = ops{i}.D1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
80 D2{i} = ops{i}.D2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
81 H{i} = ops{i}.H;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
82 Hi{i} = ops{i}.HI;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
83 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
84 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
85 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
86 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
87 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
88
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
89 %====== Assemble full operators ========
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
90 A = spdiag(a);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
91 obj.A = A;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
92 RHO = spdiag(rho);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
93 obj.RHO = RHO;
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
94 obj.RHOi = inv(RHO);
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
95
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
96 obj.D1 = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
97 obj.D2 = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
98 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
99 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
100 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
101 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
102
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
103 % D1
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
104 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
105 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
106
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
107 % Boundary operators
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
108 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
109 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
110 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
111 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
112
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
113 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
114 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
115 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
116 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
117
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
118 % D2
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
119 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
120 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
121 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
122 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
123
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
124 for i = 1:m(2)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
125 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
126 p = ind(:,i);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
127 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
128 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
129
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
130 for i = 1:m(1)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
131 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
132 p = ind(i,:);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
133 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
134 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
135
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
136 % Quadratures
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
137 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
138 obj.Hi = inv(obj.H);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
139 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
140 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
141 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
142
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
143 % Boundary coefficient matrices and quadratures
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
144 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
145 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
146 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
147 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
148 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
149 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
150
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
151 % 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
152 E = cell(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
153 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
154 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
155 e = sparse(dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
156 e(i) = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
157 E{i} = kron(I,e);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
158 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
159 obj.E = E;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
160
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
161 % Differentiation matrix D (without SAT)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
162 D2 = obj.D2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
163 D1 = obj.D1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
164 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
165 d = @kroneckerDelta; % Kronecker delta
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
166 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
167 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
168 for j = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
169 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
170 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
171 );
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
172 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
173 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
174 obj.D = D;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
175 %=========================================%
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
176
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
177 % Divergence operator for BC
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
178 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
179 % Loop over boundaries
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
180 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
181 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
182 % Loop over components
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
183 for j = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
184 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
185 + 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
186 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
188 obj.Div = Div;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
190 % Kroneckered norms and coefficients
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
191 I_dim = speye(dim);
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
192 obj.RHOi_kron = kron(obj.RHOi, I_dim);
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
193 obj.Hi_kron = kron(obj.Hi, I_dim);
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
194
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
195 % Misc.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
196 obj.m = m;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
197 obj.h = h;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
198 obj.order = order;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
199 obj.grid = g;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
200 obj.dim = dim;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
202 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
203
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
205 % 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
206 % 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
207 % 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
208 % 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
209 % 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
210 % 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
211 % 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
212 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
213 default_arg('type','free');
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
214 default_arg('parameter', []);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
215
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
216 % 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
217 % nj: outward unit normal component.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
218 % 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
219 % 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
220 [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
221 switch nj
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
222 case 1
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
223 e = obj.e_r;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
224 d = obj.d1_r;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
225 case -1
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
226 e = obj.e_l;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
227 d = obj.d1_l;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
228 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
229
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
230 E = obj.E;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
231 Hi = obj.Hi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
232 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
233 A = obj.A;
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
234 RHOi = obj.RHOi;
674
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 phi = obj.phi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
237 H11 = obj.H11;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
238 h = obj.h;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
239
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
240 RHOi_kron = obj.RHOi_kron;
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
241 Hi_kron = obj.Hi_kron;
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
242
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
243 % Divergence operator
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
244 Div = obj.Div{j};
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
245
674
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
246 switch type
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
247 % Dirichlet boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
248 case {'D','d','dirichlet'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
249 tuning = 1.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
250 phi = obj.phi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
251
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
252 sigma = tuning * obj.dim/(H11*h(j)) +...
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
253 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
254
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
255 closure = - sigma*E{j}*RHOi*Hi*A*e{j}*H_gamma*e{j}'*E{j}' ...
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
256 + nj*RHOi_kron*Hi_kron*Div'*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
257
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
258 penalty = + sigma*E{j}*RHOi*Hi*A*e{j}*H_gamma ...
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
259 - nj*RHOi_kron*Hi_kron*Div'*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
260
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
261 % Free boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
262 case {'F','f','Free','free'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
263
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
264 closure = -nj*E{j}*RHOi*Hi*e{j} ...
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
265 *H_gamma*e{j}'*A*e{j}*e{j}'*Div;
676
9926efb39330 Clean up dilation BC code.
Martin Almquist <malmquist@stanford.edu>
parents: 675
diff changeset
266 penalty = nj*E{j}*RHOi*Hi*e{j} ...
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
267 *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
268
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
269
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
270 % Unknown boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
271 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
272 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
273 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
274 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
275
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
276 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
277 % 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
278 % 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
279 tuning = 1.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
280 % tuning = 20.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
281 error('Interface not implemented');
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
282 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
283
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
284 % 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
285 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
286
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
287 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
288 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
289 j = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
290 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
291 j = 2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
292 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
293 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
294 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
295
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
296 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
297 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
298 nj = -1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
299 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
300 nj = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
301 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
302 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
303
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
304 % 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
305 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
306
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
307 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
308 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
309 j = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
310 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
311 j = 2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
312 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
313 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
314 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
315
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
316 switch op
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
317 case 'e'
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
318 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
319 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
320 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
321 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
322 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
323 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
324 case 'd'
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
325 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326 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
327 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
328 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
329 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
330 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
331 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332 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
333 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
334
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
335 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
337 function N = size(obj)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338 N = prod(obj.m);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
339 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
340 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
341 end