mesh region

About the development of the FEM module/workbench.

Moderator: bernd

ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: mesh region

Postby ElMastro » Tue Jul 02, 2019 10:57 am

Mesh.unv.zip
(83.15 KiB) Downloaded 12 times
This one is the one made with freecad. I can't post the meshes made with Salome because they are 384 Mb each one. I'll make some smaller ones and post them.
User avatar
bernd
Posts: 8472
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: mesh region

Postby bernd » Tue Jul 02, 2019 6:32 pm

ElMastro wrote:
Tue Jul 02, 2019 10:52 am
Well, it finished loading.
I can confirm that importing the *.unv in freecad and exporting form it, everything works in calculix launcher, however in freecad the groups aren't listed.
great than we will be able to make one with FreeCAD too :)
User avatar
bernd
Posts: 8472
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: mesh region

Postby bernd » Tue Jul 02, 2019 6:33 pm

ElMastro wrote:
Tue Jul 02, 2019 10:57 am
... I'll make some smaller ones and post them.
cool
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: mesh region

Postby ElMastro » Wed Jul 03, 2019 3:14 pm

Brnd, here are the files:
Mesh_from_Salome.unv.zip
Mesh created with Salome Meca
(17.82 KiB) Downloaded 11 times
Saved_with_freecad.unv.zip
Same mesh, imported and exported with Freecad
(17.82 KiB) Downloaded 9 times
The first made with Salome, the later imported and exported with freecad.
I have to make a correction I noted that in Data/Property tab there are listed 4 groups after import (I believe two should probably be the nodesets)
User avatar
bernd
Posts: 8472
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: mesh region

Postby bernd » Wed Jul 03, 2019 3:23 pm

ElMastro wrote:
Wed Jul 03, 2019 3:14 pm
I have to make a correction I noted that in Data/Property tab there are listed 4 groups after import (I believe two should probably be the nodesets)
If a mesh is imported, no FreeCAD FEM mesh group objects (which will generate mesh groups on meshing) are created, but the mesh group data of the unv will be imported and is visible as you mentioned in the Data/Property tab. By python you have full access to all this data.


But more interesting to me is:
ElMastro wrote:
Wed Jul 03, 2019 3:14 pm
Brnd, here are the files:
Mesh_from_Salome.unv.zipSaved_with_freecad.unv.zip The first made with Salome, the later imported and exported with freecad.
Does this unv exported from FreeCAD works together with CalculiX luncher?
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: mesh region

Postby ElMastro » Wed Jul 03, 2019 4:29 pm

Yes the one exported from freecad works. It shows two groups and a certain quantity of submesh/nodeset. The two groups do have different names but occupy the same face. Probably I did wrong something on Salome Meca
User avatar
bernd
Posts: 8472
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: mesh region

Postby bernd » Thu Jul 04, 2019 10:31 am

bernd wrote:
Wed Jul 03, 2019 3:23 pm
ElMastro wrote:
Wed Jul 03, 2019 3:14 pm
I have to make a correction I noted that in Data/Property tab there are listed 4 groups after import (I believe two should probably be the nodesets)
If a mesh is imported, no FreeCAD FEM mesh group objects (which will generate mesh groups on meshing) are created, but the mesh group data of the unv will be imported and is visible as you mentioned in the Data/Property tab. By python you have full access to all this data.
import the unv exported with Salome and play with Python in FreeCAD ...

Code: Select all

mesh = App.ActiveDocument.Mesh_from_Salome.FemMesh

for g in mesh.Groups:
    mesh.getGroupName(g)
    mesh.getGroupElementType(g)
    mesh.getGroupElements(g)


# for some reason the groups are saved twice ... means we are only interested in Face group with ID 0 and Node group ID 2

# I assume the nodes are the nodes of the faces group ... We will gone check this ...

# get all nodes for the faces group
grfaces = mesh.getGroupElements(0)
grnodes = mesh.getGroupElements(2)

nodes_of_grfaces = []
for f in grfaces:
    nodes_of_grfaces += list(mesh.getElementNodes(f))

nodes_of_grfaces = tuple(sorted(list(set(nodes_of_grfaces))))

if nodes_of_grfaces == grnodes:
    print('The Node group ID 2 are the nodes of the Faces from Face group with ID 0')

# YEAH ... :-) q.e.d

# Lets make a mesh out of it to see what Faces are in Face group with ID 0

import Fem
grmesh = Fem.FemMesh()

for n in grnodes:
    nvec = mesh.getNodeById(n)
    grmesh.addNode(nvec.x, nvec.y, nvec.z, n)

for f in grfaces:
    mesh.getElementNodes(f)
    grmesh.addFace(list(mesh.getElementNodes(f)), f)

Fem.show(grmesh)

Salome_mesh_get_the_groups.FCStd
(26.23 KiB) Downloaded 11 times

screen.png
screen.png (113.25 KiB) Viewed 354 times
User avatar
bernd
Posts: 8472
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: mesh region

Postby bernd » Thu Jul 04, 2019 10:40 am

since we have all informations, lets make the mesh with FreeCAD, print some informations and export it to unv ...

Salome_mesh_made_with_FreeCAD.FCStd
(44.07 KiB) Downloaded 13 times
Mesh_from_Salome.unv.txt
(163.92 KiB) Downloaded 13 times

informations:

Code: Select all

mesh = App.ActiveDocument.FEMMeshGmsh.FemMesh
for g in mesh.Groups:
    mesh.getGroupName(g)
    mesh.getGroupElementType(g)
    mesh.getGroupElements(g)

Code: Select all

>>> 
>>> mesh = App.ActiveDocument.FEMMeshGmsh.FemMesh
>>> 
>>> for g in mesh.Groups:
...     mesh.getGroupName(g)
...     mesh.getGroupElementType(g)
...     mesh.getGroupElements(g)
... 
'FEMMeshGroup'
'Face'
(593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696)
>>> 
>>> 

Would you be so kind and test this unv in CalculiX luncher ?
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: mesh region

Postby ElMastro » Fri Jul 05, 2019 11:14 am

Sorry, I can't
when running

Code: Select all

>>> 
>>> mesh = App.ActiveDocument.FEMMeshGmsh.FemMesh
>>> 
>>> for g in mesh.Groups:
...     mesh.getGroupName(g)
...     mesh.getGroupElementType(g)
...     mesh.getGroupElements(g)
... 
'FEMMeshGroup'
'Face'
(593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696)
>>> 
>>> 
it says
File "<input>", line 5
mesh = App.ActiveDocument.FEMMeshGmsh.FemMesh
^
SyntaxError: invalid syntax
,
However when I input Mesh_from_Salome.unv.txt in Calculix launcher it shows two groups
User avatar
bernd
Posts: 8472
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: mesh region

Postby bernd » Fri Jul 05, 2019 4:13 pm

you get an syntax error on

Code: Select all

mesh = App.ActiveDocument.FEMMeshGmsh.FemMesh
?