sfepy.discrete.common.region module

class sfepy.discrete.common.region.Region(name, definition, domain, parse_def, kind='cell', parent=None, tdim=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

property 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]

Make a copy based on the region kind.

delete_zero_faces(eps=1e-14)[source]
property 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]
property faces
property 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:
cellsarray

The array of cells.

domainDomain instance

The domain containing the facets.

namestr, optional

The name of the region.

kindstr, optional

The kind of the region.

parentstr, optional

The name of the parent region.

Returns:
objRegion instance

The new region.

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

Create a new region containing given facets.

Parameters:
facetsarray

The array with indices to unique facets.

domainDomain instance

The domain containing the facets.

namestr, optional

The name of the region.

kindstr, optional

The kind of the region.

parentstr, optional

The name of the parent region.

Returns:
objRegion instance

The new region.

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

Create a new region containing given vertices.

Parameters:
verticesarray

The array of vertices.

domainDomain instance

The domain containing the vertices.

namestr, optional

The name of the region.

kindstr, optional

The kind of the region.

Returns:
objRegion 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.

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

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

Get number of region cells.

Parameters:
is_surfacebool

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

Returns:
n_cellsint

The number of cells.

has_cells()[source]
light_copy(name, parse_def, tdim=None)[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(mirror_name=None, ret_name=False)[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.

property 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]