OOF2: The Manual
Name
PropertyRegistration — Register new Properties
Synopsis
from oof2.engine.propertyregistration import PropertyRegistration class PropertyRegistration: def __init__(self, name, subclass, modulename, ordering, params=[], fields=[], fluxes=[], propertyType=None, outputs=[], nonlinear=0, secret=0, tip=parameter.emptyTipString, discussion=parameter.emptyTipString)
Description
Every new Property
class must have a single
PropertyRegistration
object. The
PropertyRegistration
contains meta-data
about the Property
and inserts it in
the global list of all Property
classes, which allows it to appear in the user interface.
PropertyRegistrations
are defined only
in Python, even for Properties
that are
defined in C++. This means that all C++
Property
subclasses must be swigged. It's
sufficient to swig the class and the constructor. Other
methods do not have to be made available in Python.
PropertyRegistration
constructor parameters
The only required parameters are name
,
subclass
, modulename
,
and ordering
. The others can all be
omitted if they're not needed for a particular
Property
. The default values for the
optional parameters are given in the synopsis, above.
When creating a PropertyRegistration
,
it's advisable to use Python keyword arguments so that it's
clear which parameters have been omitted.
name
-
name
is a string containing the name of theProperty
, as it will appear in scripts and in the GUI. In the GUI,Properties
are arranged hierarchically in a tree. Thename
is a colon separated string, in which each segment is a branch of theProperty
tree. For example, the cubic elasticity property'sname
isMechanical:Elasticity:Anisotropic:Cubic
, and it appears in the GUI like this: subclass
-
This is the
Property
class that is being registered. It must either be a swigged C++Property
subclass, a Python class derived from a swigged C++Property
subclass, or a Python class derived fromPyPropertyWrapper
. Note that the argument is the actual class, not an instance of the class. modulename
-
modulename
is a string containing the name of the Python module in which the Python interface to the class is defined. For example, if the swig output file isshoofly.py
in directoryXYZ
which is in the Python path, thenmodulename
would be'XYZ.shoofly'
. ordering
-
ordering
determines thisProperty
's position when listed in the GUI. It has no other significance. It can be either an integer or a floating point number. (Nodes of theProperty
tree in the GUI are listed in order of increasingordering
. Theordering
of an intermediate node in the tree is taken to be the smallestordering
of any of its children.) params
-
The arguments for every
Property
's constructor are a name, a registration, and a variable number of additional values that quantify theProperty
's behavior. These additional arguments are determined by thePropertyRegistration
'sparams
argument.params
is a Python list ofParameter
subclass instances. Each entry in the list specifies a type (which is implied by theParameter
subclass), a constructor argument name, a default value, and a help string. The parameters must appear in the same order in theparams
list as they do in theProperty
's constructor's argument list.For example, a mass density
Property
could have aFloatParameter
calleddensity
,params=[FloatParameter('density', value=1.0, tip='mass density')]
while a triclinic thermal expansion
Property
would have aTriclinicRank2TensorParameter
(for the modulus) and aFloatParameter
for the zero-stress temperature:params = [TriclinicRank2TensorParameter( name='alpha', value=TriclinicRank2Tensor(xx=1, yy=1, zz=1), tip='Thermal expansion tensor'), FloatParameter('T0', 0.0, tip='Stress free temperature') ]
See Parameter for a list of all of OOF2's built-in
Parameter
types and their constructor arguments. fields
-
This is a list of
Field
objects, indicating whichFields
theProperty
depends upon. TheProperty
will not be used unless all of theFields
in the list are defined on the mesh being solved. fluxes
-
This is a list of
Flux
objects, indicating whichFluxes
theProperty
contributes to. TheProperty
will not be used unless some of theFluxes
in the list are used in the activeEquations
. propertyType
-
The
propertyType
is a string that categorizes theProperty
. No twoProperties
in aMaterial
can have the samepropertyType
. The functionMaterial::fetchProperty
locatesProperties
by theirpropertyType
.When registering a new
Property
, it's important to use the samepropertyType
that was used for otherProperties
of that type. The existing OOF2propertyTypes
are given in Table 8.3. outputs
-
outputs
is a list of strings, each one the name of anPropertyOutput
to which theProperty
'soutput
function contributes. nonlinear
-
nonlinear
should be set to 1 if nonlinear solvers will be needed to solve a mesh containing thisProperty
. Generally, this means that theProperty
contains quantities that areField
dependent. secret
-
secret
should be set to 1 if theProperty
shouldn't appear in the GUI. This should not be used except by those who know what they're doing. tip
-
tip
is a short string describing theProperty
. It should be something suitable for displaying as a pop-up tooltip in the GUI. discussion
-
discussion
is a longer string describing theProperty
, meant to be included in the OOF2 manual. The string should be written in DocBook XML. The manual will embed it inside a<refsect1>
element.[62]Since it's often inconvenient to include large blocks of text inside a
PropertyRegistration
, the text can be put into a separate file. The file name can be passed to the functionloadFile
from theoof2.common.IO.xmlmenudump
module. Thendiscussion
should be set to the return value fromloadFile
. (loadFile
doesn't actually read the file unless the users manual is being generated, so there's no cpu or memory used when doing it this way, and the file often doesn't even have to be distributed with the code.) In any case, thediscussion
argument is optional. A generic message will be generated if it's absent.
Property Types
The following table lists the propertyTypes
used in OOF2 PropertyRegistrations
.
Not all of the types listed here are fully available yet
— some are still in development or reserved for future
use.
Table 8.3. Property Types
|
Description |
---|---|
|
Spatial charge distribution |
|
Dielectric permittivity |
|
Elastic modulus |
|
Externally applied body force density |
|
Heat sources and sinks |
|
Heat capacity |
|
Mass density, for dynamic equations |
|
Crystalline orientation |
|
Piezoelectric modulus |
|
Plastic deformation rules |
|
Thermal conductivity |
|
Thermal expansion tensor and stress-free temperature |