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
3from flow360.component.simulation.migration import ProbeOutput
4from flow360.component.simulation.unit_system import u
5
6# Get the absolute path to the script file
7script_dir = os.path.dirname(os.path.abspath(__file__))
8# Change the current working directory to the script directory
9os.chdir(script_dir)
10
11my_monitor = ProbeOutput.read_all_v0_monitors(
12 file_path="./ProbeOutput_tutorial_Flow360.json", mesh_unit=u.m
13)
14
15print(my_monitor)
16
17"""
18with SI_unit_system:
19 params = fl.SimulationParams(
20 ...
21 outputs=[
22 ...
23 *my_monitor,
24 ...
25 ]
26 ...
27 )
28"""
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.