# sfepy.discrete.common.region module

class sfepy.discrete.common.region.Region(name, definition, domain, parse_def, kind='cell', parent=None, tdim=None)

  Region defines a subset of a FE domain.

  Region kinds:

  - cell_only, facet_only, face_only, edge_only, vertex_only - only the specified entities are included, others are empty sets (so that the operators are still defined)

  - cell, facet, face, edge, vertex - entities of higher dimension are not included

  The ‘cell’ kind is the most general and it is the default.

  Region set-like operators: + (union), - (difference), * (intersection), followed by one of (‘v’, ‘e’, ‘f’, ‘c’, and ‘s’) for vertices, edges, faces, cells, and facets.

  Created: 31.10.2005

  property cells
  contains(other)

    Return True in the region contains the other region.

    The check is performed using entities corresponding to the other region kind.

  copy()

    Make a copy based on the region kind.

  delete_zero_faces(eps=1e-14)
  property edges
  eval_op_cells(other, op)
  eval_op_edges(other, op)
  eval_op_faces(other, op)
  eval_op_facets(other, op)
  eval_op_vertices(other, op)
  property faces
  property facets
  finalize(allow_empty=False)

    Initialize the entities corresponding to the region kind and regenerate all already existing (accessed) entities of lower topological dimension from the kind entities.

  static from_cells(cells, domain, name='region', kind='cell', parent=None)

    Create a new region containing given cells.

    Parameters:
      cells array

        The array of cells.

      domain Domain instance

        The domain containing the facets.

      name str, optional

        The name of the region.

      kind str, optional

        The kind of the region.

      parent str, optional

        The name of the parent region.

    Returns:
      obj Region instance

        The new region.

  static from_facets(facets, domain, name='region', kind='facet', parent=None)

    Create a new region containing given facets.

    Parameters:
      facets array

        The array with indices to unique facets.

      domain Domain instance

        The domain containing the facets.

      name str, optional

        The name of the region.

      kind str, optional

        The kind of the region.

      parent str, optional

        The name of the parent region.

    Returns:
      obj Region instance

        The new region.

  static from_vertices(vertices, domain, name='region', kind='cell')

    Create a new region containing given vertices.

    Parameters:
      vertices array

        The array of vertices.

      domain Domain instance

        The domain containing the vertices.

      name str, optional

        The name of the region.

      kind str, optional

        The kind of the region.

    Returns:
      obj Region instance

        The new region.

  get_cell_indices(cells, true_cells_only=True)

    Return indices of cells in the region cells.

    Raises ValueError if true_cells_only is True and the region kind does not allow cells. For true_cells_only equal to False, cells incident to facets are returned if the region itself contains no cells.

    Raises ValueError if all cells are not in the region cells.

  get_cells(true_cells_only=True)

    Get cells of the region.

    Raises ValueError if true_cells_only is True and the region kind does not allow cells. For true_cells_only equal to False, cells incident to facets are returned if the region itself contains no cells. Obeys parent region, if given.

  get_charfun(by_cell=False, val_by_id=False)

    Return the characteristic function of the region as a vector of values defined either in the mesh vertices (by_cell == False) or cells. The values are either 1 (val_by_id == False) or sequential id + 1.

  get_edge_graph()

    Return the graph of region edges as a sparse array having uid(k) + 1 at (i, j) if vertex[i] is connected with vertex[j] by the edge k.

    Degenerate edges are ignored.

  get_entities(dim)

    Return mesh entities of dimension dim.

  get_facet_indices()

    Return an array (per group) of (iel, ifa) for each facet. A facet can be in 1 (surface) or 2 (inner) cells.

  get_mirror_region(name)
  get_n_cells(is_surface=False)

    Get number of region cells.

    Parameters:
      is_surface bool

        If True, number of edges or faces according to domain dimension is returned instead.

    Returns:
      n_cells int

        The number of cells.

  has_cells()
  light_copy(name, parse_def, tdim=None)
  set_kind(kind)
  set_kind_tdim()
  setup_from_highest(dim, allow_lower=True, allow_empty=False)

    Setup entities of topological dimension dim using the available entities of the highest topological dimension.

  setup_from_vertices(dim)

    Setup entities of topological dimension dim using the region vertices.

  setup_mirror_region(mirror_name=None, ret_name=False)

    Find the corresponding mirror region, set up element mapping.

  update_shape()

    Update shape of each group according to region vertices, edges, faces and cells.

  property vertices

sfepy.discrete.common.region.are_disjoint(r1, r2)

  Check if the regions r1 and r2 are disjoint.

  Uses vertices for the check - *_only regions not allowed.

sfepy.discrete.common.region.get_dependency_graph(region_defs)

  Return a dependency graph and a name-sort name mapping for given region definitions.

sfepy.discrete.common.region.get_parents(selector)

  Given a region selector, return names of regions it is based on.

sfepy.discrete.common.region.sort_by_dependency(graph)