Skip to content

Commit

Permalink
test: Add a test for System Coupling related settings (#2812)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
3 people authored May 16, 2024
1 parent c23aab7 commit 2f038e8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/ansys/fluent/core/systemcoupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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()
Expand Down
16 changes: 16 additions & 0 deletions tests/test_systemcoupling.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2f038e8

Please sign in to comment.