File vector2d.hxx

Class for 2D vectors. Built on the Field2D class, all operators relating to vectors are here (none in Field classes). As with Field2D, Vector2D are constant in z (toroidal angle) Components are either co- or contra-variant, depending on a flag. By default they are covariant.

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

Author

B. Dudson, October 2007

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

Defines

__VECTOR2D_H__

Functions

const Vector2D operator*(BoutReal lhs, const Vector2D &rhs)
const Vector2D operator*(const Field2D &lhs, const Vector2D &rhs)
const Vector3D operator*(const Field3D &lhs, const Vector2D &rhs)
const Vector2D cross(const Vector2D &lhs, const Vector2D &rhs)

Cross product.

const Vector3D cross(const Vector2D &lhs, const Vector3D &rhs)

Cross product.

const Coordinates::FieldMetric abs(const Vector2D &v, const std::string &region = "RGN_ALL")

Absolute value (Modulus) of given vector v

|v| = sqrt( v dot v )

inline const Coordinates::FieldMetric abs(const Vector2D &v, REGION region)
inline Vector2D toFieldAligned(Vector2D v, const std::string &region = "RGN_ALL")

Transform to and from field-aligned coordinates.

inline Vector2D fromFieldAligned(Vector2D v, const std::string &region = "RGN_ALL")
inline Vector2D emptyFrom(const Vector2D &v)

Create new Vector2D with same attributes as the argument, but uninitialised components.

inline Vector2D zeroFrom(const Vector2D &v)

Create new Vector2D with same attributes as the argument, and zero-initialised components.

inline Vector2D &ddt(Vector2D &f)

Time derivative of 2D vector field.

class Vector2D : public FieldData
#include <vector2d.hxx>

A vector with three components (x,y,z) which only vary in 2D (x and y). Implemented as a collection of three Field2D objects.

Public Functions

Vector2D(const Vector2D &f)
Vector2D(Mesh *localmesh = nullptr, bool covariant = true, CELL_LOC location = CELL_LOC::centre)

Many-argument constructor for fully specifying the initialisation of a Vector3D.

~Vector2D() override
void toCovariant()

In-place conversion to covariant form.

void toContravariant()

In-place conversion to contravariant form.

Vector2D *timeDeriv()

Return a pointer to the time-derivative field.

Vector2D &operator=(const Vector2D &rhs)

Assignment.

Vector2D &operator=(BoutReal val)

Assign a BoutReal value. This sets all components to the same value val.

Vector2D v = 0.0;

is equivalent to

Vector2D v; v.x = 0.0; v.y = 0.0; v.z = 0.0;

The only real use for this is setting vector to zero.

Vector2D &operator+=(const Vector2D &rhs)
const Vector2D operator-() const

Unary minus, changes sign of all components.

Vector2D &operator-=(const Vector2D &rhs)

Subtract another vector.

Vector2D &operator*=(BoutReal rhs)

Multiply all components by rhs.

Vector2D &operator*=(const Field2D &rhs)

Multiply all components by rhs.

Vector2D &operator/=(BoutReal rhs)

Divide all components by rhs.

Vector2D &operator/=(const Field2D &rhs)

Divide all components by rhs.

const Vector2D operator+(const Vector2D &rhs) const

Addition.

const Vector3D operator+(const Vector3D &rhs) const

Addition.

const Vector2D operator-(const Vector2D &rhs) const

Subtract vector rhs.

const Vector3D operator-(const Vector3D &rhs) const

Subtract vector rhs.

const Vector2D operator*(BoutReal rhs) const

Multiply all components by rhs.

const Vector2D operator*(const Field2D &rhs) const

Multiply all components by rhs.

const Vector3D operator*(const Field3D &rhs) const

Multiply all components by rhs.

const Vector2D operator/(BoutReal rhs) const

Divides all components by rhs.

const Vector2D operator/(const Field2D &rhs) const

Divides all components by rhs.

const Vector3D operator/(const Field3D &rhs) const

Divides all components by rhs.

const Coordinates::FieldMetric operator*(const Vector2D &rhs) const

Dot product.

const Field3D operator*(const Vector3D &rhs) const

Dot product.

virtual Vector2D &setLocation(CELL_LOC loc) override

Set component locations consistently.

virtual CELL_LOC getLocation() const override

Get component location.

inline virtual bool is3D() const override

True if variable is 3D.

inline virtual int elementSize() const override

Number of BoutReals in one element.

virtual void applyBoundary(bool init = false) override

Apply boundary condition to all fields.

inline void applyBoundary(const std::string &condition)
inline void applyBoundary(const char *condition)
virtual void applyTDerivBoundary() override

Public Members

Coordinates::FieldMetric x
Coordinates::FieldMetric y
Coordinates::FieldMetric z

components

bool covariant = {true}

true if the components are covariant (default)

Private Members

Vector2D *deriv = {nullptr}

Time-derivative, can be NULL.

CELL_LOC location = {CELL_CENTRE}

Location of the variable in the cell.