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 Field2D abs(const Vector2D &v, const std::string &region = "RGN_ALL")

Absolute value (Modulus) of given vector v

|v| = sqrt( v dot v )

const Field2D abs(const Vector2D &v, REGION region)
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(Mesh *fieldmesh = nullptr)
Vector2D(const Vector2D &f)
~Vector2D()
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 Field2D operator*(const Vector2D &rhs) const

Dot product.

const Field3D operator*(const Vector3D &rhs) const

Dot product.

void setLocation(CELL_LOC loc)

Set variable cell location

CELL_LOC getLocation() const
void accept(FieldVisitor &v)

Visitor pattern support.

bool isReal() const

Returns true if field consists of BoutReal values.

bool is3D() const

True if variable is 3D.

int byteSize() const

Number of bytes for a single point.

int BoutRealSize() const

Number of BoutReals (not implemented if not BoutReal)

void applyBoundary(bool init = false)

Apply boundary condition to all fields.

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

Public Members

Field2D x
Field2D y
Field2D 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.