annotate +scheme/elasticShearVariable.m @ 677:eeaf9a00e304 feature/poroelastic

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