FEM FemMesh2Mesh

From FreeCAD Documentation
Revision as of 19:13, 5 November 2022 by FandaL (talk | contribs) (Added scale option, removed 2D example (the tool now supports both 2D and 3D FEM mesh))

FEM FemMesh2Mesh

Menu location
Mesh → FEM mesh to mesh
Workbenches
FEM
Default shortcut
None
Introduced in version
-
See also
FEM tutorial

Description

This tool converts surfaces of 3D elements of a selected FEM mesh to mesh, or converts 2D FEM mesh to mesh. Internally it picks FEM mesh element faces which are unique (not shared by two elements) and uses them to create faces of a mesh. Optionally it allows to create a deformed mesh caused by the action of the defined forces. This is done by adding the displacement of the FEM results to the mesh nodes (scale of the displacement can be set by python).

Usage

  1. Select a FEM mesh object.
  2. Optionally also select the FEM results.
  3. There are several ways to invoke the command:
    • Press the FEM mesh to mesh button.
    • Select the Mesh → FEM mesh to mesh option from the menu.

Scripting

When you use GUI, but requires displacement scale factor

  1. Select a FEM mesh object and FEM results
  2. Run the following code with your scale (e.g. 5)
import femmesh.femmesh2mesh
out_mesh = femmesh.femmesh2mesh.femmesh_2_mesh(FreeCAD.ActiveDocument.Mesh.FemMesh, FreeCAD.ActiveDocument.CCX_Results, 5)
import Mesh
Mesh.show(Mesh.Mesh(out_mesh))

Example controlled fully by python

from os.path import join
the_file = join(FreeCAD.getResourceDir(), "examples", "FemCalculixCantilever3D.FCStd")
fc_file = FreeCAD.openDocument(the_file)
fem_mesh = fc_file.getObject("Box_Mesh").FemMesh  # do not remove the _
result = fc_file.getObject("CCX_Results")
scale = 1  # displacement scale factor
from femmesh import femmesh2mesh
out_mesh = femmesh2mesh.femmesh_2_mesh(fem_mesh, result, scale)
import Mesh
Mesh.show(Mesh.Mesh(out_mesh))