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 setlike 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.

property
edges
¶

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.
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_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_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.

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 namesort name mapping for given region definitions.