ASCOT5
Loading...
Searching...
No Matches
Data Structures | Functions
linint.h File Reference

Linear interpolation library. More...

#include "../offload_acc_omp.h"
#include "../ascot5.h"
#include "../spline/interp.h"

Go to the source code of this file.

Data Structures

struct  linint1D_data
 1D interpolation struct. More...
 
struct  linint2D_data
 2D interpolation struct. More...
 
struct  linint3D_data
 3D interpolation struct. More...
 

Functions

void linint1D_init (linint1D_data *str, real *c, int n_x, int bc_x, real x_min, real x_max)
 Initialize linear interpolation struct for scalar 1D data.
 
void linint2D_init (linint2D_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 linear interpolation struct for scalar 2D data.
 
void linint3D_init (linint3D_data *str, real *c, int n_x, int n_y, int n_z, int bc_x, int bc_y, int bc_z, real x_min, real x_max, real y_min, real y_max, real z_min, real z_max)
 Initialize linear interpolation struct for scalar 3D data.
 
int linint1D_eval_f (real *f, linint1D_data *str, real x)
 Evaluate interpolated value of 1D scalar field.
 
DECLARE_TARGET_END int linint2D_eval_f (real *f, linint2D_data *str, real x, real y)
 Evaluate interpolated value of 2D scalar field.
 
DECLARE_TARGET_END int linint3D_eval_f (real *f, linint3D_data *str, real x, real y, real z)
 Evaluate interpolated value of 3D scalar field.
 

Detailed Description

Linear interpolation library.

Linear interpolation interpolates data given on a uniform grid. Each axis may have either natural or periodic boundary condition.

The interpolant does not need any initialization on the host. After offloading is done, call linintXD_init() which assigns the values and a pointer to the data to a linint struct.

Definition in file linint.h.

Function Documentation

◆ linint1D_init()

void linint1D_init ( linint1D_data * str,
real * c,
int n_x,
int bc_x,
real x_min,
real x_max )

Initialize linear interpolation struct for scalar 1D data.

Parameters
strpointer to struct to be initialized
carray where data is 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 22 of file linint1D.c.

◆ linint2D_init()

void linint2D_init ( linint2D_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 linear interpolation struct for scalar 2D data.

Parameters
strpointer to struct to be initialized
carray where data is 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 25 of file linint2D.c.

◆ linint3D_init()

void linint3D_init ( linint3D_data * str,
real * c,
int n_x,
int n_y,
int n_z,
int bc_x,
int bc_y,
int bc_z,
real x_min,
real x_max,
real y_min,
real y_max,
real z_min,
real z_max )

Initialize linear interpolation struct for scalar 3D data.

Parameters
strpointer to struct to be initialized
carray where data is stored
n_xnumber of data points in the x direction
n_ynumber of data points in the y direction
n_znumber of data points in the z direction
bc_xboundary condition for x axis
bc_yboundary condition for y axis
bc_zboundary condition for z 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
z_minminimum value of the z axis
z_maxmaximum value of the z axis

Definition at line 29 of file linint3D.c.

◆ linint1D_eval_f()

int linint1D_eval_f ( real * f,
linint1D_data * str,
real x )

Evaluate interpolated value of 1D scalar field.

This function evaluates the interpolated value of a 1D scalar field using linear interpolation.

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 grid.

< Normalized x coordinate in current cell

Definition at line 47 of file linint1D.c.

◆ linint2D_eval_f()

DECLARE_TARGET_END int linint2D_eval_f ( real * f,
linint2D_data * str,
real x,
real y )

Evaluate interpolated value of 2D scalar field.

This function evaluates the interpolated value of a 2D scalar field using bilinear interpolation.

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 grid.

Definition at line 58 of file linint2D.c.

◆ linint3D_eval_f()

DECLARE_TARGET_END int linint3D_eval_f ( real * f,
linint3D_data * str,
real x,
real y,
real z )

Evaluate interpolated value of 3D scalar field.

This function evaluates the interpolated value of a 3D scalar field using trilinear interpolation.

Parameters
fvariable in which to place the evaluated value
strdata struct for data interpolation
xx-coordinate
yy-coordinate
zz-coordinate

Definition at line 70 of file linint3D.c.