bempp.api.grid.io

Routines for import and export.

Module Contents

Functions

import_grid(filename)

Import a grid.

export(filename[, grid, grid_function, data_type, ...])

Export grids and grid functions.

_transform_array(a[, mode])

Transform a data array.

bempp.api.grid.io.import_grid(filename)

Import a grid.

This routine uses the meshio library to export grids. A number of types are supported, including vtk, vtu, gmsh, dolphin xml. For a full list see

https://github.com/nschloe/meshio

bempp.api.grid.io.export(filename, grid=None, grid_function=None, data_type=None, transformation=None, write_binary=True)

Export grids and grid functions.

This method internally uses the meshio library. For a full list of supported data types see

https://github.com/nschloe/meshio

Note that export of domain indices is only possible for Gmsh (.msh) format files.

Parameters

filenamestring

The name of the file to write out. The data type is chosen based on the file ending.

gridGrid object

A grid object to export.

grid_functionGridFunction object

Grid function to export

data_typestring

Either ‘node’ for vertex data or ‘element’ for data at element centers.

transformationstring or callable

One of ‘real’, ‘imag’, ‘abs’, ‘log_abs’, None or a callable object. Transforms the data on input. A callable must return numpy arrays with the same number of dimensions as the input. If transformation is None the data is not modified.

write_binaryBoolean

Use binary format (write_binary=True) for the data if supported by the file format.

bempp.api.grid.io._transform_array(a, mode=None)

Transform a data array.

Parameters

anp.ndarray

Either a scalar array or a two dimensional data array.

modestring, callable or None

One of ‘real’, ‘imag’, ‘abs’, ‘log_abs’, ‘abs_squared’, a transformation callable or None. The callable needs to take an input array of dimension 2 and return an array of dimension 2. If mode is None the input array is not modified.