Geometry and Mesh (fedoo.mesh)

Mesh classes

Mesh(nodes[, elements, elm_type, node_sets, ...])

Fedoo Mesh object.

MultiMesh(nodes[, elements_dict, node_sets, ...])

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

Node and element selection

Use the selection methods to obtain node or element IDs without changing mesh geometry. Pass name to find_nodes or find_elements to also store the result in mesh.node_sets or mesh.element_sets. Node IDs refer to the shared node table. For a MultiMesh, global element IDs follow the concatenated submesh order.

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

Return a list of nodes from a given selection criterion

Mesh.find_elements(selection_criterion[, ...])

Return a list of elements from a given selection criterion

Mesh.get_elements_from_nodes(node_set[, ...])

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

mesh.find_surface_nodes(mesh, seed[, ...])

Find the nodes of the connected exterior patch containing a seed.

mesh.find_edge_nodes(mesh, seed[, angle, ...])

Return node IDs along a connected exterior feature-edge chain.

Coordinates and field expressions

find_nodes selects by node coordinates. find_elements tests element centers by default; use select_by="nodes" with all_nodes=True or False to require all nodes or at least one node to satisfy the criterion. Both methods accept mathematical expressions, and data=results makes result fields and components such as Stress_XX available. Fields are converted to Node or Element values according to the selection method.

import fedoo as fd

nodes = mesh.find_nodes("X", 0, name="Left")
elements = mesh.find_elements("X > 0.5", name="Right")
loaded_nodes = mesh.find_nodes("Disp_X > 0.01 and Y > 0", data=results)
stressed_elements = mesh.find_elements("Stress_XX > 100", data=results)

Use mesh.get_elements_from_nodes(nodes) to select elements from node IDs. See Fedoo interactive viewer for the corresponding interactive node/element set managers and conversions.

Connected exterior surface selection

mesh.find_surface_nodes(seed, seed_type="Node", angle=30) returns sorted node IDs on the connected exterior patch containing a node or global element seed. It crosses neighboring faces when their normal-angle difference is at most angle degrees: 0 joins flat faces; 30 stops at a right-angle edge. The test is local, so a smoothly curved patch can wrap around the geometry.

nodes = mesh.find_surface_nodes(top_node_id, angle=30)
mesh.node_sets["selected_surface"] = nodes
surface = fd.mesh.extract_surface(mesh, node_set=nodes)

The same function is available as fd.mesh.find_surface_nodes(mesh, ...). Solid internal faces are removed, including interfaces between MultiMesh submeshes. Midside nodes are included; normals use corner geometry. For a three-dimensional shell mesh, existing tri/quad faces are traversed instead; use mesh.extract_elements(mesh.get_elements_from_nodes(nodes)) to extract the selected shell patch. For two-dimensional meshes, the selection follows exterior boundary edges. Non-manifold edges stop the selection.

A seed at a corner may belong to distinct patches. In this case AmbiguousSurfaceSeed exposes candidate face_ids and normals; repeat the call with seed_face set to the desired exterior face ID. The viewer presents this choice in a dialog. Node Sets provides a seed ID, a maximum normal angle, and Select surface nodes. Select activates the single-node picker. All viewer surface/edge selection uses node seeds. Interior nodes cannot seed a patch. For planar XYZ meshes use Boundary edges (2D mesh); the equivalent Python option is boundary_edges=True. The resulting node selection can be saved as a named set and exported to FDH5.

Connected exterior edge selection

For a 3D mesh, Exterior edges (3D) selects nodes along creases and open shell boundaries. Sharpness is the minimum angle between adjacent exterior face normals that identifies a crease. Turn limit is the maximum direction change allowed while following that edge. Smooth surface tessellation lines are excluded; branches and sharp changes of direction stop traversal. The seed must lie on an eligible edge. A corner touching distinct edge chains offers a starting-edge choice. Midside nodes are included.

nodes = mesh.find_edge_nodes(edge_node_id, angle=30, feature_angle=30)
mesh.node_sets["selected_edge"] = nodes

The same function is available as fd.mesh.find_edge_nodes(mesh, ...). AmbiguousEdgeSeed exposes candidate edge_ids, endpoints and directions; repeat with seed_edge to choose one chain explicitly.

Mesh manipulation functions

stack(mesh1, mesh2[, name])

Make the spatial stack of two mesh objects which have the same element shape.

extrude(mesh, extrude_path[, n_nodes, ndim, ...])

Build a volume or surface mesh from the extrusion of a surface or wire mesh.

thicken(mesh, thickness[, n_nodes, normal, name])

Create a solid by thickening a surface mesh along nodal normals.

extract_surface(mesh[, reduce_order, ...])

Build a mesh of the surface from a given 2D or 3D mesh.

extract_edges(mesh[, reduce_order, ...])

Extract edges from a given 2D or 3D mesh.

change_elm_type(mesh, elm_type[, name])

Attempt to change the type of element of a mesh.

quad2tri(mesh)

Change the type of element of a mesh from 'quad4' to 'tri3'.

Import and export meshes

Use fedoo.Mesh.read() to import mesh geometry and connectivity:

VTK and other PyVista formats

VTK formats are read through PyVista: legacy .vtk meshes, XML unstructured grids (.vtu) and XML polygonal surfaces (.vtp). The imported geometry must contain cell types supported by Fedoo.

import fedoo as fd

mesh = fd.Mesh.read("model.vtu", name="Domain")
# Legacy VTK meshes and polygonal surfaces:
# mesh = fd.Mesh.read("model.vtk")
# mesh = fd.Mesh.read("surface.vtp")

fedoo.Mesh.from_pyvista() also accepts existing PyVista UnstructuredGrid and PolyData objects, including mixed cell types. It imports geometry and Fedoo’s _nset_/_eset_ field-data conventions, but not ordinary point/cell result arrays. Element sets are not imported through the PyVista path for mixed meshes.

Abaqus import

Use fedoo.Mesh.read() to import the mesh from an Abaqus deck:

mesh = fd.Mesh.read("model.inp", name="Domain")

Abaqus .inp files use meshlane, with meshio as a fallback. Install the recommended reader with pip install "fedoo[io]". Supported first- and second-order element types are converted to Fedoo elements. *NSET and *ELSET definitions become mesh.node_sets and mesh.element_sets. Several element types produce a fedoo.MultiMesh, with element sets stored on the corresponding submeshes. Unsupported cell types are skipped with a warning; isolated vertex cells are ignored.

Importing an Abaqus deck does not create its materials, loads or analysis steps; define those in Fedoo after importing the mesh.

Importing with meshlane or meshio

To explicitly use meshlane for another supported format, such as Gmsh, pass its mesh object to fedoo.Mesh.from_meshio():

import meshlane

mesh = fd.Mesh.from_meshio(meshlane.read("model.msh"))

fedoo.Mesh.from_meshio() accepts both meshlane and meshio objects and preserves their point/cell sets. Multiple supported cell types return a fedoo.MultiMesh.

Exporting mesh geometry

Export mesh geometry with fedoo.Mesh.save(), for example mesh.save("model.vtk"). Use fedoo.read_data() for saved simulation results, including FDH5, rather than fedoo.Mesh.read().

Legacy readers

The following legacy readers handle specific ASCII VTK/Gmsh formats. Prefer fedoo.Mesh.read() or fedoo.Mesh.from_meshio() for new workflows.

import_file(filename[, name])

Import a mesh from a file.

import_msh(filename[, name, mesh_type])

Import a mesh from a msh file (gmsh format).

import_vtk(filename[, name])

Import a mesh from a legacy ASCII VTK file.

Mesh Creation Functions

Examples: Creating simple meshes and swept geometries (built-in generators, extrusion and swept geometries) and Nodal Hessian recovery on a fedoo mesh (nodal gradient and Hessian recovery on a mesh).

rectangle_mesh([nx, ny, x_min, x_max, ...])

Create a rectangular Mesh

box_mesh([nx, ny, nz, x_min, x_max, y_min, ...])

Create the mesh of a box

disk_mesh([radius, nr, nt, elm_type, ndim, name])

Create a surface mesh of a disk or an ellipse

hole_plate_mesh([nr, nt, length, height, ...])

Create a mesh of a 2D plate with a hole

hollow_disk_mesh([radius, thickness, nr, ...])

Create a surface mesh of an hollow disk or an ellipse

I_shape_mesh([height, width, web_thickness, ...])

Create the mesh of a I.

line_mesh_1D([n_nodes, x_min, x_max, ...])

Create the Mesh of a straight line with corrdinates in 1D.

line_mesh([n_nodes, x_min, x_max, elm_type, ...])

Create the Mesh of a straight line

line_mesh_cylindric([nt, r, theta_min, ...])

Create the mesh of a curved line based on cylindrical coordinates

circle_mesh([n, r, elm_type, ndim, name])

Create the mesh of a cicle.

grid_mesh_cylindric([nr, nt, r_min, r_max, ...])

Create a mesh as a regular grid in cylindrical coordinate

generate_cylindrical_local_frame(crd[, ...])

Generate cylindrical local frames (er, etheta, ez) at each node.

structured_mesh_2D(data, edge1, edge2, ...)

Create a 2D structured grid from 4 edges.

generate_nodes(mesh, N, data[, type_gen])

Add regularly espaced nodes to an existing mesh between to existing nodes.