From 2f038e8a94bf2bb47e746e6be26c092ca13e6202 Mon Sep 17 00:00:00 2001 From: Oleg Chernukhin <92750311+ochernuk@users.noreply.github.com> Date: Thu, 16 May 2024 12:18:42 -0400 Subject: [PATCH] test: Add a test for System Coupling related settings (#2812) * test: Add a test for System Coupling related settings * fix: proper path for system coupling test (#2829) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Raphael Luciano --- src/ansys/fluent/core/systemcoupling.py | 14 ++++++++++++-- tests/test_systemcoupling.py | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/test_systemcoupling.py diff --git a/src/ansys/fluent/core/systemcoupling.py b/src/ansys/fluent/core/systemcoupling.py index 039e100c170..e8117f92b6d 100644 --- a/src/ansys/fluent/core/systemcoupling.py +++ b/src/ansys/fluent/core/systemcoupling.py @@ -5,6 +5,7 @@ from typing import List import xml.etree.ElementTree as XmlET +import ansys.fluent.core as pyfluent from ansys.fluent.core.utils.fluent_version import FluentVersion @@ -89,13 +90,22 @@ def get_scp_string() -> str: file_name=scp_file_name ) - # download the file locally in case Fluent is in a container if self._solver._fluent_connection._remote_instance != None: + # download the file locally in case Fluent is remote + # assume file transfer service is configured - download the file self._solver.download(scp_file_name) + elif self._solver.connection_properties.inside_container: + # Right now, the way that PyFluent containers and tests are set up, + # the local Fluent container working directory will correspond to + # pyfluent.EXAMPLES_PATH in the host, so that is where the SCP file + # will be written. + examples_path_scp = os.path.join(pyfluent.EXAMPLES_PATH, scp_file_name) + if os.path.exists(examples_path_scp): + scp_file_name = examples_path_scp assert os.path.exists( scp_file_name - ), "ERROR: could not create System Coupling SCP file" + ), f"ERROR: could not create System Coupling SCP file: {scp_file_name}" with open(scp_file_name, "r") as f: xml_string = f.read() diff --git a/tests/test_systemcoupling.py b/tests/test_systemcoupling.py new file mode 100644 index 00000000000..86223bd1b54 --- /dev/null +++ b/tests/test_systemcoupling.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.fluent_version(">=24.1") +def test_systemcoupling_mixing_elbow_settings(load_mixing_elbow_case_dat): + """Very superficial test of System Coupling related settings.""" + solver = load_mixing_elbow_case_dat + # check participant type, analysis type, regions, and variables + assert solver.system_coupling.participant_type == "FLUENT" + assert solver.system_coupling.get_analysis_type() == "Steady" + regions = solver.system_coupling.get_regions() + variables = solver.system_coupling.get_variables() + # [wall-inlet, wall-elbow, elbow-fluid, hot-inlet, cold-inlet, outlet] + assert len(regions) >= 6 + # [force, dsip, temp, htc, hflow, nwt, hrate, cond, lorentz-force] + assert len(variables) >= 9