4.7. Utilities

A set of utilities are provided with cbcpost. Below are just a few of them. For a more complete set of utilities, refer to the programmers-reference.

4.7.1. The ParamDict-class

The ParamDict-class extends to the stadard python dict. It supports dot-notation (mydict[“key”] == mydict.key), and nested parameters.


Extend this documentation.

4.7.2. The Parameterized-class

The Parameterized-class is sued for classes that are associated with a set of parameters. All subclasses must implement the method Parameterized.default_params(), which return a ParamDict/dict with default values for the parameters.

When initialized, it takes a params-option where specific parameters are set, and overwriting the associated parameters returned from default_params. This is then stored in an attribute params attached to the object.

When initializing a Parameterized-object, no new keys are allowed. This means that all parameters of a Parameterized-instance must be defined with default values in default_params.

The class is subclasses several places within cbcpost:

  • Field
  • PostProcessor
  • Restart
  • Replay

4.7.3. Pooling of function spaces

When using many different functions across a large function, it may be useful to reuse FunctionSpace definitions. This has two basic advantages:

  • Reduced memory consumption
  • Reduced computational cost

Space pools are grouped according to mesh, with Mesh.id() used as keys in a weakref.WeakValueDictionary. Once a mesh is out of focus in the program, the related SpacePool is removed.

4.7.4. Submesh creation

The SubMesh-class in dolfin is not currently supported in dolfin. In cbcpost, the function create_submesh() is the equivalent functionality, but with parallel support.

This allows for arbitrary submeshes in parallel based by providing a MeshFunction and marker.


Submesh created with create_submesh in cbcpost.

4.7.5. Mesh slicing

Three-dimensional meshes can be sliced in cbcpost with the Slice-class. The Slice-class takes basemesh, togetther with a point and normal defining the slicing plane, to create a slicemesh.

The Slice-class is a subclass of dolfin.Mesh.


A complex 3D-mesh, with an associated slicemesh.


Slice-instances are intended for visualization only, and may produce erronous results if used for computations.