Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
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
1 change: 1 addition & 0 deletions doc/changelog.d/4994.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add BaseSession changes
27 changes: 27 additions & 0 deletions src/ansys/fluent/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,33 @@ def id(self) -> str:
"""Return the session ID."""
return self._fluent_connection._id

@property
def precision(self) -> int:
"""Return the current solver precision.

Returns
-------
int
``1`` for single precision, ``2`` for double precision.
"""
return 2 if self.scheme.eval("(rp-double?)") else 1

@property
def dimension(self) -> int:
"""Return the current dimensionality.

Returns
-------
int
``2`` for 2D, ``3`` for 3D.
"""
return 3 if self.scheme.eval("(rp-3d?)") else 2
Comment on lines +315 to +335
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should return the enums no?


@property
def processor_count(self) -> int:
"""Return the current processor count."""
return int(str(self.rp_vars("parallel/nprocs_string")).strip('"'))

def start_journal(self, file_name: str):
"""Executes tui command to start journal."""
warnings.warn("Use -> journal.start()", PyFluentDeprecationWarning)
Expand Down
13 changes: 7 additions & 6 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,17 @@ def test_additional_arguments_fluent_launch_args_string():


def test_processor_count():
def get_processor_count(solver):
return int(solver.rp_vars("parallel/nprocs_string").strip('"'))

grpc_kwds = get_grpc_launcher_args_for_gh_runs()
with pyfluent.launch_fluent(processor_count=2, **grpc_kwds) as solver:
assert get_processor_count(solver) == 2
with pyfluent.launch_fluent(
dimension=2, precision="single", processor_count=2, **grpc_kwds
) as solver:
assert solver.dimension == 2
assert solver.precision == 1
assert solver.processor_count == 2
# The following check is not yet supported for container launch
# https://github.com/ansys/pyfluent/issues/2624
# with pyfluent.launch_fluent(additional_arguments="-t2") as solver:
# assert get_processor_count(solver) == 2
# assert solver.processor_count == 2


def test_container_mount_source_target(caplog):
Expand Down
Loading