annotate +scheme/elasticVariable.m @ 679:247b58a4dbe8 feature/poroelastic

Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
author Martin Almquist <malmquist@stanford.edu>
date Mon, 05 Feb 2018 14:45:26 -0800
parents 06676c40e77f
children b035902869a8
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 properties
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7 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
8 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
9
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10 grid
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11 dim
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13 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
14
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
15 % 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
16 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
17 MU % Shear modulus, variable coefficient
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
18 RHO, RHOi % Density, variable
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
19
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20 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
21 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
22
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23 % Second derivatives
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24 D2_lambda
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 D2_mu
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 % 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
28 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
29 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
30
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
31 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
32 phi % Borrowing constant for (d1 - e^T*D1) from R
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
33 gamma % Borrowing constant for d1 from M
678
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 % 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
42 RHOi_kron
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
43 Hi_kron
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
44 end
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 methods
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
47
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
48 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
49 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
50 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
51 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
52 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
53 dim = 2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
54
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
55 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
56
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
57 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
58 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
59 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
60 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
61 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
62
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
63 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
64 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
65
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
66 % 1D operators
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67 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
68 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
69 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
70 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
71
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
72 % Borrowing constants
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
73 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
74 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
75 obj.phi = beta/obj.H11;
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
76 obj.gamma = ops{1}.borrowing.M.d1;
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
77
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86 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
87
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
99
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
100 %====== 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
117 % D1
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
118 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
119 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
120
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
121 % Boundary operators
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
122 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
123 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
124 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
125 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
126
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
127 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
128 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
129 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
130 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
131
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
132 % D2
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
133 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
134 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
135 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
136 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
137 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
138
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
139 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
140 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
141 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
142
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
143 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
144 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
145 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
146 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
147
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
148 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
149 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
150 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
151
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
152 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
153 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
154 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
155 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
156
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
157 % Quadratures
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
158 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
159 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
160 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
161 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
162 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
163
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
164 % 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
165 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
166 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
167 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
168 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
169 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
170 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
171 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
172 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
173
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
174 % 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
175 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
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 );
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
186 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
187 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
188 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
189 );
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 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
192 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
193 %=========================================%
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
195 % 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
196 % 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
197 % 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
198 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
199 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
200 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
201 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
202 % 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
203
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204 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
205 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
206 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
207 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
208 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
209
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
210 % 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
211 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
212 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
213 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
214 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
215 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
216
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
217 % 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
218 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
219 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
220 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
221 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
222 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
223 -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
224 -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
225 -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
226
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
227 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
228 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
229 +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
230 +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
231
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
232 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
233 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
234 end
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 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
237 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
238 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
239 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
240 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
241 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
242
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
243 % 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
244 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
245 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
246 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
247
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
248 % Misc.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
249 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
250 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
251 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
252 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
253 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
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
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
257
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
258 % 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
259 % 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
260 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
261 % type is a cell array of strings specifying the type of boundary condition for each component.
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
262 % 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
263 % 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
264 % 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
265 function [closure, penalty] = boundary_condition(obj, boundary, type, parameter)
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
266 default_arg('type',{'free','free'});
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
267 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
268
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
269 % 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
270 % 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
271 % 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
272 % 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
273 [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
274 switch nj
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
275 case 1
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
276 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
277 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
278 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
279 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
280 case -1
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
281 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
282 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
283 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
284 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
285 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
286
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
287 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
288 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
289 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
290 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
291 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
292 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
293
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
294 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
295 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
296
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
297 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
298 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
299
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
300 % Preallocate
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
301 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
302 penalty = cell(dim,1);
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
303 for k = 1:dim
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
304 penalty{k} = sparse(dim*m_tot, m_tot/obj.m(j));
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
305 end
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
306
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
307 % Loop over components that we (potentially) have different BC on
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
308 for k = 1:dim
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
309 switch type{k}
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
310
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
311 % Dirichlet boundary condition
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
312 case {'D','d','dirichlet','Dirichlet'}
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
313
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
314 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
315 phi = obj.phi;
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
316 h = obj.h(j);
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
317 h11 = obj.H11*h;
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
318 gamma = obj.gamma;
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
319
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
320 a_lambda = dim/h11 + 1/(h11*phi);
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
321 a_mu_i = 2/(gamma*h);
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
322 a_mu_ij = 2/h11 + 1/(h11*phi);
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
323
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
324 d = @kroneckerDelta; % Kronecker delta
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
325 db = @(i,j) 1-d(i,j); % Logical not of Kronecker delta
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
326 alpha = @(i,j) tuning*( d(i,j)* a_lambda*LAMBDA ...
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
327 + d(i,j)* a_mu_i*MU ...
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
328 + db(i,j)*a_mu_ij*MU );
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
330 % Loop over components that Dirichlet penalties end up on
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
331 for i = 1:dim
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
332 C = T{k,i};
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
333 A = -d(i,k)*alpha(i,j);
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
334 B = A + C;
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
335 closure = closure + E{i}*RHOi*Hi*B'*e{j}*H_gamma*(e{j}'*E{k}' );
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
336 penalty{k} = penalty{k} - E{i}*RHOi*Hi*B'*e{j}*H_gamma;
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
337 end
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
339 % Free boundary condition
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
340 case {'F','f','Free','free','traction','Traction','t','T'}
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
341 closure = closure - E{k}*RHOi*Hi*e{j}*H_gamma* (e{j}'*tau{k} );
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
342 penalty{k} = penalty{k} + E{k}*RHOi*Hi*e{j}*H_gamma;
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
343
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
344 % 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
345 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346 error('No such boundary condition: type = %s',type);
679
247b58a4dbe8 Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
Martin Almquist <malmquist@stanford.edu>
parents: 678
diff changeset
347 end
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
349 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
351 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
352 % 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
353 % 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
354 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
355 % 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
356 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
357 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
358
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
359 % 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
360 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
361
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
362 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
363 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
364 j = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
365 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
366 j = 2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
367 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
368 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
369 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
370
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
371 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
372 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
373 nj = -1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
374 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
375 nj = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
376 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
377 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
378
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
379 % 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
380 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
381
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
382 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
383 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
384 j = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
385 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
386 j = 2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
387 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
388 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
389 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
390
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
391 switch op
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
392 case 'e'
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
393 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
394 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
395 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
396 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
397 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
398 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
399 case 'd'
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
400 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
401 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
402 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
403 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
404 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
405 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
406 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
407 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
408 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
409
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
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
412 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
413 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
414 end
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 end