sfepy.fem.region module

class sfepy.fem.region.Region(name, definition, domain, parse_def)[source]

Region defines a subset of a FE domain.

Created: 31.10.2005

add_e(other)[source]
add_n(other)[source]
complete_description(ed, fa, surface_integral=False)[source]

Complete the region description by listing edges and faces for each element group.

Parameters:

ed : Facets instance

The edge facets.

fa : Facets instance

The face facets.

surface_integral : bool

If True, the each region surface facet (edge in 2D, face in 3D) can be listed only in one group. Sub-entities are updated accordingly (vertices in 2D, vertices and edges in 3D).

Notes

If surface_integral is False, self.edges, self.faces simply list edge/face indices per group (pointers to ed.facets, fa.facets) - repetitions among groups are possible.

contains(other)[source]

Tests only igs for now!!!

copy()[source]

Vertices-based copy.

create_mapping(kind, ig)[source]

Create mapping from reference elements to physical elements, given the integration kind (‘v’ or ‘s’).

This mapping can be used to compute the physical quadrature points.

Returns:

mapping : VolumeMapping or SurfaceMapping instance

The requested mapping.

delete_groups(digs)[source]

Delete given element groups from the region.

delete_zero_faces(eps=1e-14)[source]

Delete faces with zero area.

static from_faces(faces, domain, name='region', igs=None, can_cells=False)[source]

Create a new region containing given faces.

Parameters:

faces : array

The array with indices to domain.fa.

domain : Domain instance

The domain containing the faces.

name : str, optional

The name of the region.

igs : list, optional

The allowed element groups. Other groups will be ignored, even though the region might have faces in them - the same effect the ‘forbid’ flag has.

can_cells : bool, optional

If True, the region can have cells.

Returns:

obj : Region instance

The new region.

static from_vertices(vertices, domain, name='region', igs=None, can_cells=False, surface_integral=False)[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.

igs : list, optional

The allowed element groups. Other groups will be ignored, even though the region might have vertices in them - the same effect the ‘forbid’ flag has.

can_cells : bool, optional

If True, the region can have cells.

surface_integral : bool, optional

If True, then each region surface facet (edge in 2D, face in 3D) can be listed only in one group.

Returns:

obj : Region instance

The new region.

get_cell_offsets()[source]
get_cells(ig, true_cells_only=True)[source]

Get cells of the region.

Raises ValueError if true_cells_only is True and the cells are not true cells (e.g. surface integration region).

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 nodes (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_faces(ig)[source]
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_surface_entities(ig)[source]

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

get_vertices(ig)[source]
get_vertices_of_cells(return_per_group=False)[source]

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

Parameters:

return_per_group : bool

It True, return also a dict of vertices per element group.

has_cells()[source]
has_cells_if_can()[source]
intersect_e(other)[source]
intersect_n(other)[source]
iter_cells()[source]
light_copy(name, parse_def)[source]
select_cells(n_verts)[source]

Select cells containing at least n_verts[ii] vertices per group ii.

select_cells_of_surface(reset=True)[source]

Select cells corresponding to faces (or edges in 2D).

set_cells(cells)[source]
set_faces(faces, igs=None, can_cells=False)[source]

Set region data using given faces. The region description is complete afterwards.

Parameters:

faces : array

The array with indices to domain.fa.

igs : list, optional

The allowed element groups. Other groups will be ignored, even though the region might have faces in them.

can_cells : bool, optional

If True, the region can have cells.

set_from_group(ig, vertices, n_cell)[source]

Set region to contain the given element group.

set_vertices(vertices)[source]
setup_face_indices(reset=True)[source]

Initialize an array (per group) of (iel, ifa) for each face.

setup_mirror_region()[source]

Find the corresponding mirror region, set up element mapping.

sub_e(other)[source]
sub_n(other)[source]
switch_cells(can_cells)[source]
update_groups(force=False)[source]

Vertices common to several groups are listed only in all of them - fa, ed.unique_indx contain no edge/face duplicates already.

update_shape()[source]

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

update_vertices()[source]
sfepy.fem.region.get_dependency_graph(region_defs)[source]

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

sfepy.fem.region.get_parents(selector)[source]

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

sfepy.fem.region.sort_by_dependency(graph)[source]