The bempp.visualization2 module

Introduction

This module contains functions employing the VTK toolkit to plot grid functions and solutions of integral equations.

Reference

bempp.visualization2.plotData(tvtkGrids=None, tvtkGridFunctions=None, tvtkStructuredGridData=None, dataRange=None, scalar=True)

Visualize multiple scalar or vector data sets in the same plot.

This function plots an arbitrary number of grids, grid functions and data sets sampled on regular 2D grids of points in a single window. The grid functions and structured grid data can be scalar- or vector-valued depending on the value of the parameter ‘scalar’.

Parameters:
  • tvtkGrids:

    None, an object returned by tvtkGrid(), or a list of such objects.

  • tvtkGridFunctions:

    None, an object returned by tvtkGridFunction(), or a list of such objects.

  • tvtkStructuredGridData

    None, an object returned by tvtkStructuredGridData(), or a list of such objects.

  • dataRange

    Can be None or a tuple of two floats. In the first case, the data range of the plot will be determined automatically, otherwise it will be set to the specified tuple.

  • scalar (bool)

    If True, the arguments tvtkGridFunctions and tvtkStructuredGridData should represent scalar-valued data sets, otherwise vector-valued data sets.

Returns a Traits object that contains the visualization.

bempp.visualization2.plotGrid(grid, representation='wireframe')

Visualize a grid.

Parameters:
  • gf (Grid):

    The grid to be plotted.

  • representation (str)

    Plot type (e.g. ‘wireframe’, ‘surface’).

Returns a Traits object that contains the visualization.

bempp.visualization2.plotGridFunction(gf, dataRange=None)

Visualize a grid function.

Parameters:
  • gf (GridFunction):

    The grid function to be plotted.

Returns a Traits object that contains the visualization.

bempp.visualization2.plotScalarData(tvtkGrids=None, tvtkGridFunctions=None, tvtkStructuredGridData=None, dataRange=None)

Visualize multiple scalar data sets in the same plot.

This function plots an arbitrary number of grids, scalar-valued grid functions and
data sets sampled on regular 2D grids of points in a single window.
Parameters:
  • tvtkGrids:

    None, an object returned by tvtkGrid(), or a list of such objects.

  • tvtkGridFunctions:

    None, an object returned by tvtkGridFunction(), or a list of such objects.

  • tvtkStructuredGridData

    None, an object returned by tvtkStructuredGridData(), or a list of such objects.

  • dataRange

    Can be None or a tuple of two floats. In the first case, the data range of the plot will be determined automatically, otherwise it will be set to the specified tuple.

Returns a Traits object that contains the visualization.

bempp.visualization2.plotStructuredGridData(points, data, dims, dataRange=None)

Visualize data sampled on a regular 2D grid of points.

Parameters:
  • points (2D NumPy array):

    Array of point coordinates of dimension (3, np), where np is the number of points. The points should be lying on a regular grid.

  • data (1D or 2D NumPy array)

    Array of data values corresponding to each point. It can be either a 1D array of length np (number of points) or a 2D array of dimensions (1, np) or (3, np).

  • dims

    A tuple of two numbers representing the first and second dimension of the grid of points. Their product must be equal to np.

  • dataRange

    Can be None or a tuple of two floats. In the first case, the data range of the plot will be determined automatically, otherwise it will be set to the specified tuple.

Returns a Traits object that contains the visualization.

Example usage:

import numpy as np
from bempp import visualization2 as vis

x, y, z = np.mgrid[0:1:5j, 0:2:10j, 0:0:1j]
nx, ny = x.shape[:2]
points = np.vstack((x.ravel(), y.ravel(), z.ravel()))

evaluationOptions = createEvaluationOptions()
field = somePotentialOperator.evaluateAtPoints(someGridFunction, points,
                                               evaluationOptions)
vis.plotStructuredGridData(points, field, (nx, ny))
bempp.visualization2.plotThreePlanes(points, vals)

Plot a three planes view of data.

Parameters:
  • points:

    An mgrid object defining points in a box.

  • vals:

    The corresponding values.

Potential values in the correct format are returned by the function tools.evaluatePotentialInBox.

bempp.visualization2.plotVectorData(tvtkGrids=None, tvtkGridFunctions=None, tvtkStructuredGridData=None, dataRange=None)

Visualize multiple scalar data sets in the same plot.

This function plots an arbitrary number of grids, vector-valued grid functions and data sets sampled on regular 2D grids of points in a single window.

Parameters:
  • tvtkGrids:

    None, an object returned by tvtkGrid(), or a list of such objects.

  • tvtkGridFunctions:

    None, an object returned by tvtkGridFunction(), or a list of such objects.

  • tvtkStructuredGridData

    None, an object returned by tvtkStructuredGridData(), or a list of such objects.

  • dataRange

    Can be None or a tuple of two floats. In the first case, the data range of the plot will be determined automatically, otherwise it will be set to the specified tuple.

Returns a Traits object that contains the visualization.

bempp.visualization2.show()

Display the graphical objects created so far

bempp.visualization2.tvtkGrid(grid)

Return a TVTK object visualizing the specified grid.

bempp.visualization2.tvtkGridFunction(g)

Return a TVTK object visualizing the specified grid function.

bempp.visualization2.tvtkStructuredGridData(points, data, dims)

Return a TVTK object visualizing data on a structured grid.

Parameters:
  • points (2D NumPy array):

    Array of point coordinates of dimension (3, np), where np is the number of points. The points should be lying on a regular grid.

  • data (1D or 2D NumPy array)

    Array of data values corresponding to each point. It can be either a 1D array of length np (number of points) or a 2D array of dimensions (1, np) or (3, np).

  • dims

    A tuple of two numbers representing the first and second dimension of the grid of points. Their product must be equal to np.

Example usage:

import numpy as np
from bempp import visualization2 as vis

evaluationOptions = createEvaluationOptions()

x, y, z = np.mgrid[0:1:5j, 0:2:10j, 0:0:1j]
nx, ny = x.shape[:2]
points = np.vstack((x.ravel(), y.ravel(), z.ravel()))
field = somePotentialOperator.evaluateAtPoints(someGridFunction, points,
                                               evaluationOptions)
tvtkObj1 = vis.tvtkStructuredGridData(points, field, (nx, ny))

x, y, z = np.mgrid[0:0:1j, 0:2:10j, 0:5:7j]
ny, nz = x.shape[1:]
points = np.vstack((x.ravel(), y.ravel(), z.ravel()))
field = somePotentialOperator.evaluateAtPoints(someGridFunction, points,
                                               evaluationOptions)
tvtkObj2 = vis.tvtkStructuredGridData(points, field, (ny, nz))
plotScalarData(tvtkStructuredData=[tvtkObj1, tvtkObj2])

Table Of Contents

Previous topic

The bempp.visualization module

This Page