From a42a081438c46849f24cc0320f34841dc25f53fa Mon Sep 17 00:00:00 2001 From: Mainak Kundu <94432368+mkundu1@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:01:46 -0500 Subject: [PATCH] test: Add test for accessing udm svar data (#3555) --- tests/conftest.py | 15 +++++++++++++++ tests/test_solution_variables.py | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 14180cdf200..d55e3c903dd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -283,6 +283,13 @@ def new_solver_session(): solver.exit() +@pytest.fixture +def new_solver_session_t4(): + solver = create_session(processor_count=4) + yield solver + solver.exit() + + @pytest.fixture def new_solver_session_sp(): solver = create_session(precision="single") @@ -329,6 +336,14 @@ def mixing_elbow_settings_session(new_solver_session): return solver +@pytest.fixture +def mixing_elbow_case_session_t4(new_solver_session_t4): + solver = new_solver_session_t4 + case_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow") + solver.settings.file.read(file_type="case", file_name=case_name) + return solver + + @pytest.fixture def mixing_elbow_case_data_session(new_solver_session): solver = new_solver_session diff --git a/tests/test_solution_variables.py b/tests/test_solution_variables.py index 68da304e901..2c7d3d5d24e 100644 --- a/tests/test_solution_variables.py +++ b/tests/test_solution_variables.py @@ -212,3 +212,30 @@ def test_solution_variable_does_not_modify_case(new_solver_session): domain_name="mixture", ) assert not solver.scheme_eval.scheme_eval("(case-modified?)") + + +@pytest.mark.fluent_version(">=25.2") +def test_solution_variable_udm_data(mixing_elbow_case_session_t4): + solver = mixing_elbow_case_session_t4 + solver.tui.define.user_defined.user_defined_memory("2") + solver.settings.solution.initialization.hybrid_initialize() + solver.settings.solution.run_calculation.iterate(iter_count=1) + udm_data = solver.fields.solution_variable_data.get_data( + solution_variable_name="SV_UDM_I", + domain_name="mixture", + zone_names=["wall-elbow"], + )["wall-elbow"] + np.testing.assert_array_equal(udm_data, np.zeros(4336)) + udm_data[:2168] = 5 + udm_data[2168:] = 10 + solver.fields.solution_variable_data.set_data( + solution_variable_name="SV_UDM_I", + domain_name="mixture", + zone_names_to_solution_variable_data={"wall-elbow": udm_data}, + ) + new_array = solver.fields.solution_variable_data.get_data( + solution_variable_name="SV_UDM_I", + domain_name="mixture", + zone_names=["wall-elbow"], + )["wall-elbow"] + np.testing.assert_array_equal(new_array, udm_data)