Test request: OpenFOAM solver for FemWorkbench

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

qingfeng.xia
Posts: 153
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Postby qingfeng.xia » Fri Sep 09, 2016 8:56 am

bernd wrote:
qingfeng.xia wrote: 1. Do you means create a CFD workbench? , that sounds challenging to me, I am not sure how to create Gui/Resource part, maybe I leave the icon still in Fem module (not sure as we did not specify icon path, but icon name),

2. then CMakeLists.txt, Init.py and InitGui.py should be make a pure python module?
You could start the new workbench not in FreeCAD src but in your ./FreeCAD Mod directory in your home directory.With this you need just a few files to start. See https://github.com/berndhahnebach/FreeC ... aster/MyWB for my simple template for a new workbench in Mod directory of your ./FreeCAD folder in your home directory. It has just two simple tools. With this there is no Cmake needed, because no installation is needed.
Later if you would like to go for a PullRequest to integrate it in FreeCAD source you could add the Cmake stuff.

qingfeng.xia wrote:3 . If I need the post-processing and creat-meshing command, can I just import from "_CommandFemMesh.py" or I must copy into new module?
You can use any module and any object from any module in any other module. It just need to be available and of couse you need to import the module.

qingfeng.xia wrote:4. I think I need a SelectionObserver python class.
I have one small just for FEM you could import it. Arch has an own python selection observer class. Assambly2 has one too.

qingfeng.xia wrote:5. To add new command MenuItem/ToolbarItem to workbench, I need to add into Fem/Gui/Workbench.cpp. Is that possible to add into InitGui.py now? Or I should make Cfd/Gui/ cpp files.
Yes you could just add it to InitGui.py See my small template.

There are dozens of modules around which are installed in your user Mod. You could have a look at the code if you need something. One of the best is lattice2. I truelly can recomend installing it.

bernd
Thanks very much, it is a promising tutorial, I will try this weekend and let you know. Thanks Qingfeng
Ubuntu LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
User avatar
bernd
Posts: 7051
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Test request: OpenFOAM solver for FemWorkbench

Postby bernd » Fri Sep 09, 2016 9:16 am

qingfeng.xia wrote:Thanks very much, it is a promising tutorial, I will try this weekend and let you know. Thanks Qingfeng
If there are questions just drop a message. In an own module you are free with naming, code style whatever and since you are the first one you can name it CFD :)
makkemal
Posts: 380
Joined: Wed Apr 29, 2015 12:41 pm

Re: Test request: OpenFOAM solver for FemWorkbench

Postby makkemal » Mon Sep 12, 2016 11:50 am

I have run a number of tests on this which worked
This is going to be the start of a something new
I also think this will fit into its own workbench.
I just needs a few more things to work from start to finish inside freecad

Great contribution :D thanks
johan
Posts: 14
Joined: Tue Nov 29, 2016 8:37 pm

Re: Test request: OpenFOAM solver for FemWorkbench

Postby johan » Wed Nov 30, 2016 11:47 am

I started playing with the CFD WB and it is a great initiative.

I decided to try and setup the lid driven cavity problem and I seem to have some trouble with the unv mesh that FreeCAD creates. After setting up the case, I tried to write the case input, but ideasUnvToFoam complains about

Code: Select all

For group 1 named wall trying to read 0 patch face indices.
and when I looked at the TestCase.unv file I could see that no patch faces are written to the boundaries.
1 0 0 0 0 0 0 0
wall
2 0 0 0 0 0 0 0
slip
3 0 0 0 0 0 0 0
movingWall
Secondly, is it possible to change the direction of the uniformVelocity BC. I tried playing with the "Direction" input option, but I kept running into "Invalid syntax" errors.
User avatar
bernd
Posts: 7051
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Test request: OpenFOAM solver for FemWorkbench

Postby bernd » Thu Dec 01, 2016 6:05 am

johan wrote:I started playing with the CFD WB and it is a great initiative.

I decided to try and setup the lid driven cavity problem and I seem to have some trouble with the unv mesh that FreeCAD creates. After setting up the case, I tried to write the case input, but ideasUnvToFoam complains about

Code: Select all

For group 1 named wall trying to read 0 patch face indices.
and when I looked at the TestCase.unv file I could see that no patch faces are written to the boundaries.
1 0 0 0 0 0 0 0
wall
2 0 0 0 0 0 0 0
slip
3 0 0 0 0 0 0 0
movingWall
What exact are you missing, Are you missing group data in your unv file?
johan wrote:Secondly, is it possible to change the direction of the uniformVelocity BC. I tried playing with the "Direction" input option, but I kept running into "Invalid syntax" errors.
Do you mean constraint Self weight? AFAIK at the moment it is only implemented in CalculiX input writer. The direction and velocity are hard coded there. It goes in z-direction and the velocity is 9.81 kgM/s^2 . Check https://github.com/FreeCAD/FreeCAD/blob ... cx.py#L749
johan
Posts: 14
Joined: Tue Nov 29, 2016 8:37 pm

Re: Test request: OpenFOAM solver for FemWorkbench

Postby johan » Thu Dec 01, 2016 9:54 am

With regards to the unv file, it seems like the mesh.obj for some reason does not store the faces of the boundaries (https://github.com/qingfengxia/Cfd/blob ... fdTools.py), resulting in the zero entries when writing the boundary faces. I need to, however, check that I did not somewhere make a rookie mistake in the setup.

I was actually referring to the "Direction" of the ConstraintFluidBoundary and not the gravitational acceleration (g = 9.81 m/s^2) in the self weight constraint. Coming from a flow background, I thought the direction should be specified instead of derived from a geometric entity by selecting an edge or a face. At the moment the ConstraintFluidBoundary allows one to only select faces (not edges as with force constraints in FEM), because for flow problems BCs should only be applied to faces. It might be useful to have the option to select edges when specifying "Direction".
User avatar
bernd
Posts: 7051
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Test request: OpenFOAM solver for FemWorkbench

Postby bernd » Thu Dec 01, 2016 12:24 pm

Ahh than both problems seam related to qingfengs code. You may get in contact with him directly. He writes at the forum rarely.
bernd
johan
Posts: 14
Joined: Tue Nov 29, 2016 8:37 pm

Re: Test request: OpenFOAM solver for FemWorkbench

Postby johan » Thu Dec 01, 2016 12:34 pm

Thanks, I will contact qingfengs directly about the CFD workbench. I did have some trouble getting netgen to build in fedora and I am hoping there is not something that I missed that is causing the problems with my mesh object.
johan
Posts: 14
Joined: Tue Nov 29, 2016 8:37 pm

Re: Test request: OpenFOAM solver for FemWorkbench

Postby johan » Fri Dec 23, 2016 10:11 am

We added a couple of extensions to Qingfeng's CFD WB

https://github.com/jaheyns/FreeCAD.git

and it would it would be great to hear what you think. I have also attached the case set up that reproduce the elbow tutorial from OpenFOAM.

It is now possible to run the solver from the workbench. The view results option is still not working and one has to activate the "CfdAnalysis" (which still shows the FEM WB options) before you could setup the fluid case under "OpenFOAM".
Attachments
elbow.fcstd
(582.25 KiB) Downloaded 29 times
makkemal
Posts: 380
Joined: Wed Apr 29, 2015 12:41 pm

Re: Test request: OpenFOAM solver for FemWorkbench

Postby makkemal » Fri Dec 23, 2016 2:16 pm

What needs to be installed .
mine does not do anything further that this

Code: Select all

0.0: Check dependencies...
0.0: case writer is called

Code: Select all

makke@ubuntu:~/FreeCAD_comp$ foamVersion 
OpenFOAM-4.1

Code: Select all

pip install pyfoam
Requirement already satisfied: pyfoam in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: numpy in /usr/lib/python2.7/dist-packages (from pyfoam)

Code: Select all

OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9344 +13 (Git)
Build type: Unknown
Branch: CFD
Hash: 5e9900ee4be99e2339c0cd3a81bf9c5365bfe1e2
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17