Skip to content

numenic/CfdOF

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CfdOF: A Computational fluid dynamics (CFD) workbench for FreeCAD

This workbench aims to help users set up and run CFD analyses within the FreeCAD modeller. It guides the user in selecting the relevant physics, specifying the material properties, generating a mesh, assigning boundary conditions and choosing the solver settings before running the simulation. Best practices are specified to maximise the stability of the solvers.

screenshot

The workbench serves as a front-end (GUI) for the popular OpenFOAM® CFD toolkit (www.openfoam.org, www.openfoam.com).

Disclaimer: This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com, and owner of the OPENFOAM® and OpenCFD® trade marks

Features

Current:

  • Incompressible, laminar flow (simpleFoam, pimpleFoam)
  • Extension to turbulent flow using RANS (k-omega SST)
  • Incompressible free-surface flow (interFoam, multiphaseInterFoam)
  • High-speed compressible flow (HiSA)
  • Basic material database
  • Flow initialisation with a potential solver
  • Cut-cell Cartesian meshing with boundary layers (cfMesh)
  • Cut-cell Cartesian meshing with baffles (snappyHexMesh)
  • Tetrahedral meshing using Gmsh
  • Postprocessing using Paraview
  • Porous regions and porous baffles
  • Runs on Windows 7-10 and Linux
  • Unit/regression testing
  • New case builder using an extensible template structure
  • Macro scripting

Platforms supported

Linux

Any system on which FreeCAD and the prerequisites listed below can be installed.

Windows

Windows 7-10; 64-bit version is required.

macOS

Not widely tested, but success has been reported. See the following forum post for instructions.

Getting started

Prerequisites

The CfdOF workbench depends on the following external software, some of which can be automatically installed (see below for instructions).

Setting up the CfdOF workbench

Windows

The latest release or development FreeCAD build can be obtained (64 bit version) and installed by respectively running the installer or extracting the .7z archive to a directory <FreeCAD-directory>. In the latter case, FreeCAD can be run in place (<FreeCAD-directory>\bin\FreeCAD.exe).

Before installing CfdOF, the Plot workbench must first be installed into FreeCAD using the Addon manager:

  • Run FreeCAD
  • Select Tools | Addon manager ...
  • Select Plot in the list of workbenches, and click "Install/update"
  • Restart FreeCAD
  • Repeat the above for the "CfdOF" workbench
  • For installation of dependencies, see below

Note: The CfdOF workbench can be updated at any time through the Addon manager.

Dependency installation

Dependencies can be checked and installed conveniently from the CfdOF Preferences panel in FreeCAD. In the FreeCAD window, select Edit | Preferences ... and choose "CfdOF".

The OpenFOAM installation is via the OpenCFD MinGW package, and the BlueCFD Core port of OpenFOAM is also supported. The OpenCFD docker package is also currently supported but has some issues.

OpenFOAM can be installed manually using the above links, or by clicking the relevant button in the Preferences panel described above. If you experience problems running OpenFOAM in CfdOF, please make sure you have a working installation by following instructions on the relevant websites.

To interface correctly with the OpenFOAM installation, CfdOF needs to be able to write to its install location. Some users experience problems using a location inside C:\Program Files due to restrictions imposed by Windows User Account Control. It is therefore suggested to install to an alternative location, preferably in your home directory.

Set the OpenFOAM install directory in the preferences panel to the install directory ending in the 'vXXXX' subfolder (where XXXX is the version number installed) for the MinGW package, or the BlueCFD install directory. It will be automatically detected in the default install locations.

Any version of ParaView can be installed, by following the above link or clicking the relevant button in the Preferences panel. Set the ParaView install path in the preferences panel to the 'paraview.exe' file in the 'bin' subfolder of the ParaView installation. Common defaults will be detected if it is left blank.

Likewise, cfMesh and HiSA can be installed from the Preferences panel. Do not close it until the 'Install completed' message is received. Note that the OpenFOAM installation must be in a writable location for cfMesh and HiSA to be installed successfully.

Choosing the "Check dependencies" option will verify that all prerequisites have been successfully installed.

Linux

AppImages of the latest release or development versions of FreeCAD can be downloaded and run directly without installation. Note that you will have to enable execution permission on the downloaded file to run it. The Ubuntu PPA daily build packages are an alternative binary option. Otherwise, FreeCAD can be built from the source code at https://github.com/FreeCAD/FreeCAD .

Note:

  • Installations of FreeCAD via Linux package managers (including the PPA daily build above) make use of your local python installation. Therefore you might need to install additional python packages to get full functionality. The dependency checker (see below) can help to diagnose this.
  • Note that the 'Snap' container installed through some distributions' package managers can be problematic as it does not allow access to system directories, and therefore OpenFOAM has to be installed in the user's home directory to be runnable from FreeCAD.

For the reasons above we recommend the AppImage as the most robust installation option on Linux.

Before installing CfdOF, the Plot workbench must first be installed into FreeCAD using the Addon manager:

  • Run FreeCAD
  • Select Tools | Addon manager ...
  • Select Plot in the list of workbenches, and click "Install/update"
  • Restart FreeCAD
  • Repeat the above for the "CfdOF" workbench
  • For installation of dependencies, see below
Dependency installation

Dependencies can be checked and some of them installed conveniently from the CFD Preferences panel in FreeCAD. In the FreeCAD window, select Edit | Preferences ... and choose "CFD".

However, in Linux, manual installation is required for OpenFOAM (OpenCFD or Foundation versions), Paraview and Gmsh (optional). They should be installed using the links above or your distribution's package manager. Note, however, that the OpenFOAM packages bundled in some Linux distributions may be out of date or incomplete; for example, the standard Debian and Ubuntu packages do not include the build command 'wmake' and therefore cannot be used with the optional components 'HiSA' and 'cfMesh'. We therefore recommend installation of the packages supplied through the official websites above.

Set the OpenFOAM install directory in the preferences panel - examples of typical install locations are /opt/openfoam8 or /home/user/OpenFOAM/OpenFOAM-8.x (It will be automatically detected in common default install locations). Note that if you have loaded the desired OpenFOAM environment already, the install directory should be left blank.

cfMesh and HiSA can be installed using the Preferences panel described above, and can be downloaded and built from their source code inside your OpenFOAM installation if you have not already done so yourself. Note that this is a lengthy process.

Choosing the "Check dependencies" option will verify that all prerequisites have been successfully installed.

Documentation

At present there is no formal documentation for CfdOF apart from this README. However, demonstration cases are provided inside the 'demos' folder of the CfdOF workbench directory. These aim to provide a basic overview of features and best practices. The examples are run by loading and executing the macro files ending in '.FCMacro' in the various sub-directories in the 'demos' directory. Where there are several numbered files, these should be run in order and aim to demonstrate step-by-step how the case is set up.

Community assistance may be sought at the CfdOF dedicated FreeCAD forum, and a list of various third-party documentation is available in the following forum post.

FAQ

Q: Do I have to create a watertight geometry?

A: This isn't necessary if using the cartesian mesh generators snappyHexMesh and cfMesh. You can make use of shells and compounds instead of creating solids, as long as the collection of shapes in the compound being meshed blocks off the volume desired. Gaps smaller than the mesh spacing are also allowed.

Feedback

Reporting Bugs

Please discuss issues on the CfdOF FreeCAD forum for community assistance. Bugs can be reported on the gitlab project site.

Please first read the guidelines for reporting bugs in order to provide sufficient information.

Development

Total alertsLanguage grade: Python

It is asked that developers should only add functionality or code that is working and can be tested. Dead code, even portions included for possible future functionality, reduces function clarity and increases the maintenance overhead. Our philosophy is 'Do the basics well' and therefore robust operation takes precedence over extended functionality.

Testing

Unit and regression testing is supported. Where possible, it is asked that new functionality be included in the unit test framework.

In order to run the tests, the following command can be used from the terminal:

FreeCAD -t TestCfdOF

Alternatively, from FreeCAD, select the 'Testing framework' workbench, choose the 'Self-test' button, select the 'TestCfdOF' test name and click 'Start'.

Style guide

For consistency please follow PEP8

  1. Use 4 spaces per indentation level (spaces are preferred over tabs).

  2. Limit all lines to a maximum of 120 characters.

  3. Break lines before binary operators.

  4. Blank lines

    • Surround top-level function and class definitions with two lines.

    • Definitions inside a class are surrounded by a single line.

  5. Imports should usually be on separate lines.

  6. Comments

    • Docstrings always use """ triple double-quotes """

    • Block comment starts with a # and a single space and are indented to the same level as that code

    • Use inline comments sparingly. They are on the same line as a statement and should be separated by at least two spaces from the statement.

  7. Avoid trailing whitespaces

  8. Naming convention

    • ClassNames (Camel)
    • variable_names_without_capitals (Underscore)
    • CONSTANTS_USE_CAPITALS (Uppercase)
    • functionsWithCapitals (Although not following PEP8, Camel-case instead of underscore is preferred as it is widely used within FreeCAD)
    • __class_attribute (Double leading underscore)

Acknowledgements

Funding

This development was made possible through initial funding from Eskom Holdings SOC Ltd and the Council for Scientific and Industrial Research (South Africa).

Lead developers

The code is primarily developed by

Contributors

We acknowledge significant contributions from

  • Qingfeng Xia (2015) - Original framework
  • Michael Hindley (2016) - Initial concept
  • Klaus Sembritzki (2017) - Multiphase extension
  • Thomas Schrader (2017-) info@schraderundschrader.de - Testing and user assistance

Dedication

CfdOF is dedicated to the memory of Michael Hindley. It is thanks to his irrepressible enthusiasm for FreeCAD and open source software that this workbench exists. Rest in peace.

About

Computational Fluid Dynamics (CFD) for FreeCAD based on OpenFOAM solver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 72.4%
  • C++ 23.8%
  • Shell 3.4%
  • GLSL 0.4%