File difops.hxx

Differential operators

Changelog:

2009-01 Ben Dudson bd512@york.ac.uk

  • Added two optional parameters which can be put in any order These determine the method to use (DIFF_METHOD) and CELL_LOC location of the result. Both of these options are defined in bout_types.hxx

Copyright 2010 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu

Contact: Ben Dudson, bd512@york.ac.uk

This file is part of BOUT++.

BOUT++ is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

BOUT++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with BOUT++. If not, see http://www.gnu.org/licenses/.

Enums

enum BRACKET_METHOD

Poisson bracket methods

Values:

standard

Use b0xGrad_dot_Grad.

simple

Keep only terms in X-Z.

arakawa

Arakawa method in X-Z (optimised)

ctu

Corner Transport Upwind (CTU) method. Explicit method only, needs the timestep from the solver

arakawa_old

Older version, for regression testing of optimised version.

Functions

const Field2D Grad_par(const Field2D &var, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")

Parallel derivative (central differencing) in Y along unperturbed field

Parameters
  • var: The field to be differentiated
  • outloc: The cell location where the output is needed (if staggered grids is enabled)
  • method: The method to use. The default is set in the options.

const Field2D Grad_par(const Field2D &var, const std::string &method, CELL_LOC outloc = CELL_DEFAULT)
const Field2D Grad_par(const Field2D &var, CELL_LOC outloc, DIFF_METHOD method)
const Field2D Grad_par(const Field2D &var, DIFF_METHOD method, CELL_LOC outloc)
const Field3D Grad_par(const Field3D &var, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
const Field3D Grad_par(const Field3D &var, const std::string &method, CELL_LOC outloc = CELL_DEFAULT)
const Field3D Grad_par(const Field3D &var, CELL_LOC outloc, DIFF_METHOD method)
const Field3D Grad_par(const Field3D &var, DIFF_METHOD method, CELL_LOC outloc)
const Field3D Grad_parP(const Field3D &apar, const Field3D &f)

Derivative along perturbed magnetic field in Clebsch coordinate system

b0 dot Grad - (1/B)b0 x Grad(apar) dot Grad

Combines the parallel and perpendicular calculation to include grid-points at the corners.

const Field2D Vpar_Grad_par(const Field2D &v, const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")

vpar times parallel derivative along unperturbed B-field (upwinding)

\[ v\mathbf{b}_0 \cdot \nabla f \]

Parameters
  • v: The velocity in y direction
  • f: The scalar field to be differentiated
  • outloc: The cell location of the output. By default this is the same as f
  • method: The numerical method to use. The default is set in the options

const Field2D Vpar_Grad_par(const Field2D &v, const Field2D &f, const std::string &method, CELL_LOC outloc = CELL_DEFAULT)
const Field2D Vpar_Grad_par(const Field2D &v, const Field2D &f, CELL_LOC outloc, DIFF_METHOD method)
const Field2D Vpar_Grad_par(const Field2D &v, const Field2D &f, DIFF_METHOD method, CELL_LOC outloc)
const Field3D Vpar_Grad_par(const Field3D &v, const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
const Field3D Vpar_Grad_par(const Field3D &v, const Field3D &f, const std::string &method, CELL_LOC outloc = CELL_DEFAULT)
const Field3D Vpar_Grad_par(const Field3D &v, const Field3D &f, CELL_LOC outloc, DIFF_METHOD method)
const Field3D Vpar_Grad_par(const Field3D &v, const Field3D &f, DIFF_METHOD method, CELL_LOC outloc)
const Field2D Div_par(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")

parallel divergence operator

\[ B \partial_{||}(f/B) = B \nabla\cdot (\mathbf{b}f/B ) \]

Parameters
  • f: The component of a vector along the magnetic field
  • outloc: The cell location for the result. By default the same as f
  • method: The numerical method to use

const Field2D Div_par(const Field2D &f, const std::string &method, CELL_LOC outloc = CELL_DEFAULT)
const Field2D Div_par(const Field2D &f, CELL_LOC outloc, DIFF_METHOD method)
const Field2D Div_par(const Field2D &f, DIFF_METHOD method, CELL_LOC outloc)
const Field3D Div_par(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
const Field3D Div_par(const Field3D &f, const std::string &method, CELL_LOC outloc = CELL_DEFAULT)
const Field3D Div_par(const Field3D &f, CELL_LOC outloc, DIFF_METHOD method)
const Field3D Div_par(const Field3D &f, DIFF_METHOD method, CELL_LOC outloc)
const Field3D Div_par(const Field3D &f, const Field3D &v)
const Field3D Div_par_flux(const Field3D &v, const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
const Field3D Div_par_flux(const Field3D &v, const Field3D &f, const std::string &method, CELL_LOC outloc = CELL_DEFAULT)
const Field3D Div_par_flux(const Field3D &v, const Field3D &f, CELL_LOC outloc, DIFF_METHOD method)
const Field3D Div_par_flux(const Field3D &v, const Field3D &f, DIFF_METHOD method, CELL_LOC outloc = CELL_DEFAULT)
const Field2D Grad2_par2(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")

second parallel derivative

\[ (\mathbf{b} dot \nabla)(\mathbf{b} dot \nabla) \]

Note: For parallel Laplacian use LaplacePar

Parameters
  • f: The field to be differentiated
  • outloc: The cell location of the result

const Field2D Grad2_par2(const Field2D &f, CELL_LOC outloc, DIFF_METHOD method)
const Field3D Grad2_par2(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
const Field3D Grad2_par2(const Field3D &f, CELL_LOC outloc, DIFF_METHOD method)
const Field3D Grad_par_CtoL(const Field3D &var)

Parallel derivatives, converting between cell-centred and lower cell boundary These are a simple way to do staggered differencing

const Field2D Grad_par_CtoL(const Field2D &var)
const Field3D Vpar_Grad_par_LCtoC(const Field3D &v, const Field3D &f, const std::string &region = "RGN_NOBNDRY")
const Field3D Vpar_Grad_par_LCtoC(const Field3D &v, const Field3D &f, REGION region = RGN_NOBNDRY)
const Field3D Grad_par_LtoC(const Field3D &var)
const Field2D Grad_par_LtoC(const Field2D &var)
const Field3D Div_par_LtoC(const Field3D &var)
const Field2D Div_par_LtoC(const Field2D &var)
const Field3D Div_par_CtoL(const Field3D &var)
const Field2D Div_par_CtoL(const Field2D &var)
const Field2D Div_par_K_Grad_par(BoutReal kY, const Field2D &f, CELL_LOC outloc = CELL_DEFAULT)

Parallel divergence of diffusive flux, K*Grad_par

\[ \nabla \cdot ( \mathbf{b}_0 kY (\mathbf{b}_0 \cdot \nabla) f ) \]

Parameters
  • kY: The diffusion coefficient
  • f: The field whose gradient drives a flux

const Field3D Div_par_K_Grad_par(BoutReal kY, const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)
const Field2D Div_par_K_Grad_par(const Field2D &kY, const Field2D &f, CELL_LOC outloc = CELL_DEFAULT)
const Field3D Div_par_K_Grad_par(const Field2D &kY, const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)
const Field3D Div_par_K_Grad_par(const Field3D &kY, const Field2D &f, CELL_LOC outloc = CELL_DEFAULT)
const Field3D Div_par_K_Grad_par(const Field3D &kY, const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)
const Field2D Delp2(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, bool useFFT = true)

Perpendicular Laplacian operator

This version only includes terms in X and Z, dropping derivatives in Y. This is the inverse operation to the Laplacian inversion class.

For the full perpendicular Laplacian, use Laplace_perp

const Field3D Delp2(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, bool useFFT = true)
const FieldPerp Delp2(const FieldPerp &f, CELL_LOC outloc = CELL_DEFAULT, bool useFFT = true)
const Field2D Laplace_perp(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT)

Perpendicular Laplacian, keeping y derivatives

const Field3D Laplace_perp(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)
const Field2D Laplace_par(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT)

Parallel Laplacian operator

const Field3D Laplace_par(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)
const Field2D Laplace(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT)

Full Laplacian operator (par + perp)

const Field3D Laplace(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)
const Field2D b0xGrad_dot_Grad(const Field2D &phi, const Field2D &A, CELL_LOC outloc = CELL_DEFAULT)

Terms of form b0 x Grad(phi) dot Grad(A)

const Field3D b0xGrad_dot_Grad(const Field3D &phi, const Field2D &A, CELL_LOC outloc = CELL_DEFAULT)

Terms of form

\[ \mathbf{b}_0 \times \nabla \phi \cdot \nabla A \]

Parameters
  • phi: The scalar potential
  • A: The field being advected
  • outloc: The cell location where the result is defined. By default the same as A.

const Field3D b0xGrad_dot_Grad(const Field2D &phi, const Field3D &A, CELL_LOC outloc = CELL_DEFAULT)
const Field3D b0xGrad_dot_Grad(const Field3D &phi, const Field3D &A, CELL_LOC outloc = CELL_DEFAULT)
const Field2D bracket(const Field2D &f, const Field2D &g, BRACKET_METHOD method = BRACKET_STD, CELL_LOC outloc = CELL_DEFAULT, Solver *solver = nullptr)

Compute advection operator terms, which can be cast as antisymmetric Poisson brackets

\[ [f, g] = (1/B) \mathbf{b}_0 \times \nabla f \cdot \nabla g \]

Parameters
  • f: The potential
  • g: The field being advected
  • method: The method to use
  • outloc: The cell location where the result is defined. Default is the same as g
  • solver: Pointer to the time integration solver

const Field3D bracket(const Field2D &f, const Field3D &g, BRACKET_METHOD method = BRACKET_STD, CELL_LOC outloc = CELL_DEFAULT, Solver *solver = nullptr)
const Field3D bracket(const Field3D &f, const Field2D &g, BRACKET_METHOD method = BRACKET_STD, CELL_LOC outloc = CELL_DEFAULT, Solver *solver = nullptr)
const Field3D bracket(const Field3D &f, const Field3D &g, BRACKET_METHOD method = BRACKET_STD, CELL_LOC outloc = CELL_DEFAULT, Solver *solver = nullptr)

Variables

constexpr BRACKET_METHOD BRACKET_STD = BRACKET_METHOD::standard
constexpr BRACKET_METHOD BRACKET_SIMPLE = BRACKET_METHOD::simple
constexpr BRACKET_METHOD BRACKET_ARAKAWA = BRACKET_METHOD::arakawa
constexpr BRACKET_METHOD BRACKET_CTU = BRACKET_METHOD::ctu
constexpr BRACKET_METHOD BRACKET_ARAKAWA_OLD = BRACKET_METHOD::arakawa_old