You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to save pictures of a scene for different states as shown in the code below. It only works if I enable scene_test.display(). In the background the GUI internally sets the camera according to the state and then saves the picture. This happens even without the GUI. However, it adds a lot of run time to the code. Is there a way to make this process faster?
import ansys.fluent.core as pyfluent
session = pyfluent.launch_fluent(precision="double", processor_count=16, dimension = None, ui_mode="gui")
import_filename = r"..\file_name.cas.h5"
session.file.read_case_data(file_name = import_filename )
# Define the configurations
configurations = [
"state_custom_y-10_z-5", "state_custom_y-10_z-2.5", "state_custom_y-10_z0", "state_custom_y-10_z2.5", "state_custom_y-10_z5",
"state_custom_y-5_z-5", "state_custom_y-5_z-2.5", "state_custom_y-5_z0", "state_custom_y-5_z2.5", "state_custom_y-5_z5",
"state_custom_y0_z-5", "state_custom_y0_z-2.5", "state_custom_y0_z0", "state_custom_y0_z2.5", "state_custom_y0_z5",
"state_custom_y5_z-5", "state_custom_y5_z-2.5", "state_custom_y5_z0", "state_custom_y5_z2.5", "state_custom_y5_z5",
"state_custom_y10_z-5", "state_custom_y10_z-2.5", "state_custom_y10_z0", "state_custom_y10_z2.5", "state_custom_y10_z5"
]
# Set the graphics resolution
graphics = session.settings.results.graphics
if graphics.picture.use_window_resolution.is_active():
graphics.picture.use_window_resolution = True
# graphics.picture.x_resolution = 3840
# graphics.picture.y_resolution = 2880
# Create the scene
session.results.scene["scene-test-vanes"] = {}
session.results.scene["scene-test-vanes"].title = "scene-test-vanes"
session.results.scene["scene-test-vanes"].graphics_objects["mesh-1"] = {}
session.results.scene["scene-test-vanes"].graphics_objects["mesh-2"] = {}
session.results.scene["scene-test-vanes"].graphics_objects["mesh-3"] = {}
session.results.scene["scene-test-vanes"].graphics_objects["mesh-4"] = {}
session.results.scene["scene-test-vanes"].graphics_objects["contour-ui-pd"] = {}
# Loop through each configuration and save the picture
for config in configurations:
session.results.scene["scene-test-vanes"].display_state_name = config
scene_test = session.results.scene["scene-test-vanes"]
scene_test.display()
file_name = rf"..\scene_{config}.png"
graphics.picture.save_picture(file_name=file_name)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I wanted to save pictures of a scene for different states as shown in the code below. It only works if I enable
scene_test.display()
. In the background the GUI internally sets the camera according to the state and then saves the picture. This happens even without the GUI. However, it adds a lot of run time to the code. Is there a way to make this process faster?Beta Was this translation helpful? Give feedback.
All reactions