FEM unit test failure in Cmd mode

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

FEM unit test failure in Cmd mode

Post by bernd »

I have the following unit test failure which I am really strugle with to reproduce outside of the unit test. As a start point I would like to know if others can reproduce this?

- start FreeCADCmd (it ONLY happens in Cmd!)
- run code ...

Code: Select all

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName("femtest.testccxtools.TestCcxTools.test_1_static_analysis"))
output:

Code: Select all

Constraint fixed: FemConstraintFixed
  Finite element mesh nodes will be retrieved by searching the appropriate nodes in the finite element mesh.
  ReferenceShape ... Type: Face, Object name: Box, Object label: Box, Element name: Face1
Unexpected error when writing CalculiX input file: <class 'TypeError'>
E
======================================================================
ERROR: test_1_static_analysis (femtest.testccxtools.TestCcxTools)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femtest/testccxtools.py", line 143, in test_1_static_analysis
    error = fea.write_inp_file()
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femtools/ccxtools.py", line 650, in write_inp_file
    self.inp_file_name = inp_writer.write_calculix_input_file()
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femsolver/calculix/writer.py", line 113, in write_calculix_input_file
    self.write_calculix_one_input_file()
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femsolver/calculix/writer.py", line 143, in write_calculix_one_input_file
    self.write_node_sets_constraints_fixed(inpfile)
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femsolver/calculix/writer.py", line 501, in write_node_sets_constraints_fixed
    self.get_constraints_fixed_nodes()
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femsolver/writerbase.py", line 133, in get_constraints_fixed_nodes
    femobj
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femmesh/meshtools.py", line 48, in get_femnodes_by_femobj_with_references
    node_set = get_femnodes_by_references(femmesh, femobj['Object'].References)
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femmesh/meshtools.py", line 84, in get_femnodes_by_references
    references_femnodes += get_femnodes_by_refshape(femmesh, ref)
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femmesh/meshtools.py", line 110, in get_femnodes_by_refshape
    nodes += femmesh.getNodesByFace(r)
TypeError: argument 1 must be Part.TopoShape, not Part.Face

----------------------------------------------------------------------
Ran 1 test in 0.045s

FAILED (errors=1)
<unittest.runner.TextTestResult run=1 errors=1 failures=0>
>>> >>> 
As I tried for two hours already, I may give more informations later on ...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FEM unit test failure in Cmd mode

Post by bernd »

The method does not accept a Part.Face but would like to have a Part.TopoShape instead. A Part.Face is a Part.TopoShape! Or am I wrong?
wmayer
Founder
Posts: 20298
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FEM unit test failure in Cmd mode

Post by wmayer »

No failure with version 0.19R16784 or 0.19R16810
PaulG
Posts: 39
Joined: Mon Feb 25, 2019 5:38 pm

Re: FEM unit test failure in Cmd mode

Post by PaulG »

No failure on 0.18.1 or 0.19R16786 on Mint 18.1 xenial with python 2.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: FEM unit test failure in Cmd mode

Post by looo »

No failure with: 0.19.16793 py3.7.1 qt5.6.3
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FEM unit test failure in Cmd mode

Post by bernd »

tested again. it fails for me on self compiled 0.19.16810 on debian buster on FreeCADCmd, it does not fail on installed FreeCAD. I will do a fresh rebuild, if it does not help I try a VM of fresh Debian an FreeCAD.

By the use of vagrant this runs while haveing a beer :mrgreen:
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FEM unit test failure in Cmd mode

Post by bernd »

wmayer
Founder
Posts: 20298
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FEM unit test failure in Cmd mode

Post by wmayer »

When reformatting the code to for easier testing it still works OK:

Code: Select all

active_doc=App.newDocument()

box = active_doc.addObject("Part::Box", "Box")
fixed_constraint = active_doc.addObject("Fem::ConstraintFixed", "FemConstraintFixed")
fixed_constraint.References = [(box, "Face1")]
active_doc.recompute()

import Fem
ref = fixed_constraint.References[0]
femmesh = Fem.FemMesh()

from femmesh.meshtools import get_femnodes_by_refshape as getnodes
getnodes(femmesh, ref)
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FEM unit test failure in Cmd mode

Post by bernd »

I tried this before werner, but it does not fail if I use the code this way. It only fails inside the unit test, only in cmd mode only on my Debian only if self compiled.

In a new Debian testing virtual machine it does not fail.

Mhh I made a fresh build yesterday but it still fails.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FEM unit test failure in Cmd mode

Post by bernd »

I collected all informations in last commit on branch https://github.com/berndhahnebach/FreeC ... femunitcmd (ATM: https://github.com/berndhahnebach/FreeC ... it/344110e)

code to run on my computer in FreeCADCmd:

Code: Select all

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName("femtest.testcmdproblem.TestCmdProblem.test_cmdproblem"))

error output:

Code: Select all

>>> 
>>> import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName("femtest.testcmdproblem.TestCmdProblem.test_cmdproblem"))

>>> import TestCmdProblem 
(<Part::PartFeature>, ('Face1',))
  ReferenceShape ... Type: Face, Object name: Box, Object label: Box, Element name: Face1
<Face object at 0x55615290c8c0>
<class 'Part.Face'>
Face
E
======================================================================
ERROR: test_cmdproblem (femtest.testcmdproblem.TestCmdProblem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femtest/testcmdproblem.py", line 65, in test_cmdproblem
    getnodes(femmesh, ref)
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Fem/femmesh/meshtools.py", line 114, in get_femnodes_by_refshape
    nodes += femmesh.getNodesByFace(r)
TypeError: argument 1 must be Part.TopoShape, not Part.Face

----------------------------------------------------------------------
Ran 1 test in 0.008s

FAILED (errors=1)
<unittest.runner.TextTestResult run=1 errors=1 failures=0>
>>> >>> 


on (copied from FreeCAD Gui) but same build:

OS: Debian GNU/Linux 10 (buster) (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16810 (Git)
Build type: Unknown
Branch: master
Hash: fc37053210d2abc058c6e14b06d7b8e28aeee8ea
Python version: 3.7.3rc1
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Switzerland (de_CH)
Post Reply