GSoC2020, FEM: extend examples

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

Sudhanshu wrote: Fri May 15, 2020 8:33 pm It was done, but there is an issue now.
Since this is the logic of the accept method:

Code: Select all

    def accept(self):
        print("\nExample will be run.")
        item = self.view.selectedItems()[0]
        example = item.text(0)
        # if done this way the Python commands are printed in Python console
        FreeCADGui.doCommand("from femexamples." + str(example) + "  import setup")
        FreeCADGui.doCommand("setup()")
Now if I select "CCX cantilever face load" from the GUI the command getting executed is this:

Code: Select all

from femexamples.CCX cantilever face load  import setup
And this is obviously the wrong command.
The only way of getting the file name from this name I can think of is to get access to the files_info object and then iterate over it matching the names.
But this is highly inefficient!!

Other use of the name property could be to setup tool tips.
What do you say?
Since @bernd looks busy, @HoWill and @kkremitzki can you tell me a solution for this?

HoWil wrote: Mon May 04, 2020 6:03 pm Ping
kkremitzki wrote: Sat May 09, 2020 12:12 am Ping
I will complete the hinged beam example till then.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: GSoC2020, FEM: extend examples

Post by bernd »

Have some patience. completing the hinged example is a good idea. I have been working on an important improvement, which will be very helpful for you. With latest master you can open all old FEM files! They will be migeated on import.
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

bernd wrote: Sat May 16, 2020 7:49 pm Have some patience. completing the hinged example is a good idea. I have been working on an important improvement, which will be very helpful for you. With latest master you can open all old FEM files! They will be migeated on import.
Ok. That sounds cool.
Sorry for my impatience.
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

Sudhanshu wrote: Sat May 16, 2020 7:03 pm I will complete the hinged beam example till then.
Ok here it is attached.
I do think that applying the same tansform constraint to both the faces wasn't the best idea.
But I will wait for your review.
Attachments
Beam_hinged_generated.FCStd
(788.18 KiB) Downloaded 18 times
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

bernd wrote: Sun Apr 26, 2020 6:39 pm
Sudhanshu wrote: Fri Apr 24, 2020 9:12 pm So can I consider the constraint_transform_torque example completed?

no, as long as we do not get reasonable results it is not completed. Furthermore a unit test is still missing.
So I was wondering how we can run unit tests in FreeCAD and from FreeCAD --help I found that the command is FreeCAD -t 0 for all the tests. And so I tried it:

Code: Select all

[sudhanshu@archlinux build_nonetgen]$ ./bin/FreeCAD -t 0
FreeCAD 0.19, Libs: 0.19R20910 +41 (Git)
© Juergen Riegel, Werner Mayer, Yorik van Havre and others 2001-2020
FreeCAD is free and open-source software licensed under the terms of LGPL2+ license.
FreeCAD wouldn't be possible without FreeCAD community.
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

connect failed: No such file or directory
import TestFemImport 
import TestObjectExistance 
import TestFemCommon 
import TestObjectCreate 
import TestObjectType 
import TestMaterialUnits 
import TestMeshCommon 
import TestMeshEleTetra10 
import TestResult 
import TestCcxTools 
import TestSolverFrameWork 
test_import_draft (drafttests.test_import.DraftImport)
Import the Draft module. ... 
------------------------------------------------------------------------------
  Try importing 'Draft'
ok
test_import_draft_geomutils (drafttests.test_import.DraftImport)
Import Draft geometrical utilities. ... 
------------------------------------------------------------------------------
  Try importing 'DraftGeomUtils'
ok
test_import_draft_svg (drafttests.test_import.DraftImport)
Import Draft SVG utilities. ... 
------------------------------------------------------------------------------
  Try importing 'getSVG'
ok
test_import_draft_vecutils (drafttests.test_import.DraftImport)
Import Draft vector utilities. ... 
------------------------------------------------------------------------------
  Try importing 'DraftVecUtils'
ok
test_arc (drafttests.test_creation.DraftCreation)
Create a circular arc. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft Arc'
  radius=2
  startangle=0, endangle=90
ok
test_arc_3points (drafttests.test_creation.DraftCreation)
Create a circular arc from three points. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft Arc 3Points'
  a=Vector (5.0, 0.0, 0.0), b=Vector (4.0, 3.0, 0.0)
  c=Vector (0.0, 5.0, 0.0)
----------------
Arc by 3 points
p1: Vector (5.0, 0.0, 0.0)
p2: Vector (4.0, 3.0, 0.0)
p3: Vector (0.0, 5.0, 0.0)
Radius: 5.000000000000002
Center: Vector (-1.3322676295501878e-15, -1.3322676295501878e-15, 0.0)
ok
test_bezcurve (drafttests.test_creation.DraftCreation)
Create a bezier curve of six points, degree five. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft BezCurve'
  a=Vector (0.0, 0.0, 0.0), b=Vector (2.0, 2.0, 0.0)
  c=Vector (5.0, 3.0, 0.0), d=Vector (9.0, 0.0, 0.0)
  e=Vector (12.0, 5.0, 0.0), f=Vector (12.0, 8.0, 0.0)
ok
test_bspline (drafttests.test_creation.DraftCreation)
Create a BSpline of three points. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft BSpline'
  a=Vector (0.0, 0.0, 0.0), b=Vector (2.0, 0.0, 0.0)
  c=Vector (2.0, 2.0, 0.0)
ok
test_circle (drafttests.test_creation.DraftCreation)
Create a circle. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft Circle'
  radius=3
ok
test_cubicbezcurve (drafttests.test_creation.DraftCreation)
Create a cubic bezier curve of four points. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft CubBezCurve'
  a=Vector (0.0, 0.0, 0.0), b=Vector (2.0, 2.0, 0.0)
  c=Vector (5.0, 3.0, 0.0), d=Vector (9.0, 0.0, 0.0)
ok
test_dimension_angular (drafttests.test_creation.DraftCreation)
Create an angular dimension between two lines at given angles. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft Dimension Angular'
  Occasionally crashes
  center=Vector (0.0, 0.0, 0.0)
  angle1=59.99999999999999, angle2=10.0
  point=Vector (3.0, 1.0, 0.0)
Traceback (most recent call last):
  File "/run/media/sudhanshu/Thunder/Repos/FreeCAD_sd/build_nonetgen/Mod/Draft/draftviewproviders/view_dimension.py", line 730, in attach
    self.onChanged(vobj,"FontSize")
  File "/run/media/sudhanshu/Thunder/Repos/FreeCAD_sd/build_nonetgen/Mod/Draft/draftviewproviders/view_dimension.py", line 875, in onChanged
    self.font.size = vobj.FontSize.Value * self.ScaleMultiplier
<class 'AttributeError'>: 'ViewProviderAngularDimension' object has no attribute 'ScaleMultiplier'
Traceback (most recent call last):
  File "/run/media/sudhanshu/Thunder/Repos/FreeCAD_sd/build_nonetgen/Mod/Draft/draftviewproviders/view_dimension.py", line 875, in onChanged
    self.font.size = vobj.FontSize.Value * self.ScaleMultiplier
<class 'AttributeError'>: 'ViewProviderAngularDimension' object has no attribute 'ScaleMultiplier'
ok
test_dimension_linear (drafttests.test_creation.DraftCreation)
Create a linear dimension. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft Dimension'
  Occasionally crashes
  a=Vector (0.0, 0.0, 0.0), b=Vector (9.0, 0.0, 0.0)
  c=Vector (4.0, -1.0, 0.0)
ok
test_dimension_radial (drafttests.test_creation.DraftCreation)
Create a circle and then a radial dimension. ... 
------------------------------------------------------------------------------
  Temporary document 'DraftCreation'
  Test 'Draft Dimension Radial'
  radius=3
  startangle=0, endangle=90
ICE default IO error handler doing an exit(), pid = 126439, errno = 32
Program received signal SIGSEGV, Segmentation fault.
#0  /usr/lib/libc.so.6(+0x3c370) [0x7fa37f93b370]
#1  0x7fa3801b32b6 in QAbstractEventDispatcherPrivate::allocateTimerId() from /usr/lib/libQt5Core.so.5+0x36
#2  0x7fa3801b38aa in QAbstractEventDispatcher::registerTimer(int, Qt::TimerType, QObject*) from /usr/lib/libQt5Core.so.5+0x1a
#3  0x7fa3801e65ef in QObject::startTimer(int, Qt::TimerType) from /usr/lib/libQt5Core.so.5+0x6f
#4  0x7fa3801efd9e in QTimer::start() from /usr/lib/libQt5Core.so.5+0x3e
#5  0x7fa38125c43b in QNetworkConfigurationManagerPrivate::startPolling() from /usr/lib/libQt5Network.so.5+0xdb
#6  0x7fa38125ca1e in QNetworkConfigurationManagerPrivate::updateConfigurations() from /usr/lib/libQt5Network.so.5+0x54e
#7  /usr/lib/libQt5Network.so.5(+0x15c857) [0x7fa3812f4857]
#8  0x7fa3801e3ada in QObject::event(QEvent*) from /usr/lib/libQt5Core.so.5+0x2ba
#9  0x7fa3801b6516 in QCoreApplication::notifyInternal2(QObject*, QEvent*) from /usr/lib/libQt5Core.so.5+0x1a6
#10  0x7fa3801b8d56 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) from /usr/lib/libQt5Core.so.5+0x156
#11  /usr/lib/libQt5Core.so.5(+0x2fe244) [0x7fa38020f244]
#12  /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x27e) [0x7fa37ce296be]
#13  /usr/lib/libglib-2.0.so.0(+0x6d531) [0x7fa37ce2b531]
#14  /usr/lib/libglib-2.0.so.0(g_main_context_iteration+0x31) [0x7fa37ce2b571]
#15  0x7fa38020e890 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/libQt5Core.so.5+0x60
#16  0x7fa3801b505c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/libQt5Core.so.5+0x12c
#17  0x7fa37ffd9c62 in QThread::exec() from /usr/lib/libQt5Core.so.5+0x62
#18  /usr/lib/libQt5Core.so.5(+0xc9dd6) [0x7fa37ffdadd6]
#19  /usr/lib/libpthread.so.0(+0x9422) [0x7fa381483422]
#20  /usr/lib/libc.so.6(clone+0x43) [0x7fa37f9feb83]
:shock:
Maybe I should try FEM specific tests first.
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

Sudhanshu wrote: Tue May 19, 2020 8:23 pm
Maybe I should try FEM specific tests first.
So I found this commit of @bernd: git commit 5022c8d

And the result is attached in the file.
But the fact that the result ended with this (when I did not directed the output to a file):

Code: Select all

Ran 49 tests in 38.256s

OK
System exit
This means that the tests of "TestFem" have been passed I guess.
But then again, I don't think my examples were tested because they were not in the list :?: .
Since the other tests mentioned in the commit are part of TestFem, I think it's not required to run them.

Guess I need to do more research in testing in FreeCAD.
Attachments
TestFem.txt
(47.38 KiB) Downloaded 18 times
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: GSoC2020, FEM: extend examples

Post by bernd »

https://github.com/FreeCAD/FreeCAD/blob ... y#L52-L287

this will help you to run a specfic test, or test class or all tests of a workbench
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: GSoC2020, FEM: extend examples

Post by bernd »

git commit 3f399736db will help you to create a unit test for the torque example
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

Ok. Thanks!!
I will look into them in the morning?
bernd wrote: Sat May 16, 2020 7:49 pm Have some patience. completing the hinged example is a good idea. I have been working on an important improvement, which will be very helpful for you. With latest master you can open all old FEM files! They will be migeated on import.
What's the status of this work by the way??
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: GSoC2020, FEM: extend examples

Post by bernd »

How about the unit test?

I have normalised FEM license header with git commit a3a61c334 Would you fix the header in all your edited or new created files?
Post Reply