Biswajit Banerjee

### Particle data in VTK XML

Outputting simulation data in C++

In my previous post on writing VTK output files I described how mesh data can be output in VTK XML format. In this article I will talk about how I output particle data from my simulations.

These simulations use a number of techniques depending on the requirements. I use the MPM (Material Point Method) and RBD (Rigid body dynamics) with the occasional DEM (Discrete/Distict element method) and Peridynamics simulation. When I am running RBD or DEM simulations, the particles may have not spherical shapes and the shape and orientation information have to be encoded into the output data in addition to other physical state variables.

Note: The visualization of non-spherical particles in Visit/Paraview requires the implementation of a plugin that can perform the appropriate transformation. Alternatively, we can convert each particle into a surface mesh before writing the output. We will not discuss these issues at this stage. However, in future posts we will show how these plots can be generated using Javascript.

##### Particle data

We will assume that the particles are ellipsoids. The particle data that we will output in this example are:

• The particle ID
• The particle radii in the three principal axis directions
• The three principal axis orientations
• The particle position
• The particle velocity
##### Writing the particle data

To write the particles data to the disk, we follow the same approach as we did for the grid/mesh data in the previous post. The writeParticles function has the form

We have already seen the addTimeToVTKDataSet method in the previous post. The main difference in this case is the new addParticlesToVTKDataSet method:

You can see a working example of this approach in the Matiti code.

##### Displaying the output

The VTK XML file output to disk using this approach can be visualized in Visit or ParaView. Notice that we are not able to use the particle geometry and orientation information in either of these tools without extra work. The plot below shows the output of a rigid body dynamics simulation in the presence of Coriolis forces.

#### Remarks

Now that the basic input/output issues have been addressed, we will be able to explore possible designs of an integrated user interface to automate the generation of input files and perform simple visualizations of the results. Future blog posts will discuss our exploration of Javascript frameworks and libraries that can potentially aid this process.