## 2D Mesh

About the development of the FEM module/workbench.
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### 2D Mesh

In structural engineering field all FEM models are made with 2D and 1D elements. I'm able to import the meshes from the calculation software we use at the office into FreeCAD.

screen1.jpg (134.63 KiB) Viewed 2436 times

In Fem_Workbench is shown how to make a FEM Mesh using python but only for 3D-meshes

These two posts of Juegen gave some informations about FEM-module.
viewtopic.php?f=18&t=6963#p56362
viewtopic.php?f=18&t=6992&start=10#p57065

The mesh object can allready handle 2D-Meshes. Does it mean if I create my Mesh in python (by converting the imported mesh) I am able to use the 2Dmesh object? It would mean I could show the nodes on the screen but not the mesh since the 2D meshes do not have visuals yet?

I wonder if it is possible by python to put even constraints on the 2D mesh by python and make a analysis in calculix? Attached a simple slab I would like to play with.
Attachments
simpleslab--structural.fcstd
ediloren
Posts: 186
Joined: Wed May 08, 2013 9:23 pm
Location: Italy
Contact:

### Re: 2D Mesh

If you mean, meshing the surface of the objects, this is perfectly possible, also from the gui. Look under 'mesh part' (sorry i'm not in front of my computer now, cannot post a screenshot)

Enrico
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: 2D Mesh

ediloren wrote:If you mean, meshing the surface of the objects ...
I allready have a mesh. I would like to turn it into a FEM-Mesh

Code: Select all

`import FreeCAD, Femm = Fem.FemMesh()m.addNode(0,1,0)m.addNode(0,0,1)m.addNode(1,0,0)m.addFace([1,2,3])Fem.show(m)Gui.ActiveDocument.ActiveObject.HighlightedNodes = [1,2,3]`

Shows the points of the little FEM-Mesh, is it a FEM-Mesh? If it's a FEM-Mesh that would mean a FEM-Mesh could be made from the imported Parts this way! How to add constraints to that FEM-Mesh? I know the node numbers to add to. Same for loads ...
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: 2D Mesh

The code of the last post seam to made a FEM-Mesh, just forgot to print it ...

Code: Select all

`>>> m========================== Dump contents of mesh ==========================1) Total number of nodes:      32) Total number of edges:      03) Total number of faces:      14) Total number of polygons:   05) Total number of volumes:   06) Total number of polyhedrons:   07) Total number of linear edges:   08) Total number of linear faces:   18.1) Number of linear triangles:     18.2) Number of linear quadrangles:   09) Total number of linear volumes:   010) Total number of quadratic edges:   011) Total number of quadratic faces:   012) Total number of quadratic volumes:   0===========================================================================>>> `
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: 2D Mesh

Mhh but trying to get a Mesh out of the file provided (simpleslab--structural.fcstd) addNode does not accept a Point

Code: Select all

`>>> import FreeCAD, Fem>>> m = Fem.FemMesh()>>> testnode = App.ActiveDocument.ID1009954_Entry__1009950_body.Shape.Faces[0].Edges[0].Vertexes[0].Point>>> testnodeVector (5.0, -2.5, 3.125)>>> m.addNode(testnode) Traceback (most recent call last):  File "<input>", line 1, in <module>TypeError: addNode() accepts:-- addNode(x,y,z)-- addNode(x,y,z,ElemId)`
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: 2D Mesh

Mhh sorry for posting that much ...

Just correcting myself ...

Code: Select all

`>>> import FreeCAD, Fem>>> m = Fem.FemMesh()>>> testnode = App.ActiveDocument.ID1009954_Entry__1009950_body.Shape.Faces[0].Edges[0].Vertexes[0]>>> nx=testnode.X>>> ny=testnode.Y>>> nz=testnode.Z>>> m.addNode(nx,ny,nz) 1>>> >>> m========================== Dump contents of mesh ==========================1) Total number of nodes:      12) Total number of edges:      03) Total number of faces:      04) Total number of polygons:   05) Total number of volumes:   06) Total number of polyhedrons:   07) Total number of linear edges:   08) Total number of linear faces:   09) Total number of linear volumes:   010) Total number of quadratic edges:   011) Total number of quadratic faces:   012) Total number of quadratic volumes:   0===========================================================================>>> `
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: 2D Mesh

Got the Mesh, but FreeCAD crashes ...

Code: Select all

`import FreeCAD, Femfaces = App.ActiveDocument.ID1009954_Entry__1009950_body.Shape.Facesm = Fem.FemMesh()nodeid = 1for f in faces:  vertiece = f.Vertexes  for vnr, v in enumerate(vertiece):    vx = v.X    vy = v.Y    vz = v.Z    #print '(', vx, ', ', vy, ', ', vz, ', ', nodeid, ')'    m.addNode(vx,vy,vz,nodeid)     nodeid += 1    if vnr == 0:      facenode1 = nodeid    elif vnr == 1:      facenode2 = nodeid    elif vnr == 2:      facenode3 = nodeid    else:      print 'error in facenodes'                m.addFace([facenode1,facenode1,facenode1,])  Fem.show(m)m # aktivate Mesh in TreeViewlist = range(m.NodeCount+1)list = list[1:]Gui.ActiveDocument.ActiveObject.HighlightedNodes = list  `

do not change the view. Just zoom in and out using the mouse wheel and FreeCAD crashes. I can remember this again and again. I havn't had this with this version of FreeCAD with non of lots of modells.

OS: Windows 7
Word size: 64-bit
Version: 0.14.3691 (Git)
Branch: master
Hash: 691fd1128672c8bd472cece87c9e9d07b71d6fee
Python version: 2.7.6
Qt version: 4.8.5
Coin version: 4.0.0a
SoQt version: 1.6.0a
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: 2D Mesh

same crash on:

OS: Ubuntu 14.04.1 LTS
Word size of OS: 32-bit
Version: 0.15.4086 (Git)
Branch: master
Hash: f87bd2ac352dee9ea9aa27096141e0a37326fa45
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a

Code: Select all

`bhb@ubuntuVM:~\$ freecadFreeCAD 0.15, Libs: 0.15R4086 (Git)© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2014  #####                 ####  ###   ####    #                    #      # #   #   #   #     ##  #### ####  #     #   #  #   #   ####  # # #  # #  #  #     #####  #   #   #     #   #### ####  #    #     # #   #   #     #   #    #     #    #     # #   #  ##  ##  ##  #     #   #### ####   ### #     # ####   ##  ##  ##libGL error: pci id for fd 15: 80ee:beef, driver (null)OpenGL Warning: Failed to connect to host. Make sure 3D acceleration is enabled for this VM.libGL error: core dri or dri2 extension not foundlibGL error: failed to load driver: vboxvideosh: 1: SMDS_MemoryLimit: not found*** Abort *** an exception was raised, but no catch was found.   ... The exception is:SIGSEGV 'segmentation violation' detected. Address 1e4bhb@ubuntuVM:~\$`

BTW: ubuntu runs in VirtualBox
shoogen
Posts: 2822
Joined: Thu Dec 01, 2011 5:24 pm

### Re: 2D Mesh

i can reproduce the problem

Code: Select all

`#0  0x00007fff6699c1fc in FemGui::ViewProviderFemMesh::getElement (this=    0x52d4ce0, detail=0x5304920)    at /home/sebastian/free-cad/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp:420#1  0x00007ffff75c85f9 in Gui::SoFCUnifiedSelection::handleEvent (this=    0x24ffc30, action=0x96deb0)    at /home/sebastian/free-cad/src/Gui/SoFCUnifiedSelection.cpp:363#2  0x00007ffff4df6707 in SoNode::handleEventS(SoAction*, SoNode*) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#3  0x00007ffff4bbbc85 in SoAction::traverse(SoNode*) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#4  0x00007ffff4d06f3c in SoChildList::traverse(SoAction*, int, int) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#5  0x00007ffff4debf5d in SoGroup::doAction(SoAction*) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#6  0x00007ffff4e082bf in SoSeparator::doAction(SoAction*) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#7  0x00007ffff4df6707 in SoNode::handleEventS(SoAction*, SoNode*) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#8  0x00007ffff4bbbc85 in SoAction::traverse(SoNode*) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#9  0x00007ffff4bc690a in SoHandleEventAction::beginTraversal(SoNode*) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#10 0x00007ffff4bbc4c2 in SoAction::apply(SoNode*) ()   from /usr/lib/x86_64-linux-gnu/libCoin.so.80#11 0x00007ffff4d25499 in SoEventManager::actuallyProcessEvent(SoEvent const*)    () from /usr/lib/x86_64-linux-gnu/libCoin.so.80#12 0x00007ffff762d1b8 in SIM::Coin3D::Quarter::QuarterWidget::processSoEvent (    this=0x96a0a0, event=0x39a1b70)    at /home/sebastian/free-cad/src/Gui/Quarter/QuarterWidget.cpp:807#13 0x00007ffff7638435 in SIM::Coin3D::Quarter::SoQTQuarterAdaptor::processSoEvent (this=0x96a0a0, event=0x39a1b70)    at /home/sebastian/free-cad/src/Gui/Quarter/SoQTQuarterAdaptor.h:93#14 0x00007ffff765fa83 in Gui::View3DInventorViewer::processSoEventBase (this=    0x96a0a0, ev=0x39a1b70)    at /home/sebastian/free-cad/src/Gui/View3DInventorViewer.cpp:1515#15 0x00007ffff7646b2f in Gui::NavigationStyle::processSoEvent (this=    0x24d0710, ev=0x39a1b70)    at /home/sebastian/free-cad/src/Gui/NavigationStyle.cpp:1263#16 0x00007ffff764b7cc in Gui::CADNavigationStyle::processSoEvent (this=    0x24d0710, ev=0x39a1b70)    at /home/sebastian/free-cad/src/Gui/CADNavigationStyle.cpp:436#17 0x00007ffff7646a7c in Gui::NavigationStyle::processEvent (this=0x24d0710,     ev=0x39a1b70) at /home/sebastian/free-cad/src/Gui/NavigationStyle.cpp:1246#18 0x00007ffff765fa4a in Gui::View3DInventorViewer::processSoEvent (this=    0x96a0a0, ev=0x39a1b70)    at /home/sebastian/free-cad/src/Gui/View3DInventorViewer.cpp:1510#19 0x00007ffff762f535 in SIM::Coin3D::Quarter::EventFilter::eventFilter (this=    0x24c9b20, obj=0x96a0a0, qevent=0x7fffffffbfc0)    at /home/sebastian/free-cad/src/Gui/Quarter/EventFilter.cpp:164#20 0x00007ffff0c6acc6 in QCoreApplicationPrivate::sendThroughObjectEventFilters (this=<optimized out>, receiver=0x96a0a0, event=0x7fffffffbfc0)    at kernel/qcoreapplication.cpp:1025#21 0x00007ffff17226dc in QApplicationPrivate::notify_helper (this=this@entry=    0x8161a0, receiver=receiver@entry=0x96a0a0, e=e@entry=0x7fffffffbfc0)    at kernel/qapplication.cpp:4552#22 0x00007ffff17273eb in QApplication::notify (this=<optimized out>, receiver=    0x24f6330, e=0x7fffffffc550) at kernel/qapplication.cpp:4099#23 0x00007ffff73ded7b in Gui::GUIApplication::notify (this=0x7fffffffd0f0,     receiver=0x24f6330, event=0x7fffffffc550)    at /home/sebastian/free-cad/src/Gui/Application.cpp:1537#24 0x00007ffff0c6ab5e in QCoreApplication::notifyInternal (this=    0x7fffffffd0f0, receiver=0x24f6330, event=0x7fffffffc550)    at kernel/qcoreapplication.cpp:915#25 0x00007ffff172354b in sendEvent (event=<optimized out>,     receiver=<optimized out>)    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231#26 QApplicationPrivate::sendMouseEvent (receiver=0x24f6330, event=    0x7fffffffc550, alienWidget=0x0, nativeWidget=0x24f6330, buttonDown=    0x7ffff21f82a8, lastMouseReceiver=..., spontaneous=true)`

OS: Debian GNU/Linux 7.6 (wheezy)
Word size of OS: 64-bit
Version: 0.15.4090 +7 (Git)