OOF2: The Manual
Name
Field — Base class for fields
Synopses
(Only those methods useful when extending OOF2 are listed here.)
C++ Synopsis
#include "engine/field.h"class Field {const std::string& name() const;int ndof() const;virtual IteratorP iterator(Planarity planarity) const;bool is_defined(const CSubProblem* subproblem) const;bool is_active(const CSubProblem* subproblem) const;virtual DegreeOfFreedom* operator()(const FuncNode* node,
int component) const;DegreeOfFreedom* operator()(const FuncNode& node,
int component) const;DegreeOfFreedom* operator()(const ElementFuncNodeIterator& node,
int component) const;double value(const FuncNode* node,
int component) const;double value(const ElementFuncNodeIterator& node,
int component) const;virtual OutputValue output(const ElementFuncNodeIterator& node) const;virtual OutputValue output() const;
}
Python Synopsis
from oof2.SWIG.engine.field import Fieldclass Field:def ndof(self)def is_defined(self, mesh)def is_active(self, mesh)def iterator(self, planarity)def value(self, node, component)
Description
Field is a base class for all types of
fields in OOF2. The role of fields is described in Section 2.5.3. Like Fluxes and
Equations,
Field instances are global objects — there is one
instance for each physical field. Fields store information
about the physical field (such as its name and dimension), but
do not store the actual values of the Field. That's done by
a Mesh, by using bookkeeping data from a Field.
Most of the programming interface for Fields is defined in
the base class, which is an abstract C++ class. Most of the
API is available from both C++ and Python.
Most of the Field objects encountered by OOF2 users and
extenders are actually instances of the CompoundField
class, which pairs the in-plane and out-of-plane parts of a
Field, both of which are Fields themselves. All
operations on a CompoundField operate
on the in-plane part, unless specifically noted otherwise.
Methods
std::string & name() const
name returns the name assigned to
the Field when it was created. See
Section 8.1.
int ndof() const
ndof returns the number of degrees
of freedom in the Field. This is the
number of data values that must be allocated to store the
Field at each Node of the Mesh.
For CompoundFields,
ndof returns the size of the
in-plane part.
IteratorP iterator(Planarity p)
iterator returns an IteratorP
object which can be used to loop over all of the degrees of
freedom of a Field. For example, the
following code snippet zeros the values of a
Field on a node:
Field field; // Assume that this has been set.
ElementFuncNodeIterator node; // This too.
FEMesh *mesh; // And this.
for(IteratorP i=field.iterator(ALL_INDICES); !i.end(); ++i) {
DegreeOfFreedom *dof = field(mesh, node, i);
dof->value() = 0.0;
}
bool is_defined(const FEMesh *mesh) const
is_defined indicates whether the
Field has been defined on
the given FEMesh.
Defined Fields have been assigned
values on Nodes.
bool is_active(const FEMesh *mesh) const
is_active indicates whether the
Field has been activated on
the given FEMesh.
Active Fields are being solved for.
DegreeOfFreedom *operator()(...)
const
DegreeOfFreedom *operator()(const FuncNode*, int component) const; DegreeOfFreedom *operator()(const FuncNode&, int component) const; DegreeOfFreedom *operator()(const ElementFuncNodeIterator&, int component) const; DegreeOfFreedom *operator()(const ElementFuncNodeIterator&, const IteratorP&) const;
This family of methods are all ways of obtaining the value
of a Field at the given Node.
The different methods are provided for convenience, to allow
different representations of Nodes or
Field components. All of these
methods return a pointer to a DegreeOfFreedom
object, which wraps the actual Field
component value and is stored at the
Node.
DegreeOfFreedoms are low-level,
fairly primitive objects, so these methods cannot be used to
extract aggregate values (such as all of the components of a
multicomponent Field). To do that,
see Field::output.
These functions only return Field
values at Nodes. To get values
interpolated at an arbitrary point within an Element,
see Element::outputField.
double value(node, component)
The value function is a shortcut
for evaluating a component of a Field
at a Node. In C++, the given
node must be a FuncNode
pointer or a ElementFuncNodeIterator
reference. In Python, it must be a FuncNode
object.
OutputValue output(...) const
OutputValue output(const ElementFuncNodeIterator&) const; OutputValue output(const FuncNode&) const = 0;
These functions return an OutputValue
object which wraps an OutputVal
object which contains the value of the
Field at the given Node.
These calls are mostly used as a mechanism for generically
transferring Field values to Python
when plotting data, but they can also be useful when writing
Field-dependent Propertys.
The output functions differ from
Field::operator()
by returning all of the components of a multi-dimensional
Field in one call.



