Mercurial > repos > public > sbplib
comparison +scheme/Elastic2dVariable.m @ 965:db3411264b96 feature/poroelastic
Remove use of tensor library in B assembly
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Sat, 22 Dec 2018 16:41:17 +0100 |
parents | c75ddd568fcc |
children | 4a85cff53107 |
comparison
equal
deleted
inserted
replaced
964:99c2ef883dc6 | 965:db3411264b96 |
---|---|
307 obj.h = h; | 307 obj.h = h; |
308 obj.order = order; | 308 obj.order = order; |
309 obj.grid = g; | 309 obj.grid = g; |
310 obj.dim = dim; | 310 obj.dim = dim; |
311 | 311 |
312 % Used for adjoint optimization | 312 % B, used for adjoint optimization |
313 obj.B = cell(1,dim); | 313 B = cell(dim, 1); |
314 for i = 1:dim | 314 for i = 1:dim |
315 obj.B{i} = zeros(m(i),m(i),m(i)); | 315 B{i} = cell(m_tot, 1); |
316 for k = 1:m(i) | 316 end |
317 c = sparse(m(i),1); | 317 |
318 c(k) = 1; | 318 for i = 1:dim |
319 [~, obj.B{i}(:,:,k)] = ops{i}.D2(c); | 319 for j = 1:m_tot |
320 end | 320 B{i}{j} = sparse(m_tot, m_tot); |
321 end | 321 end |
322 end | |
323 | |
324 ind = grid.funcToMatrix(g, 1:m_tot); | |
325 | |
326 % Direction 1 | |
327 for k = 1:m(1) | |
328 c = sparse(m(1),1); | |
329 c(k) = 1; | |
330 [~, B_1D] = ops{1}.D2(c); | |
331 for l = 1:m(2) | |
332 p = ind(:,l); | |
333 B{1}{(k-1)*m(2) + l}(p, p) = B_1D; | |
334 end | |
335 end | |
336 | |
337 % Direction 2 | |
338 for k = 1:m(2) | |
339 c = sparse(m(2),1); | |
340 c(k) = 1; | |
341 [~, B_1D] = ops{2}.D2(c); | |
342 for l = 1:m(1) | |
343 p = ind(l,:); | |
344 B{2}{(l-1)*m(2) + k}(p, p) = B_1D; | |
345 end | |
346 end | |
347 | |
348 obj.B = B; | |
322 | 349 |
323 end | 350 end |
324 | 351 |
325 | 352 |
326 % Closure functions return the operators applied to the own domain to close the boundary | 353 % Closure functions return the operators applied to the own domain to close the boundary |