File fv_ops.hxx#

namespace FV#

Functions

Field3D Div_a_Grad_perp(const Field3D &a, const Field3D &f)#

Vorticity:

\[ \nabla (a \cdot \nabla_\perp(f)) \]

inline Field3D Div_a_Laplace_perp(const Field3D &a, const Field3D &x)#
const Field3D Div_par_K_Grad_par(const Field3D &k, const Field3D &f, bool bndry_flux = true)#

Divergence of a parallel diffusion

\[ \nabla_\parallel(k \cdot \nabla_\parallel(f) ) \]

const Field3D D4DY4(const Field3D &d, const Field3D &f)#

4th-order derivative in Y, using derivatives on cell boundaries.

A one-sided 3rd-order derivative, given a value at a boundary is:

\[ \frac{d^3f}{dx^3} \simeq \tfrac{16}{5} f_b - 6 f_0 + 4 f_1 - \tfrac{6}{5} f_2 \]

where:

  • \(f_b\) is the value on the boundary,

  • \(f_0\) is the cell to the left of the boundary,

  • \(f_1\) to the left of \(f_0\), and

  • \(f_2\) to the left of f_1:

.. code:: text f_2 | f_1 | f_0 | f_b

NB: Uses to/from FieldAligned coordinates

No fluxes through domain boundaries

const Field3D D4DY4_Index(const Field3D &f, bool bndry_flux = true)#

4th-order dissipation term

\[ \frac{d^3f}{dx^3} \simeq \tfrac{16}{5} f_b - 6 f_0 + 4 f_1 - \tfrac{6}{5} f_2 \]

where:

  • \(f_b\) is the value on the boundary,

  • \(f_0\) is the cell to the left of the boundary,

  • \(f_1\) to the left of \(f_0\), and

  • \(f_2\) to the left of f_1:

.. code:: text f_2 | f_1 | f_0 | f_b

void communicateFluxes(Field3D &f)#

Communicate fluxes between processors Takes values in guard cells, and adds them to cells

template<typename CellEdges = MC>
const Field3D Div_par(const Field3D &f_in, const Field3D &v_in, const Field3D &wave_speed_in, bool fixflux = true)#

Finite volume parallel divergence

Preserves the sum of f*J*dx*dy*dz over the domain

NB: Uses to/from FieldAligned coordinates

Parameters:
  • f_in[in] The field being advected. This will be reconstructed at cell faces using the given CellEdges method

  • v_in[in] The advection velocity. This will be interpolated to cell boundaries using linear interpolation

  • wave_speed_in[in] Local maximum speed of all waves in the system at each

  • fixflux[in] Fix the flux at the boundary to be the value at the midpoint (for boundary conditions)

template<typename CellEdges = MC>
const Field3D Div_f_v(const Field3D &n_in, const Vector3D &v, bool bndry_flux)#

Div ( n * v ) &#8212; Magnetic drifts

This uses the expression

Div( A ) = 1/J * d/di ( J * A^i )

Hence the input vector should be contravariant

Note: Uses to/from FieldAligned

Field3D Div_Perp_Lap(const Field3D &a, const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)#

X-Z Finite Volume diffusion operator

struct Stencil1D#

Stencil used for Finite Volume calculations which includes cell face values L and R

Public Members

BoutReal c#

Cell centre values.

BoutReal m#
BoutReal p#
BoutReal mm#
BoutReal pp#
BoutReal L#

Left and right cell face values.

BoutReal R#
struct Upwind#

First order upwind for testing

Public Functions

inline void operator()(Stencil1D &n)#
struct Fromm#

Fromm method

Public Functions

inline void operator()(Stencil1D &n)#
struct MinMod#

Second order slope limiter method

Limits slope to minimum absolute value of left and right gradients. If at a maximum or minimum slope set to zero, i.e. reverts to first order upwinding

Public Functions

inline void operator()(Stencil1D &n)#

Private Functions

inline BoutReal _minmod(BoutReal a, BoutReal b)#

Internal helper function for minmod slope limiter

If the inputs have different signs then returns zero, otherwise chooses the value with the minimum magnitude.

struct MC#

Monotonised Central (MC) second order slope limiter (Van Leer)

Limits the slope based on taking the slope with the minimum absolute value from central, 2*left and 2*right. If any of these slopes have different signs then the slope reverts to zero (i.e. 1st-order upwinding).

Public Functions

inline void operator()(Stencil1D &n)#

Private Functions

inline BoutReal minmod(BoutReal a, BoutReal b, BoutReal c)#