Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/ansys/fluent/core/session_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,24 @@ def from_connection(

Raises
------
RuntimeError
If trying to connect to a 'PureMeshing' session as it cannot
be separated from a 'Meshing' session.
TypeError
If the session type does not match the expected session type.
"""
expected = "Solver" if cls.__name__ == "PrePost" else cls.__name__
if expected == "PureMeshing":
raise RuntimeError(
"PureMeshing cannot be created using 'from_connection'. "
"Please use Meshing instead."
)
session = pyfluent.connect_to_fluent(
ip=ip,
port=port,
server_info_file_name=server_info_file_name,
password=password,
)

expected = "Solver" if cls.__name__ == "PrePost" else cls.__name__
actual = session.__class__.__name__

if actual != expected:
Expand Down
35 changes: 35 additions & 0 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,41 @@ def test_new_launch_fluent_api():
solver.exit()
solver_connected.exit()

solver_aero = pyfluent.SolverAero.from_install()
assert solver_aero.is_server_healthy()

ip = solver_aero.connection_properties.ip
port = solver_aero.connection_properties.port
password = solver_aero.connection_properties.password

solver_aero_connected = pyfluent.SolverAero.from_connection(
ip=ip, port=port, password=password
)
assert solver_aero_connected.is_server_healthy()

solver_aero.exit()
solver_aero_connected.exit()

meshing = pyfluent.Meshing.from_install()
assert meshing.is_server_healthy()

ip = meshing.connection_properties.ip
port = meshing.connection_properties.port
password = meshing.connection_properties.password

meshing_connected = pyfluent.Meshing.from_connection(
ip=ip, port=port, password=password
)
assert meshing_connected.is_server_healthy()

with pytest.raises(RuntimeError):
meshing_connected = pyfluent.PureMeshing.from_connection(
ip=ip, port=port, password=password
)

meshing.exit()
meshing_connected.exit()


def test_new_launch_fluent_api_from_container():
import ansys.fluent.core as pyfluent
Expand Down
Loading