Dear Ansys Developers,
I am building a topology optimization toolchain using Python as the outer optimization driver and Fluent 2025 R2 for the primal/adjoint solves. I am using PyFluent to directly inject initialization fields (e.g., γ, α, k) into Fluent’s User Defined Memory (UDM) blocks via the solution_variable_data API.
The Issue:
When I attempt to push data into SV_UDM_I with 1 UDM allocated, the data maps perfectly to the cell coordinates (creating my desired structured pin geometry). However, when 3 (or more) UDMs are allocated, the exact same injection method results in scrambled, randomized data across the domain.
It appears the gRPC bridge is failing to correctly map or serialize the multi-dimensional interleaved/sequential memory blocks when SetSvarData is called for multiple UDMs, resulting in fields bleeding into each other.
My Injection Command:
# arr_udm_flat is a 1D numpy float64 array sized (num_cells * num_udms)
solver.fields.solution_variable_data.set_data(
variable_name="SV_UDM_I",
zone_names_to_data={zone_name: arr_udm_flat},
domain_name=domain_name
)
Environment:
Fluent 2025 R2 (3D, Double Precision, 8 parallel processes)
ansys-fluent-core versions tested: v0.35.0, v0.39.1, v0.40.1
What I have tried (none of which resolved the scrambling with 3+ UDMs):
Array Shaping: Attempted pushing standard 1D flattened arrays, Interleaved (num_cells, 3) 2D tensors, and Sequential (3, num_cells) 2D tensors.
Ghost Cell Padding: Explicitly sized the NumPy array to match Fluent's total allocated memory (including partition ghost cells) rather than just the active cell count.
Alternative APIs: Attempted to bypass SV_UDM_I by using field_data.set_scalar_field_data("user-memory-0", ...) for individual injections, but this method is deprecated/unavailable in newer PyFluent builds for Cell Zones.
- Bypass the "solver.fields.solution_variable_data.set_data" method and use a User Defined Function based on txt files saved to hard disk --> also the same read-in error in case of more than one .
Attachments:
PIC1) Target_Distribution.png: The successful geometric distribution when only 1 UDM is allocated.
PIC2) Scrambled_Multiple_UDMs.png: The randomized data corruption that occurs when 3 UDMs are allocated and pushed.
PIC3) Fluent visualization of well injected UDM, in case there is only one UDM defined
Code_Snippet.py: My minimal reproducible example for centroid extraction and UDM injection.




Has anyone successfully injected multi-column data into SV_UDM_I using recent PyFluent builds, or is there a specific undocumented array shape/stride required by the gRPC serializer for multiple UDMs? Any guidance is appreciated.