annotate +scheme/Elastic2dVariableAnisotropic.m @ 1338:da61892884a4 feature/D2_boundary_opt

Add support for using periodic grids.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 13 May 2022 13:29:05 +0200
parents 8d9fc7981796
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
1 classdef Elastic2dVariableAnisotropic < scheme.Scheme
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
2
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
3 % Discretizes the elastic wave equation:
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4 % rho u_{i,tt} = dj C_{ijkl} dk u_j
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
5 % opSet should be cell array of opSets, one per dimension. This
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6 % is useful if we have periodic BC in one direction.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7 % Assumes fully compatible operators
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9 properties
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10 m % Number of points in each direction, possibly a vector
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11 h % Grid spacing
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13 grid
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
14 dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
15
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
16 order % Order of accuracy for the approximation
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
17
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
18 % Diagonal matrices for variable coefficients
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
19 RHO, RHOi, RHOi_kron % Density
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20 C % Elastic stiffness tensor
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
21
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22 D % Total operator
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23 D1 % First derivatives
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
24 % D2 % Second derivatives
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26 % Boundary operators in cell format, used for BC
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 T_w, T_e, T_s, T_n
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29 % Traction operators
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
30 tau_w, tau_e, tau_s, tau_n % Return vector field
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
31 tau1_w, tau1_e, tau1_s, tau1_n % Return scalar field
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
32 tau2_w, tau2_e, tau2_s, tau2_n % Return scalar field
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34 % Inner products
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
35 H, Hi, Hi_kron, H_1D
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
36
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
37 % Boundary inner products (for scalar field)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
38 H_w, H_e, H_s, H_n
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
39
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
40 % Boundary restriction operators
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
41 e_w, e_e, e_s, e_n % Act on vector field, return vector field at boundary
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
42 e1_w, e1_e, e1_s, e1_n % Act on vector field, return scalar field at boundary
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
43 e2_w, e2_e, e2_s, e2_n % Act on vector field, return scalar field at boundary
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
44 e_scalar_w, e_scalar_e, e_scalar_s, e_scalar_n; % Act on scalar field, return scalar field
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
45
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
46 % E{i}^T picks out component i
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
47 E
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
48
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
49 % Borrowing constants of the form gamma*h, where gamma is a dimensionless constant.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
50 h11 % First entry in norm matrix
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
51
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
52 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
53
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
54 methods
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
55
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
56 % The coefficients can either be function handles or grid functions
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
57 % optFlag -- if true, extra computations are performed, which may be helpful for optimization.
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
58 function obj = Elastic2dVariableAnisotropic(g, order, rho, C, opSet, optFlag, hollow)
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
59 default_arg('hollow', false);
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
60 default_arg('rho', @(x,y) 0*x+1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
61 default_arg('opSet',{@sbp.D2VariableCompatible, @sbp.D2VariableCompatible});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
62 default_arg('optFlag', false);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
63 dim = 2;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
64
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
65 C_default = cell(dim,dim,dim,dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
66 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67 for j = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
68 for k = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
69 for l = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
70 C_default{i,j,k,l} = @(x,y) 0*x + 1;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
71 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
72 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
73 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
74 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
75 default_arg('C', C_default);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
76 assert(isa(g, 'grid.Cartesian'))
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
77
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
78 if isa(rho, 'function_handle')
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
79 rho = grid.evalOn(g, rho);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
80 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
81
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
82 C_mat = cell(dim,dim,dim,dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
83 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
84 for j = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
85 for k = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
86 for l = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
87 if isa(C{i,j,k,l}, 'function_handle')
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
88 C{i,j,k,l} = grid.evalOn(g, C{i,j,k,l});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
89 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
90 C_mat{i,j,k,l} = spdiag(C{i,j,k,l});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
91 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
92 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
93 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
94 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
95 obj.C = C_mat;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
96
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
97 m = g.size();
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
98 m_tot = g.N();
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
99 lim = g.lim;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
100 if isempty(lim)
1338
da61892884a4 Add support for using periodic grids.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1335
diff changeset
101 % TODO: Work for periodic grids (last gp not included)!
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
102 x = g.x;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
103 lim = cell(length(x),1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
104 for i = 1:length(x)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
105 lim{i} = {min(x{i}), max(x{i})};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
106 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
107 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
108
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
109 % 1D operators
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
110 ops = cell(dim,1);
1303
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
111 opsHollow = cell(dim,1);
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
112 h = zeros(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
113 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
114 ops{i} = opSet{i}(m(i), lim{i}, order);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
115 h(i) = ops{i}.h;
1303
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
116 if hollow
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
117 opsHollow{i} = sbp.D2VariableCompatibleHollow(m(i), lim{i}, order);
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
118 end
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
119 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
120
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
121 % Borrowing constants
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
122 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
123 obj.h11{i} = h(i)*ops{i}.borrowing.H11;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
124 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
125
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
126 I = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
127 D1 = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
128 D2 = cell(dim,1);
1303
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
129 D2Hollow = cell(dim,1);
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
130 H = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
131 Hi = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
132 e_0 = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
133 e_m = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
134 d1_0 = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
135 d1_m = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
136
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
137 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
138 I{i} = speye(m(i));
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
139 D1{i} = ops{i}.D1;
1303
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
140 if hollow
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
141 D2Hollow{i} = opsHollow{i}.D2;
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
142 end
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
143 D2{i} = ops{i}.D2;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
144 H{i} = ops{i}.H;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
145 Hi{i} = ops{i}.HI;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
146 e_0{i} = ops{i}.e_l;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
147 e_m{i} = ops{i}.e_r;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
148 d1_0{i} = ops{i}.d1_l;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
149 d1_m{i} = ops{i}.d1_r;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
150 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
151
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
152 %====== Assemble full operators ========
1206
6b203030fb37 Fix performance (full matrices) issues in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
153 I_dim = speye(dim, dim);
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
154 RHO = spdiag(rho);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
155 obj.RHO = RHO;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
156 obj.RHOi = inv(RHO);
1206
6b203030fb37 Fix performance (full matrices) issues in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
157 obj.RHOi_kron = kron(obj.RHOi, I_dim);
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
158
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
159 obj.D1 = cell(dim,1);
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
160 D2_temp = cell(dim,dim,dim);
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
161
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
162 % D1
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
163 obj.D1{1} = kron(D1{1},I{2});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
164 obj.D1{2} = kron(I{1},D1{2});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
165
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
166 % Boundary restriction operators
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
167 e_l = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
168 e_r = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
169 e_l{1} = kron(e_0{1}, I{2});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
170 e_l{2} = kron(I{1}, e_0{2});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
171 e_r{1} = kron(e_m{1}, I{2});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
172 e_r{2} = kron(I{1}, e_m{2});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
173
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
174 e_scalar_w = e_l{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
175 e_scalar_e = e_r{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
176 e_scalar_s = e_l{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
177 e_scalar_n = e_r{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
178
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
179 e_w = kron(e_scalar_w, I_dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
180 e_e = kron(e_scalar_e, I_dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
181 e_s = kron(e_scalar_s, I_dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
182 e_n = kron(e_scalar_n, I_dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
183
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
184 % E{i}^T picks out component i.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
185 E = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
186 I = speye(m_tot,m_tot);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
188 e = sparse(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189 e(i) = 1;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
190 E{i} = kron(I,e);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
191 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
192 obj.E = E;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
193
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194 e1_w = (e_scalar_w'*E{1}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
195 e1_e = (e_scalar_e'*E{1}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
196 e1_s = (e_scalar_s'*E{1}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
197 e1_n = (e_scalar_n'*E{1}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
198
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
199 e2_w = (e_scalar_w'*E{2}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
200 e2_e = (e_scalar_e'*E{2}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201 e2_s = (e_scalar_s'*E{2}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
202 e2_n = (e_scalar_n'*E{2}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
203
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
205 % D2
1335
8d9fc7981796 Calculate width for all orders
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1304
diff changeset
206 width = order+1;
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
207 switch order
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
208 case 2
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
209 nBP = 2;
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
210 case 4
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
211 nBP = 6;
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
212 case 6
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
213 nBP = 9;
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
214 end
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
215 for j = 1:dim
1206
6b203030fb37 Fix performance (full matrices) issues in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
216 for k = 1:dim
6b203030fb37 Fix performance (full matrices) issues in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
217 for l = 1:dim
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
218 if hollow
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
219 D2_temp{j,k,l} = sparse(m_tot, m_tot);
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
220 else
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
221 D2_temp{j,k,l} = spalloc(m_tot, m_tot, width*m_tot);
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
222 end
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
223 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
224 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
225 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
226 ind = grid.funcToMatrix(g, 1:m_tot);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
227
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
228 k = 1;
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
229 if hollow
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
230 mask = sparse(m(1), m(1));
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
231 mask(1:nBP, 1:nBP) = speye(nBP, nBP);
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
232 mask(end-nBP+1:end, end-nBP+1:end) = speye(nBP, nBP);
1304
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
233 maskXSmall = kron(mask, speye(m(2), m(2)));
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
234 maskX = E{1}*maskXSmall*E{1}' + E{2}*maskXSmall*E{2}';
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
235 end
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
236 for r = 1:m(2)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
237 p = ind(:,r);
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
238 for j = 1:dim
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
239 for l = 1:dim
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
240 coeff = C{k,j,k,l};
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
241 if hollow && r > nBP && r < m(2) - nBP + 1
1303
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
242 D_kk = D2Hollow{1}(coeff(p));
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
243 else
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
244 D_kk = D2{1}(coeff(p));
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
245 end
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
246 D2_temp{j,k,l}(p,p) = D_kk;
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
247 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
248 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
249 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
250
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
251 k = 2;
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
252 if hollow
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
253 mask = sparse(m(2), m(2));
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
254 mask(1:nBP, 1:nBP) = speye(nBP, nBP);
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
255 mask(end-nBP+1:end, end-nBP+1:end) = speye(nBP, nBP);
1304
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
256 maskYSmall = kron(speye(m(1), m(1)), mask);
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
257
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
258 maskY = E{1}*maskYSmall*E{1}' + E{2}*maskYSmall*E{2}';
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
259 mask = maskX + maskY;
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
260 mask = mask>0;
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
261
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
262 maskSmall = maskXSmall + maskYSmall;
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
263 maskSmall = maskSmall>0;
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
264 end
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
265 for r = 1:m(1)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
266 p = ind(r,:);
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
267 for j = 1:dim
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
268 for l = 1:dim
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
269 coeff = C{k,j,k,l};
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
270 if hollow && r > nBP && r < m(1) - nBP + 1
1303
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
271 D_kk = D2Hollow{2}(coeff(p));
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
272 else
49e3870335ef Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents: 1302
diff changeset
273 D_kk = D2{2}(coeff(p));
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
274 end
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
275 D2_temp{j,k,l}(p,p) = D_kk;
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
276 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
277 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
278 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
279
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
280 % Quadratures
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
281 obj.H = kron(H{1},H{2});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
282 obj.Hi = inv(obj.H);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
283 obj.H_w = H{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
284 obj.H_e = H{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
285 obj.H_s = H{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
286 obj.H_n = H{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
287 obj.H_1D = {H{1}, H{2}};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
288
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
289 % Differentiation matrix D (without SAT)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
290 D1 = obj.D1;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
291 D = sparse(dim*m_tot,dim*m_tot);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
292 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
293 for j = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
294 for k = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
295 for l = 1:dim
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
296 if i == k
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
297 D = D + E{j}*D2_temp{j,k,l}*E{l}';
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
298 D2_temp{j,k,l} = [];
1206
6b203030fb37 Fix performance (full matrices) issues in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
299 else
1304
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
300 if hollow
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
301 D = D + E{j}*(maskSmall*D1{i})*C_mat{i,j,k,l}*D1{k}*E{l}';
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
302 else
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
303 D = D + E{j}*(D1{i})*C_mat{i,j,k,l}*D1{k}*E{l}';
a38e80fdbf60 Improve performance for the hollow case
Martin Almquist <malmquist@stanford.edu>
parents: 1303
diff changeset
304 end
1206
6b203030fb37 Fix performance (full matrices) issues in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
305 end
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
306 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
307 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
308 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
309 end
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
310 clear D2_temp;
1302
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
311 if hollow
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
312 mask = maskX + maskY;
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
313 mask = mask>0;
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
314 D = mask*D;
a0d615bde7f8 Add the hollow option to the anisotropic diffops
Martin Almquist <malmquist@stanford.edu>
parents: 1260
diff changeset
315 end
1206
6b203030fb37 Fix performance (full matrices) issues in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
316 D = obj.RHOi_kron*D;
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
317 obj.D = D;
1253
89dad61cad22 Make Elastic2dVariable faster and more memory efficient
Martin Almquist <malmquist@stanford.edu>
parents: 1252
diff changeset
318 clear D;
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
319 %=========================================%'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
320
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
321 % Numerical traction operators for BC.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
322 %
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
323 % Formula at boundary j: % tau^{j}_i = sum_l T^{j}_{il} u_l
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
324 %
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
325 T_l = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326 T_r = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
327 tau_l = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
328 tau_r = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
330 D1 = obj.D1;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
331
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332 % Boundary j
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
333 for j = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
334 T_l{j} = cell(dim,dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
335 T_r{j} = cell(dim,dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336 tau_l{j} = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
337 tau_r{j} = cell(dim,1);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
339 [~, n_l] = size(e_l{j});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
340 [~, n_r] = size(e_r{j});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
341
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
342 % Traction component i
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
343 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
344 tau_l{j}{i} = sparse(dim*m_tot, n_l);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
345 tau_r{j}{i} = sparse(dim*m_tot, n_r);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
347 % Displacement component l
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348 for l = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
349 T_l{j}{i,l} = sparse(m_tot, n_l);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350 T_r{j}{i,l} = sparse(m_tot, n_r);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
351
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
352 % Derivative direction k
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
353 for k = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
354 T_l{j}{i,l} = T_l{j}{i,l} ...
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
355 - (e_l{j}'*C_mat{j,i,k,l}*D1{k})';
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
356 T_r{j}{i,l} = T_r{j}{i,l} ...
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
357 + (e_r{j}'*C_mat{j,i,k,l}*D1{k})';
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
358 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
359 tau_l{j}{i} = tau_l{j}{i} + (T_l{j}{i,l}'*E{l}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
360 tau_r{j}{i} = tau_r{j}{i} + (T_r{j}{i,l}'*E{l}')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
361 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
362 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
363 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
364
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
365 % Traction tensors, T_ij
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
366 obj.T_w = T_l{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
367 obj.T_e = T_r{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
368 obj.T_s = T_l{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
369 obj.T_n = T_r{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
370
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
371 % Restriction operators
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
372 obj.e_w = e_w;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
373 obj.e_e = e_e;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
374 obj.e_s = e_s;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
375 obj.e_n = e_n;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
376
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
377 obj.e1_w = e1_w;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
378 obj.e1_e = e1_e;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
379 obj.e1_s = e1_s;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
380 obj.e1_n = e1_n;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
381
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
382 obj.e2_w = e2_w;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
383 obj.e2_e = e2_e;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
384 obj.e2_s = e2_s;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
385 obj.e2_n = e2_n;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
386
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
387 obj.e_scalar_w = e_scalar_w;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
388 obj.e_scalar_e = e_scalar_e;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
389 obj.e_scalar_s = e_scalar_s;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
390 obj.e_scalar_n = e_scalar_n;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
391
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
392 % First component of traction
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
393 obj.tau1_w = tau_l{1}{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
394 obj.tau1_e = tau_r{1}{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
395 obj.tau1_s = tau_l{2}{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
396 obj.tau1_n = tau_r{2}{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
397
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
398 % Second component of traction
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
399 obj.tau2_w = tau_l{1}{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
400 obj.tau2_e = tau_r{1}{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
401 obj.tau2_s = tau_l{2}{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
402 obj.tau2_n = tau_r{2}{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
403
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
404 % Traction vectors
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
405 obj.tau_w = (e_w'*e1_w*obj.tau1_w')' + (e_w'*e2_w*obj.tau2_w')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
406 obj.tau_e = (e_e'*e1_e*obj.tau1_e')' + (e_e'*e2_e*obj.tau2_e')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
407 obj.tau_s = (e_s'*e1_s*obj.tau1_s')' + (e_s'*e2_s*obj.tau2_s')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
408 obj.tau_n = (e_n'*e1_n*obj.tau1_n')' + (e_n'*e2_n*obj.tau2_n')';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
409
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
410 % Kroneckered norms and coefficients
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
411 obj.Hi_kron = kron(obj.Hi, I_dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
412
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
413 % Misc.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
414 obj.m = m;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
415 obj.h = h;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
416 obj.order = order;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
417 obj.grid = g;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
418 obj.dim = dim;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
419
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
420 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
421
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
422
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
423 % Closure functions return the operators applied to the own domain to close the boundary
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
424 % Penalty functions return the operators to force the solution. In the case of an interface it returns the operator applied to the other doamin.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
425 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
426 % bc is a cell array of component and bc type, e.g. {1, 'd'} for Dirichlet condition
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
427 % on the first component. Can also be e.g.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
428 % {'normal', 'd'} or {'tangential', 't'} for conditions on
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
429 % tangential/normal component.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
430 % data is a function returning the data that should be applied at the boundary.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
431 % neighbour_scheme is an instance of Scheme that should be interfaced to.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
432 % neighbour_boundary is a string specifying which boundary to interface to.
1203
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
433
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
434 % For displacement bc:
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
435 % bc = {comp, 'd', dComps},
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
436 % where
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
437 % dComps = vector of components with displacement BC. Default: 1:dim.
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
438 % In this way, we can specify one BC at a time even though the SATs depend on all BC.
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
439 function [closure, penalty] = boundary_condition(obj, boundary, bc, tuning)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
440 default_arg('tuning', 1.0);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
441
1202
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
442 assert( iscell(bc), 'The BC type must be a 2x1 or 3x1 cell array' );
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
443 comp = bc{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
444 type = bc{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
445 if ischar(comp)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
446 comp = obj.getComponent(comp, boundary);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
447 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
448
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
449 e = obj.getBoundaryOperatorForScalarField('e', boundary);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
450 tau = obj.getBoundaryOperator(['tau' num2str(comp)], boundary);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
451 T = obj.getBoundaryTractionOperator(boundary);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
452 h11 = obj.getBorrowing(boundary);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
453 H_gamma = obj.getBoundaryQuadratureForScalarField(boundary);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
454 nu = obj.getNormal(boundary);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
455
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
456 E = obj.E;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
457 Hi = obj.Hi;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
458 RHOi = obj.RHOi;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
459 C = obj.C;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
460
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
461 dim = obj.dim;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
462 m_tot = obj.grid.N();
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
463
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
464 % Preallocate
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
465 [~, col] = size(tau);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
466 closure = sparse(dim*m_tot, dim*m_tot);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
467 penalty = sparse(dim*m_tot, col);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
468
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
469 j = comp;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
470 switch type
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
471
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
472 % Dirichlet boundary condition
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
473 case {'D','d','dirichlet','Dirichlet','displacement','Displacement'}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
474
1202
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
475 if numel(bc) >= 3
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
476 dComps = bc{3};
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
477 else
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
478 dComps = 1:dim;
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
479 end
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
480
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
481 % Loops over components that Dirichlet penalties end up on
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
482 % Y: symmetrizing part of penalty
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
483 % Z: symmetric part of penalty
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
484 % X = Y + Z.
1202
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
485
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
486 % Nonsymmetric part goes on all components to
1203
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
487 % yield traction in discrete energy rate
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
488 for i = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
489 Y = T{j,i}';
1202
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
490 X = e*Y;
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
491 closure = closure + E{i}*RHOi*Hi*X'*e*H_gamma*(e'*E{j}' );
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
492 penalty = penalty - E{i}*RHOi*Hi*X'*e*H_gamma;
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
493 end
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
494
1203
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
495 % Symmetric part only required on components with displacement BC.
25cadc69a589 Update comments in Anisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1202
diff changeset
496 % (Otherwise it's not symmetric.)
1202
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
497 for i = dComps
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
498 Z = sparse(m_tot, m_tot);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
499 for l = 1:dim
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
500 for k = 1:dim
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
501 Z = Z + nu(l)*C{l,i,k,j}*nu(k);
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
502 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
503 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
504 Z = -tuning*dim/h11*Z;
1202
31d7288d0653 Make Anisotropic work for mixed displacement/traction BC at the same boundary.
Martin Almquist <malmquist@stanford.edu>
parents: 1201
diff changeset
505 X = Z;
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
506 closure = closure + E{i}*RHOi*Hi*X'*e*H_gamma*(e'*E{j}' );
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
507 penalty = penalty - E{i}*RHOi*Hi*X'*e*H_gamma;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
508 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
509
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
510 % Free boundary condition
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
511 case {'F','f','Free','free','traction','Traction','t','T'}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
512 closure = closure - E{j}*RHOi*Hi*e*H_gamma*tau';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
513 penalty = penalty + E{j}*RHOi*Hi*e*H_gamma;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
514
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
515 % Unknown boundary condition
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
516 otherwise
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
517 error('No such boundary condition: type = %s',type);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
518 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
519 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
520
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
521 % type Struct that specifies the interface coupling.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
522 % Fields:
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
523 % -- tuning: penalty strength, defaults to 1.0
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
524 % -- interpolation: type of interpolation, default 'none'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
525 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary,type)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
526
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
527 defaultType.tuning = 1.0;
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
528 defaultType.interpolation = 'none';
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
529 default_struct('type', defaultType);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
530
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
531 switch type.interpolation
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
532 case {'none', ''}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
533 [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
534 case {'op','OP'}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
535 [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
536 otherwise
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
537 error('Unknown type of interpolation: %s ', type.interpolation);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
538 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
539 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
540
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
541 function [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
542 tuning = type.tuning;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
543
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
544 % u denotes the solution in the own domain
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
545 % v denotes the solution in the neighbour domain
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
546
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
547 u = obj;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
548 v = neighbour_scheme;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
549
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
550 % Operators, u side
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
551 e_u = u.getBoundaryOperatorForScalarField('e', boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
552 tau_u = u.getBoundaryOperator('tau', boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
553 h11_u = u.getBorrowing(boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
554 nu_u = u.getNormal(boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
555
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
556 E_u = u.E;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
557 C_u = u.C;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
558 m_tot_u = u.grid.N();
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
559
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
560 % Operators, v side
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
561 e_v = v.getBoundaryOperatorForScalarField('e', neighbour_boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
562 tau_v = v.getBoundaryOperator('tau', neighbour_boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
563 h11_v = v.getBorrowing(neighbour_boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
564 nu_v = v.getNormal(neighbour_boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
565
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
566 E_v = v.E;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
567 C_v = v.C;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
568 m_tot_v = v.grid.N();
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
569
1252
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
570 % Fix {'e', 's'}, {'w', 'n'}, and {'x','x'} couplings
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
571 flipFlag = false;
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
572 e_v_flip = e_v;
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
573 if (strcmp(boundary,'s') && strcmp(neighbour_boundary,'e')) || ...
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
574 (strcmp(boundary,'e') && strcmp(neighbour_boundary,'s')) || ...
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
575 (strcmp(boundary,'w') && strcmp(neighbour_boundary,'n')) || ...
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
576 (strcmp(boundary,'n') && strcmp(neighbour_boundary,'w')) || ...
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
577 (strcmp(boundary,'s') && strcmp(neighbour_boundary,'s')) || ...
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
578 (strcmp(boundary,'n') && strcmp(neighbour_boundary,'n')) || ...
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
579 (strcmp(boundary,'w') && strcmp(neighbour_boundary,'w')) || ...
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
580 (strcmp(boundary,'e') && strcmp(neighbour_boundary,'e'))
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
581
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
582 flipFlag = true;
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
583 e_v_flip = fliplr(e_v);
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
584
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
585 t1 = tau_v(:,1:2:end-1);
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
586 t2 = tau_v(:,2:2:end);
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
587
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
588 t1 = fliplr(t1);
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
589 t2 = fliplr(t2);
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
590
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
591 tau_v(:,1:2:end-1) = t1;
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
592 tau_v(:,2:2:end) = t2;
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
593 end
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
594
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
595 % Operators that are only required for own domain
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
596 Hi = u.Hi_kron;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
597 RHOi = u.RHOi_kron;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
598 e_kron = u.getBoundaryOperator('e', boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
599 T_u = u.getBoundaryTractionOperator(boundary);
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
600
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
601 % Shared operators
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
602 H_gamma = u.getBoundaryQuadratureForScalarField(boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
603 H_gamma_kron = u.getBoundaryQuadrature(boundary);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
604 dim = u.dim;
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
605
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
606 % Preallocate
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
607 [~, m_int] = size(H_gamma);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
608 closure = sparse(dim*m_tot_u, dim*m_tot_u);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
609 penalty = sparse(dim*m_tot_u, dim*m_tot_v);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
610
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
611 % ---- Continuity of displacement ------
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
612
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
613 % Y: symmetrizing part of penalty
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
614 % Z: symmetric part of penalty
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
615 % X = Y + Z.
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
616
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
617 % Loop over components to couple across interface
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
618 for j = 1:dim
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
619
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
620 % Loop over components that penalties end up on
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
621 for i = 1:dim
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
622 Y = 1/2*T_u{j,i}';
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
623 Z_u = sparse(m_int, m_int);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
624 Z_v = sparse(m_int, m_int);
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
625 for l = 1:dim
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
626 for k = 1:dim
1207
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
627 Z_u = Z_u + e_u'*nu_u(l)*C_u{l,i,k,j}*nu_u(k)*e_u;
05a01f77d0e3 Swap indices and fix bug in ElasticVariableAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents: 1204
diff changeset
628 Z_v = Z_v + e_v'*nu_v(l)*C_v{l,i,k,j}*nu_v(k)*e_v;
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
629 end
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
630 end
1252
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
631
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
632 if flipFlag
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
633 Z_v = rot90(Z_v,2);
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
634 end
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
635
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
636 Z = -tuning*dim*( 1/(4*h11_u)*Z_u + 1/(4*h11_v)*Z_v );
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
637 X = Y + Z*e_u';
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
638 closure = closure + E_u{i}*X'*H_gamma*e_u'*E_u{j}';
1252
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
639 penalty = penalty - E_u{i}*X'*H_gamma*e_v_flip'*E_v{j}';
8fc2f9a4c882 Add (temporary) fix for e-s , w-n, and x-x couplings
Martin Almquist <malmquist@stanford.edu>
parents: 1208
diff changeset
640
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
641 end
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
642 end
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
643
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
644 % ---- Continuity of traction ------
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
645 closure = closure - 1/2*e_kron*H_gamma_kron*tau_u';
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
646 penalty = penalty - 1/2*e_kron*H_gamma_kron*tau_v';
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
647
1204
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
648 % ---- Multiply by inverse of density x quadraure ----
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
649 closure = RHOi*Hi*closure;
687515778437 Add anisotropic interface
Martin Almquist <malmquist@stanford.edu>
parents: 1203
diff changeset
650 penalty = RHOi*Hi*penalty;
1201
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
651
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
652 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
653
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
654 function [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
655 error('Non-conforming interfaces not implemented yet.');
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
656 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
657
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
658 % Returns the component number that is the tangential/normal component
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
659 % at the specified boundary
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
660 function comp = getComponent(obj, comp_str, boundary)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
661 assertIsMember(comp_str, {'normal', 'tangential'});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
662 assertIsMember(boundary, {'w', 'e', 's', 'n'});
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
663
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
664 switch boundary
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
665 case {'w', 'e'}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
666 switch comp_str
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
667 case 'normal'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
668 comp = 1;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
669 case 'tangential'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
670 comp = 2;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
671 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
672 case {'s', 'n'}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
673 switch comp_str
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
674 case 'normal'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
675 comp = 2;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
676 case 'tangential'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
677 comp = 1;
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
678 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
679 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
680 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
681
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
682 % Returns h11 for the boundary specified by the string boundary.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
683 % op -- string
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
684 function h11 = getBorrowing(obj, boundary)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
685 assertIsMember(boundary, {'w', 'e', 's', 'n'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
686
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
687 switch boundary
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
688 case {'w','e'}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
689 h11 = obj.h11{1};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
690 case {'s', 'n'}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
691 h11 = obj.h11{2};
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
692 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
693 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
694
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
695 % Returns the outward unit normal vector for the boundary specified by the string boundary.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
696 function nu = getNormal(obj, boundary)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
697 assertIsMember(boundary, {'w', 'e', 's', 'n'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
698
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
699 switch boundary
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
700 case 'w'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
701 nu = [-1,0];
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
702 case 'e'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
703 nu = [1,0];
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
704 case 's'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
705 nu = [0,-1];
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
706 case 'n'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
707 nu = [0,1];
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
708 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
709 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
710
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
711 % Returns the boundary operator op for the boundary specified by the string boundary.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
712 % op -- string
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
713 function o = getBoundaryOperator(obj, op, boundary)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
714 assertIsMember(boundary, {'w', 'e', 's', 'n'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
715 assertIsMember(op, {'e', 'e1', 'e2', 'tau', 'tau1', 'tau2'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
716
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
717 switch op
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
718 case {'e', 'e1', 'e2', 'tau', 'tau1', 'tau2'}
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
719 o = obj.([op, '_', boundary]);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
720 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
721
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
722 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
723
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
724 % Returns the boundary operator op for the boundary specified by the string boundary.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
725 % op -- string
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
726 function o = getBoundaryOperatorForScalarField(obj, op, boundary)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
727 assertIsMember(boundary, {'w', 'e', 's', 'n'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
728 assertIsMember(op, {'e'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
729
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
730 switch op
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
731
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
732 case 'e'
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
733 o = obj.(['e_scalar', '_', boundary]);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
734 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
735
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
736 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
737
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
738 % Returns the boundary operator T_ij (cell format) for the boundary specified by the string boundary.
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
739 % Formula: tau_i = T_ij u_j
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
740 % op -- string
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
741 function T = getBoundaryTractionOperator(obj, boundary)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
742 assertIsMember(boundary, {'w', 'e', 's', 'n'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
743
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
744 T = obj.(['T', '_', boundary]);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
745 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
746
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
747 % Returns square boundary quadrature matrix, of dimension
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
748 % corresponding to the number of boundary unknowns
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
749 %
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
750 % boundary -- string
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
751 function H = getBoundaryQuadrature(obj, boundary)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
752 assertIsMember(boundary, {'w', 'e', 's', 'n'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
753
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
754 H = obj.getBoundaryQuadratureForScalarField(boundary);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
755 I_dim = speye(obj.dim, obj.dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
756 H = kron(H, I_dim);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
757 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
758
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
759 % Returns square boundary quadrature matrix, of dimension
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
760 % corresponding to the number of boundary grid points
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
761 %
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
762 % boundary -- string
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
763 function H_b = getBoundaryQuadratureForScalarField(obj, boundary)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
764 assertIsMember(boundary, {'w', 'e', 's', 'n'})
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
765
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
766 H_b = obj.(['H_', boundary]);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
767 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
768
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
769 function N = size(obj)
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
770 N = obj.dim*prod(obj.m);
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
771 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
772 end
8f4e79aa32ba Add fully compatible D2Variable opSet and first implementation of ElasticAnisotropic
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
773 end