update on FreeCAD + OpenFOAM fluid dynamic computation

A subforum specific to the development of the OpenFoam-based workbenches ( Cfd https://github.com/qingfengxia/Cfd and CfdOF https://github.com/jaheyns/CfdOF )

Moderator: oliveroxtoby

HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by HoWil »

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: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by qingfeng.xia »

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/ ... /Readme.md

I would love to see some feedback for stage III development, see roadmap:
https://github.com/qingfengxia/FreeCAD/ ... roadmap.md

A video preview of OpenFoam plugin for FreeCAD Fem workbench
http://www.iesensor.com/FreeCADDoc/oepn ... engXIA.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 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by HoWil »

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
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by HoWil »

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: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by qingfeng.xia »

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 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by bernd »

@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: 159
Joined: Tue Sep 02, 2014 9:41 am

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by m42kus »

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.
My GSoC Devlog: ceeli.github.io/gsoc
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by makkemal »

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

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by Kunda1 »

Linking this thread to issue #2459
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by saso »

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/
Post Reply