Ejemplo n.º 1
0
Archivo: grid.py Proyecto: csdms/pymt
def get_structured_node_connectivity(grid, grid_id):
    """Get cell connectivity on a structured grid of quadrilaterals.

    Parameters
    ----------
    grid: grid_like
        A structured grid.
    grid_id : int
        Grid identifier.

    Returns
    -------
    conn : ndarray
        Connectivities of nodes to cells.

    Examples
    --------
    >>> from pymt.component.grid import get_structured_node_connectivity
    >>> class StructuredGrid(object):
    ...     def get_grid_shape(self, grid_id):
    ...         return (2, 3)
    >>> g = StructuredGrid()
    >>> (c, o) = get_structured_node_connectivity(g, 0)
    >>> c
    array([0, 1, 4, 3, 1, 2, 5, 4])
    >>> o
    array([4, 8])
    """
    shape = grid.get_grid_shape(grid_id)
    return get_connectivity(shape, with_offsets=True)
Ejemplo n.º 2
0
def get_structured_node_connectivity(grid, grid_id):
    """Get cell connectivity on a structured grid of quadrilaterals.

    Parameters
    ----------
    grid: grid_like
        A structured grid.
    grid_id : int
        Grid identifier.

    Returns
    -------
    conn : ndarray
        Connectivities of nodes to cells.

    Examples
    --------
    >>> from pymt.component.grid import get_structured_node_connectivity
    >>> class StructuredGrid(object):
    ...     def get_grid_shape(self, grid_id):
    ...         return (2, 3)
    >>> g = StructuredGrid()
    >>> (c, o) = get_structured_node_connectivity(g, 0)
    >>> c
    array([0, 1, 4, 3, 1, 2, 5, 4])
    >>> o
    array([4, 8])
    """
    shape = grid.get_grid_shape(grid_id)
    return get_connectivity(shape, with_offsets=True)
Ejemplo n.º 3
0
    def __init__(self, *args, **kwds):
        kwds.setdefault("indexing", "xy")
        kwds.setdefault("set_connectivity", True)
        ordering = kwds.pop("ordering", "cw")
        if ordering not in ["cw", "ccw"]:
            raise TypeError("ordering not understood (valid choices are 'cw' or 'ccw')")

        shape = args[-1]

        if kwds["set_connectivity"]:
            (c, o) = get_connectivity(shape, ordering=ordering, with_offsets=True)
            self._set_connectivity(c, o)
            kwds["set_connectivity"] = False

        super(Structured, self).__init__(*args, **kwds)
Ejemplo n.º 4
0
    def __init__(self, *args, **kwds):
        kwds.setdefault('indexing', 'xy')
        kwds.setdefault('set_connectivity', True)
        ordering = kwds.pop('ordering', 'cw')
        if ordering not in ['cw', 'ccw']:
            raise TypeError(
                "ordering not understood (valid choices are 'cw' or 'ccw')")

        shape = args[-1]

        if kwds['set_connectivity']:
            (c, o) = get_connectivity(shape,
                                      ordering=ordering,
                                      with_offsets=True)
            self._set_connectivity(c, o)
            kwds['set_connectivity'] = False

        super(Structured, self).__init__(*args, **kwds)
Ejemplo n.º 5
0
    def __init__(self, *args, **kwds):
        kwds.setdefault("indexing", "xy")
        kwds.setdefault("set_connectivity", True)
        ordering = kwds.pop("ordering", "cw")
        if ordering not in ["cw", "ccw"]:
            raise TypeError(
                "ordering not understood (valid choices are 'cw' or 'ccw')")

        shape = args[-1]

        if kwds["set_connectivity"]:
            (c, o) = get_connectivity(shape,
                                      ordering=ordering,
                                      with_offsets=True)
            self._set_connectivity(c, o)
            kwds["set_connectivity"] = False

        super(Structured, self).__init__(*args, **kwds)