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
MultiMeshis useful when a mesh contains several element blocks, possibly with different element types or with several blocks using the same element type. All submeshes sharenodes. Internally, submeshes are stored in order; this order defines integer indexing and FDH5submesh_Xids.A
MultiMeshcan 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
Meshobjects:>>> 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 aMeshif only one submesh matches, or a view-likeMultiMeshif several submeshes share that element type.- Parameters:
nodes (numpy.ndarray) – Shared node coordinates.
elements_dict (dict, optional) – Submesh definitions. Values may be connectivity arrays,
Meshobjects,(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 andregister_nameis True, theMultiMeshis registered inMeshBase.get_all().register_name (bool, default=True) – If False, the
MultiMeshname is kept locally but not registered inMeshBase.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
ndimdimensions.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
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.
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
Return a dict with all the known Mesh (with a name).
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)
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
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.
Remove the nodes that are not associated with any element.
MultiMesh.remove_nodes(index_nodes)Remove some nodes and associated element.
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]
Coordinates of the element centers.
Element sets using the global MultiMesh cell numbering.
Element type of each submesh, in submesh id order.
Element-type indexed view kept for backward compatibility.
Total number of elements in all submeshes.
Number of nodes associated to each element.
Total number of nodes in the Mesh.
Name of the mesh.
Dimension of the mesh.
Ordered view of the submeshes.
nodes[i] gives the coordinates of the ith node.
Dict containing node sets associated to the mesh
List of elements.
Type of the element (str).