Talk to an engineer

Color maps: better CFD visualization in Simcenter STAR-CCM+

In short

What makes two colors a good match, and why the familiar color wheel is not enough for data. Which map type fits which quantity, with marine examples. A STAR-CCM+ macro that turns company identity colors into a complete, perceptually correct set of color maps.

A color map is part of your measurement, not decoration. It decides which gradients a viewer notices, where they think the flow separates, and whether a colleague with red-green color blindness sees anything at all. Yet many CFD images still leave the office in a default blue-to-red rainbow.

This post covers three things:

  1. Color basics. What makes two colors a good match, and why the familiar color wheel is not enough for data.
  2. Choosing a color scale for CFD. Which map type fits which quantity, with marine examples: free surface, waves, cavitation, exhaust gas and propeller wake.
  3. A STAR-CCM+ macro. It turns company identity colors into a complete, perceptually correct set of color maps.

Part 1: What makes colors a good match

First things first. Here are some important terms when we describe colors:

  • Lightness: how bright it looks.
  • Chroma: how colorful it is, from grey to vivid.
  • Hue: which color family it belongs to: red, orange, teal, blue and so on.

Two colors work well in a plot when their hues are distinct, but their lightness is similar. A good color scale also changes lightness steadily across its range. The traditional color wheel addresses hue, but not lightness.

color terms

However, there is a problem with the color spaces we typically use (RGB and HSV) when picking colors. They do not measure the color as the eye sees them. For example, pure yellow and pure blue both have 100 % “value” in HSV. But in the perceptual Oklab space yellow has a lightness of 0.97 and blue only 0.45. Hence, if you put both in one color map, the yellow band jumps out to the eye, whether the data do anything there or not.

The typical HSV color gradient varies Hue but keeps the Saturation and Value. The Oklab color gradient on the other hand varies the Hue with constant lightness and chroma. The difference is an uneven gradient of the HSV color gradient, that can misguide the perception of the observer of CFD results.

problem with color scales

Perceptual color spaces such as CIELAB, CAM02-UCS and Oklab fix this. Equal distances in them correspond roughly to equal perceived differences. Oklab was published in December 2020 by the Swedish engineer Björn Ottosson and is now part of the CSS color standard for the web. The macro in Part 3 uses Oklab for all its calculations.

Complementary colors, and what the color wheel misses

Newton´s book, Opticks, presented the circle of colors to illustrate their relation between them. While Newton only showed the spectral hues, today´s color wheel is often used determine complementary colors, which sit opposite each other and gives the strongest hue contrast. That is a good start for a diverging color map for simulation results, where one hue stands for negative and the other for positive values. However, to handle data, the pair must also pass three further tests:

  1. Equal lightness. Otherwise, one side of zero looks more important than the other.
  2. Enough chroma on both sides, so the two ends are clearly colored and not greyish.
  3. Distinguishable for color-blind viewers. About 8 % of men and 0.5 % of women have a color-vision deficiency, most often red-green (Crameri et al., 2020). In an engineering team of twenty, odds are that at least one person cannot tell your red from your green.

The compatibility with color-vision deficiency can be simulated according to a model of Machado et al. (2009). Below we have five example color pairs through these tests. Separation is the color distance in Oklab, which is better with a higher value.

color checks

Red and green look like a perfect complementary pair on the wheel. But for a red-green color-blind viewer, their separation drops from 0.36 to 0.06 and both turn olive-brown according to Machado et al.´s model. Blue against orange (or teal against coral) runs along the yellow-blue axis, which red-green color-blind viewers still see. That is why it is the safest backbone for diverging maps.

Part 2: Color scale for CFD results

Why the rainbow fails in CFD

The rainbow (“jet”, “blue-red”) changes hue but not lightness. Its brightest band, yellow, sits in the middle of the range rather than at an end. The uneven gradients, as discussed above add artificial boundaries in some parts of the range and hide small-scale variation in others.

In the praxis example of the backward facing step simulation, we can observe a misconception when the default color map draws our attention to two color bands (light blue and yellow) in the gradient. Those artificial boundaries look like physics and indicate a high velocity gradient.

While the Oklab color scale represents the actually even gradient of the flow velocity, clarified also by the contour plot in the figure below. In a CFD picture. A sharp cyan-to-yellow edge reads as a shear layer, a separation line or a shock, even where the field is smooth

Another example is the residence time in an internal pipe flow simulation. Here the color scale hides small-scale variation in the center of the pipe while our attention is drawn to the near wall and outlet region. At the same time wisely chosen color map reviles more details about the flow field.

Step 1: Match the map type to the quantity

The accurate representation of data suggested by Crameri et al., 2020 provides distinctive guidelines for choosing the correct color map. It is simplified in the figure below. Work your way down the questions in Figure 5. The first “yes” decides the map type, so the order matters: a periodic angle is never treated as a magnitude, and a cavitation margin is treated as a threshold before it is treated as a signed value.

selecting flowchart

Step 2: Settings that matter as much as the colors

  • Fix the range. Auto-ranging changes the colors from frame to frame in an animation and from case to case in a design study. Fix it once per quantity and reuse it across the whole report.
  • Keep diverging maps symmetric. If the range is −2 … 5, the neutral center no longer sits at zero and viewers read a bias that isn’t there.
  • Design for the background. On a light page, let low values fade into the background so the free stream disappears and the wake stands out. In VR or photorealistic scenes, use a dark-centered variant instead.
  • Use opacity on purpose. In resampled volume rendering, the opacity ramp of the color map decides what you see. Make air, clean air or liquid without vapor fully transparent, and the hull, propeller or superstructure stays visible.
  • Use a logarithmic mapping for quantities that span decades, such as y+ or turbulent viscosity ratio.
  • One quantity, one color map, one range. Across a report, the same colors must always mean the same values.

In short: Choose the color map type from the physics of the quantity, then fix its range and adapt it to the background. Choosing by taste comes last.

Marine examples

We can implement the above guidelines for an example color map set, dedicated to marine applications in the vlp set (Volupe’s own set of STAR-CCM+ color maps). The common principle: a color that means something physical (water is blue, vapor is white, smoke is grey, hot is bright).

ApplicationColor mapComment
Free surfacevof-waterAir matches the light background. A colored band marks the 0.5 contour, so a smeared interface is visible at once.
Free surface, overlayvof-water-clear-airSame colors, but air is fully transparent, so the hull above the waterline stays visible.
Wave patternwave-elevationDiverging: blue troughs, amber crests, near white for calm water. Using a range symmetric about the flat-water level.
Cavitation on bladescavitation-surfaceVapor fraction: 0 is metal grey, so non-cavitating areas read as geometry; sheet and tip cavitation show in coral to crimson.
Cavitation riskcavitation-marginCp + σ with a hard edge at 0: everything below vapor pressure is red, the safe margin is muted teal.
Cavitation in volume renderscavitation-volumeWhite-cyan vapor that fades to invisible at zero, like cavitation-tunnel photographs.
Exhaust gasexhaust-smoke, exhaust-heatSmoke that darkens with concentration and is transparent in clean air; temperature on a black-body scale.
Propeller wakewake-bandedTen bands of 0.1 u/U give iso-wake contours without a separate contour displayer.

The figures below show four of these maps in real simulations: the KCS container ship, and the PPTC propeller in open water. Beside each image are the lightness profile of its color bar and simulations for the three common types of color blindness.

marine example with Volupe color scale

Part 3: Brand Colormaps

Allowing you to utilize the learned aspects about colors and to easily embed it into your workflow, we prepared a single STAR-CCM+ macro “BrandColormaps.java”. It builds five color maps according to above discussions, based on e.g. your two company colors. It also writes a shareable .colormap file.

Brand color map example form Volupe´s brand colors
MapHow the two colors are used
<prefix>-sequentiallight → color 1 → dark
<prefix>-bandedthe sequential map in 10 flat steps
<prefix>-divergingcolor 1 ← light center → color 2
<prefix>-cycliclight → color 1 → dark → color 2 → light
<prefix>-thresholdcolor 2 below the center value, a hard edge, then light → muted color 1 above

Every map follows the fixed lightness profile in Oklab. The lightness profiles are shaped according to the data types: linear for sequential and banded, a symmetric V for diverging and cyclic. etc. Each map needs conversion to linear RGB values, such that Simcenter STAR-CCM+ can read them. This conversion uses the code provided by https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab

Below figure shows the five maps for four color pairs. The macro uses the two colors as given. If they are hard to tell apart, as with red and green for color-blind viewers, it prints a warning but still builds the maps.

example colors

At its core, the macro uses a few lines of the STAR-CCM+ Java API. A color map is a list of stops (position, r, g, b) plus an opacity list (position, alpha):

LookupTableManager ltm = sim.get(LookupTableManager.class);

UserLookupTable t = ltm.createLookupTable();

t.setColorMap(new ColorMap(new DoubleVector(colorValues),  

                           new DoubleVector(alphaValues),  

                           0));                            


t.setPresentationName("acme-diverging");

Conclusion

Here we have outlined some of the basics of color theory plus some guidelines for the creation of CFD color maps. If you are interested in more details and advanced post-processing for CFD simulation results, please check out our dedicated course https://volupe.com/events/advanced-post-processing-simcenter-star-ccm-on-site-training/ and contact us at support@volupe.com

Download

Sources

Working with Simcenter STAR-CCM+?

More Simcenter STAR-CCM+ articles

All 257 Simcenter STAR-CCM+ articles

Florian Vesting and seven other application specialists write here.

Loading

We use your address only to send these emails and never pass it to Siemens or other partners. Every email has an unsubscribe link. Privacy policy