annotate +scheme/elasticDilationVariable.m @ 674:dd84b8862aa8 feature/poroelastic

First implementation of elastic dilation variable. Constant coeff is stable.
author Martin Almquist <malmquist@stanford.edu>
date Tue, 16 Jan 2018 17:41:55 -0800
parents
children 90bf651abc7c
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);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
175 for i = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
176 Div{i} = sparse(m_tot,dim*m_tot);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
177 for j = 1:dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
178 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
179 + 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
180 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
181 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
182 obj.Div = Div;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
183
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
184 % Misc.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
185 obj.m = m;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
186 obj.h = h;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 obj.order = order;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
188 obj.grid = g;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189 obj.dim = dim;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
190
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
191 end
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
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194 % 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
195 % 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
196 % 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
197 % 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
198 % 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
199 % 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
200 % 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
201 % 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
202 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
203 default_arg('type','free');
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204 default_arg('parameter', []);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
205
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
206 delta = @kroneckerDelta; % Kronecker delta
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
207 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
208
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
209 % 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
210 % nj: outward unit normal component.
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
211 % 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
212 % 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
213 [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
214 switch nj
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
215 case 1
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
216 e = obj.e_r;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
217 d = obj.d1_r;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
218 case -1
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
219 e = obj.e_l;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
220 d = obj.d1_l;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
221 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
222
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
223 E = obj.E;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
224 Hi = obj.Hi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
225 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
226 A = obj.A;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
227 RHO = obj.RHO;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
228 D1 = obj.D1;
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 phi = obj.phi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
231 H11 = obj.H11;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
232 h = obj.h;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
233
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
234 switch type
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
235 % Dirichlet boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
236 case {'D','d','dirichlet'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
237 error('Not implemented');
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
238 tuning = 1.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
239 phi = obj.phi;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
240
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
241 closures = cell(obj.dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
242 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
243 % Loop over components
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
244 for i = 1:obj.dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
245 H_gamma_i = obj.H_boundary{i};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
246 sigma_ij = tuning*delta(i,j)*2/(gamma*h(j)) +...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
247 tuning*delta_b(i,j)*(2/(H11*h(j)) + 2/(H11*h(j)*phi));
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
248
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
249 ci = E{i}*inv(RHO)*nj*Hi*...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
250 ( (e{j}*H_gamma*e{j}'*A*e{j}*d{j}')'*E{i}' + ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
251 delta(i,j)*(e{j}*H_gamma*e{j}'*A*e{j}*d{j}')'*E{j}' ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
252 ) ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
253 - sigma_ij*E{i}*inv(RHO)*Hi*A*e{j}*H_gamma*e{j}'*E{i}';
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
254
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
255 cj = E{j}*inv(RHO)*nj*Hi*...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
256 ( delta_b(i,j)*(e{j}*H_gamma*e{j}'*A*D1{i})'*E{i}' ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
257 );
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
258
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
259 if isempty(closures{i})
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
260 closures{i} = ci;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
261 else
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
262 closures{i} = closures{i} + ci;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
263 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
264
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
265 if isempty(closures{j})
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
266 closures{j} = cj;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
267 else
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
268 closures{j} = closures{j} + cj;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
269 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
270
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
271 pii = - E{i}*inv(RHO)*nj*Hi*...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
272 ( (H_gamma*e{j}'*A*e{j}*d{j}')' + ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
273 delta(i,j)*(H_gamma*e{j}'*A*e{j}*d{j}')' ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
274 ) ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
275 + sigma_ij*E{i}*inv(RHO)*Hi*A*e{j}*H_gamma;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
276
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
277 pji = - E{j}*inv(RHO)*nj*Hi*...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
278 ( delta_b(i,j)*(H_gamma*e{j}'*A*D1{i})' );
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
279
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
280 % Dummies
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
281 pij = - 0*E{i}*e{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
282 pjj = - 0*E{j}*e{j};
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 if isempty(penalties{i,i})
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
285 penalties{i,i} = pii;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
286 else
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
287 penalties{i,i} = penalties{i,i} + pii;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
288 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
289
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
290 if isempty(penalties{j,i})
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
291 penalties{j,i} = pji;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
292 else
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
293 penalties{j,i} = penalties{j,i} + pji;
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 if isempty(penalties{i,j})
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
297 penalties{i,j} = pij;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
298 else
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
299 penalties{i,j} = penalties{i,j} + pij;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
300 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
301
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
302 if isempty(penalties{j,j})
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
303 penalties{j,j} = pjj;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
304 else
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
305 penalties{j,j} = penalties{j,j} + pjj;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
306 end
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 [rows, cols] = size(closures{1});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
309 closure = sparse(rows, cols);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
310 for i = 1:obj.dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
311 closure = closure + closures{i};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
312 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
313 penalty = penalties;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
314
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
315 % Free boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
316 case {'F','f','Free','free'}
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
317 closures = cell(obj.dim,1);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
318 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
319
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
320 % Divergence operator
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
321 Div = obj.Div{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
322
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
323 % Loop over components
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
324 %for i = 1:obj.dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
325 closure = -nj*E{j}*inv(RHO)*Hi*e{j} ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326 *H_gamma*e{j}'*A*e{j}*e{j}'*Div;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
327 penalty = nj*E{j}*inv(RHO)*Hi*e{j} ...
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
328 *H_gamma*e{j}'*A*e{j};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329 %end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
330 % [rows, cols] = size(closures{1});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
331 % closure = sparse(rows, cols);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332 % for i = 1:obj.dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
333 % closure = closure + closures{i};
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
334 % for j = 1:obj.dim
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
335 % if i~=j
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336 % [rows cols] = size(penalties{j,j});
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
337 % penalties{i,j} = sparse(rows,cols);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338 % end
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 % penalty = penalties;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
342
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
343
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
344 % Unknown boundary condition
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
345 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346 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
347 end
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 [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
351 % 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
352 % 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
353 tuning = 1.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
354 % tuning = 20.2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
355 error('Interface not implemented');
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
356 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
357
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
358 % 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
359 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
360
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
361 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
362 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
363 j = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
364 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
365 j = 2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
366 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
367 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
368 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
369
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
370 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
371 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
372 nj = -1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
373 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
374 nj = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
375 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
376 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
377
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
378 % 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
379 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
380
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
381 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
382 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
383 j = 1;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
384 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
385 j = 2;
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
386 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
387 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
388 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
389
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
390 switch op
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
391 case 'e'
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
392 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
393 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
394 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
395 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
396 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
397 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
398 case 'd'
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
399 switch boundary
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
400 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
401 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
402 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
403 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
404 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
405 otherwise
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
406 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
407 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
408
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
409 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
410
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
411 function N = size(obj)
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
412 N = prod(obj.m);
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
413 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
414 end
dd84b8862aa8 First implementation of elastic dilation variable. Constant coeff is stable.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
415 end