This project aims to ease the environment setup for FreeCAD CfdOF workbench.
Basically it's a nix-shell configuration of a FreeCAD environment with CfdOF installed.
By the time I finished this project, I found preCICE adapters and solvers packaged with the Nix package manager which has a simliar goal(reproducibility). That's a flakes repository for NixOS.
- Install
nix
. Follow the instruction of your distro. Or you can follow the instructions by nix official.- For Arch users, simply
pacman -Sy nix
, and enablenix-daemon
service.
- For Arch users, simply
- Change working directory to here, the repository.
- Open a new shell with
nix-shell freecad-cfd.nix
. Packages are built in this step. This is the way to launch an interactive shell, and normally the packages are built only once. - In the new shell, install
CfdOF
plugin by executing the scriptinstall-mod-cfdof.sh
- this script pins the module's git revision, making it reproducible
- Run
mkdir -p freecad-state/{home,userdata,temp}
to create the folders for FreeCAD data. ReadshellHook
variable infreecad-cfd.nix
andcmd.sh
for more details. - (Optional) In console, run
freecad -t TestCfdOF
, and it will test the workbench. - In console, run
freecad
, and enjoy your journey. - (Optional) To further test the environment, you need to load a demo from CfdOF, and run the calculation.
- In some cases, testing a single demo cannot ensure everything works.
- Later you don't need to run the steps above again if you want to launch FreeCAD directly, just change directory here and execute
start-cfd.sh
. The script will pass the arguments to FreeCAD.
- FreeCAD version is pinned with
nixpkgs
release.- Config path is changed with environment variables.
- Warning: NEVER hard code ANY path in FreeCAD settings.
- Config path is changed with environment variables.
- OpenFOAM and related components which are not maintained in
nixpkgs
are built through local package definitions.- Versions are pinned by pinning source code version.
cfmesh-cfdof
andhisa
don't have versioned source code, and their code packages are relatively small, so the code packages are bundled.
CfdOF
's version is pinned by git commit hash.nixgl
is used to make UI working.
My building platform: EPYC 7D12(1.1GHz, 32 core 64 threads) with 128G RAM.
- FreeCAD: about 10 minutes
- OpenFOAM: around 50 minutes, it looks not fully parallel
- cfmesh-cfdof: the scripts build it sequentially, about 15 minutes
- hisa: the scripts build it sequentially, about 14 minutes
- parmetis and scotch are rebuilt for their dynamic linking libraries, and these shouldn't take long time to build
The rest packages are provided by nixpkgs prebuilts.
As of FreeCAD 0.21.2, the FEM workbench has a bug that prevents correct detection of solvers in system path.
If you don't need this patch or don't want to rebuild, just comment out freecad-patched
and uncomment pkgs.freecad
in freecad-cfd.nix
.
This project is licensed under the MIT license. The license doesn't apply to the bundled source code zips(cfmesh, hisa), which are licensed under GPL3.