Open
Description
This issue pertains to the Observing Events example in the PyFluent documentation.
Current Example Code:
@execute_in_event_loop_threadsafe
def initialize_call_back(session, event_info: SolutionInitializedEventInfo | DataLoadedEventInfo):
pyvista_windows_manager.refresh_windows(session.id, ["contour-1", "contour-2"])
matplot_windows_manager.refresh_windows("", ["residual"])
callback_init_id = solver.events.register_callback(SolverEvent.SOLUTION_INITIALIZED, initialize_call_back)
Proposed Improvements:
-
Avoid referencing old-style visualization interactions.
- The example currently references
pyvista_windows_manager
andmatplot_windows_manager
, which may not align with the modern API direction. If visualization is necessary in the example, consider a more generic, high-level approach.
- The example currently references
-
Rename
initialize_call_back()
for clarity.- The function name should describe its purpose. A more intuitive name, such as
refresh_windows()
, would improve readability.
- The function name should describe its purpose. A more intuitive name, such as
-
Use
callback=
explicitly inregister_callback()
.- Instead of
solver.events.register_callback(SolverEvent.SOLUTION_INITIALIZED, initialize_call_back)
, write:solver.events.register_callback(SolverEvent.SOLUTION_INITIALIZED, callback=refresh_windows)
- This makes it clearer that the second argument is the callback function.
- Instead of
-
Remove
callback_init_id
if unused.- Since
callback_init_id
is not used after assignment, it should be omitted to avoid confusion.
- Since
Metadata
Metadata
Assignees
Type
Projects
Status
2025 Q2 Apr - Jun