OOF2: The Manual
Name
Equation — Base class for Equations
Synopses
Only those methods useful when extending OOF2 are listed here.
C++ Synopsis
#include "engine/equation.h"
class Equation {const std::string& name() const;int dim() const;int ndof() const;Components* components() const;virtual FieldIndex* getIndex(const std::string& name) const;bool is_active(const CSubProblem* subproblem) const;
}
Description
Equation is the abstract base class for
all Equation objects. Like Fields and
Fluxes,
Equation instances are global objects
— there is one instance of each particular
Equation that is shared among all
meshes. For example, there is only one
Force_Balance
Equation, although many different
meshes may be solving it.
Like Fields and Fluxes, when an
Equation is created, a reference to it is
kept in the main OOF2 namespace with the name of the
Equation:
>>> from ooflib.SWIG.engine.equation import PlaneFluxEquation
>>> eq = PlaneFluxEquation("StressEq", Stress, 3) # creates variable StressEq
>>> StressEq is eq
True
Creating an Equation object does
not mean that it will be solved on a
mesh. Equations are only solved if they have been explicitly
activated
and their Fluxes
depend upon active Fields on
the mesh. Whether or not a Flux
depends on a Field is a
function of the mesh's material Properties.
The entire API for Equations is defined
in the base class. The derived classes redefine base class
methods but do not add any new ones of their own, except for
their constructors.
Most OOF2 extensions will probably never need to use an
Equation object explicitly.
Methods
const std::string& name() const
name returns the name assigned to
the Equation when it was created.
See Section 8.3.
int dim() const and int ndof() const
dim and
ndof are equivalent. They return
the number of components of in the
Equation. For example, the heat
equation has one component, while the in-plane force balance
equation has two.
Components* components() const
components returns a pointer to a
Components object which can be used to loop over the
components of the Equation. Unlike
Field::components,
Equation::components does not take a
Planarity argument.
For example, in C++ you can write
Equation *eqn = Equation::getEquation("Force_Balance");
for(IndexP index : *eqn->components()) {
... Do something with IndexP index
} or in Python:
from ooflib.SWIG.engine.equation import getEquation
for index in getEquation("Force_Balance").components():
... Do something with FieldIndex index
Note that the index object returned in C++ is an IndexP,
which is a wrapper around a FieldIndex pointer. In Python
the wrapping is unnecessary and the index object is just a
FieldIndex.
getIndex
FieldIndex* getIndex(std::string& name) const;
getIndex() returns a FieldIndex object,
given the name of the desired index.
Different Equation subclasses expect
different strings, and return different subclasses of
FieldIndex. For example, a DivergenceEquation
of a SymmetricTensorFlux
expects the name to be
"x" or y, and
returns a VectorFieldIndex.
In C++ the returned value is a pointer to a newly allocated
object. The caller is responsible for deleting it. An easy
way to do that is to wrap it in an IndexP:
Equation *eqn = ...;
IndexP index = IndexP(eqn->getIndex("x"));
bool is_active(const CSubProblem *subproblem) const
is_active indicates whether or not
the Equation is being
solved on the given subproblem.



