parametric pipeline between freecad and openfoam

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

Post Reply
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

parametric pipeline between freecad and openfoam

Post by remcat »

Hello all,

I am using the openfoam cfd workbench embedded in freecad. It’s working fine. Is there a way to achieve a parametric study, by varying a geometrical parameter (such as a distance or a pipe diameter) and makes the calculus automatically running during night?
At the end, the aim is to plot a given simulated parameter (such as U velocity or presure) versus the geometric variable to optimised the design.
Thx for help,
Remy

ps: i can give any help/advices/traduction for the forum in french if required.
User avatar
oliveroxtoby
Posts: 837
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: parametric pipeline between freecad and openfoam

Post by oliveroxtoby »

remcat wrote: Wed May 01, 2019 8:41 am Hello all,

I am using the openfoam cfd workbench embedded in freecad. It’s working fine. Is there a way to achieve a parametric study, by varying a geometrical parameter (such as a distance or a pipe diameter) and makes the calculus automatically running during night?
At the end, the aim is to plot a given simulated parameter (such as U velocity or presure) versus the geometric variable to optimised the design.
Thx for help,
Remy

ps: i can give any help/advices/traduction for the forum in french if required.
Yes. Thanks to FreeCAD's python scripting capabilities, this is a strength. Whenever you make an edit, you will see code emitted in the Python console, and this can be saved as a macro for replaying later. Editing and adding an appropriate loop to this script should allow you to batch-generate the cases you need for the study.

Note that at present, CfdOF doesn't output the code to actually run the mesh generator or solver. You would need script it to output to a sequence of different output directories, and then you can loop the runs overnight from the shell.

Please update the workbench first as I have added code emission for writing the cases which was missing.
Please provide all the information requested in this post before reporting problems with CfdOF.
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Re: parametric pipeline between freecad and openfoam

Post by remcat »

Hi Oliveroxtoy,

Thanks for your answer!
I am not a specialist in python scripting, but, i understand the basis. I recorded a macro: first, i modify a parameter (say a diameter), then i add cfdof analysis, modify physics and so on. You are right, the mesh and solver generator does not output the code.

>>You would need script it to output to a sequence of different output directories.
what do you mean?

I am going to update first the workbench this evening and i will reply on thursday (tomorrow its national holiday in France :P )
++Remy
User avatar
oliveroxtoby
Posts: 837
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: parametric pipeline between freecad and openfoam

Post by oliveroxtoby »

remcat wrote: Tue May 07, 2019 9:12 am Hi Oliveroxtoy,

Thanks for your answer!
I am not a specialist in python scripting, but, i understand the basis. I recorded a macro: first, i modify a parameter (say a diameter), then i add cfdof analysis, modify physics and so on. You are right, the mesh and solver generator does not output the code.

>>You would need script it to output to a sequence of different output directories.
what do you mean?
If you are going to generate a batch of cases, you will need to output them to separate directories. You can set the this by editing the relevant property of the mesh and solver objects (and see the python code generated).

Having done that you can then make a shell script to loop over all these mesh directories running the generated Allmesh script in each one, and to loop over all the solver directories and run the Allrun script in each.
Please provide all the information requested in this post before reporting problems with CfdOF.
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Re: parametric pipeline between freecad and openfoam

Post by remcat »

Hello Oliver (think your first name?),

I am still working on the subject: here are some basics infos. The timers in the meshtab and solvertab do not work anymore since you modified the meshtab.
Also, i started to be familliar with the different folders, and the allrun.sh that is executed using the bash command. I saw that simpleFoam solver is executed from this shell file.
I also observed that if i changed the physics to compressible flow, the allrun file still runs the simpleFoam solver. I would expect that the rhosimpleFoam should be used?

I am not familliar with openfoam (rather solidworks+comsol) but i started to learm using youtube tutorials. In my opinion, the main advantage of having such cfdof tool embedded in freecad is in the fact that you can optimise the design in real time using variables. Such communication solution already exists between solid and comsol, but i find it a little bit useless (difficult to use). Having such solution directly embedded in the same open soft, i.e. freecad would be a very good and attractive idea.

Cheers,
Remy
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Re: parametric pipeline between freecad and openfoam

Post by remcat »

Ok, the compressible case is still not supported in the current version. :roll: I understood my mistake.
++remy
thschrader
Veteran
Posts: 3154
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: parametric pipeline between freecad and openfoam

Post by thschrader »

remcat wrote: Wed May 15, 2019 3:39 pm Ok, the compressible case is still not supported in the current version. :roll: I understood my mistake.
++remy
Try to use the HISA solver at windspeed lower mach 0,2.
This is windspeed on buildings.
Report your results. Here.
Greetings Thomas

EDIT 18.05.2019:
Here is an example using HISA-solver at low mach windspeed.
https://forum.freecadweb.org/viewtopic. ... 1&start=20
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: parametric pipeline between freecad and openfoam

Post by qingfeng.xia »

remcat wrote: Wed May 01, 2019 8:41 am Hello all,

I am using the openfoam cfd workbench embedded in freecad. It’s working fine. Is there a way to achieve a parametric study, by varying a geometrical parameter (such as a distance or a pipe diameter) and makes the calculus automatically running during night?
At the end, the aim is to plot a given simulated parameter (such as U velocity or presure) versus the geometric variable to optimised the design.
Thx for help,
Remy

ps: i can give any help/advices/traduction for the forum in french if required.

parametric study is definitely one of the goal of FreeCAD+FEM/CFD.
you can record python script in FreeCAD, then change all boundary setup (face selected from GUI by a python function to locate the face)

here is my example
https://github.com/qingfengxia/CAE_pipeline
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
Post Reply