FEM Result Export to File
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
FEM Result Export to File
I would like to export my FEM results as a usable model. I can replicate similar requests I found while searching (https://forum.freecadweb.org/viewtopic.php?t=68433 and https://forum.freecadweb.org/viewtopic.php?f=18&t=48882) to create an array of Vector objects. How do I put this in a form which I can export as a mesh or solid? As an alternative, when I try to do something dead-simple like File>Export...>obj to take a copy of the result mesh, I return a mostly empty file. It feels like I am missing something obvious. Is there some way to pipe the Vector array into a mesh file which I can save?
OS: Ubuntu 20.04.5 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 0d9536ed3e8c7f40197b5606e1b7873625e1d6fe
Python version: 3.8.10
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.2
Locale: English/United States (en_US)
Example file seems unnecessary for this question, but I can provide a cube on request.
OS: Ubuntu 20.04.5 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 0d9536ed3e8c7f40197b5606e1b7873625e1d6fe
Python version: 3.8.10
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.2
Locale: English/United States (en_US)
Example file seems unnecessary for this question, but I can provide a cube on request.
Re: FEM Result Export to File
This tool may help you: FEM FemMesh2Mesh
-
- Veteran
- Posts: 3158
- Joined: Sat May 20, 2017 12:06 pm
- Location: Germany
Re: FEM Result Export to File
Thanks.
I used the script to generate the obj-mesh from FEM-result.
How can I get the deformed mesh? As a start to run FEM
with shell imperfections.
Re: FEM Result Export to File
That tool seemed promising, but it seems it only outputs the starting mesh not the displacement mesh. It looks like thschrader is asking the same thing.
Re: FEM Result Export to File
@thschrader @whoneyc According to the description on the wiki, this tool can export the deformed mesh but only for solid elements. For shell elements, undeformed mesh is exported. But maybe it wouldn’t be very difficult to add a code that could handle this.
Re: FEM Result Export to File
I agree, but this is my first time looking at FreeCAD scripting. Please bear with my newb problems here.
I have two methods to generate similar outputs. The first is to look at the FemMesh2Mesh output which follows the format:
Code: Select all
out_mesh = femmesh.femmesh2mesh.femmesh_2_mesh(FreeCAD.ActiveDocument.ResultMesh.FemMesh)
Mesh.show(Mesh.Mesh(out_mesh))
FreeCAD.ActiveDocument.ResultMesh.ViewObject.hide()
Code: Select all
doc = App.ActiveDocument
resnodes_notdeformed = list(doc.ResultMesh.FemMesh.Nodes.values())
displacements = doc.CCX_Results.DisplacementVectors
sum = [a + b for a, b in zip(resnodes_notdeformed, displacements)]
When I attempt to run
Code: Select all
Mesh.show(Mesh.Mesh(sum))
-
- Veteran
- Posts: 3158
- Joined: Sat May 20, 2017 12:06 pm
- Location: Germany
Re: FEM Result Export to File
OK. But what must I do? Workflow?
Thanks, Thomas
Re: FEM Result Export to File
Select the mesh object and the result file “CCX_Results”. Click FEM mesh to mesh. The new mesh object should appear (corresponding to deformation scale = 1).
For me it works for 3D as well as 2D mesh. Wiki seems to be outdated.
Note that for buckling and frequency analysis, deformation is normalized. CalculiX finds only the shape, not the scale. So the scale is real only for static (or thermomechanical) analysis.
Code: Select all
OS: Ubuntu Core 20 (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.1.29177 +233 (Git) Snap 245
Build type: Release
Branch: tag: 0.20.1
Hash: f5d13554ecc7a456fb6e970568ae5c74ba727563
Python 3.8.10, Qt 5.15.3, Coin 4.0.0, Vtk 7.1.1, OCC 7.6.3
Locale: English/United States (en_US)
Re: FEM Result Export to File
OK. I think it would be nice to add a scale as a parameter, but for now, you can do it manually:
1) Copy the source code to the FreeCAD python console
https://github.com/FreeCAD/FreeCAD/blob ... #L171-L180
where the highlighted block is changed to
Code: Select all
triangle = [myFemMesh.getNodeById(face_nodes[0]) + dispVec0 * 100,
myFemMesh.getNodeById(face_nodes[1]) + dispVec1 * 100,
myFemMesh.getNodeById(face_nodes[2]) + dispVec2 * 100]
output_mesh.extend(triangle)
# print("my triangle: ", triangle)
if len(face_nodes) == 4:
dispVec3 = myResults.DisplacementVectors[myResults.NodeNumbers.index(face_nodes[3])]
triangle = [myFemMesh.getNodeById(face_nodes[2]) + dispVec2 * 100,
myFemMesh.getNodeById(face_nodes[3]) + dispVec3 * 100,
myFemMesh.getNodeById(face_nodes[0]) + dispVec0 * 100]
2) select CCX_Results object and mesh object
3) run the modified function by
Code: Select all
import Mesh
out_mesh = femmesh_2_mesh(FreeCAD.ActiveDocument.ResultMesh.FemMesh, FreeCAD.ActiveDocument.CCX_Results)
Mesh.show(Mesh.Mesh(out_mesh))