API Reference

Meshes

TensorMesh(h[, origin])

TensorMesh is a mesh class that deals with tensor product meshes.

CylindricalMesh(h[, origin, cartesian_origin])

CylindricalMesh is a mesh class for cylindrical problems.

CurvilinearMesh(node_list, **kwargs)

CurvilinearMesh is a mesh class that deals with curvilinear meshes.

TreeMesh([h, origin])

TreeMesh is a class for adaptive QuadTree (2D) and OcTree (3D) meshes.

tree_mesh.TreeCell

A Cell of the TreeMesh

Numerical Operators

operators.DiffOperators()

Class creates the differential operators that you need!

operators.InnerProducts()

This is a base for the discretize mesh classes.

Mesh IO

load_mesh(file_name)

Open a json file and load the mesh into the target class

Visualization

mixins.mpl_mod.InterfaceMPL()

This class is used for simple discretize mesh plotting using matplotlib.

mixins.mpl_mod.Slicer(mesh, v[, xslice, …])

Plot slices of a 3D volume, interactively (scroll wheel).

mixins.vtk_mod.InterfaceVTK()

This class is full of methods that enable discretize meshes to be converted to VTK data objects (and back when possible).

Testing

tests.OrderTest([methodName])

OrderTest is a base class for testing convergence orders with respect to mesh sizes of integral/differential operators.

tests.check_derivative(fctn, x0[, num, …])

Basic derivative check

tests.get_quadratic(A, b[, c])

Given A, b and c, this returns a quadratic, Q

tests.rosenbrock(x[, return_g, return_H])

Rosenbrock function for testing GaussNewton scheme

Utilities

General Utilities

utils.download(url[, folder, overwrite, verbose])

Function to download all files stored in a cloud directory

Interpolation Operations

utils.interpolation_matrix(locs, x[, y, z])

Local interpolation computed for each receiver point in turn

utils.volume_average(mesh_in, mesh_out[, …])

Volume averaging interpolation between meshes.

Mesh Utilities

utils.example_curvilinear_grid(nC, exType)

utils.unpack_widths(value)

unpack_widths takes a list of numbers and tuples that have the form.

utils.closest_points_index(mesh, pts[, grid_loc])

Move a list of points to the closest points on a grid.

utils.extract_core_mesh(xyzlim, mesh[, …])

Extracts Core Mesh from Global mesh

utils.random_model(shape[, seed, …])

Create a random model by convolving a kernel with a uniformly distributed model.

utils.mesh_builder_xyz(xyz, h[, …])

Function to quickly generate a Tensor or Tree mesh given a cloud of xyz points, finest core cell size and padding distance.

utils.refine_tree_xyz(mesh, xyz[, method, …])

Refine a TreeMesh based on xyz point locations

utils.active_from_xyz(mesh, xyz[, …])

Returns an active cell index array below a surface

Matrix Utilities

utils.mkvc(x[, n_dims])

Creates a vector with the number of dimension specified

utils.sdiag(h)

Sparse diagonal matrix

utils.sdinv(M)

Inverse of a sparse diagonal matrix

utils.speye(n)

Sparse identity

utils.kron3(A, B, C)

Three kron prods

utils.spzeros(n1, n2)

a sparse matrix of zeros

utils.ddx(n)

Define 1D derivatives, inner, this means we go from n+1 to n

utils.av(n)

Define 1D averaging operator from nodes to cell-centers.

utils.av_extrap(n)

Define 1D averaging operator from cell-centers to nodes.

utils.ndgrid(*args, **kwargs)

Form tensorial grid for 1, 2, or 3 dimensions.

utils.ind2sub(shape, inds)

From the given shape, returns the subscripts of the given index

utils.sub2ind(shape, subs)

From the given shape, returns the index of the given subscript

utils.get_subarray(A, ind)

subarray

utils.inverse_3x3_block_diagonal(a11, a12, …)

inverts a stack of 3x3 matrices

utils.inverse_2x2_block_diagonal(a11, a12, …)

Inverts a stack of 2x2 matrices by using the inversion formula

utils.make_property_tensor(M, tensor)

utils.inverse_property_tensor(M, tensor[, …])

utils.TensorType(M, tensor)

utils.Zero()

Attributes

utils.Identity([positive])

Attributes

Mathematical Operations

utils.rotate_points_from_normals(XYZ, n0, n1)

rotates a grid so that the vector n0 is aligned with the vector n1

utils.rotation_matrix_from_normals(v0, v1[, tol])

Performs the minimum number of rotations to define a rotation from the direction indicated by the vector n0 to the direction indicated by n1.

utils.cylindrical_to_cartesian(grid[, vec])

Take a grid defined in cylindrical coordinates \((r, heta, z)\) and transform it to cartesian coordinates.

utils.cartesian_to_cylindrical(grid[, vec])

Take a grid defined in cartesian coordinates and transform it to cyl coordinates

utils.is_scalar(f)

utils.as_array_n_by_dim(pts, dim)

utils.cyl2cart(grid[, vec])

An alias for cylindrical_to_cartesian

utils.cart2cyl(grid[, vec])

An alias for cartesian_to_cylindrical

Curvilinear Mesh Utilities

utils.volume_tetrahedron(xyz, A, B, C, D)

Returns the volume for tetrahedras volume specified by the indexes A to D.

utils.face_info(xyz, A, B, C, D[, average, …])

function [N] = face_info(y,A,B,C,D)

utils.index_cube(nodes, grid_size[, n])

Returns the index of nodes on the mesh.

Base Mesh

base.BaseMesh(shape_cells[, origin, …])

BaseMesh does all the counting you don’t want to do.

base.BaseRectangularMesh(shape_cells[, …])

Attributes

base.BaseTensorMesh(h[, origin])

Base class for tensor-product style meshes