In this section, we provide a basic introduction to ParaView. This tutorial is designed to give you a quick start on creating plots of the results generated by Sapphire++. We will use the output generated by the quick-start example for illustration.
This tutorial is not intended to be a comprehensive introduction to ParaView. For a more detailed guide, please refer to the ParaView User Guide. We want to clarify that all tasks presented here can also be accomplished using VisIt. The author does not express any preference for ParaView over VisIt. The example images in this tutorial use ParaView Version 5.12.1 on macOS. Please note that the interface may be subject to alterations.
Install ParaView
To install ParaView, you can download the latest version on the ParaView download page. On most Linux systems you can alternatively use the package manager, e.g.,
sudo apt-get install paraview
On macOS, you can use Homebrew to install ParaView:
brew install --cask paraview
As an alternative, ParaView can be installed using conda/conda-forge.
conda create --name ParaView python=3.13
conda activate ParaView
conda install paraview
Open Files
After launching ParaView, follow these steps to open the results generated by the quick-start example:
Open File Dialog: Click Open to open the file selection dialog.

- Navigate to Results Folder: Browse to the results folder located at /path/to/sapphirepp/results/01.
- Select Files: Select the solution_*.pvtu files as a Group to open the results as a time-series.
Confirm Selection: Click OK to confirm and load the selected files.

Visualize the Data as a 2D Plot
To get an initial impression of the data, we will visualize it in a 2D plot. As discussed in the quick-start, the x-axis in this plot corresponds to the spatial variable \(x\), while the y-axis represents the momentum component \(\ln p\).
- Display the Data: Click Apply to display the data. Initially, this will show the 2D data plane without any coloring.
- Plot \(f_{000}(x, \ln p)\): To create a false color plot of the isotropic component \(f_{000}(x, \ln p)\), select f_000 as the quantity to display.
Animate Time Evolution: Click Play to animate through the different time steps.

- Adjust Visible Data Range: If the displayed results look incorrect, it may be because the visible data range does not match the actual data range. To fix this, click Rescale to Data Range.
Update Color Map: The color map will adjust accordingly, now showing meaningful values that represent the results.

Create f(x) Plot
To visualize a cut-out of the data along the x-axis, follow these steps:
- Plot Over Line: Click on Plot Over Line to create a line along which ParaView will generate a cut-out of the data.
- Align Line with X-Axis: Align the line along the x-axis by clicking X-Axis.
- Shift the Line: To avoid sampling values exactly along a cell boundary, we recommend shifting the line slightly in the y-direction. Adjust the y-values of the start and end points, Point1 and Point2, to achieve this. For more details on this practice, refer to the Tips and Tricks for Visualization section.
Apply Changes: Click Apply to apply the changes.

- Line Chart View: A new window with a LineChartView is created, showing the data along the defined line.
- X-Axis Values: You might notice that the values on the x-axis do not represent the x-coordinate. Instead, they show the arc_length, the length along the line.
- Adjust X-Axis: To adjust the values along the x-axis, change the X Array Name to Points_X.
Reset View: The line chart plot might now show the wrong data range for the x-coordinates. To adjust the view, click Reset.

The line plot now shows all coefficients \(f_{lms}(x)\) (plus the additional quantity subdomain). Since only \(f_{000}\) and \(f_{100}\) are non-zero, we want to remove the other quantities from the plot to improve readability. Follow these steps:
- Select Data Object: In the Pipeline Browser, select solution_0000.pvtu* to modify the quantities related to the data object.
- Select Arrays: In the Properties window, select only f_000 and f_100 to be displayed. Deactivate all other quantities.
- Apply Changes: Click Apply to apply the changes.
Legend: The legend will now only show the f_000 and f_100 components.

Create f(p) Plot
Next, we want to create a plot of \(p^4 f_{000}(p)\). Scaling by \(p^4\) helps in visualizing the \(f_{000}(p) \propto p^{-4}\) power law more effectively. To generate this plot, we first need to calculate the quantity \(p^4 f_{000}\):
- Select Render View: Click on RenderView1 to ensure it is selected before proceeding.
- Select Data Object: In the Pipeline Browser, select solution_0000.pvtu* to start from the original data for calculating the derived quantity \(p^4 f_{000}\).
Create Calculator: Click on Filters > Common > Calculator to create a new calculator object.

- Enter Equation: In the equation field, enter the following expression: exp(4*CoordsY) * f_000. Here, CoordsY represents the y-coordinate, i.e., \(\ln p\). You can see a list of available quantities in the calculator by clicking on Scalars.
- Enter Array Name: In the Result Array Name field, enter a name for the result. LaTeX is supported, so we use $p^4 f_{000}$.
Apply the Change: Click on Apply to apply the changes. The 2D plot will now show a second color bar displaying \(p^4 f_{000}\).

To create a line plot along the \(\ln p\)-axis, we can follow a similar procedure as before:
- Plot Over Line: Click on Plot Over Line to create a new line for a cut-out of the data.
- Align Line with Y-Axis: Align the line along the y-axis/ \(\ln p\)-axis by clicking Y-Axis.
- Shift the Line: To avoid sampling values exactly along a cell boundary, shift the line slightly in the x-direction by adjusting the x-values of the start and end points, Point1 and Point2.
Apply Changes: Click Apply to apply the changes.

- Line Chart View: A new window with a LineChartView is created, showing the data along the defined line.
- Adjust X-Axis: Change the X Array Name to Points_Y to adjust the values along the x-axis, corresponding to \(\ln p\).
- Filter Quantities: To display only the \(p^4 f_{000}\) quantity, deactivate f_000 and f_100 in the Series Parameters selection.
Reset View: Click Reset to adjust the view.

For better visualization, we want to use a log-log plot. The x-axis, \(\ln p\), is already a logarithmic variable, but we can use built-in ParaView features to scale the y-axis logarithmically. Follow these steps:
- Set Custom Range for Y-Axis: Click on Left Axis Custom Range to enable custom range settings for the y-axis.
- Enter Minimum Value: In the Left Axis Range Minimum field, enter a value, e.g., 1e-2, to ensure that only positive values are shown. This step is crucial to avoid error warnings in the next step.
- Enable Log Scale: Click on Left Axis Log Scale to set the y-axis to a logarithmic scale.
- Apply Changes: Click Apply to apply the changes.
Logarithmic Y-Axis: The y-axis of the \(p^4 f_{000}(p)\) plot is now displayed in logarithmic scale.

In the plot, you might notice some unusual artefacts and discontinuities. These artefacts appear when trying to visualize the discontinuous Galerkin results produced by Sapphire++. The section on Visualization Tips and Tricks discusses this topic in detail. In our case, there is an easy way to get rid of these artefacts. However, note that this trick might not always work:
- Change Sampling Pattern: Change the Sampling Pattern to Sample At Segment Centers.
- Apply Changes: Click Apply to apply the changes.
Artefact-Free Plot: The artefacts should now disappear, resulting in a continuous line plot.

Save the Plot
As a final step, we need to save and export the plot. Using the 2D plot as an example, we first need to label the axes:
- Select 2D Plot: Click on RenderView to ensure the 2D plot is selected.
- Select Data to View: In the Pipeline Browser, deactivate the PlotOverLine and Calculator objects to display only the original data.
- Activate Grid: Enable the grid by clicking on Data Axes Grid.
- Open Grid Editor: Click on Data Axes Grid > Edit to open the grid editor.
- Edit the Labels: Adjust the Title Texts for the axes. LaTeX is supported, so we can use $x$ for the X Title and $\ln p$ for the Y Title.
Confirm Changes: Click OK to apply the changes.

Next, we change to a logarithmic color map.
- Set Custom Data Range: Click on Rescale to Custom Data Range to open a dialog for entering the data range.
- Disable automatic rescaling: Disable the Enable automatic rescale feature.
- Enter Data Range: Enter a strictly positive data range, e.g. from 1e-2 to 10. This step is crucial to avoid error warnings when using a logarithmic color map.
Apply Changes: Click Ok to apply the changes.

- Open Color Map Editor: Click on Edit Color Map to open the Color Map Editor.
- Color Map Editor: A new window, the Color Map Editor is created.
- Logarithmic Color Map: To use a logarithmic color map, click on Use Log Scale When Mapping Data To Colors.
- Change Color Map: To use a perceptually uniform color map, change to the Virdis (matplotlib) color map.
Close Color Map Editor: Close the Color Map Editor by clicking on x.

Finally, we can export the plot as an image and explore other useful features:
- Export Plot: Click on File > Save Screenshot... to open a file dialog and save the plot as a .png or other image format.
- Save State: Use File > Save State... to save the current state of the ParaView session. This allows you to close ParaView and continue your work later.
Load State: Use File > Load State... to resume your work from where you left off.

- Author
- Florian Schulze (flori.nosp@m.an.s.nosp@m.chulz.nosp@m.e@mp.nosp@m.i-hd..nosp@m.mpg..nosp@m.de)
- Date
- 2024-07-31