Streamer fluid modeling - An overview of ARCoS  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions | Variables
interpol2.c File Reference

New interpolation routines. More...

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include "grid.h"
#include "interpol2.h"
#include "parameters.h"
#include "proto.h"
#include "rz_array.h"
#include "species.h"
Include dependency graph for interpol2.c:

Go to the source code of this file.

Macros

#define anm(N_, M_)   this->stencil[(N_) * this->method->q + (M_)]
 

Functions

static double gen_apply (interpol_t *this, double r, double z)
 gen_apply ?????.
 
void bilin_set_coeffs (interpol_t *this)
 For bilinear interpolations, the standard fallback routines are too slow, so we define optimized routines to increase performance. The results, however, should be the same.
 
void quadlog_set_coeffs (interpol_t *this)
 
double quadlog_apply (interpol_t *this, double r, double z)
 
interpol_tinterpol_new_a (double Lr, double Lz, interpol_method_t *method)
 Creates a new interpolator that uses a given method.
 
void interpol_free (interpol_t *this)
 Frees the interpolator.
 
void interpol_set_stencil (interpol_t *this, double r0, double z0,...)
 Sets the stencil of the interpolation object.
 
void interpol_set_stencil_at (grid_t *grid, interpol_t *this, double r0, double z0, rz_array_t *ar, int ir, int iz, int itheta)
 Sets the stencil reading from an array.
 
void interpol_set_coeffs (interpol_t *this)
 Calculates the coefficients of the interpolating polynomial.
 
double interpol_apply (interpol_t *this, double r, double z)
 Evaluates the interpolating polynomial.
 
double bilin_apply (interpol_t *this, double r, double z)
 

Variables

double matrix_zero [] = {1.0}
 
interpol_method_t interpol_zero
 
interpol_method_t interpol_zero_masses
 
double matrix_quadratic []
 
interpol_method_t interpol_quadratic
 
interpol_method_t interpol_quadratic_masses
 
double matrix_wackers []
 In this approach, we make sure that the interpolation error at the matrix center (anm(2, 2)) is zero (this is used by J. Wackers' code)
 
interpol_method_t interpol_wackers
 
interpol_method_t interpol_wackers_masses
 
double matrix_averaged []
 
interpol_method_t interpol_averaged
 
interpol_method_t interpol_averaged_masses
 
double matrix_bilin []
 
interpol_method_t interpol_bilin
 
interpol_method_t interpol_bilin_masses
 
interpol_method_t interpol_quadlog
 
interpol_method_tinterpol_methods_index [MAX_INTERPOL_METHODS]
 

Detailed Description

New interpolation routines.

We want to obtain a function $f(r, z)$ from another one $phi(r, z)$ which is known only in some points of a stencil, $\phi(r0 + i dr, z0 + j dz), 0 <= {i, j} < q$.

We approximate $f$ as

$f(r, z) = \sum_{nm} (r - r0)^n (z - z0)^m c_{nm}$

where $m + n < p$, $p$ being the order of the interpolating function plus one.

The coefficients $c_{nm}$ are calculated from $\phi$ as

$c_{nm} = \sum_{ij} b_{nm ij} phi(r0 + i L, z0 + j L)$

Thus, to define an interpolation method, we only need the matrix $b_{nm ij}$, which has $1/2 q^2 p(p+1)$ elements.

HOWEVER, using this general interpolation matrix turns out to be too slow. Hence we define also specific routines that have the same interface and that are called transparently. Thus the calling program does not have to worry about the internals of how the interpolation is computed.

Definition in file interpol2.c.

Macro Definition Documentation

#define anm (   N_,
  M_ 
)    this->stencil[(N_) * this->method->q + (M_)]

Definition at line 40 of file interpol2.c.

Function Documentation

static double gen_apply ( interpol_t this,
double  r,
double  z 
)
static

gen_apply ?????.

Definition at line 211 of file interpol2.c.

Here is the caller graph for this function:

void bilin_set_coeffs ( interpol_t this)

For bilinear interpolations, the standard fallback routines are too slow, so we define optimized routines to increase performance. The results, however, should be the same.

Definition at line 363 of file interpol2.c.

void quadlog_set_coeffs ( interpol_t this)

Definition at line 410 of file interpol2.c.

Here is the call graph for this function:

double quadlog_apply ( interpol_t this,
double  r,
double  z 
)

Definition at line 424 of file interpol2.c.

Here is the call graph for this function:

interpol_t* interpol_new_a ( double  Lr,
double  Lz,
interpol_method_t method 
)

Creates a new interpolator that uses a given method.

Definition at line 49 of file interpol2.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void interpol_free ( interpol_t this)

Frees the interpolator.

Definition at line 70 of file interpol2.c.

Here is the caller graph for this function:

void interpol_set_stencil ( interpol_t this,
double  r0,
double  z0,
  ... 
)

Sets the stencil of the interpolation object.

r0 and z0 are the coordinates of the bottom-left corner of the stencil (the [0,0] point).

Definition at line 83 of file interpol2.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void interpol_set_stencil_at ( grid_t grid,
interpol_t this,
double  r0,
double  z0,
rz_array_t ar,
int  ir,
int  iz,
int  itheta 
)

Sets the stencil reading from an array.

ir, iz give the index of the cell in the array corresponding to the stencil origin.

Definition at line 116 of file interpol2.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void interpol_set_coeffs ( interpol_t this)

Calculates the coefficients of the interpolating polynomial.

Has to be called after interpol_set_stencil.

Definition at line 161 of file interpol2.c.

Here is the caller graph for this function:

double interpol_apply ( interpol_t this,
double  r,
double  z 
)

Evaluates the interpolating polynomial.

Definition at line 190 of file interpol2.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double bilin_apply ( interpol_t this,
double  r,
double  z 
)

Definition at line 382 of file interpol2.c.

Variable Documentation

double matrix_zero[] = {1.0}

You are not supposed to understand these numbers. Refer to InterpolArrays.nb

Definition at line 246 of file interpol2.c.

interpol_method_t interpol_zero
Initial value:

Definition at line 248 of file interpol2.c.

interpol_method_t interpol_zero_masses
Initial value:

Definition at line 252 of file interpol2.c.

double matrix_quadratic[]
Initial value:
=
{-0.1111111111111111, 0.2222222222222222, -0.1111111111111111,
0.2222222222222222, 0.5555555555555556, 0.2222222222222222,
-0.1111111111111111, 0.2222222222222222, -0.1111111111111111,
-0.1666666666666667, 0 , 0.1666666666666667,
-0.1666666666666667, 0 , 0.1666666666666667,
-0.1666666666666667, 0 , 0.1666666666666667,
-0.1666666666666667, -0.1666666666666667, -0.1666666666666667,
0 , 0 , 0 ,
0.1666666666666667, 0.1666666666666667, 0.1666666666666667,
0.1666666666666667, -0.3333333333333333, 0.1666666666666667,
0.1666666666666667, -0.3333333333333333, 0.1666666666666667,
0.1666666666666667, -0.3333333333333333, 0.1666666666666667,
0.25 , 0 , -0.25 ,
0.25 , 0 , -0.25 ,
0 , 0 , 0 ,
-0.25 , 0 , 0.25 ,
0.1666666666666667, 0.1666666666666667, 0.1666666666666667,
-0.3333333333333333, -0.3333333333333333, -0.3333333333333333,
0.1666666666666667, 0.1666666666666667, 0.1666666666666667
}

Coefficients for a 9-point stencil quadratic interpolation.

Definition at line 260 of file interpol2.c.

interpol_method_t interpol_quadratic
Initial value:

Definition at line 282 of file interpol2.c.

interpol_method_t interpol_quadratic_masses
Initial value:

Definition at line 286 of file interpol2.c.

double matrix_wackers[]
Initial value:
=
{ 0 , 0 , 0 ,
0 , 1.0 , 0 ,
0 , 0 , 0 ,
-0.1666666666666667, 0 , 0.1666666666666667,
-0.1666666666666667, 0 , 0.1666666666666667,
-0.1666666666666667, 0 , 0.1666666666666667,
-0.1666666666666667, -0.1666666666666667, -0.1666666666666667,
0 , 0 , 0 ,
0.1666666666666667, 0.1666666666666667, 0.1666666666666667,
0.1 , -0.2 , 0.1 ,
0.3 , -0.6 , 0.3 ,
0.1 , -0.2 , 0.1 ,
0.25 , 0 , -0.25 ,
0 , 0 , 0 ,
-0.25 , 0 , 0.25 ,
0.1 , 0.3 , 0.1 ,
-0.2 , -0.6 , -0.2 ,
0.1 , 0.3 , 0.1 }

In this approach, we make sure that the interpolation error at the matrix center (anm(2, 2)) is zero (this is used by J. Wackers' code)

Definition at line 293 of file interpol2.c.

interpol_method_t interpol_wackers
Initial value:

Definition at line 313 of file interpol2.c.

interpol_method_t interpol_wackers_masses
Initial value:

Definition at line 317 of file interpol2.c.

double matrix_averaged[]
Initial value:
=
{ -0.01880341880341880 , -0.008547008547008547, -0.01880341880341880 ,
-0.008547008547008547, 1.109401709401709 , -0.008547008547008547,
-0.01880341880341880 , -0.008547008547008547, -0.01880341880341880 ,
-0.1666666666666667 , 0 , 0.1666666666666667 ,
-0.1666666666666667 , 0 , 0.1666666666666667 ,
-0.1666666666666667 , 0 , 0.1666666666666667 ,
-0.1666666666666667 , -0.1666666666666667 , -0.1666666666666667 ,
0 , 0 , 0 ,
0.1666666666666667 , 0.1666666666666667 , 0.1666666666666667 ,
0.1128205128205128 , -0.1987179487179487 , 0.1128205128205128 ,
0.3012820512820513 , -0.6564102564102564 , 0.3012820512820513 ,
0.1128205128205128 , -0.1987179487179487 , 0.1128205128205128 ,
0.25 , 0 , -0.25 ,
0 , 0 , 0 ,
-0.25 , 0 , 0.25 ,
0.1128205128205128 , 0.3012820512820513 , 0.1128205128205128 ,
-0.1987179487179487 , -0.6564102564102564 , -0.1987179487179487 ,
0.1128205128205128 , 0.3012820512820513 , 0.1128205128205128 }

Definition at line 322 of file interpol2.c.

interpol_method_t interpol_averaged
Initial value:

Definition at line 342 of file interpol2.c.

interpol_method_t interpol_averaged_masses
Initial value:

Definition at line 346 of file interpol2.c.

double matrix_bilin[]
Initial value:
=
{ 1.0, 0.0, 0.0, 0.0,
-1.0, 0.0, 1.0, 0.0,
-1.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
1.0, -1.0, -1.0, 1.0,
0.0, 0.0, 0.0, 0.0}

Definition at line 351 of file interpol2.c.

interpol_method_t interpol_bilin
Initial value:

Definition at line 396 of file interpol2.c.

interpol_method_t interpol_bilin_masses
Initial value:

Definition at line 403 of file interpol2.c.

interpol_method_t interpol_quadlog
Initial value:

Definition at line 432 of file interpol2.c.

interpol_method_t* interpol_methods_index[MAX_INTERPOL_METHODS]