annotate +scheme/elasticVariable.m @ 685:b035902869a8 feature/poroelastic

Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
author Martin Almquist <malmquist@stanford.edu>
date Thu, 08 Feb 2018 16:43:43 -0800
parents 247b58a4dbe8
children
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
685
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
5 % opSet should be cell array of opSets, one per dimension. This
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
6 % is useful if we have periodic BC in one direction.
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8 properties
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9 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
10 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
11
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12 grid
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13 dim
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 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
16
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
17 % 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
18 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
19 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
20 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
21
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22 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
23 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
24
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 % Second derivatives
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26 D2_lambda
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 D2_mu
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29 % 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
30 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
31 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
32
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
41 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
42
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
43 % 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
44 RHOi_kron
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
45 Hi_kron
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
46 end
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 methods
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
49
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
50 function obj = elasticVariable(g ,order, lambda_fun, mu_fun, rho_fun, opSet)
685
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
51 default_arg('opSet',{@sbp.D2Variable, @sbp.D2Variable});
678
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('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
53 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
54 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
55 dim = 2;
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 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
58
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
59 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
60 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
61 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
62 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
63 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
64
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
65 h = g.scaling();
685
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
66 lim = g.lim;
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
68 % 1D operators
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
69 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
70 for i = 1:dim
685
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
71 ops{i} = opSet{i}(m(i), lim{i}, order);
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
72 end
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 % Borrowing constants
685
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
75 for i = 1:dim
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
76 beta = ops{i}.borrowing.R.delta_D;
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
77 obj.H11{i} = ops{i}.borrowing.H11;
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
78 obj.phi{i} = beta/obj.H11{i};
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
79 obj.gamma{i} = ops{i}.borrowing.M.d1;
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
80 end
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
81
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
92 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
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
103
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
104 %====== 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
113 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
114 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
115 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
116 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
117 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
118 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
119 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
120
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
121 % D1
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{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
123 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
124
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
125 % Boundary operators
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
126 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
127 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
128 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
129 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
130
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
131 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
132 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
133 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
134 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
135
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
136 % D2
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
137 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
138 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
139 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
140 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
141 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
142
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
143 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
144 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
145 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
146
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
147 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
148 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
149 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
150 end
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 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
153 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
154 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
155
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
156 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
157 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
158 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
159 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
160
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
161 % Quadratures
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 = 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
163 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
164 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
165 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
166 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
167
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
168 % 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
169 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
170 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
171 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
172 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
173 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
174 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
175 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
176 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
177
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
178 % 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 );
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
190 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
191 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
192 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
193 );
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
195 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
196 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
197 %=========================================%
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
198
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
199 % 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
200 % 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
201 % 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
202 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
203 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
204 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
205 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
206 % 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
207
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
208 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
209 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
210 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
211 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
212 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
213
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
214 % 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
215 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
216 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
217 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
218 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
219 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
220
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
221 % 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
222 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
223 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
224 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
225 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
226 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
227 -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
228 -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
229 -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
230
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
231 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
232 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
233 +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
234 +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
235
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
236 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
237 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
238 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
239
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
240 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
241 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
242 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
243 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
244 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
245 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
246
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
247 % 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
248 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
249 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
250 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
251
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
252 % Misc.
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
253 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
254 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
255 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
256 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
257 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
258
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
259 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
260
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 % 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
263 % 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
264 % 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
265 % 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
266 % 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
267 % 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
268 % 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
269 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
270 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
271 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
272
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
273 % 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
274 % 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
275 % 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
276 % 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
277 [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
278 switch nj
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
279 case 1
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
280 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
281 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
282 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
283 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
284 case -1
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
285 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
286 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
287 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
288 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
289 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
290
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
291 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
292 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
293 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
294 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
295 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
296 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
297
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
298 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
299 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
300
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
301 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
302 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
303
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
304 % Preallocate
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
305 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
306 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
307 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
308 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
309 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
310
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
311 % 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
312 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
313 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
314
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
315 % 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
316 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
317
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
318 tuning = 1.2;
685
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
319 phi = obj.phi{j};
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 h = obj.h(j);
685
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
321 h11 = obj.H11{j}*h;
b035902869a8 Make scheme/elasticVariable work with different opSets in different dim to facilitate periodic in some dim.
Martin Almquist <malmquist@stanford.edu>
parents: 679
diff changeset
322 gamma = obj.gamma{j};
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 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
325 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
326 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
327
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
328 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
329 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
330 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
331 + 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
332 + 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
333
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
334 % 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
335 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
336 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
337 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
338 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
339 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
340 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
341 end
678
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 % 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
344 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
345 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
346 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
347
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348 % 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
349 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350 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
351 end
678
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
352 end
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
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
355 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
356 % 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
357 % 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
358 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
359 % 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
360 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
361 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
362
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
363 % 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
364 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
365
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
366 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
367 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
368 j = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
369 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
370 j = 2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
371 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
372 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
373 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
374
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
375 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
376 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
377 nj = -1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
378 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
379 nj = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
380 end
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
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
383 % 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
384 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
385
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
386 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
387 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
388 j = 1;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
389 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
390 j = 2;
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
391 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
392 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
393 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
394
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
395 switch op
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'
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
397 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
398 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
399 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
400 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
401 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
402 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
403 case 'd'
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
404 switch boundary
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
405 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
406 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
407 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
408 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
409 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
410 otherwise
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
411 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
412 end
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
413
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
06676c40e77f Add scheme for complete elastic operator. Traction BC working with MMS variable coefficient.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
416 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
417 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
418 end
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