FreeCAD does many amaz­ing things, allows us to cre­ate all kinds of geome­tries and assem­blies, but we can also use FreeCAD for analy­sis of the things we make. One fas­ci­nat­ing approach is Com­pu­ta­tion­al Flu­id Dynam­ics or CFD.

CFD is essen­tial­ly a tool to show how flu­ids inter­act with objects. You could mod­el and assess water flow­ing through a pipe, or a boat in the sea, or for fly­ing objects, air­flow over a part and much more. Of course CFD can also help analyse and per­form com­plex cal­cu­la­tions on data so it’s not uncom­mon to use CFD to work out the drag coef­fi­cient of an object or it’s cen­tre of pres­sure and much more.

It’s fair to say CFD is a com­plex area and one that the author is only just begin­ning to scratch the sur­face of. There­fore this arti­cle isn’t a tuto­r­i­al on CFD direct­ly, rather we’ll look at installing the Cfd­OF work­bench which requires the instal­la­tion of some oth­er tools on your sys­tem, and then point at some use­ful tuto­ri­als online for you to begin your CFD learning.

The Cfd­OF work­bench pro­vides an inter­face for numer­ous oth­er open­source soft­ware’s which com­bine to com­plete the CFD process. These include some mesh­ing tools. CFD is com­mon­ly per­formed on meshed objects with the tar­get object placed in a con­tain­ing geo­met­ric space, a large cuboid or cylin­der per­haps. A good anal­o­gy is the con­tain­ing space is like a vir­tu­al wind tun­nel, although you aren’t lim­it­ed to just air! The whole envi­ron­ment gets turned into a mesh and often with­in the mesh var­i­ous dif­fer­ent mesh set­tings are used (called mesh refine­ments) so that ulti­mate­ly you get more detail around the sur­face of the test object. There­fore mesh­ing is impor­tant and there are numer­ous mesh pack­ages for dif­fer­ing mesh­ing approach­es built in to a suc­cess­ful Cfd­OF work­bench install.

Anoth­er com­po­nent piece of open­source soft­ware used by the Cfd­OF work­bench is Open­FOAM. Open­FOAM is the very heart of CFD oper­a­tions and is a com­plex piece of soft­ware that can per­form a wide range of com­plex flu­id flows. It’s not just capa­ble in terms of things we might obvi­ous­ly think of as com­pu­ta­tion­al flu­id dynam­ics, such as water/gases/air but can also solve prob­lems involv­ing chem­i­cal reac­tions, heat, mag­net­ic fields and more. It’s an incred­i­bly ver­sa­tile and com­plex bit of kit that gets used, often stand alone, in all man­ner of sci­en­tif­ic and aca­d­e­m­ic environments.

Final­ly there is also a piece of soft­ware called Par­aview. Par­aview is a post proces­sor that, in the case of the CdfOF work­bench, can allow you to visu­alise and analyse case data cre­at­ed with Open­FOAM. It has huge depth and com­plex­i­ty and can per­form and cre­ate all man­ner of visu­al­i­sa­tion as well as per­form­ing cal­cu­la­tions to aid fur­ther analy­sis of your models.

So we need to get all these com­po­nents installed and con­fig­ured. One advan­tage of the CdfOF is that it auto­mates some of the set­up for us using dock­er and a dock­er image. In the FreeCAD doc­u­men­ta­tion there’s instruc­tions for installing CdfOF on Win­dows and Lin­ux (also Mac but sup­port there is vari­able), also it’s worth read­ing the notes on the Cfd­OF work­bench repos­i­to­ry which are also includ­ed in the Addon man­ag­er list­ing. We opt­ed to install CdfOF on a machine run­ning stock Debian 12, run­ning the X11 win­dow­ing sys­tem, and we installed it with the FreeCAD ver­sion 1.0 app image. 

To begin, open the FreeCAD app image (if it’s the first time you might need to right click on the app image file, select prop­er­ties and then under the per­mis­sions tab you might need to tick the is exe­cutable box).

Once FreeCAD has opened, install the Cfd­OF work­bench in the usu­al way. Click tools-addon man­ag­er and then select and install the Cfd­OF work­bench. Once the Cfd­OF work­bench is installed and you’ve restart­ed FreeCAD, you can then click edit – pref­er­ences and you should see a Cfd­OF tab appear in the pref­er­ences dia­logue. Select the Cfd­OF tab. You will see that it has numer­ous input box­es into which you can set paths to the direc­to­ries where the var­i­ous oth­er pieces of soft­ware are installed. If you leave these blank then Cfd­OF work­bench will use the default most com­mon loca­tions for the install loca­tions which worked per­fect­ly for us. So on our Debian 12 machine we used a the ter­mi­nal appli­ca­tion to first run an update to update all pack­ages with

sudo apt update

we then ran;

sudo apt-get install openfoam

and after Open­FOAM had installed we ran;

sudo apt-get install paraview

to install Paraview.

For the rest of the set­up we need­ed to install dock­er. In the Cfd­OF FreeCAD doc­u­men­ta­tion page there is a link sup­plied to a guide to installing up to date dock­er on Debian so we sim­ply fol­lowed these steps. https://www.linuxtechi.com/install-docker-engine-on-debian/

One thing that slight­ly tripped us up was that not only do we need to add our user­name to the dialout group, but we also need to log out and log back in to our com­put­er hav­ing done so! Again in a ter­mi­nal we used;

sudo usermod -aG dialout “YOURUSERNAMEHERE” 

and then (after hav­ing some prob­lems we even­tu­al­ly remem­bered to) re login to the com­put­er. Now with dock­er installed and Open­FOAM and Par­aview installed we can fire up the FreeCAD app image, move back to the Cfd­OF pref­er­ences tab and then click the Install Dock­er Image but­ton. Anoth­er quick tip is that it can be use­ful to have the report view pan­el open in FreeCAD at this point so you can see mes­sages relat­ing to the dock­er con­tain­er and any poten­tial prob­lems . To open that pan­el you can click view – pan­els and then check the Report view box. There is also a small report win­dow if you scroll to the bot­tom of the Cfd­OF pref­er­ences tab which yields use­ful infor­ma­tion about the install process. Even­tu­al­ly you should be reward­ed with a com­ple­tion mes­sage indi­cat­ing the dock­er image down­load has been successful.

Final­ly before div­ing head­long into your CFD career it’s worth click­ing the Run depen­den­cy check­er but­ton in the Cfd­OF pref­er­ences dia­logue. This should hope­ful­ly report that every­thing is installed correctly.

If you are new at CFD then be pre­pared for quite a lot of learn­ing to even get any tan­gi­ble out­put! How­ev­er, there are heaps of guides and tuto­ri­als out there to help you along the way. Whilst we’d urge you to look around, the first tuto­r­i­al we worked through was this Youtube tuto­r­i­al walk­ing through set­ting up an analy­sis of water in a broad­ly L shaped square sided tube. It def­i­nite­ly intro­duced the gen­er­al process and order of dif­fer­ent oper­a­tions. This is the first video in a long series of tuto­ri­als com­piled into a playlist. Jump­ing to episode 6 in the same series the tuto­r­i­al cov­ers flow­ing air over a car design which was very use­ful for the authors par­tic­u­lar areas of inter­est. After a cou­ple of evening from zero knowl­edge of CFD the author got to the point of cre­at­ing a crude analy­sis of a Bal­lute para­chute design with 6 m/s air­flow over it. Whilst the author is con­tin­u­ous­ly dis­cov­er­ing errors in approach and dis­cov­er­ing bet­ter ways to mesh and sim­u­late, it does show that you can begin this jour­ney with very lit­tle under­ly­ing knowledge!

Final­ly, the Cfd­OF work­bench has an excel­lent devot­ed sec­tion on the FreeCAD forum. It’s def­i­nite­ly worth read­ing through as many posts there as you can as it’s a great source of valu­able infor­ma­tion by oth­er peo­ple on the CFD path!



Discover more from FreeCAD News

Subscribe to get the latest posts sent to your email.

4 responses to “Tutorial: Installing CfdOF WB to begin exploring Computational Fluid Dynamics”

  1. John Dormer Avatar
    John Dormer

    You would only have had to log out and back in for your shell to get the updat­ed group information.

    Win­dows has cursed us all with its inces­sant restart require­ments. Lin­ux only has a few things where a restart is an actu­al necessity.

    1. Jo Hinchliffe Avatar
      Jo Hinchliffe

      Ah yes, you are absolute­ly spot on there and I sort of did know that but did­n’t remem­ber it! I will update the text. Thanks. Jo

  2. fai Avatar
    fai

    Can some­one write a very basic tuto­r­i­al on how to use the FEM work­bench? Maybe throw in a lit­tle back­ground on the basics of what is FEM. I am design­ing a basic clip to 3D print and I am not sure how thick should I print and how much stress on the clip as it open wider. I just thought maybe know­ing some FEM and pos­si­bly use of the FEM work­bench might help. To be hon­est, I did not check if such a tuto­r­i­al is already avail­able. Is there a FreeCAD page that list all the text and video tuto­ri­als out there ?

    1. Jo Hinchliffe Avatar
      Jo Hinchliffe

      I think a basic set­ting up FEM would make a great tuto­r­i­al and I’ll put it on my list for tuto­ri­als to write here. Re videos… there are so many videos across so many plat­forms I’m not sure it’s pos­si­ble to keep a list and the list might be so big it’s unus­able! A good place to check out for lots of FEM tips is it has a com­plete sec­tion on the FreeCAD forum here https://forum.freecad.org/viewforum.php?f=18&sid=613cc71f8d185558d2ba5f2adaaf9ca0

Discover more from FreeCAD News

Subscribe now to keep reading and get access to the full archive.

Continue reading