ASCOT5
Loading...
Searching...
No Matches
Functions
interp2Dcomp.c File Reference

Bicubic spline interpolation in compact form. More...

#include <stdlib.h>
#include <math.h>
#include "../ascot5.h"
#include "interp.h"
#include "spline.h"

Go to the source code of this file.

Functions

int interp2Dcomp_init_coeff (real *c, real *f, int n_x, int n_y, int bc_x, int bc_y, real x_min, real x_max, real y_min, real y_max)
 Calculate bicubic spline interpolation coefficients for scalar 2D data.
 
void interp2Dcomp_init_spline (interp2D_data *str, real *c, int n_x, int n_y, int bc_x, int bc_y, real x_min, real x_max, real y_min, real y_max)
 Initialize a bicubic spline.
 
a5err interp2Dcomp_eval_f (real *f, interp2D_data *str, real x, real y)
 Evaluate interpolated value of a 2D field.
 
a5err interp2Dcomp_eval_df (real *f_df, interp2D_data *str, real x, real y)
 Evaluate interpolated value and 1st and 2nd derivatives of 2D field.
 

Detailed Description

Bicubic spline interpolation in compact form.

Definition in file interp2Dcomp.c.

Function Documentation

◆ interp2Dcomp_init_coeff()

int interp2Dcomp_init_coeff ( real * c,
real * f,
int n_x,
int n_y,
int bc_x,
int bc_y,
real x_min,
real x_max,
real y_min,
real y_max )

Calculate bicubic spline interpolation coefficients for scalar 2D data.

This function calculates the bicubic spline interpolation coefficients and stores them in a pre-allocated array. Compact cofficients are calculated.

For each data point four coefficients are stored for spline-interpolation.

Parameters
callocated array of length n_y*n_x*4 to store the coefficients
f2D data to be interpolated
n_xnumber of data points in the x direction
n_ynumber of data points in the y direction
bc_xboundary condition for x axis (0) natural (1) periodic
bc_yboundary condition for y axis (0) natural (1) periodic
x_minminimum value of the x axis
x_maxmaximum value of the x axis
y_minminimum value of the y axis
y_maxmaximum value of the y axis
Returns
zero if initialization succeeded

Definition at line 33 of file interp2Dcomp.c.

◆ interp2Dcomp_init_spline()

void interp2Dcomp_init_spline ( interp2D_data * str,
real * c,
int n_x,
int n_y,
int bc_x,
int bc_y,
real x_min,
real x_max,
real y_min,
real y_max )

Initialize a bicubic spline.

Parameters
strpointer to spline to be initialized
carray where coefficients are stored
n_xnumber of data points in the x direction
n_ynumber of data points in the y direction
bc_xboundary condition for x axis
bc_yboundary condition for y axis
x_minminimum value of the x axis
x_maxmaximum value of the x axis
y_minminimum value of the y axis
y_maxmaximum value of the y axis

Definition at line 130 of file interp2Dcomp.c.

◆ interp2Dcomp_eval_f()

a5err interp2Dcomp_eval_f ( real * f,
interp2D_data * str,
real x,
real y )

Evaluate interpolated value of a 2D field.

This function evaluates the interpolated value of a 2D scalar field using bicubic spline interpolation coefficients of the compact form.

Parameters
fvariable in which to place the evaluated value
strdata struct for data interpolation
xx-coordinate
yy-coordinate
Returns
zero on success and one if (x,y) point is outside the domain.

Definition at line 168 of file interp2Dcomp.c.

◆ interp2Dcomp_eval_df()

a5err interp2Dcomp_eval_df ( real * f_df,
interp2D_data * str,
real x,
real y )

Evaluate interpolated value and 1st and 2nd derivatives of 2D field.

This function evaluates the interpolated value of a 2D scalar field and its 1st and 2nd derivatives using bicubic spline interpolation coefficients of the compact form.

The evaluated values are returned in an array with following elements:

  • f_df[0] = f
  • f_df[1] = f_x
  • f_df[2] = f_y
  • f_df[3] = f_xx
  • f_df[4] = f_yy
  • f_df[5] = f_xy
Parameters
f_dfarray in which to place the evaluated values
strdata struct for data interpolation
xx-coordinate
yy-coordinate
Returns
zero on success and one if (x,y) point is outside the grid.

< Index jump to cell

< Index jump one x forward

< Index jump one y forward

Definition at line 260 of file interp2Dcomp.c.