annotate +scheme/elasticShearVariable.m @ 669:17e62551cdc2 feature/poroelastic

Add Dirichlet condition. Symmetric, semi-definite matrix and MMS convergence working with variable coeff!
author Martin Almquist <malmquist@stanford.edu>
date Fri, 22 Dec 2017 14:16:17 +0100
parents ed853945ee99
children 9e1d2351f539
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
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
11 A % Variable coefficient lambda of the operator (as diagonal matrix here)
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
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34 % where a = lambda.
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.
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189 % 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
190 % 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
191 % 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
192 % 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
193 % 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
194 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
195 default_arg('type','free');
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
196 default_arg('parameter', []);
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
197
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
198 delta = @kroneckerDelta; % Kronecker delta
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
199 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
200
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201 % 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
202 % nj: outward unit normal component.
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
203 % 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
204 % 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
205 [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
206 switch nj
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
207 case 1
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
208 e = obj.e_r;
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
209 d = obj.d1_r;
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
210 case -1
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
211 e = obj.e_l;
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
212 d = obj.d1_l;
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
213 end
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
214
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
215 E = obj.E;
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
216 Hi = obj.Hi;
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
217 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
218 A = obj.A;
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
219 RHO = obj.RHO;
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
220 D1 = obj.D1;
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
221
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
222 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
223 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
224 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
225 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
226
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
227 switch type
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
228 % Dirichlet boundary condition
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
229 case {'D','d','dirichlet'}
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
230 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
231 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
232
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 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
234 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
235 % 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
236 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
237 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
238 sigma_ij = tuning*delta(i,j)*2/(gamma*h(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
239 tuning*delta_b(i,j)*(2/(H11*h(j)) + 2/(H11*h(j)*phi));
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
240
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
241 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
242 ( (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
243 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
244 ) ...
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 - 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
246
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 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
248 ( 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
249 );
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 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
252 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
253 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
254 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
255 end
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
256
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
257 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
258 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
259 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
260 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
261 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
262
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 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
264 ( (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
265 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
266 ) ...
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 + 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
268
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 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
270 ( 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
271
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 % 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
273 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
274 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
275
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 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
277 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
278 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
279 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
280 end
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
281
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
282 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
283 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
284 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
285 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
286 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
287
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 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
289 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
290 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
291 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
292 end
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
293
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
294 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
295 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
296 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
297 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
298 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
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 [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
301 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
302 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
303 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
304 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
305 penalty = penalties;
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
306
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
307 % Free boundary condition
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
308 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
309 closures = cell(obj.dim,1);
ed853945ee99 Make free BC work with data. Bugfix domain size.
Martin Almquist <malmquist@stanford.edu>
parents: 664
diff changeset
310 penalties = cell(obj.dim,1);
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
311 % Loop over components
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
312 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
313 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
314 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
315 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
316 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
317 );
667
ed853945ee99 Make free BC work with data. Bugfix domain size.
Martin Almquist <malmquist@stanford.edu>
parents: 664
diff changeset
318 penalties{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
319 end
667
ed853945ee99 Make free BC work with data. Bugfix domain size.
Martin Almquist <malmquist@stanford.edu>
parents: 664
diff changeset
320 [rows, cols] = size(closures{1});
ed853945ee99 Make free BC work with data. Bugfix domain size.
Martin Almquist <malmquist@stanford.edu>
parents: 664
diff changeset
321 closure = sparse(rows, cols);
ed853945ee99 Make free BC work with data. Bugfix domain size.
Martin Almquist <malmquist@stanford.edu>
parents: 664
diff changeset
322 for i = 1:obj.dim
ed853945ee99 Make free BC work with data. Bugfix domain size.
Martin Almquist <malmquist@stanford.edu>
parents: 664
diff changeset
323 closure = closure + closures{i};
ed853945ee99 Make free BC work with data. Bugfix domain size.
Martin Almquist <malmquist@stanford.edu>
parents: 664
diff changeset
324 end
ed853945ee99 Make free BC work with data. Bugfix domain size.
Martin Almquist <malmquist@stanford.edu>
parents: 664
diff changeset
325 penalty = penalties;
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
327
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
328 % Unknown boundary condition
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329 otherwise
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
330 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
331 end
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332 end
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
333
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
334 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
335 % 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
336 % 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
337 tuning = 1.2;
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338 % tuning = 20.2;
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
339 error('Interface not implemented');
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
340 end
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
341
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
342 % 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
343 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
344
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
345 switch boundary
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346 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
347 j = 1;
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348 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
349 j = 2;
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350 otherwise
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
351 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
352 end
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
353
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
354 switch boundary
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
355 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
356 nj = -1;
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
357 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
358 nj = 1;
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 end
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
361
664
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
362 % 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
363 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
364
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
365 switch boundary
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
366 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
367 j = 1;
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
368 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
369 j = 2;
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
370 otherwise
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
371 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
372 end
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
373
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
374 switch op
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
375 case 'e'
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
376 switch boundary
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
377 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
378 return_op = obj.e_l{j};
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
379 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
380 return_op = obj.e_r{j};
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
381 end
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
382 case 'd'
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.d_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.d_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 otherwise
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
390 error(['No such operator: operatr = ' op]);
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
391 end
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
392
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
393 end
8e6dfd22fc59 Free BC now yields symmetric negative semidefinite discretization.
Martin Almquist <malmquist@stanford.edu>
parents: 663
diff changeset
394
663
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
395 function N = size(obj)
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
396 N = prod(obj.m);
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
397 end
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
398 end
b45ec2b28cc2 First implementation of elastic shear operator with free boundary BC.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
399 end