HWENO fortran 代码
时间: 2024-03-02 16:44:24 浏览: 87
这是一个简单的HWENO(High-Order Weighted Essentially Non-Oscillatory)Fortran代码示例:
```
subroutine HWENO(u, uHWENO, N, dx)
implicit none
integer, intent(in) :: N
real, intent(in) :: dx
real, dimension(0:N-1), intent(in) :: u
real, dimension(0:N-1), intent(out) :: uHWENO
real, dimension(5) :: alpha
real, dimension(5) :: w
real, dimension(5) :: uL
real, dimension(5) :: uR
real :: eps = 1e-6
integer :: i
do i = 2, N-3
alpha = [1/10.0, 6/10.0, 3/10.0, 0.0, 0.0]
w = alpha / (eps + (u(i-2:i+2)-u(i))**2)
w = w / sum(w)
uL = [u(i-2), u(i-1), u(i), u(i+1), u(i+2)]
uR = [u(i-1), u(i), u(i+1), u(i+2), u(i+3)]
uHWENO(i) = w(1)*(-uL(1)+5*uL(2)+2*uL(3))/6.0 &
+ w(2)*(2*uL(2)+5*uL(3)-uL(4))/6.0 &
+ w(3)*(2*uL(3)+5*uL(2)-uL(1))/6.0 &
+ w(4)*(11*uL(3)-7*uL(2)+2*uL(1))/6.0 &
+ w(5)*(11*uL(3)-13*uL(2)+5*uL(1))/6.0
end do
uHWENO(0) = u(0)
uHWENO(1) = u(1)
uHWENO(N-2) = u(N-2)
uHWENO(N-1) = u(N-1)
end subroutine HWENO
```
其中,`u`是输入的原始数据,`uHWENO`是输出的经过HWENO处理后的数据,`N`是数据点数,`dx`是网格间距。该代码使用了五阶HWENO格式来计算每个内部网格点的值,边界点直接复制原始数据的值。
阅读全文