Example Monitor Conversion#
This example demonstrates the conversion of legacy monitor point definitions, previously specified in a JSON format (v0), into the corresponding ProbeOutput objects compatible with the SimulationParams class used in the current Flow360 Python API. The script employs the helper function ProbeOutput.read_all_v0_monitors for this conversion process.
1import os
2
3import unyt as u
4
5from flow360.component.simulation.migration import ProbeOutput
6
7# Get the absolute path to the script file
8script_dir = os.path.dirname(os.path.abspath(__file__))
9# Change the current working directory to the script directory
10os.chdir(script_dir)
11
12my_monitor = ProbeOutput.read_all_v0_monitors(
13 file_path="./ProbeOutput_tutorial_Flow360.json", mesh_unit=u.m
14)
15
16print(my_monitor)
17
18"""
19with SI_unit_system:
20 params = fl.SimulationParams(
21 ...
22 outputs=[
23 ...
24 *my_monitor,
25 ...
26 ]
27 ...
28 )
29"""
Notes#
The script utilizes
ProbeOutput.read_all_v0_monitorsfrom theflow360.component.simulation.migrationmodule to facilitate the transition of monitor point definitions from the legacy JSON format.The resulting list of converted monitor objects can be directly incorporated into the
outputslist within aSimulationParamsinstance.