Skip to content

Commit 233e022

Browse files
LasNikasLasNikas
andauthored
Visualization doc: How to scale point size in ParaView (trixi-framework#779)
* revise doc * fix typos * add macro * change suggestions --------- Co-authored-by: LasNikas <niklas.nehe@web.de>
1 parent 590bd0d commit 233e022

File tree

1 file changed

+58
-3
lines changed

1 file changed

+58
-3
lines changed

docs/src/visualization.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,65 @@ Follow these steps to view the exported VTK files in ParaView:
1818
You will now see the following:
1919
![image](https://github.com/user-attachments/assets/383d323a-3020-4232-9dc3-682b0afe8653)
2020

21-
It is useful to make the particles larger.
22-
For this, **first** make sure you have "fluid_1.pvd" highlighted in the "Pipeline Browser" then in the "Properties" window in the bottom left change "Point Size" to a larger value.
23-
![image](https://github.com/user-attachments/assets/6e975d2c-82ed-4d53-936b-bb0beafaf515)
21+
It is useful to make the dot size dependent on the actual particle size.
22+
For this, first make sure you have "fluid_1.pvd" highlighted in the "Pipeline Browser".
23+
Then, in the Properties panel (bottom left), adjust the following settings:
24+
1. "Representation" to "Point Gaussian".
25+
2. Choose the right "Shader Preset": "Plain Circle" for 2D and "Sphere" for 3D.
26+
3. Activate "Scale by Array" and select "`particle_spacing`" in "Gaussian Scale Array".
27+
4. Deactivate "Use Scale Function".
28+
5. Set the "Gaussian Radius" to "`0.5`".
29+
![image](https://github.com/user-attachments/assets/194d9a09-5937-4ee4-b229-07078afe3ff0)
2430

31+
#### Visualization with Macro
32+
To simplify the visualization of your particle data in ParaView, you can use a macro.
33+
This macro automates the manual steps in the previous section to a single click of a button.
34+
Install the macro as follows.
35+
36+
1. **Save the macro code** (see below) as a `.py` file, e.g. `PointGaussianMacro.py`.
37+
2. Open **ParaView** and go to the top menu:
38+
**Macros****Import New Macro...** → Select the saved `.py` file.
39+
3. The macro will now appear in the **Macros** menu and can optionally be pinned to the **toolbar**.
40+
4. **Load your dataset** into ParaView.
41+
5. **Select the dataset** in the Pipeline Browser.
42+
6. Click on the macro name in the **Macros** menu (or toolbar, if pinned) to run it.
43+
7. The Point Gaussian representation with `particle_spacing` scaling will be applied automatically.
44+
45+
46+
---
47+
48+
#### Macro Code
49+
50+
```python
51+
# trace generated using paraview version 5.13.1
52+
#from paraview
53+
#paraview.compatibility.major = 5
54+
#paraview.compatibility.minor = 13
55+
56+
from paraview.simple import *
57+
paraview.simple._DisableFirstRenderCameraReset()
58+
59+
# get active source
60+
source = GetActiveSource()
61+
62+
# get active view
63+
renderView1 = GetActiveViewOrCreate('RenderView')
64+
65+
# get display properties
66+
sourceDisplay = GetDisplayProperties(source, view=renderView1)
67+
68+
# change representation type
69+
sourceDisplay.SetRepresentationType('Point Gaussian')
70+
71+
# modified display properties
72+
sourceDisplay.ShaderPreset = 'Plain circle' # for 2D, change to 'Sphere' for 3D
73+
sourceDisplay.ScaleByArray = 1
74+
sourceDisplay.SetScaleArray = ['POINTS', 'particle_spacing']
75+
sourceDisplay.UseScaleFunction = 0
76+
sourceDisplay.GaussianRadius = 0.5
77+
```
78+
79+
#### Show results
2580
To now view the result variables **first** make sure you have "fluid_1.pvd" highlighted in the "Pipeline Browser" then select them in the variable selection combo box (see picture below).
2681
Let's, for example, pick "density". To now view the time progression of the result hit the "play button" (see picture below).
2782
![image](https://github.com/user-attachments/assets/10dcf7eb-5808-4d4d-9db8-4beb25b5e51a)

0 commit comments

Comments
 (0)