File interpolation.hxx

Functions

BoutReal interp(const stencil &s)

Perform interpolation between centre -> shifted or vice-versa.

Interpolate using 4th-order staggered formula

Parameters
  • s: Input stencil. mm -> -3/2, m -> -1/2, p -> +1/2, pp -> +3/2

template<typename T>
const T interp_to(const T &var, CELL_LOC loc, const std::string region = "RGN_ALL")

Interpolate to a give cell location.

Interpolate between different cell locations

NOTE: This requires communication if the result is required in guard cells NOTE: Since corner guard cells cannot be communicated, it never makes sense to calculate interpolation in guard cells. If guard cell values are required, we must communicate (unless interpolating in z). Since mesh->communicate() communicates both x- and y-guard cells by default, there is no difference between RGN_ALL, RGN_NOX and RGN_NOY.

Parameters
  • var: Input variable
  • loc: Location of output values
  • region: Region where output will be calculated

template<typename T>
const T interp_to(const T &var, CELL_LOC loc, REGION region)
void printLocation(const Field3D &var)

Print out the cell location (for debugging)

const char *strLocation(CELL_LOC loc)
const Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z)

Interpolate a field onto a perturbed set of points.

const Field3D interpolate(const Field2D &f, const Field3D &delta_x, const Field3D &delta_z)
const Field3D interpolate(const Field2D &f, const Field3D &delta_x)
class Interpolation

Subclassed by Bilinear, HermiteSpline, Lagrange4pt

Public Functions

Interpolation(int y_offset = 0, Mesh *localmeshIn = nullptr)
Interpolation(const BoutMask &mask, int y_offset = 0, Mesh *mesh = nullptr)
virtual ~Interpolation()
virtual void calcWeights(const Field3D &delta_x, const Field3D &delta_z) = 0
virtual void calcWeights(const Field3D &delta_x, const Field3D &delta_z, const BoutMask &mask) = 0
virtual Field3D interpolate(const Field3D &f) const = 0
virtual Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z) = 0
virtual Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z, const BoutMask &mask) = 0
void setMask(const BoutMask &mask)
void setYOffset(int offset)

Public Members

int y_offset

Protected Attributes

Mesh *localmesh = {nullptr}
BoutMask skip_mask
class HermiteSpline : public Interpolation

Subclassed by MonotonicHermiteSpline

Public Functions

HermiteSpline(Mesh *mesh = nullptr)
HermiteSpline(int y_offset = 0, Mesh *mesh = nullptr)
HermiteSpline(const BoutMask &mask, int y_offset = 0, Mesh *mesh = nullptr)
void calcWeights(const Field3D &delta_x, const Field3D &delta_z)
void calcWeights(const Field3D &delta_x, const Field3D &delta_z, const BoutMask &mask)
Field3D interpolate(const Field3D &f) const
Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z)
Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z, const BoutMask &mask)

Public Static Functions

static Interpolation *CreateHermiteSpline(Mesh *mesh)

Callback function for InterpolationFactory.

Protected Attributes

Tensor<int> i_corner

This is protected rather than private so that it can be extended and used by HermiteSplineMonotonic

Tensor<int> k_corner
Field3D h00_x
Field3D h01_x
Field3D h10_x
Field3D h11_x
Field3D h00_z
Field3D h01_z
Field3D h10_z
Field3D h11_z
class MonotonicHermiteSpline : public HermiteSpline
#include <interpolation.hxx>

Monotonic Hermite spline interpolator

Similar to HermiteSpline, so uses most of the same code. Forces the interpolated result to be in the range of the neighbouring cell values. This prevents unphysical overshoots, but also degrades accuracy near maxima and minima. Perhaps should only impose near boundaries, since that is where problems most obviously occur.

Public Functions

MonotonicHermiteSpline(Mesh *mesh = nullptr)
MonotonicHermiteSpline(int y_offset = 0, Mesh *mesh = nullptr)
MonotonicHermiteSpline(const BoutMask &mask, int y_offset = 0, Mesh *mesh = nullptr)
Field3D interpolate(const Field3D &f) const

Interpolate using precalculated weights. This function is called by the other interpolate functions in the base class HermiteSpline.

Public Static Functions

static Interpolation *CreateMonotonicHermiteSpline(Mesh *mesh)

Callback function for InterpolationFactory.

class Lagrange4pt : public Interpolation

Public Functions

Lagrange4pt(Mesh *mesh = nullptr)
Lagrange4pt(int y_offset = 0, Mesh *mesh = nullptr)
Lagrange4pt(const BoutMask &mask, int y_offset = 0, Mesh *mesh = nullptr)
void calcWeights(const Field3D &delta_x, const Field3D &delta_z)
void calcWeights(const Field3D &delta_x, const Field3D &delta_z, const BoutMask &mask)
Field3D interpolate(const Field3D &f) const
Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z)
Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z, const BoutMask &mask)
BoutReal lagrange_4pt(BoutReal v2m, BoutReal vm, BoutReal vp, BoutReal v2p, BoutReal offset) const
BoutReal lagrange_4pt(const BoutReal v[], BoutReal offset) const

Public Static Functions

static Interpolation *CreateLagrange4pt(Mesh *mesh)

Callback function for InterpolationFactory.

Private Members

Tensor<int> i_corner
Tensor<int> k_corner
Field3D t_x
Field3D t_z
class Bilinear : public Interpolation

Public Functions

Bilinear(Mesh *mesh = nullptr)
Bilinear(int y_offset = 0, Mesh *mesh = nullptr)
Bilinear(const BoutMask &mask, int y_offset = 0, Mesh *mesh = nullptr)
void calcWeights(const Field3D &delta_x, const Field3D &delta_z)
void calcWeights(const Field3D &delta_x, const Field3D &delta_z, const BoutMask &mask)
Field3D interpolate(const Field3D &f) const
Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z)
Field3D interpolate(const Field3D &f, const Field3D &delta_x, const Field3D &delta_z, const BoutMask &mask)

Public Static Functions

static Interpolation *CreateBilinear(Mesh *mesh)

Callback function for InterpolationFactory.

Private Members

Tensor<int> i_corner
Tensor<int> k_corner
Field3D w0
Field3D w1
Field3D w2
Field3D w3