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: 4
Joined: Wed May 01, 2019 8:30 am

parametric pipeline between freecad and openfoam

Post by remcat » 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.

User avatar
oliveroxtoby
Posts: 281
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: parametric pipeline between freecad and openfoam

Post by oliveroxtoby » Sat May 04, 2019 9:43 pm

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.

remcat
Posts: 4
Joined: Wed May 01, 2019 8:30 am

Re: parametric pipeline between freecad and openfoam

Post by remcat » 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?

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: 281
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: parametric pipeline between freecad and openfoam

Post by oliveroxtoby » Tue May 07, 2019 8:30 pm

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.

remcat
Posts: 4
Joined: Wed May 01, 2019 8:30 am

Re: parametric pipeline between freecad and openfoam

Post by remcat » Tue May 14, 2019 7:08 pm

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: 4
Joined: Wed May 01, 2019 8:30 am

Re: parametric pipeline between freecad and openfoam

Post by remcat » 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

thschrader
Posts: 1403
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: parametric pipeline between freecad and openfoam

Post by thschrader » Thu May 16, 2019 6:50 pm

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

Post Reply