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

Cubic 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 interp1Dcomp_init_coeff (real *c, real *f, int n_x, int bc_x, real x_min, real x_max)
 Calculate cubic spline interpolation coefficients for scalar 1D data.
 
void interp1Dcomp_init_spline (interp1D_data *str, real *c, int n_x, int bc_x, real x_min, real x_max)
 Initialize a cubic spline.
 
a5err interp1Dcomp_eval_f (real *f, interp1D_data *str, real x)
 Evaluate interpolated value of 1D scalar field.
 
a5err interp1Dcomp_eval_df (real *f_df, interp1D_data *str, real x)
 Evaluate interpolated value of 1D and its 1st and 2nd derivatives.
 

Detailed Description

Cubic spline interpolation in compact form.

Definition in file interp1Dcomp.c.

Function Documentation

◆ interp1Dcomp_init_coeff()

int interp1Dcomp_init_coeff ( real * c,
real * f,
int n_x,
int bc_x,
real x_min,
real x_max )

Calculate cubic spline interpolation coefficients for scalar 1D data.

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

Parameters
callocated array of length n_x*2 to store the coefficients
f1D data to be interpolated
n_xnumber of data points in the x axis
bc_xboundary condition for the x axis
x_minminimum value of the x axis
x_maxmaximum value of the x axis

Definition at line 25 of file interp1Dcomp.c.

◆ interp1Dcomp_init_spline()

void interp1Dcomp_init_spline ( interp1D_data * str,
real * c,
int n_x,
int bc_x,
real x_min,
real x_max )

Initialize a cubic spline.

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

Definition at line 68 of file interp1Dcomp.c.

◆ interp1Dcomp_eval_f()

a5err interp1Dcomp_eval_f ( real * f,
interp1D_data * str,
real x )

Evaluate interpolated value of 1D scalar field.

This function evaluates the interpolated value of a 1D 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
Returns
zero on success and one if x point is outside the domain.

Definition at line 97 of file interp1Dcomp.c.

◆ interp1Dcomp_eval_df()

a5err interp1Dcomp_eval_df ( real * f_df,
interp1D_data * str,
real x )

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

This function evaluates the interpolated value of a 1D 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_xx
Parameters
f_dfarray in which to place the evaluated values
strdata struct for data interpolation
xx-coordinate
Returns
zero on success and one if (x,y) point is outside the grid.

< Normalized x coordinate in current cell

Definition at line 155 of file interp1Dcomp.c.