[comp.lang.fortran] splines

yorkall@hubcap.UUCP (Allen R York) (09/11/87)

Does anyone have a clues as to where I may get a 2-D spline
interpolation subroutine.  I have found plenty of 1-D routines
but the 2-D seems to be a different matter.

I want to use this in my research and don't want and probably couldn't
write my own routine.  

thanks in advance

Allen York

UUCP: {al}!gatech!hubcap!yorkall
INTERNET: {al}@hubcap.clemson.edu

:write

pgh@stl.stc.co.uk (Peter Hamer) (09/13/87)

In article <442@hubcap.UUCP> yorkall@hubcap.UUCP (Allen R York) writes:
>Does anyone have a clues as to where I may get a 2-D spline
>interpolation subroutine.  I have found plenty of 1-D routines
>but the 2-D seems to be a different matter.
>
>I want to use this in my research and don't want and probably couldn't
>write my own routine.  
>
>thanks in advance
>
>Allen York
>
>UUCP: {al}!gatech!hubcap!yorkall
>INTERNET: {al}@hubcap.clemson.edu
>
>:write
A simple algorithm for 2-D interpolation is given in "Numerical
Recipes", Press et al, CUP.  This explains the technique and provides
code in FORTRAN and Pascal.  It also assumes you know the value of the
function on a fixed grid.

This book is a good source of numerical techniques, and I recommend
it.

However, *why* do you want to interpolate? Is it as a first step in
some more complicated process (eg plotting contour lines), do you
really want to smooth rather than interpolate between accurately known
points, do you know the points on a fixed grid, why cannot you just
calculate the function, do you need continuity of derivatives?

In other words, if can you explain your problem more fully we may be
able to provide more help.
-- 

Regards,
	  Peter Hamer  (pgh@stl   ...!mcvax!ukc!stl!pgh    +44-279-29531 x 3192)

strgh@daisy.warwick.ac.uk (J E H Shaw) (09/16/87)

de Boor (1978), `A Practical Guide to Splines', Springer-Verlag,
contains many Fortran subroutines, including routines for
tensor-product spline interpolation in Chapter XVII.

Other sources (more directed towards smoothing splines) are:
1. Spath (1969), `Algorithmus 10.  Zweidimensional glatte interpolation',
   Computing (Europe) 4:178-182, +correction 8:200-201

2. Dierckx (1982), `A fast algorithm for smoothing data on a rectangular
   grid while using spline functions', SIAM J. Numer Anal. 19:1286-1303
   (+ references therein).
-- 
J.E.H.Shaw  Department of Statistics, University of Warwick, Coventry CV4 7AL
$$\times\times\qquad\top\gamma\alpha\omega\exists\qquad{\odot\odot\atop\smile}$$

yorkall@hubcap.UUCP (09/17/87)

In article <578@acer.stl.stc.co.uk>, pgh@stl.stc.co.uk (Peter Hamer) writes:
> However, *why* do you want to interpolate? Is it as a first step in
> some more complicated process (eg plotting contour lines), do you
> really want to smooth rather than interpolate between accurately known
> points, do you know the points on a fixed grid, why cannot you just
> calculate the function, do you need continuity of derivatives?
> 
> In other words, if can you explain your problem more fully we may be
> able to provide more help.
> -- 
> 
> Regards,
> 	  Peter Hamer  (pgh@stl   ...!mcvax!ukc!stl!pgh    +44-279-29531 x 3192)

Yes, I have realized since then that I should have provided more information.
Here is the background.  I have a Finite Element Mesh with irregular boundaries
and a relativley smooth distribution of several field variables.  As to save
from doing several other local steps which can be complicated, I would 
like to fit a surface to the data and be able to interpolate between the 
data points.                      

The reason for this is that the code we are running simulates the forging
process and the mesh gets highly distorted which will eventually make the 
solution diverge, but just make it innaccurate before this.  When we 
rezone the mesh, move nodal points to make the elements less distorted, 
we need to also transfer the data in the best way possible.  We are trying
least square fit which is efficient, but may not be accurate enough.

Thanks for any ideas!

Allen York    UUCP: !gatech!hubcap!yorkall
          INTERNET: yorkall@hubcap.clemson.edu

pgh@stl.stc.co.uk (Peter Hamer) (10/06/87)

 Thanks for the additional information Allen. A method that might suit
 you is fitting a surface to each triangular finite element, selecting
 parameters so that the surfaces and their derivatives are continuous at
 their boundaries. 

Cannot be too much help with references; but look at acm TOMS Dec 84

pp440- Algorithm 624 Triangulation and interpolation of arbitarily
distributed points in the plane.

pp463- Computing contours by successive solution of quintic polynomial
equations.

pp473- Algorithm 626 TRICP A contour plotting program for triangular
meshes.

... these may give you some ideas, or even be directly useful.

If you don't already know about netlib, I strongly recommend Comms
ACM, May 87, pp403-, Distribution of mathematical software via
electronic mail.  This is a wonderful source of mathematical routines.
In particular, I believe it has both the above algorithms (in the TOMS
library), and the de Boor programs JEH Shaw referenced (in the PPPACK
library).

Good luck, e-mail me if you find any good programs.
.

-- 

Regards,
	  Peter Hamer  (pgh@stl   ...!mcvax!ukc!stl!pgh    +44-279-29531 x 3192)