Stress Result in Shells

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
bernd
Posts: 7536
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Stress Result in Shells

Postby bernd » Thu Jan 17, 2019 5:09 pm

Would be interesting how Salomone handle node gaps in their mesh structure. What do they use to save and load the mesh to and from disk?
wmayer
Site Admin
Posts: 14068
Joined: Thu Feb 19, 2009 10:32 am

Re: Stress Result in Shells

Postby wmayer » Thu Jan 17, 2019 5:52 pm

Werner do you see any solution apart from use some compactMesh() right at the beginning when we create a mesh in FreeCAD. With this the mesh is renumbered during import from frd file.
The options are:
  1. Check if it's possible to find a way to make everything consistent again after a mesh has been compacted
  2. Do some kind of compact mesh before saving a project. At this stage we have the chance to make everything consistent.
  3. Copy the relevant code of the UNV reader and remove the compactMesh() call. Doing it in the original version is a bad idea because one can link the external smesh. This would be the easiest solution but requires quite a lot of code duplication.
  4. Switch to another format where it's sure that a mesh won't be reordered after load
Would be interesting how Salomone handle node gaps in their mesh structure. What do they use to save and load the mesh to and from disk?
IMO, it's a very odd behaviour to hard-code the call of compactMesh() and doesn't give any possibility to disable it.
Jee-Bee
Posts: 1766
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Stress Result in Shells

Postby Jee-Bee » Thu Jan 17, 2019 9:04 pm

bernd wrote:
Thu Jan 17, 2019 5:09 pm
Would be interesting how Salomone handle node gaps in their mesh structure. What do they use to save and load the mesh to and from disk?
Do we have any salome users over here? maybe somebody can ask it on their forum?
http://www.salome-platform.org/forum
User avatar
bernd
Posts: 7536
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Stress Result in Shells

Postby bernd » Thu Jan 17, 2019 9:35 pm

Attaches some code which would fix it for the FEM 2D start wb example.

- the code loads the example
- runs the analysis
- fixes result object and result mesh
- saves the document
- loads the document
- than the document could be saved and loaded as much as needed ...

Code: Select all

# load 2D example file and set 3D output in solver
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/FemCalculixCantilever2D.FCStd')

doc.FEMMeshGmsh.ViewObject.Visibility = False
doc.CalculiXccxTools.BeamShellResultOutput3D = True
doc.recompute()
# run the analysis
import FemGui
FemGui.setActiveAnalysis(doc.Analysis)
from femtools import ccxtools
fea = ccxtools.FemToolsCcx()
fea.update_objects()
fea.purge_results()
fea.run()

# node keys
doc.Result_mesh.FemMesh.Nodes.keys()  # starts with 178


# lets fix it ... 
# we need a new res_obj.Mesh.FemMesh and a new res_obj.NodeNumbers
# works on the FEM 2D example only, edges and faces not treated, only 15 node volume treated!

res_obj = doc.CalculiX_static_results

ononu = res_obj.NodeNumbers
res_mesh = res_obj.Mesh
omesh = res_mesh.FemMesh
onodes = omesh.Nodes
ovols = omesh.Volumes

# omesh.Nodes.keys()
# omesh.Edges
# omesh.Faces
# omesh.Volumes

nomap = {}  # 178:1, 179:2, ...
elmap = {}  # 37:1, 38:2, ...

import Fem
nmesh = Fem.FemMesh()
for i, n in enumerate(onodes):
    # print(i)
    # print(n)
    # print(onodes[n])
    nid = i + 1
    nmesh.addNode(onodes[n].x, onodes[n].y, onodes[n].z, nid)
    nomap[n] = nid

for i, v in enumerate(ovols):
    # print(i)
    # print(v)
    # print(omesh.getElementNodes(v))
    vid = i + 1
    olenodes = omesh.getElementNodes(v)
    nelenodes = []
    for on in olenodes:
        nelenodes.append(nomap[on])
    # print(nelenodes)
    nmesh.addVolume(nelenodes, vid)
    elmap[v] = vid

nnonu = []
for on in ononu:
    nnonu.append(nomap[on])

# nmesh.Nodes.keys()
# nmesh.Volumes
# nnonu
# Fem.show(nmesh)

res_obj.Mesh.FemMesh = nmesh
res_obj.NodeNumbers = nnonu
doc.recompute()


# save and reload the file
save_name = u"/home/hugo/Desktop/nodegapstest.FCStd"
doc.saveAs(save_name)
FreeCAD.closeDocument(doc.Name)
doc2 = FreeCAD.open(save_name)

# node keys
doc2.Result_mesh.FemMesh.Nodes.keys()  # starts with 1

fandaL
Posts: 324
Joined: Thu Jul 24, 2014 8:29 am

Re: Stress Result in Shells

Postby fandaL » Thu Jan 17, 2019 10:33 pm

Jee-Bee wrote:
Thu Jan 17, 2019 9:04 pm
bernd wrote:
Thu Jan 17, 2019 5:09 pm
Would be interesting how Salomone handle node gaps in their mesh structure. What do they use to save and load the mesh to and from disk?
Do we have any salome users over here? maybe somebody can ask it on their forum?
http://www.salome-platform.org/forum
I'm not Salome specialist, but as I understand Salome does not allow to manually control node and element numbers too much. If you delete elements or nodes with low numbers, the rest will be renumbered to start from 1 without gaps.
User avatar
bernd
Posts: 7536
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Stress Result in Shells

Postby bernd » Fri Jan 18, 2019 6:52 am

this compacts the result object and result mesh on inport from frd file. Since they are compacted already saving and reloading a FreeCAD file works fine. https://github.com/berndhahnebach/FreeC ... da24b2085b
User avatar
bernd
Posts: 7536
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Stress Result in Shells

Postby bernd » Sun Jan 20, 2019 9:18 pm

User avatar
HarryvL
Posts: 959
Joined: Sat Jan 06, 2018 7:38 pm

Re: Stress Result in Shells

Postby HarryvL » Mon Jan 21, 2019 12:57 pm

Great. Seams to work fine so far.