# File field3d.cxx¶

Class for 3D X-Y-Z scalar fields

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/.

Functions

Field3D operator-(const Field3D &f)

Unary minus. Returns the negative of given field, iterates over whole domain including guard/boundary cells.

Field3D pow(const Field3D &lhs, const Field2D &rhs, const std::string &rgn = "RGN_ALL")

Exponent: pow(lhs, lhs) is lhs raised to the power of rhs

Extra overloads not provided by the templates in field.hxx

This loops over the entire domain, including guard/boundary cells by default (can be changed using the rgn argument). If CHECK >= 3 then the result will be checked for non-finite numbers

FieldPerp pow(const Field3D &lhs, const FieldPerp &rhs, const std::string &rgn)
Field3D filter(const Field3D &var, int N0, const std::string &rgn = "RGN_ALL")

Fourier filtering, removes all except one mode

Parameters
• var: Variable to apply filter to
• N0: The component to keep
• rgn: The region to calculate the result over

Field3D lowPass(const Field3D &var, int zmax, bool keep_zonal, const std::string &rgn = "RGN_ALL")

Fourier low pass filtering. Removes modes higher than zmax and optionally the zonal component

Parameters
• var: Variable to apply filter to
• zmax: Maximum mode in Z
• keep_zonal: Keep the zonal component if true
• rgn: The region to calculate the result over

void shiftZ(Field3D &var, int jx, int jy, double zangle)

Perform a shift by a given angle in Z

Parameters
• var: The variable to be modified in-place
• jx: X index
• jy: Y index
• zangle: The Z angle to apply

void shiftZ(Field3D &var, BoutReal zangle, const std::string &rgn = "RGN_ALL")

Apply a phase shift by a given angle zangle in Z to all points

Parameters
• var: The variable to modify in-place
• zangle: The angle to shift by in Z
• rgn: The region to calculate the result over

void checkData(const Field3D &f, const std::string &region = "RGN_NOBNDRY")

Throw an exception if f is not allocated or if any elements are non-finite (for CHECK > 2). Loops over all points including the boundaries by default (can be changed using the rgn argument

Field2D DC(const Field3D &f, const std::string &rgn = "RGN_ALL")

Average in the Z direction

Parameters
• f: Variable to average
• rgn: The region to calculate the result over

void invalidateGuards(Field3D &var)

Force guard cells of passed field var to NaN.

bool operator==(const Field3D &a, const Field3D &b)

Test if two fields are the same, by calculating the minimum absolute difference between them

std::ostream &operator<<(std::ostream &out, const Field3D &value)

Output a string describing a Field3D to a stream.