Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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/5005.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated the session file
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This changelog entry is too vague to be useful in release notes. Please describe the user-visible documentation change more specifically (e.g., that session guide examples now use <session>.from_install()/from_container()/from_connection() rather than launch_fluent()), ideally as a complete sentence with a period to match nearby entries.

Suggested change
Updated the session file
Updated the session guide examples to use ``<session>.from_install()/from_container()/from_connection()`` instead of ``launch_fluent()``.

Copilot uses AI. Check for mistakes.
37 changes: 25 additions & 12 deletions doc/source/user_guide/session/session.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@
Using PyFluent sessions
=======================

You can obtain a PyFluent session object by calling either of the functions, :func:`launch_fluent()
<ansys.fluent.core.launcher.launcher.launch_fluent>` or :func:`connect_to_fluent() <ansys.fluent.core.launcher.launcher.connect_to_fluent>`.
The encouraged way to create a PyFluent session is to use the ``from_<...>`` class methods on a session type, for
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The encouraged way to create a PyFluent session is to use the ``from_<...>`` class methods on a session type, for
The recommended way to create a PyFluent session is to use the ``from_<...>`` class methods on a session type, for

Alternatively, we could omit that clause and launch straight into "Create a PyFluent session using the from_<...> class methods...". I think I prefer that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Noted.

example :meth:`Solver.from_install() <ansys.fluent.core.session_utilities.SessionBase.from_install>`,
:meth:`Solver.from_container() <ansys.fluent.core.session_utilities.SessionBase.from_container>`,
:meth:`Solver.from_connection() <ansys.fluent.core.session_utilities.SessionBase.from_connection>`, or
:meth:`Solver.from_pim() <ansys.fluent.core.session_utilities.SessionBase.from_pim>`.
For full details see :ref:`ref_launch_guide`.
Comment thread
mayankansys marked this conversation as resolved.
Outdated

For example, to launch a solver session from a local Fluent installation:

.. code:: python

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core.examples import download_file
>>> case_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
>>> data_file_name = download_file("mixing_elbow.dat.h5", "pyfluent/mixing_elbow")
>>> solver_session = pyfluent.launch_fluent(case_data_file_name=case_file_name)
>>> solver_session = pyfluent.Solver.from_install(case_file_name=case_file_name)

.. note::

You can also use the lower-level :func:`launch_fluent() <ansys.fluent.core.launcher.launcher.launch_fluent>`
and :func:`connect_to_fluent() <ansys.fluent.core.launcher.launcher.connect_to_fluent>` functions,
but the ``from_<...>`` class methods are recommended for new code.


Solution mode sessions
Expand Down Expand Up @@ -51,7 +61,7 @@ session that starts a second Fluent instance and is independent of your PyFluent
.. code:: python

>>> import ansys.fluent.core as pyfluent
>>> meshing_session = pyfluent.launch_fluent(mode=pyfluent.FluentMode.MESHING)
>>> meshing_session = pyfluent.Meshing.from_install()


A uniform interface exists across solver settings objects. For instance,
Expand Down Expand Up @@ -165,7 +175,7 @@ You can also create a :obj:`~ansys.fluent.core.session_pure_meshing.PureMeshing`
.. code:: python

>>> import ansys.fluent.core as pyfluent
>>> pure_meshing = pyfluent.launch_fluent(mode=pyfluent.FluentMode.PURE_MESHING)
>>> pure_meshing = pyfluent.PureMeshing.from_install()


The only difference between the two meshing session types is that a pure session cannot be
Expand Down Expand Up @@ -208,8 +218,8 @@ within its intended scope:
>>> from ansys.fluent.core.examples import download_file
>>> from ansys.fluent.core import using
>>> from ansys.fluent.core.solver import ReadCase, Viscous
>>> solver_session_1 = pyfluent.launch_fluent()
>>> solver_session_2 = pyfluent.launch_fluent()
>>> solver_session_1 = pyfluent.Solver.from_install()
>>> solver_session_2 = pyfluent.Solver.from_install()
>>> case_file = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
>>> with using(solver_session_1):
... ReadCase()(file_name=case_file)
Expand Down Expand Up @@ -295,9 +305,12 @@ each session can be ended independently of the others. Calling the ``exit()`` me


Each Fluent session terminates in this scenario because both PyFluent :ref:`Session <ref_session_guide>` objects were obtained by
calling the :func:`launch_fluent() <ansys.fluent.core.launcher.launcher.launch_fluent>` function. If the :func:`connect_to_fluent() <ansys.fluent.core.launcher.launcher.connect_to_fluent>` function were used instead, the
Fluent session would terminate upon the ``exit()`` method call if and only if the :func:`connect_to_fluent() <ansys.fluent.core.launcher.launcher.connect_to_fluent>`
function were called with the argument value ``cleanup_on_exit=True``.
using a ``from_<...>`` launch method (for example, :meth:`from_install() <ansys.fluent.core.session_utilities.SessionBase.from_install>`).
If :meth:`from_connection() <ansys.fluent.core.session_utilities.SessionBase.from_connection>` were used instead, the
Fluent session would not be terminated upon ``exit()`` by default.
For configurable cleanup behavior when attaching to an existing Fluent process,
use :func:`connect_to_fluent() <ansys.fluent.core.launcher.launcher.connect_to_fluent>`
directly with its ``cleanup_on_exit`` parameter.
Comment on lines 307 to +313
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

This paragraph clarifies that from_connection() / connect_to_fluent() (default cleanup_on_exit=False) won’t terminate Fluent on exit(), but the preceding sentence in this section still states that calling exit() terminates the connected Fluent sessions. Consider adjusting that earlier sentence to avoid implying termination is unconditional, and instead describe termination as dependent on cleanup_on_exit / launch method.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@mayankansys good point above


Session exiting can also happen implicitly when :ref:`Session <ref_session_guide>` objects are garbage collected. The same rules apply
regarding Fluent termination whether the exit is explicit via an ``<session>.exit()`` method call or implicit.
Expand All @@ -308,7 +321,7 @@ being garbage collected:
.. code:: python

>>> def run_solver():
>>> solver_session = pyfluent.launch_fluent()
>>> solver_session = pyfluent.Solver.from_install()
>>> # <insert some PyFluent solver actions>
>>> # solver is exited at the end of the function
Comment thread
mayankansys marked this conversation as resolved.

Expand Down
Loading