OOF2: The Manual
Name
OutputVal — Wrappers for Output data
Synopsis
C++ Synopsis
#include "engine/outputval.h"
class OutputVal {virtual double operator[](const IndexP& indexconst = 0);
virtual double& operator[](const IndexP& indexconst = 0);
virtual OutputVal& operator+=(const OutputVal& other) = 0;
virtual OutputVal& operator-=(const OutputVal& other) = 0;
virtual OutputVal& operator*=(double factor) = 0;
void component_pow(int power) = 0;
void component_square() = 0;
void component_sqrt() = 0;
std::vector<double>* value_list() const = 0;
IndexP getIndex(const std::string& str) const = 0;
IteratorP getIterator() const = 0;
}
class ScalarOutputVal: , public OutputVal {ScalarOutputVal(double x);
double value() const;
double& value();
}
ScalarOutputVal operator+(const ScalarOutputVal&, const ScalarOutputVal&); ScalarOutputVal operator-(const ScalarOutputVal&, const ScalarOutputVal&); ScalarOutputVal operator*(const ScalarOutputVal&, double); ScalarOutputVal operator*(double, const ScalarOutputVal&); ScalarOutputVal operator/(ScalarOutputVal&, double);
class VectorOutputVal: , public OutputVal {VectorOutputVal(int n);
int size() const;
double magnitude() const;
}
VectorOutputVal operator+(const VectorOutputVal&, const VectorOutputVal&); VectorOutputVal operator-(const VectorOutputVal&, const VectorOutputVal&); VectorOutputVal operator*(const VectorOutputVal&, double); VectorOutputVal operator*(double, const VectorOutputVal&); VectorOutputVal operator/(VectorOutputVal&, double);
#include "engine/symmmatrix.h"
class SymmMatrix3: , public OutputVal, public SymmMatrix {SymmMatrix3();
SymmMatrix3(double xx,
double yy,
double zz,
double yz,
double xz,
double xy);double operator[](const SymTensorIndex& index) const;
double& operator[](const SymTensorIndex& index);
double trace() const;
double determinant() const;
double secondInvariant() const;
double maxEigenvalue() const;
double midEigenvalue() const;
double minEigenvalue() const;
}
SymmMatrix3 operator+(const SymmMatrix3&, const SymmMatrix3&); SymmMatrix3 operator-(const SymmMatrix3&, const SymmMatrix3&); SymmMatrix3 operator*(const SymmMatrix3&, double); SymmMatrix3 operator*(double, const SymmMatrix3&); SymmMatrix3 operator/(SymmMatrix3&, double);
Python Synopsis
from oof2.SWIG.engine import outputval
class OutputVal:def __getitem__(self, index)
def getIndex(self, str)
def getIterator(self)
def __add__(self, other)
def __sub__(self, other)
def __mul__(self, other)
def __div__(self, other)
def component_pow(self, power)
def component_square(self)
def component_sqrt(self)
def value_list(self)
class ScalarOutputVal(OutputVal):def __init__(self, x)
def value(self)
class VectorOutputVal(OutputVal):def __init__(self, n)
def size(self)
def operator[](self, i)
def operator[](self, i)
from oof2.SWIG.engine import symmmatrix
class SymmMatrix3(OutputVal, SymmMatrix):def __init__(self, xx, yy, zz, yz, xz, xy)
def trace(self)
def determinant(self)
def secondInvariant(self)
def maxEigenvalue(self)
def midEigenvalue(self)
def minEigenvalue(self)
Source Files
-
SRC/engine/outputval.C
,SRC/engine/symmmatrix.C
: C++ source code -
SRC/engine/outputval.h
,SRC/engine/symmmatrix.h
: C++ header files -
SRC/engine/outputval.swg
,SRC/engine/symmmatrix.swg
: SWIG source code -
SRC/engine/outputval.spy
,SRC/engine/symmmatrix.spy
: Python code included in the SWIG output
Description
The OutputVal
classes are used to ferry
values from the finite element mesh out to the Python output machinery. The
classes give the output machinery the ability to decide what
further processing is possible
(e.g, computing components or
invariants). The OutputVal
subclasses
are wrappers for the actual datatypes (floats, tensors,
etc). The OutputValue
class provides a generic reference-counted wrapper for all of
the OutputVal
subclasses.
There are three subclasses of
OutputVal
:
-
ScalarOutputVal
for scalar quantities. -
VectorOutputVal
for vector quantities. -
SymmMatrix3
for symmetric 3×3 tensor quantities.
General OutputVal Methods
operator[](const IndexP& index), __getitem__(index)
operator[]
(in C++) and
__getitem__
(in Python) retrieve a component
of the data wrapped by the
OutputVal
. The argument must be an
IndexP
wrapper for the appropriate type of FieldIndex
.
operator+=(const OutputVal& other)
etc.
Arithmetic operations on OutputVals
are allowed where they make sense, both in C++ and Python.
In particular, it's possible to add or subtract two
OutputVals
of the same type, but it's not
possible to multiply or divide two
OutputVals
. It's only possible to
multiply or divide by floating point numbers.
Note that in many cases it's not necessary or desirable to
do arithmetic withOutputVal
objects.
The point of OutputVals
is to provide
a generic wrapper (via virtual functions in the base class)
to different kinds of output data. In any
non-generic situation, in which the
type of the data is known, it's better to do the arithmetic
on the underlying data directly, and then create a new
OutputVal
(of the appropriate flavor)
to hold the result.
component_pow(int power), component_square(), component_sqrt()
These functions operate on the components of an
OutputVal
. They operate
in-place. That is,
obj.component_square()
changes
obj
itself. It doesn't return a new
object.
std::vector<double>* value_list() const
value_list
returns a flat list of
the components of the OutputVal
, as
floating point numbers. For
SymmMatrix3
objects,
value_list
returns the six
independent components in Voigt order.
When used in C++, value_list
returns a vector that must be explicitly deallocated.
IndexP getIndex(const std::string& str)
getIndex
converts the standard
string representation of the name of a component to an IndexP
object, which can be used to access components.
For SymmMatrix3
objects, the argument
str
must be a two character string made
up of only 'x'
, 'y'
,
and 'z'
. For
VectorOutputVals
,
str
must be exactly
"x"
, "y"
, or
"z"
. For
ScalarOutputVals
,
str
is ignored.
IteratorP getIterator() const
getIterator
returns an IteratorP object suitable
for iterating over the components of the
OutputVal
.
ScalarOutputVal Methods
Methods that ScalarOutputVal
has in common
with other OutputVals
are discussed
above.
VectorOutputVal Methods
Methods that VectorOutputVal
has in common
with other OutputVals
are discussed
above.
SymmMatrix3 Methods
Methods that SymmMatrix3
has in common
with other OutputVals
are discussed
above.
SymmMatrix3(), SymmMatrix3(double...)
In C++, there are two constructors for the
SymmMatrix3
class. The version with
no arguments creates a SymmMatrix3
with all components set to zero. In the second version, all
of the components are specified by the arguments, in Voigt order.
In Python, all of the arguments to the
SymmMatrix3
constructor are optional,
with the missing ones defaulting to zero. It's best to use
keyword arguments, like this:
tensor = SymmMatrix3(xy=1.23, xz=4.56)
If keywords aren't used, then the arguments must be in Voigt order.