FEM Install

From FreeCAD Documentation
Revision as of 16:41, 6 April 2019 by Vocx (talk | contribs) (small editions)

Introduction

To be able to perform finite element analysis (FEA) within the FEM Workbench, FreeCAD makes use of two external programs: one is used for generating the FEM Mesh, and the other for numerically solving the actual analysis. You can test if your FreeCAD installation is ready for FEA by running the FEM CalculiX Cantilever 3D example which is included with every installation of FreeCAD since v0.17.

FEM solver

The default solver to perform finite element calculations is CalculiX, a simple solver for analysis of structures. FreeCAD writes a CalculiX input file, starts the solver, and reads the output, which can then be presented visually in the viewport; this means the CalculiX binary is standalone and independent from FreeCAD. Given that there are many programs that can generate a mesh, it is recommended to install the solver, and make sure it's working first.

If the solver is correctly installed, you may run the single command ccx in the terminal to obtain a simple response:

User@PC:~$ ccx

Usage: CalculiX.exe -i jobname

If the solver is installed, make sure the FEM Workbench is able to find the binary; go to Edit → Preferences → FEM → CalculiX → Search in known binary directories. If you compiled the solver yourself, untick the option, and give the correct path to the binary. For other solvers that could be used with FreeCAD, see FEM Solver.

FEM mesh generator

In order to create a FEM Mesh, FreeCAD uses Gmsh as the default mesher. For this to work, Gmsh should be installed separately from FreeCAD.

If the program is correctly installed, you may run the command gmsh in the terminal to launch the graphical interface of the program. This interface is not used by FreeCAD but demonstrates that the program is installed.

User@PC:~$ gmsh -info

Version          : 3.0.6
License          : GNU General Public License
Build OS         : Linux64
Build date       : 20171107
Build host       : lgw01-amd64-034
Build options    : 64Bit Ann Bamg Bfgs Blas(Generic) Blossom C++11 Cgns Chaco DIntegration Dlopen Fltk Gmm Jpeg Kbipack Lapack(Generic) LinuxJoystick MPI MathEx Med Mesh Mmg3d Mpeg NativeFileChooser Netgen ONELAB ONELABMetamodel OpenCASCADE OpenGL OptHom Parser Plugins Png Post Python Solver TetGen/BR Tetgen Voro3D Zlib
FLTK version     : 1.3.4
OCC version      : 6.9.1
MED version      : 3.0.6
Packaged by      : buildd
Web site         : http://gmsh.info
Mailing list     : gmsh@onelab.info

If the mesher is installed, make sure the FEM Workbench is able to find the binary; go to Edit → Preferences → FEM → Gmsh → Search in known binary directories. If you compiled the mesher yourself, untick the option, and give the correct path to the binary. See FEM Mesh for various possibilities of obtaining a valid mesh for analysis.

Netgen

Note: The Netgen mesher was disabled in March 2017, when FreeCAD transitioned to using OCCT 7.1. Please edit this information if Netgen is usable again with the stable release of FreeCAD.

In previous versions of FreeCAD, Netgen was the default mesher. For it to work with the FEM Workbench, FreeCAD had to be linked against the Netgen libraries at compile time. As FreeCAD transitioned from OCE 0.17 to OCCT 7.1, Netgen 4.9.13 failed to link against this version of OCCT, so it was decided to drop Netgen support in the FEM Workbench (the Netgen button was removed). Nevertheless, shortly afterwards some users reported success in patching Netgen 5.3.1, so that it worked with OCCT 7.x and FreeCAD.

For historical reference, see the threads:

Despite Netgen not being available from within the FEM Workbench, it can still be used by itself to produce meshes that can then be imported.

If the program is correctly installed, you may run the command netgen in the terminal to launch the graphical interface of the program.

User@PC:~$ netgen -V

NETGEN-6.2-dev
Developed by Joachim Schoeberl at
2010-xxxx Vienna University of Technology
2006-2010 RWTH Aachen University
1996-2006 Johannes Kepler University Linz
Including OpenCascade geometry kernel
Run parallel Netgen with 'mpirun -np xy netgen'
NETGENDIR = .
Tcl header version = 8.6.8
Tcl runtime version = 8.6.8 
using internal Tcl-script
optfile ./ng.opt does not exist - using default values
togl-version : 2
OCC module loaded

Installing on Windows

The FreeCAD packages available from the download page already include Netgen and CalculiX, so no additional software needs to be installed.

Installing on Linux

Linux distributions have different ways of installing software. Many distributions have software repositories and package managers; before compiling source code, look in your package manager for netgen, gmsh, calculix-ccx or ccx, and install them following the instructions of your own distribution.

Ubuntu PPA

The freecad-stable and freecad-daily personal package archives (PPA) provide a more recent version of FreeCAD than is available in the official Ubuntu repositories. These PPAs include the most recent netgen, gmsh, and calculix-ccx packages as well. See Install on Unix for more information on setting up the repositories.

If a PPA is already added to your system, install the packages as follows

sudo apt-get install netgen
sudo apt-get install gmsh
sudo apt-get install calculix-ccx

The freecad-community PPA also provides netgen, gmsh, and calculix-ccx packages for testing. If they are stable enough, they may be added to the daily or stable repositories.

Note: the thread Ubuntu Repository discusses the creation of the Ubuntu PPA packages. At the time it was written, CalculiX was not included in the Debian repositories, so there were several personal packages in Launchpad. Only one package should be installed.

Arch Linux

Get the CalculiX package from the AUR repository.

Debian

CalculiX binary

The CalculiX authors provide a pre-compiled Linux binary of the solver; it can be downloaded from the authors' website. However, since different Linux distributions have different library paths, most likely this binary will not work without making some adjustments.

To use the binary with Fedora 21, see the thread Making FEM run on linux fedora 21. For newer Fedora versions, you should compile CalculiX yourself.

If you use this binary, check that the binary is executable, that it is in the executable $PATH of your system, and that you have the necessary version of the libraries (libgfortran, liblapack, libblas, etc.) against which it was compiled. This is mentioned in the forum post FEM WB.

Use the command ldd to see the libraries that are linked by the binary. Install any missing dependency.

User@PC:~$ ldd /usr/bin/ccx

linux-vdso.so.1 (0x00007fffbabdc000)
	libspooles.so.2.2 => /usr/lib/x86_64-linux-gnu/libspooles.so.2.2 (0x00007fe9bd042000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe9bce23000)
	libarpack.so.2 => /usr/lib/x86_64-linux-gnu/libarpack.so.2 (0x00007fe9bcbd9000)
	liblapack.so.3 => /usr/lib/x86_64-linux-gnu/liblapack.so.3 (0x00007fe9bc353000)
	libgfortran.so.4 => /usr/lib/x86_64-linux-gnu/libgfortran.so.4 (0x00007fe9bbf74000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe9bbbd6000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe9bb7e5000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe9bb5cd000)
	libmpi.so.20 => /usr/lib/x86_64-linux-gnu/libmpi.so.20 (0x00007fe9bb2db000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fe9bdaa9000)
	libblas.so.3 => /usr/lib/x86_64-linux-gnu/libblas.so.3 (0x00007fe9bb080000)
	libopenblas.so.0 => /usr/lib/x86_64-linux-gnu/libopenblas.so.0 (0x00007fe9b8dda000)
	libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007fe9b8b9a000)
	libopen-rte.so.20 => /usr/lib/x86_64-linux-gnu/libopen-rte.so.20 (0x00007fe9b8912000)
	libopen-pal.so.20 => /usr/lib/x86_64-linux-gnu/libopen-pal.so.20 (0x00007fe9b8660000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe9b8458000)
	libhwloc.so.5 => /usr/lib/x86_64-linux-gnu/libhwloc.so.5 (0x00007fe9b821b000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe9b8017000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fe9b7e14000)
	libnuma.so.1 => /usr/lib/x86_64-linux-gnu/libnuma.so.1 (0x00007fe9b7c09000)
	libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007fe9b79ff000)

Compile CalculiX

Since CalculiX is a standalone application, you can either install a binary packaged for your distribution, or compile it yourself. Any CalculiX version from 2.7.x onwards should work with FreeCAD, and since the code hasn't changed much in years, lower versions than 2.7.x may work as well.

Compiling CalculiX is a task for experienced users, requiring editing the Makefiles and build options in different platforms. See the following information:

Compile Netgen

Netgen was originally linked by FreeCAD when FreeCAD used OCE, the community fork of OpenCascade (OCCT). As OCE lagged in development behind OCCT, FreeCAD switched back to OCCT. This broke the linking of Netgen, which could only link against OCCT 6.9 or OCE 0.18 and below.

Since then some success has been achieved patching and linking newer versions of Netgen against OCCT 7.1 and higher versions. Nevertheless, the inclusion of Netgen with FreeCAD is still problematic.

Installing on OSX

This information may be out of date. If you are an OSX user, please test and clean up this section

The OSX development packages of FreeCAD may include Netgen but may not include CalculiX.

See this forum post FEM on Mac OSX for information on installing CalculiX, and an updated post for more recent information.

The following posts may be outdated:

Further information

The FEM Workbench is under constant development. The most recent information is found in the FreeCAD forum.

If you have problems installing Netgen, Gmsh, or CalculiX, or another external tool, please search the forum first: