fedoo.MultiMesh

class MultiMesh(nodes: ndarray[float], elements_dict: dict | None = None, node_sets: dict | None = None, ndim: int | None = None, name: str = '', register_name: bool = True)

Fedoo mesh made of several ordered submeshes sharing one node table.

A MultiMesh is useful when a mesh contains several element blocks, possibly with different element types or with several blocks using the same element type. All submeshes share nodes. Internally, submeshes are stored in order; this order defines integer indexing and FDH5 submesh_X ids.

A MultiMesh can be created in three ways:

  • With a simple element-type dictionary, when each element type appears once:

    >>> mesh = MultiMesh(nodes, {"tri3": tri_elements, "quad4": quad_elements})
    
  • With an explicit submesh-name dictionary, when several submeshes may share the same element type:

    >>> mesh = MultiMesh(
    ...     nodes,
    ...     {
    ...         "part_a": ("tri3", tri_elements_a),
    ...         "part_b": ("tri3", tri_elements_b),
    ...     },
    ... )
    

    The dictionary key is stored as the submesh name, but internal submeshes are not registered in MeshBase.get_all().

  • From an existing list of Mesh objects:

    >>> mesh = MultiMesh.from_mesh_list([tri_mesh, quad_mesh])
    

Submeshes can be retrieved by integer id, submesh name, or element type. Integer indexing always returns a concrete Mesh. String indexing first tries exact submesh names, then element types. Element-type indexing returns a Mesh if only one submesh matches, or a view-like MultiMesh if several submeshes share that element type.

Parameters:
  • nodes (numpy.ndarray) – Shared node coordinates.

  • elements_dict (dict, optional) – Submesh definitions. Values may be connectivity arrays, Mesh objects, (elm_type, elements) tuples, or (elm_type, elements, element_sets) tuples.

  • node_sets (dict, optional) – Node sets associated with the shared node table.

  • ndim (int, optional) – Dimension of the mesh. By default, deduced from nodes.shape[1].

  • name (str, optional) – Name of the MultiMesh. If non-empty and register_name is True, the MultiMesh is registered in MeshBase.get_all().

  • register_name (bool, default=True) – If False, the MultiMesh name is kept locally but not registered in MeshBase.get_all(). This is used for internal filtered views.

__init__(nodes: ndarray[float], elements_dict: dict | None = None, node_sets: dict | None = None, ndim: int | None = None, name: str = '', register_name: bool = True) → None

Methods

MultiMesh.__getitem__(item)

MultiMesh.add_element_set(element_indices, name)

Add a set of elements to the Mesh

MultiMesh.add_internal_nodes(nb_added)

Add some nodes to the node list.

MultiMesh.add_node_set(node_indices, name)

Add a set of nodes to the Mesh

MultiMesh.add_nodes(*args)

Add some nodes to the node list.

MultiMesh.as_2d([inplace])

Return a view of the current MultiMesh in 2D.

MultiMesh.as_3d([inplace])

Return a view of the current MultiMesh in 3D.

MultiMesh.as_ndim(ndim[, inplace])

Return a MultiMesh view with node coordinates in ndim dimensions.

MultiMesh.convert_data(data[, convert_from, ...])

Convert a field between node, element and Gauss-point storage.

MultiMesh.copy([name])

Make a shallow copy of the MultiMesh.

MultiMesh.data_to_gausspoint(data[, n_elm_gp])

Convert a field array (node values or element values) to gauss points.

MultiMesh.deepcopy([name])

Make a deep copy of the node and element arrays.

MultiMesh.determine_data_type(data[, n_elm_gp])

MultiMesh.extract_elements(element_set[, name])

Return a new mesh from the set of elements defined by element_set

MultiMesh.find_coincident_nodes([tol])

Find some nodes with the same position considering a tolerance given by the argument tol.

MultiMesh.find_elements(selection_criterion)

Return global element ids matching a selection criterion.

MultiMesh.find_isolated_nodes()

Return the nodes that are not associated with any element.

MultiMesh.find_nodes(selection_criterion[, ...])

Return a list of nodes from a given selection criterion

MultiMesh.from_mesh_list(mesh_list[, name, ...])

Build a MultiMesh from an ordered list of Mesh objects.

MultiMesh.from_meshio(io_mesh[, name])

Build a Mesh from a meshlane or meshio mesh object.

MultiMesh.from_pyvista(pvmesh[, name])

Build a Mesh from a pyvista UnstructuredGrid or PolyData mesh.

MultiMesh.gausspoint_coordinates([n_elm_gp])

Return the coordinates of the integration points

MultiMesh.get_all()

Return a dict with all the known Mesh (with a name).

MultiMesh.get_element_local_frame([...])

Return geometrical local frames at element evaluation points.

MultiMesh.get_element_volumes([n_elm_gp])

Compute the volume of each element (or surface for 2D meshes).

MultiMesh.get_elements_from_nodes(node_set)

Return a list of elements that are build with the nodes given in node_set

MultiMesh.get_volume([n_elm_gp])

Compute the total volume of the mesh (or surface for 2D meshes).

MultiMesh.init_interpolation([n_elm_gp])

MultiMesh.integrate_field(field[, ...])

MultiMesh.is_periodic([tol, dim])

Test if the mesh is periodic (have nodes at the same positions on adjacent faces)

MultiMesh.merge_coincident_nodes(tol)

Find and merge node pairs whose Euclidean distance is below tol.

MultiMesh.merge_nodes(node_couples)

Merge some nodes The total number and the id of nodes are modified

MultiMesh.nearest_node(X)

Return the index of the nearst node from the given position X

MultiMesh.plot([show_edges])

Simple plot function using pyvista.

MultiMesh.plot_normals([mag, show_mesh])

Simple functions to plot the normals of a surface Mesh.

MultiMesh.read(filename[, name])

Build a Mesh from a file.

MultiMesh.remove_isolated_nodes()

Remove the nodes that are not associated with any element.

MultiMesh.remove_nodes(index_nodes)

Remove some nodes and associated element.

MultiMesh.reset_interpolation()

Remove all the saved data related to field interpolation.

MultiMesh.save(filename[, binary])

Save the mesh object to file.

MultiMesh.stack(mesh1, mesh2[, name])

Add two mesh together to make a new mesh.

MultiMesh.to_pyvista([include_sets])

Wrap the current multimesh to a pyvista UnstructuredGrid.

MultiMesh.translate(disp)

Translate the mesh using the given displacement vector The disp vector should be on the form [u, v, w]

MultiMesh.bounding_box

MultiMesh.element_centers

Coordinates of the element centers.

MultiMesh.element_sets

Element sets using the global MultiMesh cell numbering.

MultiMesh.elm_types

Element type of each submesh, in submesh id order.

MultiMesh.mesh_dict

Element-type indexed view kept for backward compatibility.

MultiMesh.n_elements

Total number of elements in all submeshes.

MultiMesh.n_elm_nodes

Number of nodes associated to each element.

MultiMesh.n_nodes

Total number of nodes in the Mesh.

MultiMesh.name

Name of the mesh.

MultiMesh.ndim

Dimension of the mesh.

MultiMesh.submeshes

Ordered view of the submeshes.

MultiMesh.nodes

nodes[i] gives the coordinates of the ith node.

MultiMesh.node_sets

Dict containing node sets associated to the mesh

MultiMesh.elements

List of elements.

MultiMesh.elm_type

Type of the element (str).