Skip to content

Compile swak4Foam for OpenFOAM v2512

1. About

swak4Foam (“Swiss Army Knife” for OpenFOAM) adds an expression language and utilities that let you create/modify fields from dictionaries-often without writing C++. For VOF cases, the key tool is funkySetFields: it’s a more powerful alternative to setFields for initializing alpha (and other fields) using geometry- and condition-based expressions (e.g., bubbles, films, stratified layers, smooth transitions) directly on the mesh.

2. Downloading swak4Foam

For Ubuntu or Linux Mint, install the required packages [1]:

sudo apt install mercurial python-is-python3

Obtaining the package from the main Mercurial development repository, using the hg command, download from the repository and checkout the right branch [2]:

1
2
3
4
5
6
source $WORK/OpenFOAM/OpenFOAM-v2512/etc/bashrc
cd $WM_PROJECT_USER_DIR

hg clone http://hg.code.sf.net/p/openfoam-extend/swak4Foam swak4Foam
cd swak4Foam
hg update develop

3. Build

  • Build the dependencies
    1
    2
    3
    4
    source $WORK/OpenFOAM/OpenFOAM-v2512/etc/bashrc
    cd $WM_PROJECT_USER_DIR/swak4Foam
    
    ./maintainanceScripts/compileRequirements.sh
    
  • Build swak4Foam
    1
    2
    3
    ./Allwmake
    
    ./Allwmake
    

After compiling, check the version with

funkySetFields -help

And the output is like

Usage: funkySetFields [OPTIONS]
Options:
  -addDummyPhi
  -additionalRegions <regions that may be needed by coupled boundary conditions>
  -allowFunctionObjects
  -case <dir>       Case directory (instead of current directory)
  -condition <logical condition>
  -correctResultBoundaryFields
  -create
  -debugParser
  -decomposeParDict <file>
                    Alternative decomposePar dictionary file
  -dictExt <extension to the default funkySetFieldsDict-dictionary>
  -dimension <dimension of created field>
  -expression <expression to write>
  -field <field to overwrite>
  -functionPlugins <comma-separated list of plugin names (no 'libswak' in the beginning and no 'FunctionPlugin.so' in the end)>
  -keepPatches
  -latestTime       Select the latest time
  -noCacheVariables
  -noCorrectPatches
  -noZero           Exclude '0/' dir from the times list
  -otherAdditionalRegions <region in other case that may be needed by coupled boundary conditions>
  -otherCase <path to other case>
  -otherHasSameTime
  -otherInterpolateOrder <order>
  -otherRegion <region in other case>
  -otherTime <time to use in other case>
  -parallel         Run in parallel
  -preloadFields <List of fields to preload>
  -region <name>    Specify mesh region (default: region0)
  -time <ranges>    List of ranges. Eg, ':10,20 40:70 1000:', 'none', etc
  -valuePatches <list of patches that get a fixed value>
  -doc              Display documentation in browser
  -help             Display short help and exit
  -help-full        Display full help and exit

Using: OpenFOAM-v2512 (2512) - visit www.openfoam.com
Build: _87ed40d256-20251219
Arch:  LSB;label=32;scalar=64

Reference

[1] Ubuntu 14.04 to 15.10

[2] swak4Foam development version