WENO 1D

Posted yuewen-chen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WENO 1D相关的知识,希望对你有一定的参考价值。

  • WENO 1D

    This from Weighted Eno Schemes For Hamilton-Jacobi Equations , Guang-Shan Jiang.
    \[ \beginalign \phi^-_x,i &=\frac112(-\frac\Delta^+\phi_i-2\Delta x+7\frac\Delta^+\phi_i-1\Delta x+7\frac\Delta^+\phi_i\Delta x+7\frac\Delta^+ \phi_i+1\Delta x)\&-\Phi^weno(\frac\Delta^-\Delta^+ \phi_i-2\Delta x,\frac\Delta^-\Delta^+ \phi_i-1\Delta x,\frac\Delta^-\Delta^+ \phi_i\Delta x,\frac\Delta^-\Delta^+ \phi_i+1\Delta x)\\phi^+_x,i &=\frac112(-\frac\Delta^+\phi_i-2\Delta x+7\frac\Delta^+\phi_i-1\Delta x+7\frac\Delta^+\phi_i\Delta x+7\frac\Delta^+ \phi_i+1\Delta x)\&+\Phi^weno(\frac\Delta^-\Delta^+ \phi_i-2\Delta x,\frac\Delta^-\Delta^+ \phi_i-1\Delta x,\frac\Delta^-\Delta^+ \phi_i\Delta x,\frac\Delta^-\Delta^+ \phi_i+1\Delta x)\\endalign \]
    \[ \beginalign* \Phi^weno(a,b,c,d)&=\frac13\omega_0(a-2b+c)+\frac16(\omega_2-\frac12)(b-2c+d)\\omega_0&=\frac\alpha_0\alpha_0+\alpha_1+\alpha_2\\omega_1&=\frac\alpha_2\alpha_0+\alpha_1+\alpha_2\\alpha_0&=\frac1(\epsilon+IS_0)^2\\alpha_1&=\frac6(\epsilon+IS_1)^2\\alpha_1&=\frac3(\epsilon+IS_2)^2\IS_0 &=13(a-b)^2+3(a-3b)^2\IS_1 &=13(b-c)^2+3(b+c)^2\IS_2 &=13(c-d)^2+3(3c-d)^2 \endalign* \]
function out= weno5_DBC(xx,uu,BC1,BC2,BC3,BC4,chose)
% 施加 Diriclet  Boundary  Condition
% 检好!
global x u h
     x=xx;
     u=uu;
     h=x(2)-x(1);
ghostL=[BC1,BC2];
ghostR=[BC3,BC4];
%*****************************************************************
%*********************  1.u^-_i+1/2 **************************
umm = circshift(u,[0 2]);     % v(i-2)
umm(1:2)=ghostL;
um  = circshift(u,[0 1]);     % v(i-1)
um(1)=ghostL(2);
up  = circshift(u,[0 -1]);    % v(i+1)
up(end)=ghostR(1);
upp = circshift(u,[0 -2]);    % v(i+2)
upp(end-1:end)=ghostR;
%2. Polynomials
p0n = (2*umm - 7*um + 11*u)/6;
p1n = ( -um  + 5*u  + 2*up)/6;
p2n = (2*u   + 5*up - upp )/6;
% 3.Smooth Indicators (Beta factors)
B0n = 13/12*(umm-2*um+u  ).^2 + 1/4*(umm-4*um+3*u).^2; 
B1n = 13/12*(um -2*u +up ).^2 + 1/4*(um-up).^2;
B2n = 13/12*(u  -2*up+upp).^2 + 1/4*(3*u-4*up+upp).^2;
%4. Constants
d0n = 1/10; d1n = 6/10; d2n = 3/10; epsilon = 1e-6;
%5. Alpha weights 
alpha0n = d0n./(epsilon + B0n).^2;
alpha1n = d1n./(epsilon + B1n).^2;
alpha2n = d2n./(epsilon + B2n).^2;
alphasumn = alpha0n + alpha1n + alpha2n;
%6. ENO stencils weigths
w0n = alpha0n./alphasumn;
w1n = alpha1n./alphasumn;
w2n = alpha2n./alphasumn;
% Numerical Flux at cell boundary, $u_i+1/2^-$;
hn = w0n.*p0n + w1n.*p1n + w2n.*p2n;
%*********************************************************************
%************************* u^+_i-1/2 *****************************
  p0p = ( -umm + 5*um + 2*u  )/6;
  p1p = ( 2*um + 5*u  - up   )/6;
  p2p = (11*u  - 7*up + 2*upp)/6;
  B0p = 13/12*(umm-2*um+u  ).^2 + 1/4*(umm-4*um+3*u).^2;  
  B1p = 13/12*(um -2*u +up ).^2 + 1/4*(um-up).^2;   
  B2p = 13/12*(u  -2*up+upp).^2 + 1/4*(3*u -4*up+upp).^2;
% Constants
d0p = 3/10; d1p = 6/10; d2p = 1/10; epsilon = 1e-6;
% Alpha weights 
alpha0p = d0p./(epsilon + B0p).^2;
alpha1p = d1p./(epsilon + B1p).^2;
alpha2p = d2p./(epsilon + B2p).^2;
alphasump = alpha0p + alpha1p + alpha2p;
% ENO stencils weigths
w0p = alpha0p./alphasump;
w1p = alpha1p./alphasump;
w2p = alpha2p./alphasump;
% Numerical Flux at cell boundary, $u_i-1/2^+$;
hp = w0p.*p0p + w1p.*p1p + w2p.*p2p;
hp2=circshift(hp,[0,-1]);  % u^(+)_i+1/2;
HP2=hp(end-4:end);
           hp2(end)=La(x(end-4)-h/2,HP2,x(end)+h/2);
hn2=circshift(hn,[0,1]) ; % u^(-)_i-1/2;
HN2=hn(1:5);
           hn2(1) =La(x(1)+h/2, HN2,x(1)-h/2);
%=============================================================================
% by Prof.Shu Chi-Wang's paper, the left derive of du^-=(u^-_i+1/2-u^-_i-1/2)/dx 
%=============================================================================
if chose==1
    out=(hp2-hp)/h;  % du^+
elseif chose==-1
    out=(hn-hn2)/h;   % du^-
end

    function out=La(x1,y,x)
       out= ((h - x + x1).*(2*h - x + x1)*(3*h - x + x1).*(4*h - x + x1)*y(1) -...
               4*(x - x1).*(-4*h + x - x1).*(-3*h + x - x1).*(-2*h + x - x1)*y(2) +... 
               6*(x - x1).*(-4*h + x - x1).*(-3*h + x - x1).*(-h + x - x1)*y(3) -...
               4*(x - x1).*(-4*h + x - x1).*(-2*h + x - x1).*(-h + x - x1).*y(4) +... 
               (x - x1).*(-3*h + x - x1).*(-2*h + x - x1).*(-h + x - x1).*y(5))./(24.*power(h,4));
    end

end

以上是关于WENO 1D的主要内容,如果未能解决你的问题,请参考以下文章

WENO3

1D1D动态规划优化

Netflix 的 API 架构演变历程

算法优化》关于1D*1D的DP的优化

诗人小G(1D1D动态规划)

Codeforces Round #774 (Div. 2)题解

(c)2006-2024 SYSTEM All Rights Reserved IT常识