annotate +scheme/elasticVariable.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
children 247b58a4dbe8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
1 classdef elasticVariable < scheme.Scheme
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
2
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
3 % Discretizes the elastic wave equation:
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4 % rho u_{i,tt} = di lambda dj u_j + dj mu di u_j + dj mu dj u_i
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
5
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7 properties
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8 m % Number of points in each direction, possibly a vector
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9 h % Grid spacing
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11 grid
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12 dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
14 order % Order of accuracy for the approximation
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
15
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
16 % Diagonal matrices for varible coefficients
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
17 LAMBDA % Variable coefficient, related to dilation
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
18 MU % Shear modulus, variable coefficient
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
19 RHO, RHOi % Density
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
21 D % Total operator
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22 D1 % First derivatives
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24 % Second derivatives
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 D2_lambda
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26 D2_mu
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28 % Traction operators used for BC
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29 T_l, T_r
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
30 tau_l, tau_r
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
31
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
32 H, Hi % Inner products
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33 phi % Borrowing constant for (d1 - e^T*D1) from R
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34 H11 % First element of H
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
35 e_l, e_r
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
36 d1_l, d1_r % Normal derivatives at the boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
37 E % E{i}^T picks out component i
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
38
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
39 H_boundary % Boundary inner products
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
40
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
41 LAMBDA_boundary_l % Variable coefficients at boundaries
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
42 LAMBDA_boundary_r
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
43 MU_boundary_l
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
44 MU_boundary_r
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
45
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
46 % Kroneckered norms and coefficients
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
47 RHOi_kron
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
48 Hi_kron
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
49 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
50
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
51 methods
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
52 % Implements the shear part of the elastic wave equation, i.e.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
53 % rho u_{i,tt} = d_i a d_j u_j + d_j a d_j u_i
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
54 % where a = mu.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
55
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
56 function obj = elasticVariable(g ,order, lambda_fun, mu_fun, rho_fun, opSet)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
57 default_arg('opSet',@sbp.D2Variable);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
58 default_arg('lambda_fun', @(x,y) 0*x+1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
59 default_arg('mu_fun', @(x,y) 0*x+1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
60 default_arg('rho_fun', @(x,y) 0*x+1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
61 dim = 2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
62
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
63 assert(isa(g, 'grid.Cartesian'))
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
64
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
65 lambda = grid.evalOn(g, lambda_fun);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
66 mu = grid.evalOn(g, mu_fun);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67 rho = grid.evalOn(g, rho_fun);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
68 m = g.size();
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
69 m_tot = g.N();
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
70
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
71 h = g.scaling();
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
72 L = (m-1).*h;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
73
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
74 % 1D operators
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
75 ops = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
76 for i = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
77 ops{i} = opSet(m(i), {0, L(i)}, order);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
78 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
79
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
80 % Borrowing constants
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
81 beta = ops{1}.borrowing.R.delta_D;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
82 obj.H11 = ops{1}.borrowing.H11;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
83 obj.phi = beta/obj.H11;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
84
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
85 I = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
86 D1 = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
87 D2 = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
88 H = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
89 Hi = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
90 e_l = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
91 e_r = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
92 d1_l = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
93 d1_r = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
94
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
95 for i = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
96 I{i} = speye(m(i));
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
97 D1{i} = ops{i}.D1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
98 D2{i} = ops{i}.D2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
99 H{i} = ops{i}.H;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
100 Hi{i} = ops{i}.HI;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
101 e_l{i} = ops{i}.e_l;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
102 e_r{i} = ops{i}.e_r;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
103 d1_l{i} = ops{i}.d1_l;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
104 d1_r{i} = ops{i}.d1_r;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
105 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
106
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
107 %====== Assemble full operators ========
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
108 LAMBDA = spdiag(lambda);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
109 obj.LAMBDA = LAMBDA;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
110 MU = spdiag(mu);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
111 obj.MU = MU;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
112 RHO = spdiag(rho);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
113 obj.RHO = RHO;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
114 obj.RHOi = inv(RHO);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
115
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
116 obj.D1 = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
117 obj.D2_lambda = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
118 obj.D2_mu = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
119 obj.e_l = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
120 obj.e_r = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
121 obj.d1_l = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
122 obj.d1_r = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
123
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
124 % D1
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
125 obj.D1{1} = kron(D1{1},I{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
126 obj.D1{2} = kron(I{1},D1{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
127
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
128 % Boundary operators
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
129 obj.e_l{1} = kron(e_l{1},I{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
130 obj.e_l{2} = kron(I{1},e_l{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
131 obj.e_r{1} = kron(e_r{1},I{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
132 obj.e_r{2} = kron(I{1},e_r{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
133
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
134 obj.d1_l{1} = kron(d1_l{1},I{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
135 obj.d1_l{2} = kron(I{1},d1_l{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
136 obj.d1_r{1} = kron(d1_r{1},I{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
137 obj.d1_r{2} = kron(I{1},d1_r{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
138
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
139 % D2
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
140 for i = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
141 obj.D2_lambda{i} = sparse(m_tot);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
142 obj.D2_mu{i} = sparse(m_tot);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
143 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
144 ind = grid.funcToMatrix(g, 1:m_tot);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
145
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
146 for i = 1:m(2)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
147 D_lambda = D2{1}(lambda(ind(:,i)));
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
148 D_mu = D2{1}(mu(ind(:,i)));
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
149
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
150 p = ind(:,i);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
151 obj.D2_lambda{1}(p,p) = D_lambda;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
152 obj.D2_mu{1}(p,p) = D_mu;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
153 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
154
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
155 for i = 1:m(1)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
156 D_lambda = D2{2}(lambda(ind(i,:)));
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
157 D_mu = D2{2}(mu(ind(i,:)));
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
158
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
159 p = ind(i,:);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
160 obj.D2_lambda{2}(p,p) = D_lambda;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
161 obj.D2_mu{2}(p,p) = D_mu;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
162 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
163
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
164 % Quadratures
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
165 obj.H = kron(H{1},H{2});
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
166 obj.Hi = inv(obj.H);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
167 obj.H_boundary = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
168 obj.H_boundary{1} = H{2};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
169 obj.H_boundary{2} = H{1};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
170
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
171 % Boundary coefficient matrices
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
172 obj.LAMBDA_boundary_l = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
173 obj.LAMBDA_boundary_r = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
174 obj.MU_boundary_l = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
175 obj.MU_boundary_r = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
176 for i = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
177 obj.LAMBDA_boundary_l{i} = obj.e_l{i}'*LAMBDA*obj.e_l{i};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
178 obj.LAMBDA_boundary_r{i} = obj.e_r{i}'*LAMBDA*obj.e_r{i};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
179 obj.MU_boundary_l{i} = obj.e_l{i}'*MU*obj.e_l{i};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
180 obj.MU_boundary_r{i} = obj.e_r{i}'*MU*obj.e_r{i};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
181 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
182
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
183 % E{i}^T picks out component i.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
184 E = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
185 I = speye(m_tot,m_tot);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
186 for i = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 e = sparse(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
188 e(i) = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189 E{i} = kron(I,e);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
190 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
191 obj.E = E;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
192
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
193 % Differentiation matrix D (without SAT)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194 D2_lambda = obj.D2_lambda;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
195 D2_mu = obj.D2_mu;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
196 D1 = obj.D1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
197 D = sparse(dim*m_tot,dim*m_tot);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
198 d = @kroneckerDelta; % Kronecker delta
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
199 db = @(i,j) 1-d(i,j); % Logical not of Kronecker delta
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
200 for i = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201 for j = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
202 D = D + E{i}*inv(RHO)*( d(i,j)*D2_lambda{i}*E{j}' +...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
203 db(i,j)*D1{i}*LAMBDA*D1{j}*E{j}' ...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204 );
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
205 D = D + E{i}*inv(RHO)*( d(i,j)*D2_mu{i}*E{j}' +...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
206 db(i,j)*D1{j}*MU*D1{i}*E{j}' + ...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
207 D2_mu{j}*E{i}' ...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
208 );
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
209 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
210 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
211 obj.D = D;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
212 %=========================================%
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
213
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
214 % Numerical traction operators for BC.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
215 % Because d1 =/= e0^T*D1, the numerical tractions are different
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
216 % at every boundary.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
217 T_l = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
218 T_r = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
219 tau_l = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
220 tau_r = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
221 % tau^{j}_i = sum_k T^{j}_{ik} u_k
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
222
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
223 d1_l = obj.d1_l;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
224 d1_r = obj.d1_r;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
225 e_l = obj.e_l;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
226 e_r = obj.e_r;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
227 D1 = obj.D1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
228
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
229 % Loop over boundaries
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
230 for j = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
231 T_l{j} = cell(dim,dim);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
232 T_r{j} = cell(dim,dim);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
233 tau_l{j} = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
234 tau_r{j} = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
235
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
236 % Loop over components
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
237 for i = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
238 tau_l{j}{i} = sparse(m_tot,dim*m_tot);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
239 tau_r{j}{i} = sparse(m_tot,dim*m_tot);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
240 for k = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
241 T_l{j}{i,k} = ...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
242 -d(i,j)*LAMBDA*(d(i,k)*e_l{k}*d1_l{k}' + db(i,k)*D1{k})...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
243 -d(j,k)*MU*(d(i,j)*e_l{i}*d1_l{i}' + db(i,j)*D1{i})...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
244 -d(i,k)*MU*e_l{j}*d1_l{j}';
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
245
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
246 T_r{j}{i,k} = ...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
247 d(i,j)*LAMBDA*(d(i,k)*e_r{k}*d1_r{k}' + db(i,k)*D1{k})...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
248 +d(j,k)*MU*(d(i,j)*e_r{i}*d1_r{i}' + db(i,j)*D1{i})...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
249 +d(i,k)*MU*e_r{j}*d1_r{j}';
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
250
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
251 tau_l{j}{i} = tau_l{j}{i} + T_l{j}{i,k}*E{k}';
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
252 tau_r{j}{i} = tau_r{j}{i} + T_r{j}{i,k}*E{k}';
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
253 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
254
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
255 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
256 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
257 obj.T_l = T_l;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
258 obj.T_r = T_r;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
259 obj.tau_l = tau_l;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
260 obj.tau_r = tau_r;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
261
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
262 % Kroneckered norms and coefficients
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
263 I_dim = speye(dim);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
264 obj.RHOi_kron = kron(obj.RHOi, I_dim);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
265 obj.Hi_kron = kron(obj.Hi, I_dim);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
266
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
267 % Misc.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
268 obj.m = m;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
269 obj.h = h;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
270 obj.order = order;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
271 obj.grid = g;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
272 obj.dim = dim;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
273
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
274 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
275
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
276
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
277 % Closure functions return the operators applied to the own domain to close the boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
278 % Penalty functions return the operators to force the solution. In the case of an interface it returns the operator applied to the other doamin.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
279 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
280 % type is a string specifying the type of boundary condition if there are several.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
281 % data is a function returning the data that should be applied at the boundary.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
282 % neighbour_scheme is an instance of Scheme that should be interfaced to.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
283 % neighbour_boundary is a string specifying which boundary to interface to.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
284 function [closure, penalty] = boundary_condition(obj, boundary, type, parameter)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
285 default_arg('type','free');
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
286 default_arg('parameter', []);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
287
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
288 % j is the coordinate direction of the boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
289 % nj: outward unit normal component.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
290 % nj = -1 for west, south, bottom boundaries
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
291 % nj = 1 for east, north, top boundaries
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
292 [j, nj] = obj.get_boundary_number(boundary);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
293 switch nj
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
294 case 1
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
295 e = obj.e_r;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
296 d = obj.d1_r;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
297 tau = obj.tau_r{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
298 T = obj.T_r{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
299 case -1
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
300 e = obj.e_l;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
301 d = obj.d1_l;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
302 tau = obj.tau_l{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
303 T = obj.T_l{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
304 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
305
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
306 E = obj.E;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
307 Hi = obj.Hi;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
308 H_gamma = obj.H_boundary{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
309 LAMBDA = obj.LAMBDA;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
310 MU = obj.MU;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
311 RHOi = obj.RHOi;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
312
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
313 phi = obj.phi;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
314 H11 = obj.H11;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
315 h = obj.h;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
316 dim = obj.dim;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
317 m_tot = obj.grid.N();
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
318
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
319 RHOi_kron = obj.RHOi_kron;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
320 Hi_kron = obj.Hi_kron;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
321
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
322 closure = sparse(dim*m_tot, dim*m_tot);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
323 penalty = cell(dim,1);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
324 switch type
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
325 % Dirichlet boundary condition
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326 case {'D','d','dirichlet'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
327 error('not implemented')
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
328 tuning = 1.2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329 phi = obj.phi;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
330
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
331 sigma = tuning * obj.dim/(H11*h(j)) +...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332 tuning * 1/(H11*h(j)*phi);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
333
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
334 closure = - sigma*E{j}*RHOi*Hi*A*e{j}*H_gamma*e{j}'*E{j}' ...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
335 + nj*RHOi_kron*Hi_kron*Div'*A*e{j}*H_gamma*e{j}'*E{j}';
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
337 penalty = + sigma*E{j}*RHOi*Hi*A*e{j}*H_gamma ...
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338 - nj*RHOi_kron*Hi_kron*Div'*A*e{j}*H_gamma;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
339
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
340 % Free boundary condition
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
341 case {'F','f','Free','free'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
342
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
343 % Loop over components of traction
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
344 for i = 1:dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
345 closure = closure - E{i}*RHOi*Hi*e{j}*H_gamma* (e{j}'*tau{i} );
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346 penalty{i} = E{i}*RHOi*Hi*e{j}*H_gamma;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
347 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
349
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350 % Unknown boundary condition
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
351 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
352 error('No such boundary condition: type = %s',type);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
353 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
354 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
355
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
356 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
357 % u denotes the solution in the own domain
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
358 % v denotes the solution in the neighbour domain
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
359 tuning = 1.2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
360 % tuning = 20.2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
361 error('Interface not implemented');
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
362 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
363
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
364 % Returns the coordinate number and outward normal component for the boundary specified by the string boundary.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
365 function [j, nj] = get_boundary_number(obj, boundary)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
366
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
367 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
368 case {'w','W','west','West', 'e', 'E', 'east', 'East'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
369 j = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
370 case {'s','S','south','South', 'n', 'N', 'north', 'North'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
371 j = 2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
372 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
373 error('No such boundary: boundary = %s',boundary);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
374 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
375
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
376 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
377 case {'w','W','west','West','s','S','south','South'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
378 nj = -1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
379 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
380 nj = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
381 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
382 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
383
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
384 % Returns the coordinate number and outward normal component for the boundary specified by the string boundary.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
385 function [return_op] = get_boundary_operator(obj, op, boundary)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
386
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
387 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
388 case {'w','W','west','West', 'e', 'E', 'east', 'East'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
389 j = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
390 case {'s','S','south','South', 'n', 'N', 'north', 'North'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
391 j = 2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
392 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
393 error('No such boundary: boundary = %s',boundary);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
394 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
395
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
396 switch op
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
397 case 'e'
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
398 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
399 case {'w','W','west','West','s','S','south','South'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
400 return_op = obj.e_l{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
401 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
402 return_op = obj.e_r{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
403 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
404 case 'd'
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
405 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
406 case {'w','W','west','West','s','S','south','South'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
407 return_op = obj.d_l{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
408 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'}
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
409 return_op = obj.d_r{j};
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
410 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
411 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
412 error(['No such operator: operatr = ' op]);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
413 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
414
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
415 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
416
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
417 function N = size(obj)
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
418 N = prod(obj.m);
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
419 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
420 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
421 end