sfepy.discrete.common.region module

class sfepy.discrete.common.region.Region(name, definition, domain, parse_def, kind=’cell’, parent=None)[source]

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

cells
contains(other)[source]

Return True in the region contains the other region.

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

copy()[source]

Vertices-based copy.

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

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)[source]

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)[source]

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’)[source]

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)[source]

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.

Notes

If the number of unique values in cells is smaller or equal to the number of cells in the region, all cells has to be also the region cells (self is a superset of cells). The region cells are considered depending on true_cells_only.

Otherwise, indices of all cells in self that are in cells are returned.

get_cells(true_cells_only=True)[source]

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)[source]

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()[source]

Return the graph of region edges as a sparse matrix 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)[source]

Return mesh entities of dimension dim.

get_facet_indices()[source]

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()[source]
get_n_cells(is_surface=False)[source]

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()[source]
light_copy(name, parse_def)[source]
set_kind(kind)[source]
set_kind_tdim()[source]
setup_from_highest(dim, allow_lower=True, allow_empty=False)[source]

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

setup_from_vertices(dim)[source]

Setup entities of topological dimension dim using the region vertices.

setup_mirror_region()[source]

Find the corresponding mirror region, set up element mapping.

update_shape()[source]

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

vertices
sfepy.discrete.common.region.are_disjoint(r1, r2)[source]

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)[source]

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

sfepy.discrete.common.region.get_parents(selector)[source]

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

sfepy.discrete.common.region.sort_by_dependency(graph)[source]