18  Text user interface (TUI)

An extremelly opinionated introduction.

Using Ansys Fluent can be a huge nightmare; the software is simply bad. There’s no way someone should commercialize such a garbage of user experience, shame on you! It happens that as CFD engineers we often need to use it and in some cases it surprisingly works as its solver is not as bad as the graphical interface. One just needs to refrain themselves from using the graphical interface and go straight to the text user interface, hereafter our friend TUI.

If you are beginning in the CFD world, stop here and go learn some good code, as OpenFOAM or SU2; continue only if you really need Fluent because of your company or job opportunities require it. If you started learing with the GUI, I have the good-bad news that you lost your time and to be productive with this garbage tool you really need to use the TUI.

For what follows let’s keep in mind the following:

; Here goes plain Scheme code and parameter definitions:
/file/read-journal "0-params.scm"   ()

; One file per Fluent project section:
/file/read-journal "1-setup.scm"    ()
/file/read-journal "2-solution.scm" ()
/file/read-journal "3-results.scm"  ()

; Do not forget this if working in a shared cluster/HPC:
/exit ()

18.1 Parameters

In the aforementioned 0-params.scm file I often start by declaring a few constants that are often useful in case setup. The following snippet illustrates the basics of what you need to know about Scheme to do something useful in Fluent: commands are declared within parenthesis, as Scheme is of LISP’s family, and parameter definitions follow a (define <symbol> <value>) syntax.

; Pi
(define pi 3.141592653589793)

; Gravity magnitude [m/s^2]
(define gravity-acceleration 9.81)

; Atmospheric pressure [Pa]
(define pressure-atm 101325.0)

; Universal gas constant [J/(mol*K)]
(define gas-constant 8.31446261815324)

One thing about Scheme that might be not familiar for people coming from other languages (or too young to have used an HP graphical calculator) is Polish notation for numerical operations: you preprend the operator to the operands. That has the advantage that (+ 1 2 3) is valid code and will add up all numbers.

; Compute some angle [deg] -> [rad]
(define theta (/ (* pi 15.0) 180.0))

; Gravity components [m/s^2]
(define gx 0.0)
(define gy (* -1 gravity-acceleration (cos theta)))
(define gz (* -1 gravity-acceleration (sin theta)))

Side-note: you might be asking yourself why the hell I project gravity acceleration components over the different axes. In some cases it is very useful if a geometry has corners or something that resembles a rectangle to keep it horizontal and apply body forces as components. For instance, when conceiving a geometry with Gmsh it will avoid a lot of trigonometry and round-off errors if you draw the body oriented as the screen. For some post-processing is is also useful to have horizontal bodies.

18.2 Troubleshooting

18.2.1 Terminal lacking interactivity

You can use rlwrap tool that adds readline functionality to any program:

# Install rlwrap (if not already installed)
sudo yum install rlwrap  # RHEL/CentOS
sudo apt install rlwrap  # Debian/Ubuntu

# Run Fluent with readline support
rlwrap fluent 3d -g

# Or create an alias
alias fluent-rl='rlwrap fluent'