Algebraic operators#

BOUT++ provides a wide variety of algebraic operators acting on fields.

The algebraic operators are listed in Table 18. For a completely up-to-date list, see the Non-member functions part of field2d.hxx, field3d.hxx, fieldperp.hxx.

Table 18 Algebraic operators#



min(f, allpe=true, region)

Minimum (optionally over all processes)

max(f, allpe=true, region)

Maximum (optionally over all processes)

pow(lhs, rhs, region)


sqrt(f, region)


abs(f, region)


exp(f, region)


log(f, region)


sin(f, region)


cos(f, region)


tan(f, region)


sinh(f, region)


cosh(f, region)


tanh(f, region)


floor(f, region)

Returns a field with the floor of f at each point

filter(f, n, region)

Calculate the amplitude of the Fourier mode in the z-direction with mode number n

lowpass(f, nmax, region)

Remove Fourier modes (in the z-direction) with mode number higher than zmax

lowpass(f, nmax, nmin, region)

Remove Fourier modes (in the z-direction) with mode number higher than zmax or lower than zmin

shiftZ(f, angle, region)

Rotate f by angle in the z-direction. \(\mathtt{angle}/2\pi\) is the fraction of the domain multiplied by \(2\pi\) so angle is in radians if the total size of the domain is \(2\pi\)

DC(f, region)

The average in the z-direction of f (DC stands for direct current, i.e. the constant part of f as opposed to the AC, alternating current, or fluctuating part)

These operators take a region argument, whose values can be [1] (see Iterating over fields)

The default value for the region argument is RGN_ALL which should work in all cases. However, the region argument can be used for optimization, to skip calculations in guard cells if it is known that those results will not be needed (for example, if no derivatives of the result will be calculated). Since these operators can be relatively expensive compared to addition, subtraction, multiplication this can be a useful performance improvement.