fedoo.Mesh
- class Mesh(nodes: ndarray[float], elements: ndarray[int] | None = None, elm_type: str | None = None, node_sets: dict | None = None, element_sets: dict | None = None, ndim: int | None = None, name: str = '')
Fedoo Mesh object.
A fedoo mesh can be initialized with the following constructors:
fedoo.Mesh.read()
to load a mesh from a file (vtk file recommanded).fedoo.Mesh.from_pyvista()
to build a mesh from pyvista UnstructuredGrid or PolyData objectsthe Mesh constructor describes bellow to build a Mesh by directly setting its attributes (node coordinates, elements list, element type, …)
Some mesh creation functions are also available in fedoo to build simple structured meshes.
- Parameters:
nodes (numpy array of float) – List of nodes coordinates. nodes[i] is the coordinate of the ith node.
elements (numpy array of int) – Elements table. elements[i] define the nodes associated to the ith element.
elm_type (str) – Type of the element. The type of the element should be coherent with the shape of elements.
ndim (int, optional:) – Dimension of the mesh. By default, ndim is deduced from the nodes coordinates using ndim = nodes.shape[1]
name (str, optional) – The name of the mesh
Example
Create a one element mesh from a 2d mesh in a 3d space:
>>> import fedoo as fd >>> import numpy as np >>> nodes = np.array([[0,0],[1,0],[1,1],[0,1]]) >>> elm = np.array([0,1,2,3]) >>> mesh = fd.Mesh(nodes, elm, 'quad4', ndim = 3, name = 'unit square mesh')
- __init__(nodes: ndarray[float], elements: ndarray[int] | None = None, elm_type: str | None = None, node_sets: dict | None = None, element_sets: dict | None = None, ndim: int | None = None, name: str = '') None
Methods
Mesh.add_element_set
(element_indices, name)Add a set of elements to the Mesh
Mesh.add_internal_nodes
(nb_added)Add some nodes to the node list.
Mesh.add_node_set
(node_indices, name)Add a set of nodes to the Mesh
Mesh.add_nodes
(*args)Add some nodes to the node list.
Mesh.add_virtual_nodes
(*args)Add some nodes to the node list.
Mesh.as_2d
([inplace])Return a view of the current mesh in 2D.
Mesh.as_3d
([inplace])Return a view of the current mesh in 3D.
Mesh.convert_data
(data[, convert_from, ...])Mesh.copy
([name])Make a copy of the mesh.
Mesh.data_to_gausspoint
(data[, n_elm_gp])Convert a field array (node values or element values) to gauss points.
Mesh.deepcopy
([name])Make a deep copy of the mesh.
Mesh.determine_data_type
(data[, n_elm_gp])Mesh.extract_elements
(element_set[, name])Return a new mesh from the set of elements defined by element_set
Mesh.find_coincident_nodes
([tol])Find some nodes with the same position considering a tolerance given by the argument tol.
Mesh.find_elements
(selection_criterion[, ...])Return a list of elements from a given selection criterion
Return the nodes that are not associated with any element.
Mesh.find_nodes
(selection_criterion[, ...])Return a list of nodes from a given selection criterion
Mesh.from_pyvista
(pvmesh[, name])Build a Mesh from a pyvista UnstructuredGrid or PolyData mesh.
Mesh.gausspoint_coordinates
([n_elm_gp])Return the coordinates of the integration points
Return a dict with all the known Mesh (with a name).
Mesh.get_element_local_frame
([n_elm_gp])Mesh.get_element_volumes
([n_elm_gp])Compute the volume of each element (or surface for 2D meshes).
Mesh.get_elements_from_nodes
(node_set[, ...])Return a list of elements that are build with the nodes given in node_set
Mesh.get_volume
([n_elm_gp])Compute the total volume of the mesh (or surface for 2D meshes).
Mesh.init_interpolation
([n_elm_gp])Mesh.integrate_field
(field[, type_field, ...])Mesh.is_periodic
([tol, dim])Test if the mesh is periodic (have nodes at the same positions on adjacent faces)
Mesh.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
Mesh.plot
([show_edges])Simple plot function using pyvista.
Mesh.plot_normals
([mag, show_mesh])Simple functions to plot the normals of a surface Mesh.
Mesh.read
(filename[, name])Build a Mesh from a file.
Remove the nodes that are not associated with any element.
Mesh.remove_nodes
(index_nodes)Remove some nodes and associated element.
Remove all the saved data related to field interpolation.
Mesh.save
(filename[, binary])Save the mesh object to file.
Mesh.stack
(mesh1, mesh2[, name])Static method - Make the spatial stack of two mesh objects which have the same element shape.
Mesh.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.
Total number of elements in the Mesh
Number of nodes associated to each element
Total number of nodes in the Mesh
Number of physical nodes in the mesh.
Name of the mesh.
Dimension of the mesh
Get the node coordinates of the physical_nodes.
nodes[i] gives the coordinates of the ith node.
elements[i] gives the nodes associated to the ith element.
Type of the element (str).
Dict containing node sets associated to the mesh
Dict containing element sets associated to the mesh