Mercurial > repos > public > sbplib
changeset 860:b758d1cf4c8e feature/poroelastic
Add computation of HI*M to D2Variable to make adjoint gradient computation easier.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Wed, 24 Oct 2018 16:16:43 -0700 |
parents | 4c7532db42cd |
children | 607c631f175e |
files | +sbp/+implementations/d2_variable_2.m +sbp/+implementations/d2_variable_4.m +sbp/+implementations/d4_variable_6.m |
diffstat | 3 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
diff -r 4c7532db42cd -r b758d1cf4c8e +sbp/+implementations/d2_variable_2.m --- a/+sbp/+implementations/d2_variable_2.m Wed Oct 03 10:43:24 2018 -0700 +++ b/+sbp/+implementations/d2_variable_2.m Wed Oct 24 16:16:43 2018 -0700 @@ -27,7 +27,7 @@ diags = -1:1; stencil = [-1/2 0 1/2]; D1 = stripeMatrix(stencil, diags, m); - + D1(1,1)=-1;D1(1,2)=1;D1(m,m-1)=-1;D1(m,m)=1; D1(m,m-1)=-1;D1(m,m)=1; D1=D1/h; @@ -40,7 +40,7 @@ scheme_radius = (scheme_width-1)/2; r = (1+scheme_radius):(m-scheme_radius); - function D2 = D2_fun(c) + function [D2, B] = D2_fun(c) Mm1 = -c(r-1)/2 - c(r)/2; M0 = c(r-1)/2 + c(r) + c(r+1)/2; @@ -54,6 +54,8 @@ M=M/h; D2=HI*(-M-c(1)*e_l*d1_l'+c(m)*e_r*d1_r'); + B = HI*M; end D2 = @D2_fun; + end \ No newline at end of file
diff -r 4c7532db42cd -r b758d1cf4c8e +sbp/+implementations/d2_variable_4.m --- a/+sbp/+implementations/d2_variable_4.m Wed Oct 03 10:43:24 2018 -0700 +++ b/+sbp/+implementations/d2_variable_4.m Wed Oct 24 16:16:43 2018 -0700 @@ -49,7 +49,7 @@ N = m; - function D2 = D2_fun(c) + function [D2, B] = D2_fun(c) M = 78+(N-12)*5; %h = 1/(N-1); @@ -131,6 +131,8 @@ cols(40+(i-7)*5:44+(i-7)*5) = [i-2;i-1;i;i+1;i+2]; end D2 = sparse(rows,cols,D2); + + B = HI*( c(end)*e_r*d1_r' - c(1)*e_l*d1_l') - D2; end D2 = @D2_fun; end \ No newline at end of file
diff -r 4c7532db42cd -r b758d1cf4c8e +sbp/+implementations/d4_variable_6.m --- a/+sbp/+implementations/d4_variable_6.m Wed Oct 03 10:43:24 2018 -0700 +++ b/+sbp/+implementations/d4_variable_6.m Wed Oct 24 16:16:43 2018 -0700 @@ -85,7 +85,7 @@ scheme_radius = (scheme_width-1)/2; r = (1+scheme_radius):(m-scheme_radius); - function D2 = D2_fun(c) + function [D2, B] = D2_fun(c) Mm3 = c(r-2)/0.40e2 + c(r-1)/0.40e2 - 0.11e2/0.360e3 * c(r-3) - 0.11e2/0.360e3 * c(r); Mm2 = c(r-3)/0.20e2 - 0.3e1/0.10e2 * c(r-1) + c(r+1)/0.20e2 + 0.7e1/0.40e2 * c(r) + 0.7e1/0.40e2 * c(r-2); @@ -128,6 +128,7 @@ M=M/h; D2 = HI*(-M - c(1)*e_l*d1_l' + c(m)*e_r*d1_r'); + B = HI*M; end D2 = @D2_fun;