You are on page 1of 7

M1 International - Arts et Metiers ParisTech

Programming and Numerical Methods


2-D interpolation in curvilinear space
The aim is to apply interpolation schemes in more than one dimension space with matlab language
on a general curvilinear grid. This application can be an opportunity to:
apply Lagrangian polynomials interpolation;
solve a non linear system with a 2D Newtons algorithm;
design a matlab program subdivided into several subroutines.

1
1.1

Method of Lagrange interpolations


One-dimensional interpolations

Let N be the size of the interpolation stencil and u a function defined on the xi discretization points.
The explicit interpolation from xi points to a point x0 is given by:
u(x0 ) =

N
X

Si u(xi )

(1)

i=1

where Si are the interpolation coefficients. In this study, the coefficients are defined for centered interpolation stencils with an even number of points N and the point x0 located such that
x N < x0 < x N +1 . There are different methods to compute the coefficients.
2

One of the most popular is based on Lagrange polynomials. The Lagrange family of interpolations
has proven to be a simple and inexpensive solution [1, 4, 3]. For a stencil of size N, the coefficients
Si are polynomials of degree N 1 defined by:
Si =

N
Y
x0 xl
xi xl
l=1,l6=i

(2)

The order of accuracy in the sense of Taylors truncation error is N.

1.2

Two-dimensional interpolations

Two different methods are presented in this section for two-dimensional or three-dimensional interpolations: the calculation directly in the curvilinear space and the the tensorization of 1-D interpolations. In the second method, the interpolation stencil is mapped in the regular Cartesian
computational space, where 1-D interpolations can be applied by direction. The difficulty is thus
reported in the choice of a particular mapping.

Let N N be the size of the interpolation stencil, and u a fonction defined on (xi , yj ) discretization
points. The explicit interpolation at a point (x0 , y0) can be written as:
u(x0 , y0 ) =

N X
N
X

Sij u(xi , yj )

(3)

i=1 j=1

where Sij are the interpolation coefficients.


1.2.1

2-D interpolations in a curvilinear space

The first possibility is to compute the interpolation coefficients directly in the physical space. The
system of Taylors expansion relationships is written and solved in the physical space. The general
formula for a 2-D interpolation u at the point (x0 , y0 ) is now expressed as:

u(x0 , y0 ) =

N
X

Sk u(xk , yk )

(4)

k=1

where Sk are the interpolation coefficients to be determined and N = N N.


The Taylor series expansion of order M of the function u at the donor points (xk , yk ) about (x0 , y0 )
reads:
X 1  p+q u 
(xk x0 )p (yk y0 )q ,
(5)
u(xk , yk ) = u(x0 , y0 ) +
p y q
p!q!
x
x0 ,y0
p,q
for 1 6 p + q 6 M. The system of equations for the coefficients Sk is obtained by replacing u(xk , yk )
by its expansion (5) in (4), and by canceling all the monomial terms up to order M. This yields:

N
X

Sk = 1, and

k=1

N
X

Sk (xk x0 )p (yk y0 )q = 0,

16p+q 6M

(6)

k=1

which can be written in the matrix form:


CS =

1 0 ... 0 0

The size of C is T N with:


T = 1/2(M + 1)(M + 2) ,
and S =
1.2.2

S1 S2 ... SN

T

T

(7)

Cpq,k = (xk x0 )p (yk y0 )q ,

is the unknown vector of coefficients.

Tensorization of 1-D interpolations

Special case of Cartesian grids First consider the case of a N N Cartesian interpolation stencil,
as depicted in figure 1. The interpolation of u at point (x0 , y0) is performed in two steps. N horizontal
interpolations of u at abscissa x0 for the different ordinate locations yj are first realized (white squares
in figure 1). The next step is to interpolate vertically at point (x0 , y0) from the intermediate values

(xi ,yj )

y0

x0
Figure 1: 2-D Cartesian interpolation stencil. White circles denote the points of the interpolation stencil,
the black square is the desired interpolated point, and white squares are the intermediate interpolated values.

at (x0 , yj ), with j = 1, ..., N. The interpolation coefficients Sij are thus simply the tensor products
of the 1-D interpolation coefficients Si and Sj . For instance, for Lagrange interpolation, we get:
N
N
Y
x0 xl Y y0 yk
Sij = Si Sj =
xi xl k=1,k6=j yj yk
l=1,l6=i

(8)

The method is hereafter referred to as 21-D interpolation. Its extension to general curvilinear
grids is based on a prior mapping of the curvilinear physical space into a Cartesian computational
space, where the 21-D method can be readily applied. The difficulty is to determine accurately the
position of the interpolated point (x0 , y0) in the reference space. This localization is straighforward
if the mapping is known analytically, e.g. for conformal transformations. In particular, when a
cylindrical formulation of the governing equations is used, the transformation is:

x =p
r cos
and y = r sin
(9)
r = x2 + y 2 and = atan(y/x)
where (x,y) are Cartesian coordinates and (r,) the polar coordinates.

Isoparametric mapping The interpolation is realized in the computational domain (,) as depicted in figure 2. The location of the interpolation point is determined by the offsets ( , ) relative
to the base point of the stencil. The calculation of high-order offsets is performed using an isoparametric mapping from the physical space to the computational domain. The latter is Cartesian regular,
so that the coefficients of a Lagrange interpolation in the -direction are defined by:
Sj =

N
1
Y
(1)N +j1
( j)
[N (j + 1)]!j! l=0,l6=j

(10)

Sherer and Scott [1] proposed a high-order extension of the procedure of Benek et al. [2] using
explicit, non-optimized Lagrangian interpolants for the isoparametric mapping. The offsets are then
3

0.24

20
18

16

14
12
0.29
0.59

0.54

0.49

10
124

126

128

130

132

134

Figure 2: Sketch of the mapping from the physical space (x, y) to the computational space (, ). The
) which contains the interpolation point (red square). The
Cartesian grid is the background grid (
curvilinear grid (
) is an O-grid around the vane (the zoom represents the lower upstream part). Donor
points (green circles) belong to the curvilinear grid. The right insert show the mapping of the curvilinear
into a Cartesian regular grid with unit spacing. The interpolation point is located in this space by the offsets
( , ) relative to the base point of the stencil (lower left donor point).

solution of the following set of equations:

N
1 N
1
X
X

Sj ( ) Si ( ) xi,j x0 = 0

F1 =
j=0 i=0

1
N
1 N
X
X

Sj ( ) Si ( ) yi,j y0
F2 =

(11)

=0

j=0 i=0

where (x0 , y0 ) and (xi,j , yi,j ) are the coordinates in the physical space for the interpolation point and
the donor points forming the stencil. The interpolation coefficients Si and Sj are given as functions
of the offset in that direction by (10). The system is solved iteratively using Newtons method:
 n+1  n 
 n

F1
1
=
J

F2
where the inverse of the Jacobian matrix J is given by:
"
#
F1
F2

1
F1 F2 F1 F2

J1 =
with D =
F2
F1
D

The derivatives can be expressed as:


N
1
N
1
X
Y
(1)N +j1
Fj
( k)
=

[N (j + 1)]!j! l=0,l6=j k=0,k6=j,k6=l

An initial guess for the offsets ( , ) should be provided by the user. One can start for instance
from the centers of the cell where the point to be interpolated is located.
4

Work

We want to program the isoparametric mapping described in the previous section with Matlab (or
Scilab).

2.1

1-D interpolation

Apply Lagrangian interpolation for a simple 1-D test function (you are asked to perform interpolation
at order 2 to 10);
% Example: Gaussian function
% -------------------------alph=log(2)/25.; % width of Gaussian
i0=20; % center of Gaussian
X2=[0:2:100]; % abscissae
nx=length(X2);
for i=1:nx,U2(i)=exp(-alph*(X2(i)-X2(i0))^2);end %Gaussian function
% interpolation at xint
% --------------------ii=23;
xint=X2(ii)+1

2.2

2-D Cartesian interpolation

Apply the tensorization for 2-D Lagrangian interpolation of order 4 on a Cartesian grid
% Definition of a 2D Gaussian function (test function)
% -----------------------------------alph=log(2)/10^2; % width of Gaussian
i0=20; % center of Gaussian
j0=20; % center of Gaussian
X2=[0:2:80]; % abscissae
Y2=[0:2:80]; % ordinate
nx=length(X2);
ny=length(Y2);
for i=1:nx
for j=1:ny
U2(i,j)=exp(-alph*((X2(i)-X2(i0))^2+(Y2(j)-Y2(j0))^2));
end
end
% Interpolation on NxN points -> order N
% -------------------------------------% order
N=4;
% width of interpolation per direction
5

dw=N;
% degrees of freedom
dl=dw*dw;
% interpolation point at (xint,yint)
% ---------------------------------ii=23;
ji=23;
xint=X2(ii)+1;
yint=Y2(ji)+1;

2.3

2-D curvilinear interpolation

Apply the tensorization for 2-D Lagrangian interpolation of order 4 on a sinusoidal grid given by:
% Definition of sinusoidal grid
% ----------------------------nx=41;
ny=41;
xmin=0;
ymin=0;
xmax=80;
ymax=80;
lx=xmax-xmin;
ly=ymax-ymin;
facteur=1.;
ax=2*facteur;
ay=2*facteur;
enex=4;
eney=4;
phix=0;
phiy=0;
omegatau=0.25;
deltax0=lx/(nx-1);
deltay0=ly/(ny-1);
for i=1:nx,
for j=1:ny,
xg(i,j) = xmin+deltax0*((i-1)+ax*sin(2.0*pi*omegatau)...
*sin(enex*pi*(j-1)*deltay0/ly+i*phix/(nx-1)));
yg(i,j) = ymin+deltay0*((j-1)+ay*sin(2.0*pi*omegatau)...
*sin(eney*pi*(i-1)*deltax0/lx+j*phiy/(ny-1)));
val(i,j)=1;
end
end

% Definition of a 2D Gaussian function (test function)


% -----------------------------------alph=log(2)/10^2; % width of Gaussian
i0=20; % center of Gaussian
j0=20; % center of Gaussian
for i=1:nx
for j=1:ny
U2(i,j)=exp(-alph*((xg(i,j)-xg(i0,j0))^2+(yg(i,j)-yg(i0,j0))^2));
end
end
% Interpolation on NxN points -> order N
% -------------------------------------% order
N=4;
% width of interpolation per direction
dw=N;
% degrees of freedom
dl=dw*dw;
% interpolation point at (xint,yint)
% ---------------------------------ii=23;
ji=23;
xint=xg(ii,ji)+1;
yint=yg(ii,ji)+1;
Then find the location of the point to be interpolated in the computational space using the isoparametric mapping and 2-D Newtons algorithm.

References
[1] S. Sherer, J. Scott, High-order compact finite-difference methods on general overset grids, J.
Comput. Phys. 210 (2005) 459496.
[2] J. Benek, J. Steger, F. Dougherty, A flexible grid embedding technique with application to the
Euler equations, AIAA Paper 83-1944.
[3] R. Guenanff, Couplage instationnaire Navier-Stokes/Euler pour la generation et le rayonnement
des sources de bruit aerodynamique, Ph.D. thesis, Universite Rennes I, no 3138 (2004).
[4] O. Marsden, C. Bogey, C. Bailly, High-order curvilinear simulations of flows around nonCartesian bodies, J. Comput. Acous. 13 (4) (2005) 731748.

You might also like