Skip to content

Scalar Quantities

Visualize scalar (real or integer)-valued data at the elements of a volume mesh.

volume mesh scalar values

Example: showing a scalar on vertices (here, random values)

# ... initialization, create mesh ...

ps_vol = ps.register_volume_mesh("test volume mesh", verts, tets=tets)

n_vert = verts.shape[0]
n_cell = tets.shape[0]

# Add a scalar function on vertices
data_vert = np.random.rand(n_vert)
ps_vol.add_scalar_quantity("my vertex val", data_vert)

# Add a scalar function on cells (with some options set)
data_cell = np.random.rand(n_cell)
ps_vol.add_scalar_quantity("my cell val", data_cell, defined_on='cells',
                           vminmax=(-3., 3.), cmap='blues', enabled=True)

// Show the GUI
ps.show()

Add scalars to elements

VolumeMesh.add_scalar_quantity(self, name, values, defined_on='vertices', enabled=None, datatype="standard", vminmax=None, cmap=None)

Add a scalar quantity to the mesh.

  • name string, a name for the quantity
  • values a length N numpy array, scalars at vertices/cells
  • defined_on one of 'vertices','cells', is this data a value per vertex or a value per cell?

This function also accepts optional keyword arguments listed below, which customize the appearance and behavior of the quantity.

Inspecting with slice planes

Slice planes have special functionality for volume mesh vertex values—they can inspect quantities on volume meshes and render them on the interior of the volume. See the slice plane documentation for details.

Scalar Quantity Options

When adding a scalar quantity, the following keyword options can be set. These are available for all kinds of scalar quantities on all structures.

Keyword arguments:

  • enabled boolean, whether the quantity is initially enabled (note that generally only one quantitiy can be shown at a time; the most recent will be used)
  • datatype, one of "standard", "symmetric", or "magnitude", affects default colormap and map range
  • vminmax, a 2-tuple of floats, specifying the min and max range for colormap limits; the default is None, which computes the min and max of the data
  • cmap, which colormap to use
  • isoline keywords (darker-shaded stripes showing isocontours of the scalar field):
    • isolines_enabled are isolines enabled (default: False)
    • isoline_width how wide should the darkend stripes be, in data units (default: dynamically estimated)
    • isoline_width_relative if true, interpret the width value as relative to the world coordinate length scale (default: False)
    • isoline_darkness how much darker should the alternating stripes be (default: 0.7)

If not specified, these optional parameters will assume a reasonable default value, or a persistent value if previously set.