Export to VTK¶
Use VTK export when you want to inspect results in ParaView or another scientific visualization tool.
Basic export¶
import os
from openkarst.io import VtkDataExporter
results = flow.run_simulation(desired_outputs=outputs)
Q_history = results["flowrates"]
y_history = results["water_depths"]
t_history = results["time"]
output_dir = os.path.join(os.getcwd(), "vtk_output")
vtk_exporter = VtkDataExporter(output_dir)
vtk_exporter.export(network, Q_history, y_history, t_history)
Mark inlet and outlet nodes¶
vtk_exporter.export(
network,
Q_history,
y_history,
t_history,
inflow_nodes=[0],
outflow_nodes=[19],
)
This also writes a static marker file for inlet and outlet nodes.
Exported fields¶
| Field | VTK location |
|---|---|
| Flow rate | conduit/cell data |
| Water depth | node/point data |
| Roughness | conduit/cell data, if available |
| Diameter | conduit/cell data, if available |
| Time | field data |
ParaView workflow¶
- Open the generated
output_timestep_*.vtkfiles. - Apply time-aware loading if ParaView detects the sequence.
- Color conduits by
Flowrate. - Color nodes or points by
WaterDepth. - Load
static_node_markers.vtkif inlet/outlet labels are helpful.