OOF2: The Manual
Name
FieldIndex — Base class for index objects
Synopses
C++ Synopsis
#include "engine/fieldindex.h"
class FieldIndex {virtual int integer() const;operator int() const;virtual bool in_plane() const;virtual FieldIndex* clone() const;
}
Description
FieldIndex is the abstract base class for
classes which refer to the components of multi-dimensional
Fields, Fluxes, Equations, and OutputVals. The
different subclasses refer to components of scalars, vectors,
and tensors.
In C++, a FieldIndex is usually obtained
by looping over a Field or Flux's components,
or calling their getIndex
method. In the first case, the returned index is automatically
wrapped in an IndexP, which handles the deallocation of the
FieldIndex. In the second, the returned
FieldIndex pointer needs to either be
explicitly deallocated or manually wrapped in an IndexP.
In Python there is no need for the IndexP class. Whenever a
FieldIndex object is returned from a C++
function to Python, it is converted into an object of the
appropriate derived class. Thus, in Python every
FieldIndex object is explicitly a ScalarFieldIndex,
VectorFieldIndex,
or other subclass of FieldIndex.
Methods
virtual int integer() const
Every kind of FieldIndex
has a canonical ordering of the indices that it
represents. For example, a VectorFieldIndex
takes the values x, y, z in that
order, and a SymTensorIndex
takes the values xx, yy, zz, yz, xz,
xy, in that order.
FieldIndex::integer() returns the
current value's position in the canonical list.
integer() is used whenever an
FieldIndex needs to determine a
position in a Python list, C++
std::vector, or other linear storage
structure. It may also be used in some situations where
functions weren't designed to accept the more abstract
FieldIndex or
IndexP objects, for whatever reason.
operator int() const
operator int converts a FieldIndex
to an integer by calling FieldIndex::integer().
It allows a FieldIndex to be used as an argument to a C++
function that is expecting a integer.
virtual bool in_plane() const
in_plane indicates whether or not
the FieldIndex refers to an in-plane or
out-of-plane index. For vectors, x
and y are in-plane and
z is out-of-plane. For tensors, any
set of indices containing a z is
out-of-plane.
virtual FieldIndex* clone() const
A FieldIndex obtained by looping over Components is
transient, and will be deleted when the iteration is
complete. If it's necessary to retain a FieldIndex, call
clone() to create a new one. It is the
caller's responsibility to delete the returned pointer.



