Skip to content

Topological Optimization DarkSky

Topological Optimization DarkySky example Image

Pipeline description

This example simplifies all the persistence pairs below 25% of the maximum persistence of the density of dark matter in an astrophysics simulation.

This example first loads the point cloud then applies a gaussian resampling to create a scalar field defined on a regular grid. Then the scalar field is smoothed with ScalarFieldSmoother (with 5 iterations). The persistence diagram is computed using PersistenceDiagram and then thresholded to create a target diagram where the persistence pairs having persistence below 25% of the maximum persistence are removed. Finally, using the topological optimization backend of TopologicalSimplification, it optimizes the scalar field to remove, as much as possible, the pairs which are not in the target diagram.

The python script computes the topological optimization and saves the optimized scalar field.

Note that the optimization will take a long time (typically, around 40 minutes). For interactive visualization purposes, we suggest to first run the optimization in batch mode with pvpython (see instructions below) and then run the post-process visualization state topologicalOptimization_darkSky_postProcess.pvsm (see instructions below).

ParaView

To reproduce the above screenshot (and run the optimization online, around 40 minutes), go to your ttk-data directory and enter the following command:

paraview states/topologicalOptimization_darkSky.pvsm

If you have already computed the optimization with pvpython (see instructions below), simply enter:

paraview states/topologicalOptimization_darkSky_postProcess.pvsm

Python code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
from paraview.simple import *

# create a new 'XML PolyData Reader'
ds14_scivis_0128_e4_dt04_10000vtp = XMLPolyDataReader(
    FileName=["./ds14_scivis_0128_e4_dt04_1.0000.vtp"]
)
ds14_scivis_0128_e4_dt04_10000vtp.PointArrayStatus = ["DarkMatter_Phi"]

# create a new 'Gaussian Resampling'
gaussianResampling1 = GaussianResampling(Input=ds14_scivis_0128_e4_dt04_10000vtp)
gaussianResampling1.ResampleField = ["POINTS", "DarkMatter_Phi"]
gaussianResampling1.ResamplingGrid = [256, 256, 256]
gaussianResampling1.GaussianSplatRadius = 0.008
gaussianResampling1.ScaleSplats = 0
gaussianResampling1.EllipticalSplats = 0
gaussianResampling1.FillVolumeBoundary = 0

# create a new 'TTK ScalarFieldSmoother'
tTKScalarFieldSmoother1 = TTKScalarFieldSmoother(Input=gaussianResampling1)
tTKScalarFieldSmoother1.ScalarField = ["POINTS", "SplatterValues"]
tTKScalarFieldSmoother1.IterationNumber = 5

# create a new 'TTK PersistenceDiagram'
tTKPersistenceDiagram1 = TTKPersistenceDiagram(Input=tTKScalarFieldSmoother1)
tTKPersistenceDiagram1.ScalarField = ["POINTS", "SplatterValues"]

# create a new 'Threshold'
threshold1 = Threshold(Input=tTKPersistenceDiagram1)
threshold1.Scalars = ["CELLS", "Persistence"]
threshold1.LowerThreshold = 0.25
threshold1.UpperThreshold = 2.0

# create a new 'TTK TopologicalSimplification'
tTKTopologicalSimplification1 = TTKTopologicalSimplification(
    Domain=tTKScalarFieldSmoother1, Constraints=threshold1
)
tTKTopologicalSimplification1.ScalarField = ["POINTS", "SplatterValues"]
tTKTopologicalSimplification1.Backend = "Topological Optimization (IEEE VIS 2024)"
tTKTopologicalSimplification1.StoppingConditionCoefficient = 0.0001
tTKTopologicalSimplification1.GradientStepSize = 0.75

# save the output
SaveData("darkSky_optimized.vti", tTKTopologicalSimplification1)

To run the above Python script, go to your ttk-data directory and enter the following command (around 40 minutes of runtime):

pvpython python/topologicalOptimization_darkSky.py

Inputs

Outputs

  • darkSky_optimized.vti: the optimized dataset.

C++/Python API

MorseSmaleComplex

PersistenceDiagram

ScalarFieldSmoother

TopologicalSimplification