About Cats2D


Recent code development

Upon leaving the Derby research group in 2014, I undertook a top to bottom review of Cats2D to identify its strengths and weaknesses, and to assess its potential for further development. Though Cats2D was developed entirely as a research code, I found that it was in excellent shape in terms of stability, reliability, and efficiency. Nevertheless, several obvious features were missing that would be expected by any user of a commercial CFD code. There were also several other features, perhaps less obvious but potentially very useful, that I aspired to add to the code. Many of the existing features weren't the best they could be, either. Some were broken, some were obsolete, and some that worked properly found little use in practice.

Before tackling these deficiencies, I made several improvements under the hood, particularly modernizing the code for 64-bit computing, but also carrying out a broad sweep for logic errors and memory leaks. To my delight I found very few actual bugs, and none of a serious nature, despite eliminating over 800 compiler warnings and correcting many minor logic errors. Equally satisfying, the Valgrind memory debugger revealed very few memory leaks, and these were duly fixed. Cats2D does not leak memory. Alongside this effort Ralph was carrying out some unexpected but welcome improvements to the frontal solver that have made it "best in class" for a sparse linear equation solver of its kind, I suspect by a wide margin.

Convinced of the soundness of the code, I next carried out a huge change that I had desired for a long time: adopting a better scheme for non-dimensionalizing the physical parameters. Cats2D was originally based on a scheme in which the conservation equations are scaled in each phase by the properties of that phase, rather than the properties of a reference phase. This approach is confusing to the user and makes it possible to specify a physically inconsistent set of parameter values (this is explained in Chapter 5 of the old user manual). The new Cats2D defines dimensionless groups in terms of the reference phase, which improves clarity by reducing the overall number of parameters, and largely eliminating the possibility of the user specifying an inconsistent set of values.

Not satisfied yet, I added a feature to allow the user to specify dimensional physical properties together with characteristic values of the field variables, from which the dimensionless groups are computed automatically. Now the user can choose whether to run the code using dimensional or dimensionless parameters. To make things even clearer, I added a feature that automatically creates LaTeX formatted tables showing the symbol, definition, and value of each parameter active in the current problem. These tables are complemented by another new feature that creates a LaTeX formatted problem statement showing the precise dimensionless governing equations and boundary conditions defined for the current problem together with narrative text ready to import into your next manuscript.

Next up was to correct an omission that any user should expect of a good CFD code: a reliable restart capability. Cats2D restarts weren't bulletproof because its solution files included only field variables and parameter values. It was up to the user to save the control and mesh files to match those solution files, plus any parameter constraints that may have been defined. To avoid mix-ups, the new Cats2D caches its input files, and any parameter constraints that are active, with its solution files, allowing for seamless and reliable restarts. Related to this work, I added a feature to browse parameter values by parameter type within solution directories, much more useful than the old feature to browse parameters by solution ID.

Also of vital need was a useful graphical display of the geometric domain showing boundary and material definitions, mesh regions, vertex positions, etc. Previously the user was obligated to manually generate drawings showing this information, which are laborious to regenerate when lost. The new Cats2D can produce a variety of geometric plot types from any mesh file. Completing this work inspired me to add numerous improvements to the graphics files in the post-processor, including the capability to add color legends, and to control many elements of plot files, such as plot size, contour and background shading, color map, label and symbol size, etc.

Somewhere in this blizzard of improvements I added field logging, which can be thought of as temporal post-processing (in contrast to the spatial nature of data commonly shown in contour plots). This started as an idea to add monitor points, a common feature in CFD codes that allows the user to observe how a variable changes at fixed locations during integration of a time-dependent problem. I've expanded the idea by adding surfaces, volumes, and end points of boundaries that may be in motion, to the objects that can be monitored. Root mean square, average, and max/min spatial norms of user-selected variables are logged at surfaces and volumes. Field logging can be customized for each problem, either through the control file or the user interface, to select which variables are logged and where they are logged.

Early on in all this, I reorganized the program to allow batch operation, and added command line options that enable the user to execute a configuration macro or read a solution when launching an interactive session, or to repeat a series of operations on a user-specified set of solution files without user intervention. This is great for testing the code during development, when it is often desired to simply read a solution, run the solver, and quit, or some other simple set of repetitive actions. Running a test which might be needed many times is reduced to a single command line.

In the course of these changes I was taken far and wide in the code, sometimes to places written long ago by Ralph that I had never fully understood or even seen before. It has given me an unprecedented opportunity to grasp the global structure of the code, to see the forest and not just the trees, so to speak. Along the way I made many small changes not described here to improve some aspect or other of the code. Menus have been reorganized and labeled more logically, obsolete items have been removed, broken features have been repaired, error checking has been strengthened, and more. Welcome to the new Cats2D.