FEM FemMesh2Mesh: Difference between revisions
m (update MenuLocation and Scripting) |
(Docnav) |
||
(38 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
<translate> |
<translate> |
||
<!--T:9--> |
|||
{{Docnav |
|||
|[[FEM_MeshGroup|FEM mesh group]] |
|||
|[[FEM_SolverCalculixCxxtools|Solver CalculiX Standard]] |
|||
|[[FEM_Workbench|FEM]] |
|||
|IconL=FEM_MeshGroup.svg |
|||
|IconR=FEM_SolverCalculixCxxtools.svg |
|||
|IconC=Workbench_FEM.svg |
|||
}} |
|||
<!--T:1--> |
<!--T:1--> |
||
{{GuiCommand |
|||
{{GuiCommand|Name=FEM FemMesh2Mesh|MenuLocation=Mesh → FEM mesh to mesh||Workbenches=[[Fem Workbench|FEM]]|Shortcut=|SeeAlso=[[FEM_tutorial|FEM tutorial]]}} |
|||
|Name=FEM FemMesh2Mesh |
|||
|MenuLocation=Mesh → FEM mesh to mesh |
|||
|Workbenches=[[FEM_Workbench|FEM]] |
|||
|SeeAlso=[[FEM_tutorial|FEM tutorial]] |
|||
}} |
|||
== Description == <!--T:2--> |
== Description == <!--T:2--> |
||
⚫ | This tool converts surfaces of 3D elements of a selected FEM mesh to mesh. Internally it picks FEM mesh element faces |
||
<!--T: |
<!--T:7--> |
||
⚫ | 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 that are unique (not shared by two elements) and uses them to create faces of a mesh. Optionally, it can be used to save a deformed mesh. This is done by adding the displacement of the FEM results to the mesh nodes (the scale of the displacement can be set using Python). |
||
Two dimensional elements from the FEM mesh are not taken into account. If you need to convert them, you can use a python script below. |
|||
== |
==Usage== <!--T:4--> |
||
# Select a FEM mesh object (optionally select additionally the FEM results) |
|||
<!--T:8--> |
|||
⚫ | |||
# Select a FEM mesh object. |
|||
# Optionally also select the FEM results. |
|||
# There are several ways to invoke the command: |
|||
⚫ | |||
#* Select the {{MenuCommand|Mesh → [[Image:FEM_FemMesh2Mesh.svg|16px]] FEM mesh to mesh}} option from the menu. |
|||
⚫ | |||
<!--T:15--> |
|||
'''Note''': The parameter ''scale'' was {{Version|0.21}}. For older versions of FreeCAD omit it from your code. |
|||
<!--T:17--> |
|||
The cantilever example: |
|||
⚫ | |||
Example: |
|||
* Load FreeCAD's 3D FEM example from the Start Workbench and run the following code |
|||
</translate> |
</translate> |
||
{{Code|code= |
{{Code|code= |
||
from os.path import join |
|||
femmesh_obj = App.ActiveDocument.getObject("Result_mesh").FemMesh |
|||
import FreeCAD as App |
|||
result = App.ActiveDocument.getObject("CalculiX_static_results") |
|||
⚫ | |||
⚫ | |||
import Mesh |
import Mesh |
||
⚫ | |||
path = join(App.getResourceDir(), "examples", "FemCalculixCantilever3D.FCStd") |
|||
doc = App.openDocument(path) |
|||
fem_mesh = doc.Box_Mesh.FemMesh |
|||
result = doc.CCX_Results |
|||
scale = 1 # displacement scale factor |
|||
⚫ | |||
Mesh.show(Mesh.Mesh(out_mesh)) |
Mesh.show(Mesh.Mesh(out_mesh)) |
||
}} |
}} |
||
<translate> |
<translate> |
||
== Converting 2D elements == <!--T:6--> |
|||
Select a mesh and run the following python script |
|||
⚫ | |||
{{Code|code= |
|||
import Mesh |
|||
def extend_by_triangle(i, j, k): |
|||
triangle = [input_mesh.getNodeById(element_nodes[i]), |
|||
input_mesh.getNodeById(element_nodes[j]), |
|||
input_mesh.getNodeById(element_nodes[k])] |
|||
return output_mesh.extend(triangle) |
|||
<!--T:10--> |
|||
selection = FreeCADGui.Selection.getSelection() |
|||
{{Docnav |
|||
input_mesh = App.ActiveDocument.getObject(selection[0].Name).FemMesh |
|||
|[[FEM_MeshGroup|FEM mesh group]] |
|||
output_mesh = [] |
|||
|[[FEM_SolverCalculixCxxtools|Solver CalculiX Standard]] |
|||
for element in input_mesh.Faces: |
|||
|[[FEM_Workbench|FEM]] |
|||
element_nodes = input_mesh.getElementNodes(element) |
|||
|IconL=FEM_MeshGroup.svg |
|||
if len(element_nodes) in [3, 6]: # tria3 or tria6 (ignoring mid-nodes) |
|||
|IconR=FEM_SolverCalculixCxxtools.svg |
|||
extend_by_triangle(0, 1, 2) |
|||
|IconC=Workbench_FEM.svg |
|||
elif len(element_nodes) in [4, 8]: # quad4 or quad8 (ignoring mid-nodes) |
|||
extend_by_triangle(0, 1, 2) |
|||
extend_by_triangle(2, 3, 0) |
|||
obj = Mesh.Mesh(output_mesh) |
|||
Mesh.show(obj) |
|||
}} |
}} |
||
⚫ | |||
{{FEM Tools navi{{#translation:}}}} |
|||
{{clear}} |
|||
{{Userdocnavi{{#translation:}}}} |
|||
⚫ |
Latest revision as of 10:12, 2 March 2024
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 that are unique (not shared by two elements) and uses them to create faces of a mesh. Optionally, it can be used to save a deformed mesh. This is done by adding the displacement of the FEM results to the mesh nodes (the scale of the displacement can be set using Python).
Usage
- Select a FEM mesh object.
- Optionally also select the FEM results.
- 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
Note: The parameter scale was introduced in version 0.21. For older versions of FreeCAD omit it from your code.
The cantilever example:
from os.path import join
import FreeCAD as App
import Mesh
from femmesh import femmesh2mesh
path = join(App.getResourceDir(), "examples", "FemCalculixCantilever3D.FCStd")
doc = App.openDocument(path)
fem_mesh = doc.Box_Mesh.FemMesh
result = doc.CCX_Results
scale = 1 # displacement scale factor
out_mesh = femmesh2mesh.femmesh_2_mesh(fem_mesh, result, scale)
Mesh.show(Mesh.Mesh(out_mesh))
FEM
- Materials: Solid, Fluid, Nonlinear mechanical, Reinforced (concrete); Material editor
- Element geometry: Beam (1D), Beam rotation (1D), Shell (2D), Fluid flow (1D)
Constraints
- Electromagnetic: Electrostatic potential, Current density, Magnetization
- Geometrical: Plane rotation, Section print, Transform
- Mechanical: Fixed, Displacement, Contact, Tie, Spring, Force, Pressure, Centrif, Self weight
- Thermal: Initial temperature, Heat flux, Temperature, Body heat source
- Overwrite Constants: Constant vacuum permittivity
- Solve: CalculiX Standard, Elmer, Mystran, Z88; Equations: Deformation, Elasticity, Electrostatic, Electricforce, Magnetodynamic, Magnetodynamic 2D, Flow, Flux, Heat; Solver: Solver control, Solver run
- Results: Purge, Show; Postprocessing: Apply changes, Pipeline from result, Warp filter, Scalar clip filter, Function cut filter, Region clip filter, Contours filter, Line clip filter, Stress linearization plot, Data at point clip filter, Filter function plane, Filter function sphere, Filter function cylinder, Filter function box
- Additional: Preferences; FEM Install, FEM Mesh, FEM Solver, FEM CalculiX, FEM Concrete; FEM Element Types
User documentation
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub