ansys-fluent-core 0.31.dev1__py3-none-any.whl → 0.31.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansys-fluent-core might be problematic. Click here for more details.

Files changed (59) hide show
  1. ansys/fluent/core/__init__.py +11 -3
  2. ansys/fluent/core/codegen/settingsgen.py +6 -0
  3. ansys/fluent/core/codegen/tuigen.py +1 -2
  4. ansys/fluent/core/docker/docker_compose.py +243 -0
  5. ansys/fluent/core/field_data_interfaces.py +6 -0
  6. ansys/fluent/core/file_session.py +158 -128
  7. ansys/fluent/core/filereader/data_file.py +11 -0
  8. ansys/fluent/core/filereader/pre_processor.py +22 -0
  9. ansys/fluent/core/fluent_connection.py +48 -20
  10. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  11. ansys/fluent/core/generated/datamodel_231/flicing.py +35 -35
  12. ansys/fluent/core/generated/datamodel_231/meshing.py +189 -189
  13. ansys/fluent/core/generated/datamodel_232/flicing.py +35 -35
  14. ansys/fluent/core/generated/datamodel_232/meshing.py +237 -237
  15. ansys/fluent/core/generated/datamodel_241/flicing.py +45 -45
  16. ansys/fluent/core/generated/datamodel_241/meshing.py +295 -295
  17. ansys/fluent/core/generated/datamodel_242/flicing.py +60 -60
  18. ansys/fluent/core/generated/datamodel_242/meshing.py +285 -285
  19. ansys/fluent/core/generated/datamodel_242/part_management.py +6 -6
  20. ansys/fluent/core/generated/datamodel_251/flicing.py +55 -55
  21. ansys/fluent/core/generated/datamodel_251/meshing.py +370 -370
  22. ansys/fluent/core/generated/datamodel_251/part_management.py +6 -6
  23. ansys/fluent/core/generated/datamodel_252/flicing.py +55 -55
  24. ansys/fluent/core/generated/datamodel_252/meshing.py +790 -428
  25. ansys/fluent/core/generated/datamodel_252/part_management.py +10 -10
  26. ansys/fluent/core/generated/datamodel_252/preferences.py +1 -1
  27. ansys/fluent/core/generated/fluent_version_252.py +4 -4
  28. ansys/fluent/core/generated/meshing/tui_252.py +1133 -1178
  29. ansys/fluent/core/generated/solver/settings_252.py +2241 -1649
  30. ansys/fluent/core/generated/solver/settings_252.pyi +1785 -1430
  31. ansys/fluent/core/generated/solver/settings_builtin.pyi +104 -0
  32. ansys/fluent/core/generated/solver/tui_252.py +2174 -2005
  33. ansys/fluent/core/launcher/container_launcher.py +39 -8
  34. ansys/fluent/core/launcher/fluent_container.py +61 -22
  35. ansys/fluent/core/launcher/launcher.py +24 -13
  36. ansys/fluent/core/launcher/launcher_utils.py +8 -0
  37. ansys/fluent/core/launcher/process_launch_string.py +2 -6
  38. ansys/fluent/core/launcher/slurm_launcher.py +1 -0
  39. ansys/fluent/core/report.py +2 -0
  40. ansys/fluent/core/services/deprecated_field_data.py +74 -46
  41. ansys/fluent/core/services/field_data.py +104 -69
  42. ansys/fluent/core/services/reduction.py +55 -66
  43. ansys/fluent/core/services/solution_variables.py +9 -1
  44. ansys/fluent/core/session.py +15 -12
  45. ansys/fluent/core/session_meshing.py +3 -0
  46. ansys/fluent/core/session_solver.py +20 -43
  47. ansys/fluent/core/session_utilities.py +429 -0
  48. ansys/fluent/core/solver/flobject.py +28 -0
  49. ansys/fluent/core/utils/deprecate.py +46 -0
  50. ansys/fluent/core/utils/file_transfer_service.py +19 -3
  51. ansys/fluent/core/utils/fluent_version.py +42 -11
  52. ansys/fluent/core/variable_strategies/__init__.py +29 -0
  53. ansys/fluent/core/variable_strategies/expr.py +186 -0
  54. ansys/fluent/core/variable_strategies/field.py +186 -0
  55. ansys/fluent/core/variable_strategies/svar.py +61 -0
  56. {ansys_fluent_core-0.31.dev1.dist-info → ansys_fluent_core-0.31.1.dist-info}/METADATA +9 -6
  57. {ansys_fluent_core-0.31.dev1.dist-info → ansys_fluent_core-0.31.1.dist-info}/RECORD +59 -53
  58. {ansys_fluent_core-0.31.dev1.dist-info → ansys_fluent_core-0.31.1.dist-info}/WHEEL +1 -1
  59. {ansys_fluent_core-0.31.dev1.dist-info → ansys_fluent_core-0.31.1.dist-info/licenses}/LICENSE +0 -0
@@ -29,8 +29,11 @@ from typing import Any, Callable, Dict
29
29
  import warnings
30
30
  import weakref
31
31
 
32
+ from deprecated.sphinx import deprecated
33
+
32
34
  from ansys.fluent.core.fluent_connection import FluentConnection
33
35
  from ansys.fluent.core.journaling import Journal
36
+ from ansys.fluent.core.launcher.launcher_utils import is_compose
34
37
  from ansys.fluent.core.pyfluent_warnings import (
35
38
  PyFluentDeprecationWarning,
36
39
  PyFluentUserWarning,
@@ -149,6 +152,7 @@ class BaseSession:
149
152
  event_type,
150
153
  get_zones_info,
151
154
  )
155
+ self.register_finalizer_callback = fluent_connection.register_finalizer_cb
152
156
 
153
157
  def _build_from_fluent_connection(
154
158
  self,
@@ -270,30 +274,23 @@ class BaseSession:
270
274
  return True if self._fluent_connection else False
271
275
 
272
276
  @property
277
+ @deprecated(version="0.20.dev9", reason="Use ``session.fields.field_info``.")
273
278
  def field_info(self):
274
279
  """Provides access to Fluent field information."""
275
- warnings.warn(
276
- "field_info is deprecated. Use fields.field_info instead.",
277
- PyFluentDeprecationWarning,
278
- )
279
280
  return self.fields.field_info
280
281
 
281
282
  @property
283
+ @deprecated(version="0.20.dev9", reason="Use ``session.fields.field_data``.")
282
284
  def field_data(self):
283
285
  """Fluent field data on surfaces."""
284
- warnings.warn(
285
- "field_data is deprecated. Use fields.field_data instead.",
286
- PyFluentDeprecationWarning,
287
- )
288
286
  return self.fields.field_data
289
287
 
290
288
  @property
289
+ @deprecated(
290
+ version="0.20.dev9", reason="Use ``session.fields.field_data_streaming``."
291
+ )
291
292
  def field_data_streaming(self):
292
293
  """Field gRPC streaming service of Fluent."""
293
- warnings.warn(
294
- "field_data_streaming is deprecated. Use fields.field_data_streaming instead.",
295
- PyFluentDeprecationWarning,
296
- )
297
294
  return self.fields.field_data_streaming
298
295
 
299
296
  @property
@@ -369,15 +366,21 @@ class BaseSession:
369
366
  """Gets and returns the fluent version."""
370
367
  return FluentVersion(self.scheme_eval.version)
371
368
 
369
+ def _exit_compose_service(self):
370
+ if self._fluent_connection._container and is_compose():
371
+ self._fluent_connection._container.stop()
372
+
372
373
  def exit(self, **kwargs) -> None:
373
374
  """Exit session."""
374
375
  logger.debug("session.exit() called")
375
376
  if self._fluent_connection:
377
+ self._exit_compose_service()
376
378
  self._fluent_connection.exit(**kwargs)
377
379
  self._fluent_connection = None
378
380
 
379
381
  def force_exit(self) -> None:
380
382
  """Forces the Fluent session to exit, losing unsaved progress and data."""
383
+ self._exit_compose_service()
381
384
  self._fluent_connection.force_exit()
382
385
 
383
386
  def file_exists_on_remote(self, file_name: str) -> bool:
@@ -89,6 +89,9 @@ class Meshing(PureMeshing):
89
89
  file_transfer_service=self._file_transfer_service,
90
90
  )
91
91
  self._fluent_connection = None
92
+ self.__doc__ = (
93
+ "The meshing session is no longer usable after switching to solution mode."
94
+ )
92
95
  return solver_session
93
96
 
94
97
  def __getattribute__(self, item: str):
@@ -77,19 +77,6 @@ def _set_state_safe(obj: SettingsBase, state: StateType):
77
77
  datamodel_logger.debug(f"set_state failed at {obj.path}")
78
78
 
79
79
 
80
- def _import_settings_root(root):
81
- _class_dict = {}
82
- api_keys = []
83
- if hasattr(root, "child_names"):
84
- api_keys = root.child_names
85
-
86
- for root_item in api_keys:
87
- _class_dict[root_item] = root.__dict__[root_item]
88
-
89
- settings_api_root = type("SettingsRoot", (object,), _class_dict)
90
- return settings_api_root()
91
-
92
-
93
80
  class Solver(BaseSession):
94
81
  """Encapsulates a Fluent solver session.
95
82
 
@@ -143,9 +130,17 @@ class Solver(BaseSession):
143
130
  self._tui = None
144
131
  self._workflow = None
145
132
  self._system_coupling = None
146
- self._settings_root = None
147
133
  self._fluent_version = None
148
134
  self._bg_session_threads = []
135
+
136
+ #: Root settings object.
137
+ self.settings = flobject.get_root(
138
+ flproxy=self._settings_service,
139
+ version=self._version,
140
+ interrupt=Solver._interrupt,
141
+ file_transfer_service=self._file_transfer_service,
142
+ scheme_eval=self.scheme_eval.scheme_eval,
143
+ )
149
144
  self._solution_variable_service = service_creator("svar").create(
150
145
  fluent_connection._channel, fluent_connection._metadata
151
146
  )
@@ -161,12 +156,12 @@ class Solver(BaseSession):
161
156
  )
162
157
  else:
163
158
  self.fields.reduction = reduction_old
164
- self._settings_api_root = None
165
159
  self.fields.solution_variable_data = self._solution_variable_data()
166
160
 
167
161
  monitors_service = service_creator("monitors").create(
168
162
  fluent_connection._channel, fluent_connection._metadata, self._error_state
169
163
  )
164
+ #: Manage Fluent's solution monitors.
170
165
  self.monitors = MonitorsManager(fluent_connection._id, monitors_service)
171
166
  self.events.register_callback(
172
167
  (SolverEvent.SOLUTION_INITIALIZED, SolverEvent.DATA_LOADED),
@@ -269,19 +264,6 @@ class Solver(BaseSession):
269
264
  if command.path in interruptible_commands:
270
265
  command._root.solution.run_calculation.interrupt()
271
266
 
272
- @property
273
- def settings(self):
274
- """Root settings object."""
275
- if self._settings_root is None:
276
- self._settings_root = flobject.get_root(
277
- flproxy=self._settings_service,
278
- version=self._version,
279
- interrupt=Solver._interrupt,
280
- file_transfer_service=self._file_transfer_service,
281
- scheme_eval=self.scheme_eval.scheme_eval,
282
- )
283
- return self._settings_root
284
-
285
267
  @property
286
268
  def system_coupling(self):
287
269
  """System coupling object."""
@@ -351,28 +333,23 @@ class Solver(BaseSession):
351
333
  def __call__(self):
352
334
  return self.get_state()
353
335
 
354
- def _populate_settings_api_root(self):
355
- if not self._settings_api_root:
356
- self._settings_api_root = _import_settings_root(self.settings)
357
-
358
- def __getattr__(self, attr):
359
- self._populate_settings_api_root()
360
- if attr in [x for x in dir(self._settings_api_root) if not x.startswith("_")]:
361
- if self.get_fluent_version() > FluentVersion.v242:
336
+ def __getattr__(self, name):
337
+ try:
338
+ return super().__getattribute__(name)
339
+ except AttributeError as ex:
340
+ if name in self.settings.child_names:
362
341
  warnings.warn(
363
- f"'{attr}' is deprecated. Use 'settings.{attr}' instead.",
342
+ f"'{name}' is deprecated. Use 'settings.{name}' instead.",
364
343
  DeprecatedSettingWarning,
365
344
  )
366
- return getattr(self._settings_api_root, attr)
345
+ return getattr(self.settings, name)
346
+ else:
347
+ raise ex
367
348
 
368
349
  def __dir__(self):
369
350
  if self._fluent_connection is None:
370
351
  return ["is_active"]
371
- settings_dir = []
372
- if self.get_fluent_version() <= FluentVersion.v242:
373
- self._populate_settings_api_root()
374
- settings_dir = dir(self._settings_api_root)
375
- dir_list = set(list(self.__dict__.keys()) + dir(type(self)) + settings_dir) - {
352
+ dir_list = set(list(self.__dict__.keys()) + dir(type(self))) - {
376
353
  "svar_data",
377
354
  "svar_info",
378
355
  "reduction",
@@ -0,0 +1,429 @@
1
+ # Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """Session utilities."""
24
+
25
+ from typing import Any, Dict
26
+
27
+ import ansys.fluent.core as pyfluent
28
+ from ansys.fluent.core.launcher.container_launcher import DockerLauncher
29
+ from ansys.fluent.core.launcher.pim_launcher import PIMLauncher
30
+ from ansys.fluent.core.launcher.pyfluent_enums import (
31
+ Dimension,
32
+ FluentLinuxGraphicsDriver,
33
+ FluentMode,
34
+ FluentWindowsGraphicsDriver,
35
+ Precision,
36
+ UIMode,
37
+ )
38
+ from ansys.fluent.core.launcher.standalone_launcher import StandaloneLauncher
39
+ from ansys.fluent.core.utils.fluent_version import FluentVersion
40
+
41
+
42
+ class SessionBase:
43
+ """Base class for Fluent sessions.
44
+
45
+ This class is not intended to be used directly. Instead, use
46
+ the `from_connection`, `from_container`, `from_install`,
47
+ or `from_pim` functions to create a session.
48
+ """
49
+
50
+ _session_mode = {
51
+ "Meshing": FluentMode.MESHING,
52
+ "PureMeshing": FluentMode.PURE_MESHING,
53
+ "PrePost": FluentMode.PRE_POST,
54
+ "Solver": FluentMode.SOLVER,
55
+ "SolverAero": FluentMode.SOLVER_AERO,
56
+ "SolverIcing": FluentMode.SOLVER_ICING,
57
+ }
58
+
59
+ @classmethod
60
+ def from_install(
61
+ cls,
62
+ ui_mode: UIMode | str | None = None,
63
+ graphics_driver: (
64
+ FluentWindowsGraphicsDriver | FluentLinuxGraphicsDriver | str
65
+ ) = None,
66
+ product_version: FluentVersion | str | float | int | None = None,
67
+ dimension: Dimension | int | None = None,
68
+ precision: Precision | str | None = None,
69
+ processor_count: int | None = None,
70
+ journal_file_names: None | str | list[str] = None,
71
+ start_timeout: int = 60,
72
+ additional_arguments: str = "",
73
+ env: Dict[str, Any] = {}, # noqa: B006
74
+ cleanup_on_exit: bool = True,
75
+ dry_run: bool = False,
76
+ start_transcript: bool = True,
77
+ case_file_name: str | None = None,
78
+ case_data_file_name: str | None = None,
79
+ lightweight_mode: bool | None = None,
80
+ py: bool | None = None,
81
+ gpu: bool | None = None,
82
+ cwd: str | None = None,
83
+ fluent_path: str | None = None,
84
+ topy: str | list | None = None,
85
+ start_watchdog: bool | None = None,
86
+ file_transfer_service: Any | None = None,
87
+ ):
88
+ """
89
+ Launch a Fluent session in standalone mode.
90
+
91
+ Parameters
92
+ ----------
93
+ ui_mode : UIMode
94
+ Defines the user interface mode for Fluent. Options correspond to values in the ``UIMode`` enum.
95
+ graphics_driver : FluentWindowsGraphicsDriver or FluentLinuxGraphicsDriver
96
+ Specifies the graphics driver for Fluent. Options are from the ``FluentWindowsGraphicsDriver`` enum
97
+ (for Windows) or the ``FluentLinuxGraphicsDriver`` enum (for Linux).
98
+ product_version : FluentVersion or str or float or int, optional
99
+ Indicates the version of Ansys Fluent to launch. For example, to use version 2025 R1, pass
100
+ ``FluentVersion.v251``, ``"25.1.0"``, ``"25.1"``, ``25.1``, or ``251``. Defaults to ``None``,
101
+ which uses the newest installed version.
102
+ dimension : Dimension or int, optional
103
+ Specifies the geometric dimensionality of the Fluent simulation. Defaults to ``None``,
104
+ which corresponds to ``Dimension.THREE``. Acceptable values are from the ``Dimension`` enum
105
+ (``Dimension.TWO`` or ``Dimension.THREE``) or integers ``2`` and ``3``.
106
+ precision : Precision or str, optional
107
+ Defines the floating point precision. Defaults to ``None``, which corresponds to
108
+ ``Precision.DOUBLE``. Acceptable values are from the ``Precision`` enum (``Precision.SINGLE``
109
+ or ``Precision.DOUBLE``) or strings ``"single"`` and ``"double"``.
110
+ processor_count : int, optional
111
+ Specifies the number of processors to use. Defaults to ``None``, which uses 1 processor.
112
+ In job scheduler environments, this value limits the total number of allocated cores.
113
+ journal_file_names : str or list of str, optional
114
+ Path(s) to a Fluent journal file(s) that Fluent will execute. Defaults to ``None``.
115
+ start_timeout : int, optional
116
+ Maximum time in seconds allowed for connecting to the Fluent server. Defaults to 60 seconds.
117
+ additional_arguments : str, optional
118
+ Additional command-line arguments for Fluent, formatted as they would be on the command line.
119
+ env : dict[str, str], optional
120
+ A mapping for modifying environment variables in Fluent. Defaults to ``None``.
121
+ cleanup_on_exit : bool, optional
122
+ Determines whether to shut down the connected Fluent session when exiting PyFluent or calling
123
+ the session's `exit()` method. Defaults to True.
124
+ dry_run : bool, optional
125
+ If True, does not launch Fluent but prints configuration information instead. The `call()` method
126
+ returns a tuple containing the launch string and server info file name. Defaults to False.
127
+ start_transcript : bool, optional
128
+ Indicates whether to start streaming the Fluent transcript in the client. Defaults to True;
129
+ streaming can be controlled via `transcript.start()` and `transcript.stop()` methods on the session object.
130
+ case_file_name : str, optional
131
+ Name of the case file to read into the Fluent session. Defaults to None.
132
+ case_data_file_name : str, optional
133
+ Name of the case data file. If both case and data files are provided, they are read into the session.
134
+ lightweight_mode : bool, optional
135
+ If True, runs in lightweight mode where mesh settings are read into a background solver session,
136
+ replacing it once complete. This parameter is only applicable when `case_file_name` is provided; defaults to False.
137
+ py : bool, optional
138
+ If True, runs Fluent in Python mode. Defaults to None.
139
+ gpu : bool, optional
140
+ If True, starts Fluent with GPU Solver enabled.
141
+ cwd : str, optional
142
+ Working directory for the Fluent client.
143
+ fluent_path: str, optional
144
+ User-specified path for Fluent installation.
145
+ topy : bool or str, optional
146
+ A flag indicating whether to write equivalent Python journals from provided journal files; can also specify
147
+ a filename for the new Python journal.
148
+ start_watchdog : bool, optional
149
+ When `cleanup_on_exit` is True, defaults to True; an independent watchdog process ensures that any local
150
+ GUI-less Fluent sessions started by PyFluent are properly closed when the current Python process ends.
151
+ file_transfer_service : Any
152
+ Service for uploading/downloading files to/from the server.
153
+
154
+ Raises
155
+ ------
156
+ UnexpectedKeywordArgument
157
+ If an unexpected keyword argument is provided.
158
+
159
+ Notes
160
+ -----
161
+ In job scheduler environments (e.g., SLURM, LSF, PBS), resources and compute nodes are allocated,
162
+ and core counts are queried from these environments before being passed to Fluent.
163
+ """
164
+ mode = cls._session_mode[cls.__name__]
165
+ argvals = locals().copy()
166
+ argvals.pop("cls", None) # Remove the class reference from the arguments
167
+ launcher = StandaloneLauncher(**argvals)
168
+ return launcher()
169
+
170
+ @classmethod
171
+ def from_container(
172
+ cls,
173
+ ui_mode: UIMode | str | None = None,
174
+ graphics_driver: (
175
+ FluentWindowsGraphicsDriver | FluentLinuxGraphicsDriver | str | None
176
+ ) = None,
177
+ product_version: FluentVersion | str | float | int | None = None,
178
+ dimension: Dimension | int | None = None,
179
+ precision: Precision | str | None = None,
180
+ processor_count: int | None = None,
181
+ start_timeout: int = 60,
182
+ additional_arguments: str = "",
183
+ container_dict: dict | None = None,
184
+ dry_run: bool = False,
185
+ cleanup_on_exit: bool = True,
186
+ start_transcript: bool = True,
187
+ py: bool | None = None,
188
+ gpu: bool | None = None,
189
+ start_watchdog: bool | None = None,
190
+ file_transfer_service: Any | None = None,
191
+ ):
192
+ """
193
+ Launch a Fluent session in container mode.
194
+
195
+ Parameters
196
+ ----------
197
+ ui_mode : UIMode
198
+ Defines the user interface mode for Fluent. Options correspond to values in the ``UIMode`` enum.
199
+ graphics_driver : FluentWindowsGraphicsDriver or FluentLinuxGraphicsDriver
200
+ Specifies the graphics driver for Fluent. Options are from the ``FluentWindowsGraphicsDriver`` enum
201
+ (for Windows) or the ``FluentLinuxGraphicsDriver`` enum (for Linux).
202
+ product_version : FluentVersion or str or float or int, optional
203
+ Indicates the version of Ansys Fluent to launch. For example, to use version 2025 R1, pass
204
+ any of ``FluentVersion.v251``, ``"25.1.0"``, ``"25.1"``, ``25.1``, or ``251``. Defaults to ``None``,
205
+ which uses the newest installed version.
206
+ dimension : Dimension or int, optional
207
+ Specifies the geometric dimensionality of the Fluent simulation. Defaults to ``None``,
208
+ which corresponds to ``Dimension.THREE``. Acceptable values include ``Dimension.TWO``,
209
+ ``Dimension.THREE``, or integers ``2`` and ``3``.
210
+ precision : Precision or str, optional
211
+ Defines the floating point precision. Defaults to ``None``, which corresponds to
212
+ ``Precision.DOUBLE``. Acceptable values include ``Precision.SINGLE``,
213
+ ``Precision.DOUBLE``, or strings ``"single"`` and ``"double"``.
214
+ processor_count : int, optional
215
+ Specifies the number of processors to use. Defaults to ``None``, which uses 1 processor.
216
+ In job scheduler environments, this value limits the total number of allocated cores.
217
+ start_timeout : int, optional
218
+ Maximum allowable time in seconds for connecting to the Fluent server. Defaults to 60 seconds.
219
+ additional_arguments : str, optional
220
+ Additional command-line arguments for Fluent, formatted as they would be on the command line.
221
+ container_dict : dict, optional
222
+ Configuration dictionary for launching Fluent inside a Docker container. See also
223
+ :mod:`~ansys.fluent.core.launcher.fluent_container`.
224
+ dry_run : bool, optional
225
+ If True, does not launch Fluent but prints configuration information instead. If dry running a
226
+ container start, this method will return the configured ``container_dict``. Defaults to False.
227
+ cleanup_on_exit : bool
228
+ Determines whether to shut down the connected Fluent session upon exit or when calling
229
+ the session's `exit()` method. Defaults to True.
230
+ start_transcript : bool
231
+ Indicates whether to start streaming the Fluent transcript in the client. Defaults to True;
232
+ streaming can be controlled via `transcript.start()` and `transcript.stop()` methods on the session object.
233
+ py : bool, optional
234
+ If True, runs Fluent in Python mode. Defaults to None.
235
+ gpu : bool, optional
236
+ If True, starts Fluent with GPU Solver enabled.
237
+ start_watchdog : bool, optional
238
+ If True and `cleanup_on_exit` is True, an independent watchdog process is run to ensure that any local
239
+ GUI-less Fluent sessions started by PyFluent are properly closed when the current Python process ends.
240
+ file_transfer_service : Any, optional
241
+ Service for uploading/downloading files to/from the server.
242
+
243
+ Returns
244
+ -------
245
+ Meshing | PureMeshing | Solver | SolverIcing | dict
246
+ Session object or configuration dictionary if ``dry_run`` is True.
247
+
248
+ Raises
249
+ ------
250
+ UnexpectedKeywordArgument
251
+ If an unexpected keyword argument is provided.
252
+
253
+ Notes
254
+ -----
255
+ In job scheduler environments (e.g., SLURM, LSF, PBS), resources and compute nodes are allocated,
256
+ and core counts are queried from these environments before being passed to Fluent.
257
+ """
258
+ mode = cls._session_mode[cls.__name__]
259
+ argvals = locals().copy()
260
+ argvals.pop("cls", None)
261
+ launcher = DockerLauncher(**argvals)
262
+ return launcher()
263
+
264
+ @classmethod
265
+ def from_pim(
266
+ cls,
267
+ graphics_driver: (
268
+ FluentWindowsGraphicsDriver | FluentLinuxGraphicsDriver | str | None
269
+ ) = None,
270
+ product_version: FluentVersion | str | float | int | None = None,
271
+ dimension: Dimension | int | None = None,
272
+ precision: Precision | str | None = None,
273
+ processor_count: int | None = None,
274
+ start_timeout: int = 60,
275
+ additional_arguments: str = "",
276
+ cleanup_on_exit: bool = True,
277
+ start_transcript: bool = True,
278
+ gpu: bool | None = None,
279
+ start_watchdog: bool | None = None,
280
+ file_transfer_service: Any | None = None,
281
+ ):
282
+ """
283
+ Launch a Fluent session in `PIM <https://pypim.docs.pyansys.com/version/stable/>`_ mode.
284
+
285
+ Parameters
286
+ ----------
287
+ graphics_driver : FluentWindowsGraphicsDriver or FluentLinuxGraphicsDriver
288
+ Specifies the graphics driver for Fluent. Options are from the ``FluentWindowsGraphicsDriver`` enum
289
+ (for Windows) or the ``FluentLinuxGraphicsDriver`` enum (for Linux).
290
+ product_version : FluentVersion or str or float or int, optional
291
+ Indicates the version of Ansys Fluent to launch. For example, to use version 2025 R1, pass
292
+ any of ``FluentVersion.v251``, ``"25.1.0"``, ``"25.1"``, ``25.1``, or ``251``. Defaults to ``None``,
293
+ which uses the newest installed version.
294
+ dimension : Dimension or int, optional
295
+ Specifies the geometric dimensionality of the Fluent simulation. Defaults to ``None``,
296
+ which corresponds to ``Dimension.THREE``. Acceptable values include ``Dimension.TWO``,
297
+ ``Dimension.THREE``, or integers ``2`` and ``3``.
298
+ precision : Precision or str, optional
299
+ Defines the floating point precision. Defaults to ``None``, which corresponds to
300
+ ``Precision.DOUBLE``. Acceptable values include ``Precision.SINGLE``,
301
+ ``Precision.DOUBLE``, or strings ``"single"`` and ``"double"``.
302
+ processor_count : int, optional
303
+ Specifies the number of processors to use. Defaults to ``None``, which uses 1 processor.
304
+ In job scheduler environments, this value limits the total number of allocated cores.
305
+ start_timeout : int, optional
306
+ Maximum allowable time in seconds for connecting to the Fluent server. Defaults to 60 seconds.
307
+ additional_arguments : str, optional
308
+ Additional command-line arguments for Fluent, formatted as they would be on the command line.
309
+ cleanup_on_exit : bool
310
+ Determines whether to shut down the connected Fluent session upon exit or when calling
311
+ the session's `exit()` method. Defaults to True.
312
+ start_transcript : bool
313
+ Indicates whether to start streaming the Fluent transcript in the client. Defaults to True;
314
+ streaming can be controlled via `transcript.start()` and `transcript.stop()` methods on the session object.
315
+ gpu : bool, optional
316
+ If True, starts Fluent with GPU Solver enabled.
317
+ start_watchdog : bool, optional
318
+ If True and `cleanup_on_exit` is True, an independent watchdog process is run to ensure that any local
319
+ GUI-less Fluent sessions started by PyFluent are properly closed when the current Python process ends.
320
+ file_transfer_service : Any, optional
321
+ Service for uploading/downloading files to/from the server.
322
+
323
+ Returns
324
+ -------
325
+ Union[Meshing, PureMeshing, Solver, SolverIcing, dict]
326
+ Session object or configuration dictionary if ``dry_run`` is True.
327
+
328
+ Raises
329
+ ------
330
+ UnexpectedKeywordArgument
331
+ If an unexpected keyword argument is provided.
332
+
333
+ Notes
334
+ -----
335
+ In job scheduler environments (e.g., SLURM, LSF, PBS), resources and compute nodes are allocated,
336
+ and core counts are queried from these environments before being passed to Fluent.
337
+ """
338
+ mode = cls._session_mode[cls.__name__]
339
+ argvals = locals().copy()
340
+ argvals.pop("cls", None)
341
+ launcher = PIMLauncher(**argvals)
342
+ return launcher()
343
+
344
+ @classmethod
345
+ def from_connection(
346
+ cls,
347
+ ip: str | None = None,
348
+ port: int | None = None,
349
+ server_info_file_name: str | None = None,
350
+ password: str | None = None,
351
+ ):
352
+ """Connect to an existing Fluent server instance.
353
+
354
+ Parameters
355
+ ----------
356
+ ip : str, optional
357
+ IP address for connecting to an existing Fluent instance. The
358
+ IP address defaults to ``"127.0.0.1"``. You can also use the environment
359
+ variable ``PYFLUENT_FLUENT_IP=<ip>`` to set this parameter.
360
+ The explicit value of ``ip`` takes precedence over ``PYFLUENT_FLUENT_IP=<ip>``.
361
+ port : int, optional
362
+ Port to listen on for an existing Fluent instance. You can use the
363
+ environment variable ``PYFLUENT_FLUENT_PORT=<port>`` to set a default
364
+ value. The explicit value of ``port`` takes precedence over
365
+ ``PYFLUENT_FLUENT_PORT=<port>``.
366
+ server_info_file_name: str
367
+ Path to server-info file written out by Fluent server. The default is
368
+ ``None``. PyFluent uses the connection information in the file to
369
+ connect to a running Fluent session.
370
+ password : str, optional
371
+ Password to connect to existing Fluent instance.
372
+
373
+ Raises
374
+ ------
375
+ TypeError
376
+ If the session type does not match the expected session type.
377
+ """
378
+ session = pyfluent.connect_to_fluent(
379
+ ip=ip,
380
+ port=port,
381
+ server_info_file_name=server_info_file_name,
382
+ password=password,
383
+ )
384
+
385
+ expected = "Solver" if cls.__name__ == "PrePost" else cls.__name__
386
+ actual = session.__class__.__name__
387
+
388
+ if actual != expected:
389
+ raise TypeError(
390
+ f"Session type mismatch: expected {expected}, got {actual}."
391
+ )
392
+
393
+ return session
394
+
395
+
396
+ class Meshing(SessionBase):
397
+ """Encapsulates a Fluent server for meshing session connection."""
398
+
399
+ pass
400
+
401
+
402
+ class PureMeshing(SessionBase):
403
+ """Encapsulates a Fluent server for pure meshing session connection."""
404
+
405
+ pass
406
+
407
+
408
+ class PrePost(SessionBase):
409
+ """Encapsulates a Fluent server for pre-post session connection."""
410
+
411
+ pass
412
+
413
+
414
+ class Solver(SessionBase):
415
+ """Encapsulates a Fluent server for solver session connection."""
416
+
417
+ pass
418
+
419
+
420
+ class SolverAero(SessionBase):
421
+ """Encapsulates a Fluent server for solver aero session connection."""
422
+
423
+ pass
424
+
425
+
426
+ class SolverIcing(SessionBase):
427
+ """Encapsulates a Fluent server for solver icing session connection."""
428
+
429
+ pass