SfePy NTC

Previous topic

sfepy.discrete.common.mappings module

Next topic

sfepy.discrete.fem.domain module

This Page

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.

Notes

Functions depending on ig are adapters for current code that should be removed after new assembling is done.

Created: 31.10.2005

cells[source]
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[source]
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[source]
facets[source]
finalize()[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_offsets()[source]
get_cells(ig, true_cells_only=True, offset=True)[source]

Get cells of the region.

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

If offset is True, the cell group offset is subtracted from the cell ids.

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_edges(ig)[source]
get_entities(dim, ig=None)[source]

Return mesh entities of dimension dim, and optionally with the cell group ig.

get_faces(ig)[source]
get_facet_indices(ig, offset=True, force_ig=True)[source]

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

If offset is True, the cell group offset is subtracted from the cell ids.

If force_ig is True, only the cells with the given ig are used.

get_facets(ig)[source]

Return either region vertices (in 1D), edges (in 2D) or faces (in 3D).

get_mirror_region()[source]
get_n_cells(ig=None, is_surface=False)[source]

Get number of region cells.

Parameters:

ig : int, optional

The group index. If None, counts from all groups are added together.

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.

get_vertices(ig)[source]
get_vertices_of_cells()[source]

Return all vertices, that are in some cell of the region.

has_cells()[source]
igs[source]

Cell group indices according to region kind.

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