update on FreeCAD + OpenFOAM fluid dynamic computation

About the development of the FEM module/workbench.
HoWil
Posts: 386
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby HoWil » Thu Feb 25, 2016 7:20 pm

Hallo,

would love to see a FreeCAD interface for OpenFOAM!!!
For all how do not know what to do with OpenFOAM here some examples where FreeCAD was already used to draw the geometry:
https://www.youtube.com/watch?v=uV84p_GTUPU
https://www.youtube.com/watch?v=KeEp6EJuIxU

and a more OpenFOAM specific introduction
https://www.youtube.com/watch?v=Kznljrg ... Du3yUq7YoT

There are also other solvers such as one for electromagnetics. This would extend the FEM simulation range for FreeCAD dramatically.
http://www.openfoam.org/features/standard-solvers.php

There is also a nice python-interface to control and manipulate OpenFoam pyfoam: https://openfoamwiki.net/index.php/Contrib/PyFoam

Please let me know if there is something to beta-test for standard FreeCAD users.

Thanks in advance,
HoWil
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby qingfeng.xia » Sun Apr 17, 2016 2:55 pm

OpenFOAM for FreeCAD finishes stage II development (2016-04-17)

This is an early preview, only for people with experience of OpenFoam.

Test instruction could be found at
https://github.com/qingfengxia/FreeCAD/tree/foambuilder_pre2/src/Mod/Fem/FoamCaseBuilder/Readme.md

I would love to see some feedback for stage III development, see roadmap:
https://github.com/qingfengxia/FreeCAD/tree/foambuilder_pre2/src/Mod/Fem/FoamCaseBuilder/Readme_roadmap.md

A video preview of OpenFoam plugin for FreeCAD Fem workbench
http://www.iesensor.com/FreeCADDoc/oepnfoam_for_freecad_qingfengXIA.mp4

The code will attempt to merge with master for version 0.17 after review. However, the OpenFoam related code is independent from CalculiX, except for the Material class. I plan to developed a general FemMaterial model (not yet finished), ultimately for multiphysics modeling in FreeCAD. Rebase to master will be easier than before.
Ubuntu 0.17-dev OpenFOAM + FreeCAD
HoWil
Posts: 386
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby HoWil » Sun Apr 24, 2016 11:53 am

Hallo qingfeng.xia,
I will test your work in the next days.
The video looks very promising.
How much work will it be to use other openfoam-solvers like the one listed here https://openfoamwiki.net/index.php/Main_ContribSolvers ?
BR,
HoWil
HoWil
Posts: 386
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby HoWil » Sun Apr 24, 2016 3:31 pm

Hello,

I managed to compile the latest build on a ubuntu 16.04.

Unfortunately Freecad crashes when I try to reproduce the simulation in your video.
It crashes when I try to assign the fluid boundary condition. I get the following messages in the terminal (see below).
I also noticed that all elements of the simulation (mesh, material,..) in the model-tree-view are not grouped. I grouped it manually.
I can create a MechanicalAnalysis (where all elements a grouped) but it seams that the results can not be loaded into Freecad after running calculix. I saved this model and opened it in my local Freecad 0.16 and could run the simulation without problems.

Do you have any clue why the open-foam version crashes while the calculix version does not?

    user@cupboard:~/Downloads/FreecadOF/FreeCAD/bin$ ./FreeCAD
    FreeCAD 0.16, Libs: 0.16R6308 (Git)
    © Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2015
    ##### #### ### ####
    # # # # # #
    # ## #### #### # # # # #
    #### # # # # # # # ##### # #
    # # #### #### # # # # #
    # # # # # # # # # ## ## ##
    # # #### #### ### # # #### ## ## ##

    Attach observer 0x1586590
    Attach observer 0x13f3bb0
    Attach observer 0x13e0a70
    Attach observer 0x13b7598
    Attach observer 0x1439438
    Attach observer 0x1439438
    Attach observer 0x1444170
    Mod pluginloader InitGui.py starting ...
    Could not parse stylesheet of widget 0x21ded00
    During initialization the error No module named yaml occurred in /home/user/.FreeCAD/Mod/freecad-pluginloader-localdirs/InitGui.py
    Attach observer 0x158c268
    Attach observer 0x120aed0
    Solver OpenFOAM is created
    Running the Python command 'Fem_NewCfdAnalysis' failed:
    Traceback (most recent call last):
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeAnalysis.py", line 184, in Activated
    _CreateCaeAnalysis('OpenFOAM')
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeAnalysis.py", line 147, in _CreateCaeAnalysis
    FreeCADGui.doCommand("CaeAnalysis.makeCaeSolver('{}')".format(solverName))
    File "<string>", line 1, in <module>
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeSolver.py", line 57, in makeCaeSolver
    obj = _createCaeSolver(solverInfo, analysis)
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeSolver.py", line 83, in _createCaeSolver
    mod = importlib.import_module(solverInfo["Module"])
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/FoamCfdSolver.py", line 35, in <module>
    from FoamCaseBuilder import supported_turbulence_models

    No module named FoamCaseBuildersh: 1: SMDS_MemoryLimit: not found
    Running the Python command 'Fem_NewMaterial' failed:
    Traceback (most recent call last):
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeAnalysis.py", line 205, in Activated
    FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)")
    File "<string>", line 1, in <module>

    No such object found in document: ''Object::connect: No such slot FemGui::TaskFemFluidBoundary::onBoundaryValueChanged(double) in /home/user/Downloads/FreecadOF/FreeCAD/src/Mod/Fem/Gui/TaskFemFluidBoundary.cpp:137
    Object::connect: (sender name: 'spinBoundaryValue')
    *** Abort *** an exception was raised, but no catch was found.
    ... The exception is:SIGSEGV 'segmentation violation' detected. Address 18
    user@cupboard:~/Downloads/FreecadOF/FreeCAD/bin$
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby qingfeng.xia » Fri May 13, 2016 12:32 pm

HoWil wrote:Hello,

I managed to compile the latest build on a ubuntu 16.04.

Unfortunately Freecad crashes when I try to reproduce the simulation in your video.
It crashes when I try to assign the fluid boundary condition. I get the following messages in the terminal (see below).
I also noticed that all elements of the simulation (mesh, material,..) in the model-tree-view are not grouped. I grouped it manually.
I can create a MechanicalAnalysis (where all elements a grouped) but it seams that the results can not be loaded into Freecad after running calculix. I saved this model and opened it in my local Freecad 0.16 and could run the simulation without problems.

Do you have any clue why the open-foam version crashes while the calculix version does not?

    user@cupboard:~/Downloads/FreecadOF/FreeCAD/bin$ ./FreeCAD
    FreeCAD 0.16, Libs: 0.16R6308 (Git)
    © Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2015
    ##### #### ### ####
    # # # # # #
    # ## #### #### # # # # #
    #### # # # # # # # ##### # #
    # # #### #### # # # # #
    # # # # # # # # # ## ## ##
    # # #### #### ### # # #### ## ## ##

    Attach observer 0x1586590
    Attach observer 0x13f3bb0
    Attach observer 0x13e0a70
    Attach observer 0x13b7598
    Attach observer 0x1439438
    Attach observer 0x1439438
    Attach observer 0x1444170
    Mod pluginloader InitGui.py starting ...
    Could not parse stylesheet of widget 0x21ded00
    During initialization the error No module named yaml occurred in /home/user/.FreeCAD/Mod/freecad-pluginloader-localdirs/InitGui.py
    Attach observer 0x158c268
    Attach observer 0x120aed0
    Solver OpenFOAM is created
    Running the Python command 'Fem_NewCfdAnalysis' failed:
    Traceback (most recent call last):
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeAnalysis.py", line 184, in Activated
    _CreateCaeAnalysis('OpenFOAM')
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeAnalysis.py", line 147, in _CreateCaeAnalysis
    FreeCADGui.doCommand("CaeAnalysis.makeCaeSolver('{}')".format(solverName))
    File "<string>", line 1, in <module>
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeSolver.py", line 57, in makeCaeSolver
    obj = _createCaeSolver(solverInfo, analysis)
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeSolver.py", line 83, in _createCaeSolver
    mod = importlib.import_module(solverInfo["Module"])
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/FoamCfdSolver.py", line 35, in <module>
    from FoamCaseBuilder import supported_turbulence_models

    No module named FoamCaseBuildersh: 1: SMDS_MemoryLimit: not found
    Running the Python command 'Fem_NewMaterial' failed:
    Traceback (most recent call last):
    File "/home/user/Downloads/FreecadOF/FreeCAD/Mod/Fem/CaeAnalysis.py", line 205, in Activated
    FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)")
    File "<string>", line 1, in <module>

    No such object found in document: ''Object::connect: No such slot FemGui::TaskFemFluidBoundary::onBoundaryValueChanged(double) in /home/user/Downloads/FreecadOF/FreeCAD/src/Mod/Fem/Gui/TaskFemFluidBoundary.cpp:137
    Object::connect: (sender name: 'spinBoundaryValue')
    *** Abort *** an exception was raised, but no catch was found.
    ... The exception is:SIGSEGV 'segmentation violation' detected. Address 18
    user@cupboard:~/Downloads/FreecadOF/FreeCAD/bin$



Thanks very much for testing. I think you can check if FemGui/FoamCaseBuilder, this folder has been copied into your FreeCAD FemGui binary dir.
It seems the FoamCaseBuilder as a python module is not accessible to Python. For quick test, I make a symlink to this FoamCaseBuilder folder to the FreeCAD/build/ (which I did not install to system wide, but test in build dir)

For C++ code sigsegv, I am not sure. I recently upgrade my ubuntu t0 16.04 will test it this weekend.
Ubuntu 0.17-dev OpenFOAM + FreeCAD
User avatar
bernd
Posts: 3877
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby bernd » Tue May 17, 2016 5:55 am

@quingfeng:
All CalculiX related code was spitted from FEM base code in FreeCAD master. Means adding a new solver is possible only by adding code without changing lots of code. See as an example the z88 solver.

https://github.com/FreeCAD/FreeCAD/comm ... 8a42058a3f


EDIT:
viewtopic.php?f=18&t=15568&p=125377#p125377
m42kus
Posts: 24
Joined: Tue Sep 02, 2014 9:41 am

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby m42kus » Fri May 20, 2016 12:09 pm

Hi, I just compiled foambuilder_pre2 on ArchLinux. The TestCase from the video works without Problems. To execute FreeCAD from the build folder (in source build) i had to execute FreeCAD like so:

Code: Select all

bin/FreeCAD --python-path=src/Mod/Fem/

That should resolve the problem mentioned by HoWil.
makkemal
Posts: 320
Joined: Wed Apr 29, 2015 12:41 pm

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby makkemal » Tue Jul 19, 2016 5:51 pm

Why are you guys so quiet, I am looking forward to the first release of this ;)
User avatar
Kunda1
Posts: 640
Joined: Thu Jan 05, 2017 9:03 pm

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby Kunda1 » Sat Feb 18, 2017 9:40 pm

Linking this thread to issue #2459
User avatar
saso
Posts: 614
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby saso » Sun Mar 19, 2017 2:25 pm

Just a few links that can be interesting, specially for architecture...

https://www.youtube.com/watch?v=7ZF8QcMekoA
https://github.com/ladybug-tools/
http://www.ladybug.tools/