Biswajit Banerjee

Visualizing ellipsoids in VisIt and ParaView

A simple hack


When the number of ellipsoids in a DEM simulation is small, we can either use a browser-based view (see Setting up Three.js ellipsoids or Plotting particles with vtk.js) or use a package in R (see Plotting ellipsoids in R). However, when several tens of thousands of ellipsoids need to be visualized, it it much more efficient to use a package such as VisIt from LLNL or ParaView from Kitware. But of these are freely available and represent more than two decades of improvements.

One of the problems with VisIt and ParaView is that these do not have tools for the direct visualization of ellipsoidal discrete elements and plugins have to be developed and compiled before ellipsoids can be viewed in a native/natural way. Even when plugins can be developed in short order, compiling the VisIt or ParaView code and linking the plugins is a nontrivial and painful exercise. A few weeks ago I spent three days just to get a basic ParaView build to compile and failed (and I had done the exact same thing with success and couple of months ago). This time around the error was due to a libprotobuf conflict .

I didn’t want to chase the problem for ever and decided to try a workaround/hack that would solve my problem. This article describes that hack.

The hack

I save my DEM simulation data in VTK format (see Particle data in VTK XML). This format can be read by both VisIt and ParaView.

I noticed that both VisIt and ParaView can display rank-2 tensors as ellipsoidal glyphs. So all I needed to visualize ellipsoids was to convert the geometry into a rank-2 tensor form that would be interpreted appropriately by the in-built glyph computation. There is some extra work (eigenvalue computation) that needs to be done by the visualization software if I use this approach, but the time saved by not having to write and link a plugin seems to be worth the extra computational cost at this stage.

The algebra is straightforward. Let the three radii of the ellipsoid be , , and . Also, let the corresponding axes have the direction unit vectors , , and . Then, using the spectral decomposition theorem, we can write the ellipsoid as a tensor

$$ \boldsymbol{E} = a\, \mathbf{a}\otimes\mathbf{a} + b\, \mathbf{b}\otimes\mathbf{b} + c\, \mathbf{c}\otimes\mathbf{c} $$

We just save this tensor and use the tensor visualization capability of VisIt/Paraview to view the ellipsoids. In my code, I just added the following:

  vtkDoubleArrayP ellipsoid = vtkDoubleArrayP::New();
  // ....
    // Compute the orientation ellipsoid
    Matrix3 a_x_a = Dyad(particle->currentAxisA(), particle->currentAxisA());
    Matrix3 b_x_b = Dyad(particle->currentAxisB(), particle->currentAxisB());
    Matrix3 c_x_c = Dyad(particle->currentAxisC(), particle->currentAxisC());
    auto ell = vec[0] * a_x_a + vec[1] * b_x_b + vec[2] * c_x_c;
    double mat[9];
    int count = 0;
    for (int ii = 0; ii < 3; ++ii) {
      for (int jj = 0; jj < 3; ++jj) {
        mat[count] = ell(ii, jj);
    ellipsoid->InsertTuple(id, mat);
  // ....

A VisIt visualization

vertex numbering
Figure 1. Visualization of the ellipsoids in VisIt.
vertex numbering
Figure 2. Visualization in R to check the orientations and positions of the VisIt ellipsoids.

Figure 1. shows a GIF of the VisIt visualization of the ellipsoids created using my approach. All I needed to do was to load by VTK formatted data and then select the “Add->Tensor->Ellipsoid” option. There are several issues one runs into when using VisIt to view the ellipsoids:

  • The resolution of the ellipsoid glyph cannot be changed, leading to angular shapes.
  • The glyphs cannot be colored using another variable, say the velocity.
  • The glyphs cannot be scaled to be the right size without a lot of trial and error.

However, the visualization is lightning fast even when ten thousand ellipsoids are loaded. To check that the orientations of the ellipsoids is correct, we can use our R-script to produce the image in Figure 2. Notice that Figures 1 and 2 appear to indicate that VisIt is doing the right thing.

A ParaView visualization

vertex numbering
Figure 3. Visualization of the ellipsoids in ParaView.

We can see the equivalent visualization produced by ParaView in Figure 3. Once again, the data are loaded directly into ParaView, passed through a Calculator filter, and then passed into a Tensor Glyph. The shapes of the ellipsoids are produced accurately, though the process is slightly slower than VisIt. However, ParaView has several advantages over VisIt:

  • The glyph resolution can be changed
  • The glyphs can be colored with a scalar variable (in this case, the -velocity)
  • The glyphs can be scaled more easily than with VisIt.


The approach we have used is a quick and dirty way of visualizing ellipsoids in VisIt and ParaView without having to compile and link plugins, a nontrivial task. We suggest this approach for visualizations of DEM ellipsoids where a large number of particles need to be viewed as a function of time.

If you have questions/comments/corrections, please contact banerjee at parresianz dot com dot zen (without the dot zen).