예제 #1
0
파일: grid.py 프로젝트: bempp/bempp
def structured_grid(lower_left, upper_right, subdivisions):
    """Create a two dimensional grid by defining the lower left and
    upper right point.

    Parameters
    ----------
    lower_left : tuple
        The (x,y) coordinate of the lower left corner of the grid.
    upper_right : tuple
        The (x,y) coordinate of the upper right corner of the grid.
    subdivisions : tuple
        A tuple (N,M) specifiying the number of subdivisions in
        each dimension.

    Returns
    -------
    grid : bempp.Grid
        A structured grid.

    Examples
    --------
    The following command creates a grid of the unit square [0,1]^2.

    >>> grid = structured_grid((0,0),(1,1),(100,100))

    """

    from bempp.core.grid.grid import structured_grid as grid_fun
    return Grid(grid_fun(lower_left, upper_right, subdivisions))
예제 #2
0
파일: grid.py 프로젝트: bempp/bempp
def grid_from_element_data(vertices, elements, domain_indices=[]):
    """Create a grid from a given set of vertices and elements.

    This function takes a list of vertices and a list of elements
    and returns a grid object.

    Parameters
    ----------
    vertices : np.ndarray[float]
        A (3xN) array of vertices.
    elements : np.ndarray[int]
        A (3xN) array of elements.

    Returns
    -------
    grid : bempp.Grid
        The grid representing the specified element data.

    Examples
    --------
    The following code creates a grid with two elements.

    >>> import numpy as np
    >>> vertices = np.array([[0,1,1,0],
                             [0,0,1,1],
                             [0,0,0,0]])
    >>> elements = np.array([[0,1],
                             [1,2],
                             [3,3]])
    >>> grid = grid_from_element_data(vertices,elements)

    """

    from bempp.core.grid.grid import grid_from_element_data as grid_fun
    return Grid(grid_fun(vertices, elements, domain_indices))