12 integer :: n_table,n_itp
13 double precision :: x_table(n_table),y_table(n_table)
14 double precision :: x_itp(n_itp),y_itp(n_itp)
23 if(x_itp(i)<x_table(1))
then
27 if(x_itp(i)>=x_table(n_table))
then
28 y_itp(i)=y_table(n_table)
31 loopt:
do j=1,n_table-1
32 if (x_itp(i)>=x_table(j) .and. x_itp(i)<x_table(j+1))
then
33 y_itp(i)=y_table(j) + (x_itp(i)-x_table(j))*&
34 (y_table(j+1)-y_table(j))/(x_table(j+1)-x_table(j))
47 integer :: n_table,n_itp
48 double precision :: x_table(n_table),y_table(n_table)
49 double precision :: x_itp(n_itp),y_itp(n_itp)
51 double precision :: at(n_table),bt(n_table),ct(n_table),dt(n_table)
52 double precision :: dxi
55 if (x_table(1)>x_itp(1) .or. x_table(n_table)<x_itp(n_itp))
then
56 call mpistop(
"out of interpolation table")
62 loopt:
do j=1,n_table-1
63 if (x_itp(i)>=x_table(j) .and. x_itp(i)<x_table(j+1))
then
64 dxi=x_itp(i)-x_table(j)
65 y_itp(i)=at(j)+bt(j)*dxi+ct(j)*dxi**2+dt(j)*dxi**3
71 if (x_itp(n_itp)==x_table(n_table)) y_itp(n_itp)=y_table(n_table)
79 double precision :: xi(ni),yi(ni)
80 double precision :: ai(ni),bi(ni),ci(ni),di(ni)
82 double precision :: matrix1(ni,ni),ri1(ni)
83 double precision :: matrix2(ni,ni),ri2(ni)
84 double precision :: mi(ni),hi(ni)
99 matrix1(i-1,i)=hi(i-1)
100 matrix1(i,i)=2*(hi(i-1)+hi(i))
102 ri1(i)=(yi(i+1)-yi(i))/hi(i)-(yi(i)-yi(i-1))/hi(i-1)
111 matrix2(2,1)=matrix1(2,1)/matrix1(1,1)
112 ri2(1)=ri1(1)/matrix1(1,1)
115 matrix2(i+1,i)=matrix1(i+1,i)/(matrix1(i,i)-matrix1(i-1,i)*matrix2(i,i-1))
119 ri2(i)=ri1(i)-matrix1(i-1,i)*ri2(i-1)
120 ri2(i)=ri2(i)/(matrix1(i,i)-matrix1(i-1,i)*matrix2(i,i-1))
125 mi(i)=ri2(i)-matrix2(i+1,i)*mi(i+1)
132 bi(i)=(yi(i+1)-yi(i))/hi(i)-hi(i)*mi(i)/2.0-hi(i)*(mi(i+1)-mi(i))/6.0
133 di(i)=(mi(i+1)-mi(i))/(6.0*hi(i))
142 double precision :: xc(0:1^D&,1:ndim),xp(1:ndim),factor(0:1^D&)
144 double precision :: dxc^D,xd^D
146 ^d&dxc^d=xc(1^dd&,^d)-xc(0^dd&,^d)\
147 ^d&xd^d=(xp(^d)-xc(0^dd&,^d))/dxc^d\
150 factor(ix^d)={abs(1-ix^d-xd^d)*}
160 double precision :: xc(0:1^D&,1:ndim),xp(1:ndim)
161 double precision :: wc(0:1^D&,1:nwc),wp(1:nwc)
164 double precision :: factor(0:1^D&)
171 wp(iw)=wp(iw)+wc(ix^d,iw)*factor(ix^d)
182 double precision :: xp(1:ndim),wp(1:nw)
184 double precision :: dxb^D,xb^L
185 integer :: inblock,ixO^L,j
186 integer :: ixb^D,ixi^D
187 double precision :: xc(0:1^D&,1:ndim),wc(0:1^D&,nw)
195 {
if (xp(^d)>=xbmin^d .and. xp(^d)<xbmax^d) inblock=inblock+1\}
196 if (inblock/=ndim)
then
197 call mpistop(
'Interpolation error: given point is not in given grid')
203 ^d&ixb^d=floor((xp(^d)-ps(igrid)%x(ixomin^dd,^d))/dxb^d)+ixomin^d\
207 xc(ixi^d,:)=ps(igrid)%x(ixb^d+ixi^d,:)
208 wc(ixi^d,:)=ps(igrid)%w(ixb^d+ixi^d,:)
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer, parameter rpxmin
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
integer, parameter rpxmax
subroutine interp_cubic_spline(x_table, y_table, n_table, x_itp, y_itp, n_itp)
subroutine get_interp_factor_linear(xc, xp, factor)
subroutine get_cubic_para(xi, yi, ai, bi, ci, di, ni)
subroutine interp_from_grid_linear(igrid, xp, wp)
subroutine interp_linear_multid(xc, xp, wc, wp, nwc)
subroutine interp_linear(x_table, y_table, n_table, x_itp, y_itp, n_itp)