Compiling FreeCAD for FEM in Mac OS

I always like to take the latest FreeCAD version to check out new features that are coming along.

Since I use a Mac operating system things aren’t the same as using a Windows or Linux system.

Some software is useful to have already installed to help in the compiling process:

Latest python, Xcode and homebrew should be installed.

Then in a terminal window type:

brew tap homebrew/science
brew tap freecad/freecad
brew install eigen
brew install --only-dependencies freecad --with-packaging-utils

(Repeat again the same instruction it seems that not everything is installed at first run)

brew install --only-dependencies freecad --with-packaging-utils
brew install gmsh --with-opencascade
Brew install netgen
brew install homebrew/science/nglib --with-opencascade

Dependencies X-Code:

xcode-select --install

After setting up all the necessary content it’s time to compile!

The source and build folders are created side-by-side under username. This will change from system to system (it’s your home folder name)

Create a folder named FreeCAD

mkdir ~/FreeCAD
cd ~/FreeCAD

You will get the following folder configuration:

/Users/username/FreeCAD

The following command will clone the FreeCAD git repository into a directory called FreeCAD-git.

git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git

Go back

cd ..

Create the build folder.

mkdir ~/FreeCAD/build
cd build

Now we need to configure (this part can change with time depending of path locations and versions):

cmake \
-DCMAKE_BUILD_TYPE="Release" \
-DBUILD_QT5=1 \
-DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" \
-DFREECAD_USE_EXTERNAL_KDL=1 \
-DBUILD_FEM_NETGEN=1 \
-DFREECAD_CREATE_MAC_APP=1 \
-DCMAKE_INSTALL_PREFIX="./.." \
-OCC_INCLUDE_DIR="/usr/local/Cellar/opencascade/7.1.0_1/include/opencascade/" \
../FreeCAD-git/

Compiling: use -j and a number (for 4 cores I use 4 + 1)

make -j5 install

An illustration of the FEM study process

Good comercial packages integrate conveniently all steps required to get results with minimum effort. As I have been demonstrating on previous posts, since open source softwares grew up each in their single box, with specific intents at their time, integration never was a primary concern, however as they matured, naturally, synergies start to take place and each project starts to fit together to supply the integrated platform that everyone is urging for. 2017 will be a year that will bring two interesting versions os software that integrate it all, FreeCAD 0.17 and Salome-Meca 2017.

Simulation Process Steps
Simulation Process Steps

Calculix interoperability

I talked a lot about Pre processors FreeCAD and Salome, in some cases the pre processor environment is more and offers the complete modelling package including a solver as in the case of FreeCAD. Calculix is the tool that will pick up a meshed model with boundary conditions and calculate specific results, being structural displacements, stresses, thermal behaviours and other physics.

A good work that was performed in making sense of these tools can be found on the following link:

https://www.theseus.fi/bitstream/handle/10024/87106/Neupane_Dilip.pdf?sequence=1

and Calculix documentation can be found here:

http://web.mit.edu/calculix_v2.7/CalculiX/cgx_2.7/doc/cgx/node4.html

It is important to know what Calculix needs input files  calculate something, this will depend on the type of files.

Geometry
• .Fbd
• .Step
• .stl

Mesh Generator and boundary-condition inputs (Model)

• Abaqus (Input)
• Ansys (Export)
• Code_Aster (Export)
• Samcef (Export)
• Dolfyn (Export)
• Duns (Export)
• Isaac (Export)
• OpenFOAM (Export)
• Nastran (Export)
• Tochnog (Export)

Mesh Generator

• Abaqus (.inp)
• Netgen

Read solver files
• Frd
• Duns
• Isaac
• OpenFOAM
• Nastran

So what’s out there again?

I always get confused with the quantity of file types there are. FreeCAD, Salome, Code_Aster, Salome Meca, Calculix, Elmer, Gmsh, NetGen, ParaView, Python, OpenFOAM, … So how can one understand how each of these work and connect to each other?

We divide the file types in 5 categories:
• Geometry
• Mesh / Model
• Boundary Conditions + Model
• Solver
• Solution

Since these softwares can do a mixture of these 5 elements it’s not that easy to keep up with so many software and so many interconnections.

• Gemetry
○ FreeCAD
○ Salome
○ Salome Meca
○ Gmsh
○ Elmer

• Mesh/Model
○ Salome
○ Salome Meca
○ Gmsh
○ NetGen
○ Elmer

• Boundary Conditions
○ FreeCAD
○ Salome-Meca
○ Gmsh
○ Elmer

• Solver
○ Code_Aster
○ Calculix
○ OpenFOAM
○ Elmer

• Solution
○ FreeCAD
○ Salome
○ Salome Meca
○ ParaViewer
○ Elmer

FreeCAD 0.17 another good step forward

The new FreeCad version that will be out, will introduce quite a few big improvements on many areas, however I will be focusing on the FEM toolbar since this version has a great number of changes. Still I have to comment that when we now go to the Part design drop down menu I saw something which made me happy. I got a strange feeling that I was working with CREO or Unigraphics where we see the base planes and can start a sketch on any one of these. This little change is a huge step forward in making it easier to work with FreeCAD.

FreeCad 0.17 Geometry
FreeCad 0.17 Geometry
FreeCad 0.16 Geometry
FreeCad 0.16 Geometry

Going now to the FEM menu. What is different can you spot it?

FreeCad 0.17 FEM Toolbar
FreeCad 0.17 FEM Toolbar
FreeCad 0.16 FEM Toolbar
FreeCad 0.16 FEM Toolbar

More icons certainly are noticiable. Fluid dynamics seems to be integrated aswell as Non linear material behaviour (looks like strain hardening tangent method), part to part contact definition and thermal boundary conditions.
We can use two meshing applications just by clicking a button for NetGen or Gmsh.

FreeCad 0.17 Meshing Options
FreeCad 0.17 Meshing Options

The boundary conditions are easy to make just like before you select a specific entity and define it. This time around we get more types of boundaryconditions for structural, thermal and fluidic problems.

FreeCad 0.17 Boundary Conditions
FreeCad 0.17 Boundary Conditions

The NetGen mesh worked smoothly, got no issues.

FreeCad 0.17 NetGen Meshing
FreeCad 0.17 NetGen Meshing

The Gmsh mesh was also easy to use and generated a tet mesh with no issues.

FreeCad 0.17 Gmsh Meshing
FreeCad 0.17 Gmsh Meshing

There are more options to explore like mesh boundary layer which I haven’t tried it yet on this new version.

FreeCad 0.17 FEM mesh boundary layer
FreeCad 0.17 FEM mesh boundary layer

This version also boost result viewing with more result types and scoping zones.

FreeCAD 0.17 FEM Results
FreeCAD 0.17 FEM Results
FreeCad 0.17 Improved solution scoping
FreeCad 0.17 Improved solution scoping

Where to get freeCAD 0.17 with FEM? You can get binaries here:

https://github.com/FreeCAD/FreeCAD/releases/

And here more specifically here
https://github.com/FreeCAD/FreeCAD/releases/tag/0.17_pre

If you use a Ubuntu distribution I recomend adding a repository which makes everything som uch easyier!

Daily updated 0.17
https://launchpad.net/~freecad-maintainers/+archive/ubuntu/freecad-daily

Salome 8.2 ParaVis

Another tool in Salome is the ParaView (ParaVis) module for Post processing.

Salome 8 ParaView
Salome 8 ParaVis

In this segment of Salome and Salome-Meca one can view the results as a normal post processor.

ParaVis Post Processing
ParaVis Post Processing

Compared to FreeCAD 0.16 this is a much better environment that allows more control over the results display . FreeCAD 0.17 is much better than it’s predecessor, however ParaVis is still a bit better, the interface is still cleaner and allows more control.

Salome 8.2 Meshing

The salome mesh environment also presents many options. It reminds me a bit of LSPrepost in the LS-Dyna product from LSTC or Hyper mesh with some differences. On the example I am showing I fused all the parts toguether since I didn’t know at the time if I could define contacts. The mesh generation algorithm’s come from NetGen it would be nice to see in the future Gmsh support as FreeCad is doing on it’s 0.17 version.

Salome 8 Meshing Interface
Salome 8 Meshing Interface

Meshing and viewing in Salome is quite simplistic and non visual. Tools like Ansys give us access to selecting surfaces, edges, and lines to allow us to define what we wanto to do to them. This is a limitation that NetGen, Gmsh and other open software lack. Also to troubleshoot a problem requires some knoledge of the mechanisms behind Salome and NetGen. Rendering sometimes fails to display meshed parts or displays parts of them and this was a bit anoying to me.

With the Salome package we get a geometry creation editor, a mesh generation editor and a post processor analyser but where is the solver? This was something that didn’t feel well when I started with Salome, I knew that eventually I would get into a dead end. And so it was wright! To use a solver I need Code-Aster or if I want the two packages bundled toguether we need to use Saolme-Meca where it intigrates the solver. I will get to that subject in a future post.

Salome 8.2 Geometry

I read a lot of information about salome as a pre processor and post processor. Basically you can make a geometry create a mesh and then view results.

The GUI is quite simple at start.

Salome 8 Menu and Toolbar
Salome 8 Menu and Toolbar

As we start diving into this program we start to see it’s complexity. If we make a new project and open the geometry pane we see myrad of tools.

Salome 8 Geometry
Salome 8 Geometry

Although the way we manipulate sketches and solids is way easyier in spaceclaim or RS Mechanical 2 Salome is good enough to make parts. I also think FreeCad isn’t the perfect environment since it also has it’s gaps, however between one and the other I am starting to prefer Salome for its interface looks more clean. A good plus in Salome is that I can define veriables and use them when I create features. Then if I want to change anything it’s plain simple, however if I don’t create the variable and link it there is no other way to change it. This point for me could be improved in the future. Since if we need to change something after it’s done its not that friendly to do it with the GUI.

Salome 8_2 Geometry Table
Salome 8_2 Geometry Table

All in all it is a solid CAD modeler that is very usefull and in my opinion far better then design modeler from Ansys and on par with FreeCAD but way behind payed CAD packages like Unigraphics, Solidworks, Creo, Spaceclaim, … Although not as good as these professional packages I think that there is no shame on using it since it is sufficiently powerfull to build and anlyse models and I also question if it is necessary all the power of those heavy weight tools. Maybe if I was allowed to ask something I would ask for more natural part building and part manipulation and selection.

Open source or Proprietary software

Life could be so easy, we get an application install it and it works out of the box. Then we use it without reading the instructions and the end result is what we wanted. We save and use the work we produced with no compatibility issues and with the quality we envisioned. This is a perfect scenario.

Now a reality check:

  • Comercial packages (proprietary) can do what we wan’t them to do, they can have a easy install too. But there will always be compatibility issues with app A and B or we need to read the manual for something specific. And some other problems will appear in the way almost definitely.
  • But of course things can get even more dirty. Open source software either is super easy to install or super difficult, they can be super static and hard to change or very flexible.

To install these types of software it will depend mostly in what operating system you use and if it already has some binaries that you can double click and install, or if there is a repository with everything you need to have the selected program to work. And here comes the installation roller coster….  No repository for your linux distro, or the specific function isn’t compiled to your version yet, there is no binary file for your OS. These are examples to name a few. When you finally solve all the installation problems, then comes using the app you so passionately managed to install through some nights of hard work. Many open source projects are under active development and the user interface may seem unfinished and difficult to use and understand or although the application works it is cumbersome to use.

Not all is about pain, after the birth and maturation of specific open source softwares comes a stage where you see that everything is as it should have been from the beginning. Good examples are Gimp or Inkscape. You get them practically in any OS and relatively easy to install for most users. Open source software takes it’s time to develop and mature but in no way we can say that it is useless or serves only the need of the home user to play around with.

Many open source project when they reach maturity off good quality are very usable, being open source may not mean the software is free for comercial purposes so special careful should be taking when using for comercial purposes.

There is no good and bad but often open source software give me insight to what communities are building but require hands on effort to make everything work.  Commercial software are traditionally easier to use and well documented or no one will buy it and if they do buy it and it doesn’t work we complain about it.

Commercial companies like Ansys are starting to have entry level products for the starter companies to try and compete with competing software adoption. Until now I haven seen much competition from the open source communities since every one was happy in their niche, developing a solver, or a mesher but no or very bad integration. This fragmation and the lack of focus and mature hindered adoption.

A positive evolution from FreeCad that aggregates at least to projects Calculix and Netgen to create an integrated simulation environment as I described on a previous post.

A integrated approach will gain adoption and with it new users that will push interest in development and will motive community effort from individuals, universities, and others…

An also positive shift in FEM integration is CAD evolution from the traditional sketch/feature driven modelling to direct modelling. This is important since it breaks a big barrier in geometry design increasing adoption. (Google summer code project direct modelling for FreeCad)

Not all is just about freecad. A good project needs a good rival and my focus on the next weeks is in presenting you Salome.

Salome 2016
Salome 2016

Calculix – FreeCad – NetGen what else????

Previously I talked about gmsh and NetGen and showed a generated mesh. I did’t go much in detail and will continue to not do so for now. Noticed on a few blogs that FreeCad had a specific FEM environment that supposedly would work connected to Calculix and NetGen.

I found this really good tutorial in https://www.freecadweb.org/wiki/FEM_tutorial

Basically it is a FreeCAD help to get running the FEM module. I did exactly what was here, but not on my mac since I know that I would face eventually some difficulties. I used windows.

I had to install the necessary modules for everything to work.

Calculix, NetGen, Gmsh and a plugin from here https://github.com/psicofil/Macros_FreeCAD

To be honest I didn’t have that many expectations since It is a freeware simulation packages built from many separate projects. I wasn’t expecting much….

The interface was surprisingly easy to use compared to Gmsh or Calculix alone. Take a look bellow.

FreeCAD FEM Boundary Conditions
FreeCAD FEM Boundary Conditions

Meshing wasn’t a trouble but it looked like it created something similar to a spider web.

FreeCAD FEM Mesher
FreeCAD FEM Mesher

Before running the resulting mesh with boundary conditions.

FreeCAD FEM BeforeResults
FreeCAD FEM BeforeResults

The final step was to solve and look at something move or visualize some colors. To visualize the final solved solution was very simple. I just had to press results.

FreeCAD FEM Deformed State
FreeCAD FEM Deformed State

Final comments: simulation starts to become user friendly and looking back there has been remarkable advances in the open community search for a free and open source FEM software. Although far from perfect it is usable and these will be the drivers of a even more persistent and strong effort to match comercial software since more users will start to use these types of FEM packages which would not be possible until today.

So who is the main beneficiary? The hobbyist and the entrepreneur.