# sfepy.discrete.fem.utils module

sfepy.discrete.fem.utils.compute_nodal_edge_dirs(nodes, region, field, return_imap=False)

  Nodal edge directions are computed by simple averaging of direction vectors of edges a node is contained in. Edges are assumed to be straight and a node must be on a single edge (a border node) or shared by exactly two edges.

sfepy.discrete.fem.utils.compute_nodal_normals(nodes, region, field, return_imap=False)

  Nodal normals are computed by simple averaging of element normals of elements every node is contained in.

sfepy.discrete.fem.utils.extend_cell_data(data, domain, rname, val=None, is_surface=False, average_surface=True)

  Extend cell data defined in a region to the whole domain.

  Parameters:
    data array

      The data defined in the region.

    domain FEDomain instance

      The FE domain.

    rname str

      The region name.

    val float, optional

      The value for filling cells not covered by the region. If not given, the smallest value in data is used.

    is_surface bool

      If True, the data are defined on a surface region. In that case the values are averaged or summed into the cells containing the region surface faces (a cell can have several faces of the surface), see average_surface.

    average_surface bool

      If True, the data defined on a surface region are averaged, otherwise the data are summed.

  Returns:
    edata array

      The data extended to all domain elements.

sfepy.discrete.fem.utils.get_edge_paths(graph, mask)

  Get all edge paths in a graph with non-masked vertices. The mask is updated.

sfepy.discrete.fem.utils.get_min_value(dofs)

  Get a reasonable minimal value of DOFs suitable for extending over a whole domain.

sfepy.discrete.fem.utils.invert_remap(remap)

  Return the inverse of remap, i.e. a mapping from a sub-range indices to a full range, see `prepare_remap()`.

sfepy.discrete.fem.utils.prepare_remap(indices, n_full)

  Prepare vector for remapping range [0, n_full] to its subset given by indices.

sfepy.discrete.fem.utils.prepare_translate(old_indices, new_indices)

  Prepare vector for translating old_indices to new_indices.

  Returns:
    translate array

      The translation vector. Then new_ar = translate[old_ar].

sfepy.discrete.fem.utils.refine_mesh(filename, level)

  Uniformly refine level-times a mesh given by filename.

  The refined mesh is saved to a file with name constructed from base name of filename and level-times appended ‘_r’ suffix.

  Parameters:
    filename str

      The mesh file name.

    level int

      The refinement level.