ansys-fluent-core 0.34.dev0__py3-none-any.whl → 0.35.dev0__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 (108) hide show
  1. ansys/fluent/core/__init__.py +48 -84
  2. ansys/fluent/core/codegen/allapigen.py +2 -2
  3. ansys/fluent/core/codegen/builtin_settingsgen.py +41 -13
  4. ansys/fluent/core/codegen/datamodelgen.py +3 -1
  5. ansys/fluent/core/codegen/print_fluent_version.py +2 -2
  6. ansys/fluent/core/codegen/settingsgen.py +18 -6
  7. ansys/fluent/core/codegen/tuigen.py +6 -5
  8. ansys/fluent/core/data_model_cache.py +2 -2
  9. ansys/fluent/core/docker/docker_compose.py +11 -9
  10. ansys/fluent/core/docker/utils.py +35 -0
  11. ansys/fluent/core/examples/downloads.py +8 -11
  12. ansys/fluent/core/exceptions.py +13 -1
  13. ansys/fluent/core/field_data_interfaces.py +239 -38
  14. ansys/fluent/core/file_session.py +167 -61
  15. ansys/fluent/core/fluent_connection.py +41 -26
  16. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  17. ansys/fluent/core/generated/datamodel_231/flicing.py +40 -40
  18. ansys/fluent/core/generated/datamodel_231/meshing.py +231 -231
  19. ansys/fluent/core/generated/datamodel_232/flicing.py +50 -50
  20. ansys/fluent/core/generated/datamodel_232/meshing.py +189 -189
  21. ansys/fluent/core/generated/datamodel_241/flicing.py +30 -30
  22. ansys/fluent/core/generated/datamodel_241/meshing.py +290 -290
  23. ansys/fluent/core/generated/datamodel_242/flicing.py +50 -50
  24. ansys/fluent/core/generated/datamodel_242/meshing.py +331 -331
  25. ansys/fluent/core/generated/datamodel_242/part_management.py +6 -6
  26. ansys/fluent/core/generated/datamodel_251/flicing.py +65 -65
  27. ansys/fluent/core/generated/datamodel_251/meshing.py +300 -300
  28. ansys/fluent/core/generated/datamodel_251/part_management.py +6 -6
  29. ansys/fluent/core/generated/datamodel_252/flicing.py +25 -25
  30. ansys/fluent/core/generated/datamodel_252/meshing.py +382 -382
  31. ansys/fluent/core/generated/datamodel_252/part_management.py +10 -10
  32. ansys/fluent/core/generated/datamodel_261/flicing.py +45 -45
  33. ansys/fluent/core/generated/datamodel_261/meshing.py +454 -435
  34. ansys/fluent/core/generated/datamodel_261/part_management.py +5 -5
  35. ansys/fluent/core/generated/datamodel_261/preferences.py +7 -0
  36. ansys/fluent/core/generated/fluent_version_252.py +1 -1
  37. ansys/fluent/core/generated/fluent_version_261.py +3 -3
  38. ansys/fluent/core/generated/meshing/tui_261.py +54 -3
  39. ansys/fluent/core/generated/solver/settings_231.py +1 -0
  40. ansys/fluent/core/generated/solver/settings_231.pyi +3025 -1
  41. ansys/fluent/core/generated/solver/settings_232.py +1 -0
  42. ansys/fluent/core/generated/solver/settings_232.pyi +3425 -1
  43. ansys/fluent/core/generated/solver/settings_241.py +1 -0
  44. ansys/fluent/core/generated/solver/settings_241.pyi +4423 -1
  45. ansys/fluent/core/generated/solver/settings_242.py +1 -0
  46. ansys/fluent/core/generated/solver/settings_242.pyi +5474 -1
  47. ansys/fluent/core/generated/solver/settings_251.py +11 -0
  48. ansys/fluent/core/generated/solver/settings_251.pyi +6006 -1
  49. ansys/fluent/core/generated/solver/settings_252.py +11 -1
  50. ansys/fluent/core/generated/solver/settings_252.pyi +6782 -2
  51. ansys/fluent/core/generated/solver/settings_261.py +5592 -2740
  52. ansys/fluent/core/generated/solver/settings_261.pyi +10335 -1994
  53. ansys/fluent/core/generated/solver/settings_builtin.py +560 -38
  54. ansys/fluent/core/generated/solver/settings_builtin.pyi +24 -18
  55. ansys/fluent/core/generated/solver/tui_261.py +409 -285
  56. ansys/fluent/core/launcher/container_launcher.py +25 -6
  57. ansys/fluent/core/launcher/error_handler.py +1 -1
  58. ansys/fluent/core/launcher/fluent_container.py +97 -45
  59. ansys/fluent/core/launcher/launch_options.py +5 -4
  60. ansys/fluent/core/launcher/launcher.py +18 -2
  61. ansys/fluent/core/launcher/launcher_utils.py +63 -15
  62. ansys/fluent/core/launcher/pim_launcher.py +17 -3
  63. ansys/fluent/core/launcher/process_launch_string.py +3 -2
  64. ansys/fluent/core/launcher/server_info.py +7 -3
  65. ansys/fluent/core/launcher/slurm_launcher.py +4 -2
  66. ansys/fluent/core/launcher/standalone_launcher.py +6 -3
  67. ansys/fluent/core/launcher/watchdog.py +6 -6
  68. ansys/fluent/core/launcher/watchdog_exec +1 -1
  69. ansys/fluent/core/logger.py +3 -1
  70. ansys/fluent/core/module_config.py +358 -0
  71. ansys/fluent/core/pyfluent_warnings.py +9 -3
  72. ansys/fluent/core/report.py +2 -2
  73. ansys/fluent/core/search.py +34 -13
  74. ansys/fluent/core/services/__init__.py +2 -2
  75. ansys/fluent/core/services/api_upgrade.py +3 -2
  76. ansys/fluent/core/services/app_utilities.py +39 -0
  77. ansys/fluent/core/services/datamodel_se.py +4 -2
  78. ansys/fluent/core/services/deprecated_field_data.py +4 -4
  79. ansys/fluent/core/services/field_data.py +185 -49
  80. ansys/fluent/core/services/health_check.py +3 -1
  81. ansys/fluent/core/services/interceptors.py +8 -6
  82. ansys/fluent/core/services/reduction.py +16 -5
  83. ansys/fluent/core/services/settings.py +1 -0
  84. ansys/fluent/core/session.py +47 -4
  85. ansys/fluent/core/session_pure_meshing.py +6 -6
  86. ansys/fluent/core/session_pure_meshing.pyi +1 -0
  87. ansys/fluent/core/session_shared.py +4 -4
  88. ansys/fluent/core/session_solver.py +41 -10
  89. ansys/fluent/core/session_solver.pyi +1 -0
  90. ansys/fluent/core/session_utilities.py +7 -0
  91. ansys/fluent/core/solver/error_message.py +2 -2
  92. ansys/fluent/core/solver/flobject.py +192 -123
  93. ansys/fluent/core/solver/function/reduction.py +37 -9
  94. ansys/fluent/core/solver/settings_builtin_bases.py +3 -3
  95. ansys/fluent/core/solver/settings_builtin_data.py +7 -17
  96. ansys/fluent/core/streaming_services/datamodel_event_streaming.py +3 -2
  97. ansys/fluent/core/streaming_services/datamodel_streaming.py +3 -1
  98. ansys/fluent/core/streaming_services/events_streaming.py +2 -18
  99. ansys/fluent/core/system_coupling.py +3 -1
  100. ansys/fluent/core/utils/__init__.py +0 -7
  101. ansys/fluent/core/utils/data_transfer.py +3 -3
  102. ansys/fluent/core/utils/file_transfer_service.py +24 -15
  103. ansys/fluent/core/utils/fluent_version.py +4 -6
  104. ansys/fluent/core/utils/networking.py +21 -11
  105. {ansys_fluent_core-0.34.dev0.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/METADATA +10 -11
  106. {ansys_fluent_core-0.34.dev0.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/RECORD +108 -106
  107. {ansys_fluent_core-0.34.dev0.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/WHEEL +1 -1
  108. {ansys_fluent_core-0.34.dev0.dist-info/licenses → ansys_fluent_core-0.35.dev0.dist-info}/LICENSE +0 -0
@@ -40,13 +40,14 @@ import logging
40
40
  import os
41
41
  from typing import Any, Dict
42
42
 
43
- from ansys.fluent.core.fluent_connection import FluentConnection
43
+ from ansys.fluent.core.fluent_connection import FluentConnection, _get_max_c_int_limit
44
44
  from ansys.fluent.core.launcher.launch_options import (
45
45
  Dimension,
46
46
  FluentLinuxGraphicsDriver,
47
47
  FluentMode,
48
48
  FluentWindowsGraphicsDriver,
49
49
  Precision,
50
+ UIMode,
50
51
  _get_argvals_and_session,
51
52
  )
52
53
  from ansys.fluent.core.session_meshing import Meshing
@@ -68,6 +69,7 @@ class PIMLauncher:
68
69
  def __init__(
69
70
  self,
70
71
  mode: FluentMode | str | None = None,
72
+ ui_mode: UIMode | str | None = None,
71
73
  graphics_driver: (
72
74
  FluentWindowsGraphicsDriver | FluentLinuxGraphicsDriver | str | None
73
75
  ) = None,
@@ -78,6 +80,7 @@ class PIMLauncher:
78
80
  start_timeout: int = 60,
79
81
  additional_arguments: str = "",
80
82
  cleanup_on_exit: bool = True,
83
+ dry_run: bool | None = None,
81
84
  start_transcript: bool = True,
82
85
  gpu: bool | None = None,
83
86
  start_watchdog: bool | None = None,
@@ -90,6 +93,8 @@ class PIMLauncher:
90
93
  ----------
91
94
  mode : FluentMode
92
95
  Specifies the launch mode of Fluent for targeting a specific session type.
96
+ ui_mode : UIMode
97
+ Defines the user interface mode for Fluent. Options correspond to values in the ``UIMode`` enum.
93
98
  graphics_driver : FluentWindowsGraphicsDriver or FluentLinuxGraphicsDriver
94
99
  Specifies the graphics driver for Fluent. Options are from the ``FluentWindowsGraphicsDriver`` enum
95
100
  (for Windows) or the ``FluentLinuxGraphicsDriver`` enum (for Linux).
@@ -115,6 +120,8 @@ class PIMLauncher:
115
120
  cleanup_on_exit : bool
116
121
  Determines whether to shut down the connected Fluent session upon exit or when calling
117
122
  the session's `exit()` method. Defaults to True.
123
+ dry_run : bool, optional
124
+ If True, returns a configuration dictionary instead of starting a Fluent session.
118
125
  start_transcript : bool
119
126
  Indicates whether to start streaming the Fluent transcript in the client. Defaults to True;
120
127
  streaming can be controlled via `transcript.start()` and `transcript.stop()` methods on the session object.
@@ -170,7 +177,9 @@ class PIMLauncher:
170
177
  FluentVersion(self.argvals["product_version"]).number
171
178
  )
172
179
  else:
173
- fluent_product_version = None
180
+ fluent_product_version = str(
181
+ FluentVersion(FluentVersion.current_release()).number
182
+ )
174
183
 
175
184
  return launch_remote_fluent(
176
185
  session_cls=self.new_session,
@@ -236,7 +245,12 @@ def launch_remote_fluent(
236
245
 
237
246
  instance.wait_for_ready()
238
247
 
239
- channel = instance.build_grpc_channel()
248
+ channel = instance.build_grpc_channel(
249
+ options=[
250
+ ("grpc.max_send_message_length", _get_max_c_int_limit()),
251
+ ("grpc.max_receive_message_length", _get_max_c_int_limit()),
252
+ ],
253
+ )
240
254
 
241
255
  fluent_connection = create_fluent_connection(
242
256
  channel=channel,
@@ -132,7 +132,7 @@ def _generate_launch_string(
132
132
  if " " in server_info_file_name:
133
133
  server_info_file_name = '"' + server_info_file_name + '"'
134
134
  launch_string += f" -sifile={server_info_file_name}"
135
- if not pyfluent.FLUENT_SHOW_MESH_AFTER_CASE_READ:
135
+ if not pyfluent.config.fluent_show_mesh_after_case_read:
136
136
  launch_string += " -nm"
137
137
  return launch_string
138
138
 
@@ -149,6 +149,7 @@ def get_fluent_exe_path(**launch_argvals) -> Path:
149
149
  Path
150
150
  Fluent executable path
151
151
  """
152
+ from ansys.fluent.core import config
152
153
 
153
154
  def get_exe_path(fluent_root: Path) -> Path:
154
155
  if launcher_utils.is_windows():
@@ -170,7 +171,7 @@ def get_fluent_exe_path(**launch_argvals) -> Path:
170
171
  return FluentVersion(product_version).get_fluent_exe_path()
171
172
 
172
173
  # (DEV) "PYFLUENT_FLUENT_ROOT" environment variable
173
- fluent_root = os.getenv("PYFLUENT_FLUENT_ROOT")
174
+ fluent_root = config.fluent_root
174
175
  if fluent_root:
175
176
  return get_exe_path(Path(fluent_root))
176
177
 
@@ -53,7 +53,9 @@ def _get_server_info_file_names(use_tmpdir=True) -> tuple[str, str]:
53
53
  temporary directory if ``use_tmpdir`` is True, otherwise it is created in the current working
54
54
  directory.
55
55
  """
56
- server_info_dir = os.getenv("SERVER_INFO_DIR")
56
+ from ansys.fluent.core import config
57
+
58
+ server_info_dir = config.fluent_server_info_dir
57
59
  dir_ = (
58
60
  Path(server_info_dir)
59
61
  if server_info_dir
@@ -95,6 +97,8 @@ def _get_server_info(
95
97
  password: str | None = None,
96
98
  ):
97
99
  """Get server connection information of an already running session."""
100
+ from ansys.fluent.core import config
101
+
98
102
  if not (ip and port) and not server_info_file_name:
99
103
  raise IpPortNotProvided()
100
104
  if (ip or port) and server_info_file_name:
@@ -105,8 +109,8 @@ def _get_server_info(
105
109
  else:
106
110
  if server_info_file_name:
107
111
  ip, port, password = _parse_server_info_file(server_info_file_name)
108
- ip = ip or os.getenv("PYFLUENT_FLUENT_IP", "127.0.0.1")
109
- port = port or os.getenv("PYFLUENT_FLUENT_PORT")
112
+ ip = ip or config.launch_fluent_ip or "127.0.0.1"
113
+ port = port or config.launch_fluent_port
110
114
 
111
115
  _check_ip_port(ip=ip, port=port)
112
116
 
@@ -64,7 +64,6 @@ are optional and should be specified in a similar manner to Fluent's scheduler o
64
64
  from concurrent.futures import Future, ThreadPoolExecutor
65
65
  import inspect
66
66
  import logging
67
- import os
68
67
  from pathlib import Path
69
68
  import shutil
70
69
  import subprocess
@@ -414,6 +413,8 @@ class SlurmLauncher:
414
413
  The allocated machines and core counts are queried from the scheduler environment and
415
414
  passed to Fluent.
416
415
  """
416
+ from ansys.fluent.core import config
417
+
417
418
  if not _SlurmWrapper.is_available():
418
419
  raise RuntimeError("Slurm is not available.")
419
420
  locals_ = locals().copy()
@@ -423,7 +424,7 @@ class SlurmLauncher:
423
424
  }
424
425
  self._argvals, self._new_session = _get_argvals_and_session(argvals)
425
426
  self.file_transfer_service = file_transfer_service
426
- if os.getenv("PYFLUENT_SHOW_SERVER_GUI") == "1":
427
+ if config.show_fluent_gui:
427
428
  ui_mode = UIMode.GUI
428
429
  self._argvals["ui_mode"] = UIMode(ui_mode)
429
430
  if self._argvals["start_timeout"] is None:
@@ -459,6 +460,7 @@ class SlurmLauncher:
459
460
  launch_cmd += _build_journal_argument(
460
461
  self._argvals["topy"], self._argvals["journal_file_names"]
461
462
  )
463
+ launch_cmd += ' --setenv="FLUENT_ALLOW_REMOTE_GRPC_CONNECTION=1"'
462
464
 
463
465
  logger.debug(f"Launching Fluent with command: {launch_cmd}")
464
466
  proc = subprocess.Popen(launch_cmd, **kwargs)
@@ -193,7 +193,7 @@ class StandaloneLauncher:
193
193
  }
194
194
  self.argvals, self.new_session = _get_argvals_and_session(argvals)
195
195
  self.file_transfer_service = file_transfer_service
196
- if os.getenv("PYFLUENT_SHOW_SERVER_GUI") == "1":
196
+ if pyfluent.config.show_fluent_gui:
197
197
  ui_mode = UIMode.GUI
198
198
  self.argvals["ui_mode"] = UIMode(ui_mode)
199
199
  if self.argvals["start_timeout"] is None:
@@ -211,7 +211,7 @@ class StandaloneLauncher:
211
211
  ):
212
212
  self.argvals["py"] = True
213
213
 
214
- if os.getenv("PYFLUENT_FLUENT_DEBUG") == "1":
214
+ if pyfluent.config.fluent_debug:
215
215
  self.argvals["fluent_debug"] = True
216
216
 
217
217
  server_info_file_name_for_server, server_info_file_name_for_client = (
@@ -234,7 +234,10 @@ class StandaloneLauncher:
234
234
  )
235
235
 
236
236
  if is_windows():
237
- if pyfluent.LAUNCH_FLUENT_STDOUT or pyfluent.LAUNCH_FLUENT_STDERR:
237
+ if (
238
+ pyfluent.config.launch_fluent_stdout
239
+ or pyfluent.config.launch_fluent_stderr
240
+ ):
238
241
  self._launch_cmd = self._launch_string
239
242
  else:
240
243
  # Using 'start.exe' is better; otherwise Fluent is more susceptible to bad termination attempts.
@@ -76,8 +76,8 @@ def launch(
76
76
  )
77
77
  )
78
78
 
79
- env_watchdog_debug = os.getenv("PYFLUENT_WATCHDOG_DEBUG", "off").upper()
80
- if env_watchdog_debug in ("1", "ON"):
79
+ debug_watchdog = pyfluent.config.watchdog_debug
80
+ if debug_watchdog:
81
81
  logger.debug(
82
82
  f"PYFLUENT_WATCHDOG_DEBUG environment variable found, "
83
83
  f"enabling debugging for watchdog ID {watchdog_id}..."
@@ -131,7 +131,7 @@ def launch(
131
131
  watchdog_id,
132
132
  ]
133
133
 
134
- if env_watchdog_debug in ("1", "ON"):
134
+ if debug_watchdog:
135
135
  logger.debug(f"Starting Watchdog logging to directory {os.getcwd()}")
136
136
 
137
137
  kwargs = {"env": watchdog_env, "stdin": subprocess.DEVNULL, "close_fds": True}
@@ -151,7 +151,7 @@ def launch(
151
151
  if os.name == "posix":
152
152
  kwargs.update(start_new_session=True)
153
153
 
154
- if env_watchdog_debug in ("1", "ON") and os.name != "nt":
154
+ if debug_watchdog and os.name != "nt":
155
155
  kwargs.update(
156
156
  stdout=open(f"pyfluent_watchdog_out_{watchdog_id}.log", mode="w"),
157
157
  stderr=open(f"pyfluent_watchdog_err_{watchdog_id}.log", mode="w"),
@@ -194,13 +194,13 @@ def launch(
194
194
  err_content = "Watchdog - %s" % f.read().replace("\n", "")
195
195
  watchdog_err.unlink()
196
196
  logger.error(err_content)
197
- if os.getenv("PYFLUENT_WATCHDOG_EXCEPTION_ON_ERROR"):
197
+ if pyfluent.config.watchdog_exception_on_error:
198
198
  raise UnsuccessfulWatchdogLaunch(err_content)
199
199
 
200
200
  logger.warning(
201
201
  "PyFluent Watchdog did not initialize correctly, proceeding without it..."
202
202
  )
203
- if os.getenv("PYFLUENT_WATCHDOG_EXCEPTION_ON_ERROR"):
203
+ if pyfluent.config.watchdog_exception_on_error:
204
204
  raise UnsuccessfulWatchdogLaunch(
205
205
  "PyFluent Watchdog did not initialize correctly."
206
206
  )
@@ -34,7 +34,7 @@ if __name__ == "__main__":
34
34
 
35
35
  logger = pyfluent.logger.get_logger("pyfluent.watchdog")
36
36
 
37
- if os.getenv("PYFLUENT_WATCHDOG_DEBUG", "OFF").upper() in ("1", "ON"):
37
+ if pyfluent.config.watchdog_debug:
38
38
  pyfluent.logger.enable(custom_config=log_config)
39
39
  logger.setLevel("DEBUG")
40
40
  logger.handlers = pyfluent.logger.get_logger(
@@ -25,6 +25,8 @@
25
25
  import logging.config
26
26
  import os
27
27
 
28
+ from ansys.fluent.core import config
29
+
28
30
  _logging_file_enabled = False
29
31
 
30
32
 
@@ -250,7 +252,7 @@ def configure_env_var() -> None:
250
252
  If logging debug output to file by default is desired, without having to use :func:`enable()` every time,
251
253
  set environment variable ``PYFLUENT_LOGGING`` to ``DEBUG``.
252
254
  """
253
- env_logging_level = os.getenv("PYFLUENT_LOGGING")
255
+ env_logging_level = config.logging_level_default
254
256
  if env_logging_level:
255
257
  if env_logging_level.isdigit():
256
258
  env_logging_level = int(env_logging_level)
@@ -0,0 +1,358 @@
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
+ """Configuration variables for PyFluent."""
23
+ import inspect
24
+ import os
25
+ from pathlib import Path
26
+ from typing import Any, Callable, Generic, TypeVar
27
+ import warnings
28
+
29
+ TConfig = TypeVar("TConfig", bound="Config")
30
+
31
+
32
+ class _ConfigDescriptor(Generic[TConfig]):
33
+ """Descriptor for managing configuration attributes."""
34
+
35
+ def __init__(
36
+ self, default_fn: Callable[[TConfig], Any], deprecated_var: str | None = None
37
+ ):
38
+ self._default_fn = default_fn
39
+ self._deprecated_var = deprecated_var
40
+
41
+ def _get_config(self, instance: TConfig) -> Any:
42
+ if not hasattr(instance, self._backing_field):
43
+ setattr(instance, self._backing_field, self._default_fn(instance))
44
+ return getattr(instance, self._backing_field)
45
+
46
+ def _set_config(self, instance: TConfig, value: Any):
47
+ setattr(instance, self._backing_field, value)
48
+
49
+ def __set_name__(self, owner: type[TConfig], name: str):
50
+ self._backing_field = "_" + name
51
+
52
+ def __get__(self, instance: TConfig, owner: type[TConfig]) -> Any:
53
+ import ansys.fluent.core as pyfluent
54
+
55
+ if self._deprecated_var is not None and self._deprecated_var in vars(pyfluent):
56
+ return getattr(pyfluent, self._deprecated_var)
57
+ return self._get_config(instance)
58
+
59
+ def __set__(self, instance: TConfig, value: Any):
60
+ import ansys.fluent.core as pyfluent
61
+
62
+ if self._deprecated_var is not None and self._deprecated_var in vars(pyfluent):
63
+ warnings.warn(
64
+ f"Deleting deprecated module-level variable '{self._deprecated_var}' which was previously set."
65
+ )
66
+ delattr(pyfluent, self._deprecated_var)
67
+ self._set_config(instance, value)
68
+
69
+
70
+ def _get_default_examples_path(instance: "Config") -> str:
71
+ """Get the default examples path."""
72
+ parent_path = Path.home() / "Downloads"
73
+ parent_path.mkdir(exist_ok=True)
74
+ return str(parent_path / "ansys_fluent_core_examples")
75
+
76
+
77
+ class Config:
78
+ """Set the global configuration variables for PyFluent."""
79
+
80
+ #: Directory where example files are downloaded.
81
+ examples_path = _ConfigDescriptor["Config"](
82
+ _get_default_examples_path, "EXAMPLES_PATH"
83
+ )
84
+
85
+ #: Host path which is mounted to the container, defaults to the value of ``PYFLUENT_CONTAINER_MOUNT_SOURCE`` environment variable.
86
+ container_mount_source = _ConfigDescriptor["Config"](
87
+ lambda instance: instance._env.get("PYFLUENT_CONTAINER_MOUNT_SOURCE"),
88
+ "CONTAINER_MOUNT_SOURCE",
89
+ )
90
+
91
+ #: Path inside the container where the host path is mounted, defaults to "/home/container/workdir".
92
+ container_mount_target = _ConfigDescriptor["Config"](
93
+ lambda instance: "/home/container/workdir", "CONTAINER_MOUNT_TARGET"
94
+ )
95
+
96
+ #: Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS, defaults to True.
97
+ infer_remoting_ip = _ConfigDescriptor["Config"](
98
+ lambda instance: True, "INFER_REMOTING_IP"
99
+ )
100
+
101
+ # Time in seconds to wait for response for each ip while inferring remoting ip, defaults to 2.
102
+ infer_remoting_ip_timeout_per_ip = _ConfigDescriptor["Config"](
103
+ lambda instance: 2, "INFER_REMOTING_IP_TIMEOUT_PER_IP"
104
+ )
105
+
106
+ #: Whether to use datamodel state caching, defaults to True.
107
+ datamodel_use_state_cache = _ConfigDescriptor["Config"](
108
+ lambda instance: True, "DATAMODEL_USE_STATE_CACHE"
109
+ )
110
+
111
+ #: Whether to use datamodel attribute caching, defaults to True.
112
+ datamodel_use_attr_cache = _ConfigDescriptor["Config"](
113
+ lambda instance: True, "DATAMODEL_USE_ATTR_CACHE"
114
+ )
115
+
116
+ #: Whether to stream and cache commands state, defaults to True.
117
+ datamodel_use_nocommands_diff_state = _ConfigDescriptor["Config"](
118
+ lambda instance: True, "DATAMODEL_USE_NOCOMMANDS_DIFF_STATE"
119
+ )
120
+
121
+ #: Whether to return the state changes on mutating datamodel RPCs, defaults to True.
122
+ datamodel_return_state_changes = _ConfigDescriptor["Config"](
123
+ lambda instance: True, "DATAMODEL_RETURN_STATE_CHANGES"
124
+ )
125
+
126
+ #: Whether to use remote gRPC file transfer service, defaults to False.
127
+ use_file_transfer_service = _ConfigDescriptor["Config"](
128
+ lambda instance: False, "USE_FILE_TRANSFER_SERVICE"
129
+ )
130
+
131
+ #: Directory where API files are written out during codegen.
132
+ codegen_outdir = _ConfigDescriptor["Config"](
133
+ lambda instance: instance._env.get(
134
+ "PYFLUENT_CODEGEN_OUTDIR", (Path(__file__) / ".." / "generated").resolve()
135
+ ),
136
+ "CODEGEN_OUTDIR",
137
+ )
138
+
139
+ #: Whether to show mesh in Fluent after case read, defaults to False.
140
+ fluent_show_mesh_after_case_read = _ConfigDescriptor["Config"](
141
+ lambda instance: False, "FLUENT_SHOW_MESH_AFTER_CASE_READ"
142
+ )
143
+
144
+ #: Whether to write the automatic transcript in Fluent, defaults to the value of ``PYFLUENT_FLUENT_AUTOMATIC_TRANSCRIPT`` environment variable.
145
+ fluent_automatic_transcript = _ConfigDescriptor["Config"](
146
+ lambda instance: instance._env.get("PYFLUENT_FLUENT_AUTOMATIC_TRANSCRIPT")
147
+ == "1",
148
+ "FLUENT_AUTOMATIC_TRANSCRIPT",
149
+ )
150
+
151
+ #: Whether to interrupt Fluent solver from PyFluent, defaults to False.
152
+ support_solver_interrupt = _ConfigDescriptor["Config"](
153
+ lambda instance: False, "SUPPORT_SOLVER_INTERRUPT"
154
+ )
155
+
156
+ #: Whether to start watchdog.
157
+ start_watchdog = _ConfigDescriptor["Config"](
158
+ lambda instance: None, "START_WATCHDOG"
159
+ )
160
+
161
+ #: Whether to enable debug logging for the watchdog, defaults to the value of ``PYFLUENT_WATCHDOG_DEBUG`` environment variable.
162
+ watchdog_debug = _ConfigDescriptor["Config"](
163
+ lambda instance: instance._env.get("PYFLUENT_WATCHDOG_DEBUG") == "1",
164
+ "WATCHDOG_DEBUG",
165
+ )
166
+
167
+ #: Whether to raise an exception when the watchdog encounters an error, defaults to the value of ``PYFLUENT_WATCHDOG_EXCEPTION_ON_ERROR`` environment variable.
168
+ watchdog_exception_on_error = _ConfigDescriptor["Config"](
169
+ lambda instance: instance._env.get("PYFLUENT_WATCHDOG_EXCEPTION_ON_ERROR")
170
+ == "1",
171
+ "WATCHDOG_EXCEPTION_ON_ERROR",
172
+ )
173
+
174
+ #: Health check timeout in seconds, defaults to 60 seconds.
175
+ check_health_timeout = _ConfigDescriptor["Config"](
176
+ lambda instance: 60, "CHECK_HEALTH_TIMEOUT"
177
+ )
178
+
179
+ #: Whether to skip health check, defaults to True.
180
+ check_health = _ConfigDescriptor["Config"](lambda instance: True, "CHECK_HEALTH")
181
+
182
+ #: Whether to print search results, defaults to True.
183
+ print_search_results = _ConfigDescriptor["Config"](
184
+ lambda instance: True, "PRINT_SEARCH_RESULTS"
185
+ )
186
+
187
+ #: Whether to clear environment variables related to Fluent parallel mode, defaults to False.
188
+ clear_fluent_para_envs = _ConfigDescriptor["Config"](
189
+ lambda instance: False, "CLEAR_FLUENT_PARA_ENVS"
190
+ )
191
+
192
+ #: Set stdout of the launched Fluent process.
193
+ #: Valid values are the same as subprocess.Popen's stdout argument.
194
+ launch_fluent_stdout = _ConfigDescriptor["Config"](
195
+ lambda instance: None, "LAUNCH_FLUENT_STDOUT"
196
+ )
197
+
198
+ #: Set stderr of the launched Fluent process.
199
+ #: Valid values are the same as subprocess.Popen's stderr argument.
200
+ launch_fluent_stderr = _ConfigDescriptor["Config"](
201
+ lambda instance: None, "LAUNCH_FLUENT_STDERR"
202
+ )
203
+
204
+ #: Set the IP address of the Fluent server while launching Fluent, defaults to the value of ``PYFLUENT_FLUENT_IP`` environment variable.
205
+ launch_fluent_ip = _ConfigDescriptor["Config"](
206
+ lambda instance: instance._env.get("PYFLUENT_FLUENT_IP"), "LAUNCH_FLUENT_IP"
207
+ )
208
+
209
+ #: Set the port of the Fluent server while launching Fluent, defaults to the value of ``PYFLUENT_FLUENT_PORT`` environment variable.
210
+ launch_fluent_port = _ConfigDescriptor["Config"](
211
+ lambda instance: instance._env.get("PYFLUENT_FLUENT_PORT"), "LAUNCH_FLUENT_PORT"
212
+ )
213
+
214
+ #: Skip password check during RPC execution when Fluent is launched from PyFluent, defaults to False.
215
+ launch_fluent_skip_password_check = _ConfigDescriptor["Config"](
216
+ lambda instance: False, "LAUNCH_FLUENT_SKIP_PASSWORD_CHECK"
217
+ )
218
+
219
+ #: The timeout in seconds to wait for Fluent to exit, defaults to the value of ``PYFLUENT_FORCE_EXIT_TIMEOUT`` environment variable.
220
+ force_exit_timeout = _ConfigDescriptor["Config"](
221
+ lambda instance: instance._env.get("PYFLUENT_FORCE_EXIT_TIMEOUT")
222
+ )
223
+
224
+ #: Whether to skip code generation of built-in settings, defaults to the value of ``PYFLUENT_CODEGEN_SKIP_BUILTIN_SETTINGS`` environment variable.
225
+ codegen_skip_builtin_settings = _ConfigDescriptor["Config"](
226
+ lambda instance: instance._env.get("PYFLUENT_CODEGEN_SKIP_BUILTIN_SETTINGS")
227
+ == "1"
228
+ )
229
+
230
+ #: Whether to launch Fluent in a container, defaults to the value of ``PYFLUENT_LAUNCH_CONTAINER`` environment variable.
231
+ launch_fluent_container = _ConfigDescriptor["Config"](
232
+ lambda instance: instance._env.get("PYFLUENT_LAUNCH_CONTAINER") == "1"
233
+ )
234
+
235
+ #: The tag of the Fluent image to use when launching in a container, defaults to the value of ``FLUENT_IMAGE_TAG`` environment variable or the latest release version of Fluent.
236
+ fluent_image_tag = _ConfigDescriptor["Config"](
237
+ lambda instance: instance._env.get(
238
+ "FLUENT_IMAGE_TAG", f"v{instance.fluent_release_version}"
239
+ )
240
+ )
241
+
242
+ #: The name of the Fluent image to use when launching in a container, defaults to the value of ``FLUENT_IMAGE_NAME`` environment variable.
243
+ fluent_image_name = _ConfigDescriptor["Config"](
244
+ lambda instance: instance._env.get("FLUENT_IMAGE_NAME")
245
+ )
246
+
247
+ #: The name of the Fluent container to use when launching in a container, defaults to the value of ``FLUENT_CONTAINER_NAME`` environment variable.
248
+ fluent_container_name = _ConfigDescriptor["Config"](
249
+ lambda instance: instance._env.get("FLUENT_CONTAINER_NAME")
250
+ )
251
+
252
+ #: Whether to use Docker Compose for launching Fluent in a container, defaults to the value of ``PYFLUENT_USE_DOCKER_COMPOSE`` environment variable.
253
+ use_docker_compose = _ConfigDescriptor["Config"](
254
+ lambda instance: instance._env.get("PYFLUENT_USE_DOCKER_COMPOSE") == "1"
255
+ )
256
+
257
+ #: Whether to use Podman Compose for launching Fluent in a container, defaults to the value of ``PYFLUENT_USE_PODMAN_COMPOSE`` environment variable.
258
+ use_podman_compose = _ConfigDescriptor["Config"](
259
+ lambda instance: instance._env.get("PYFLUENT_USE_PODMAN_COMPOSE") == "1"
260
+ )
261
+
262
+ #: The timeout in seconds to wait for Fluent to launch, defaults to the value of ``PYFLUENT_LAUNCH_FLUENT_TIMEOUT`` environment variable or 60 seconds.
263
+ launch_fluent_timeout = _ConfigDescriptor["Config"](
264
+ lambda instance: int(instance._env.get("PYFLUENT_LAUNCH_FLUENT_TIMEOUT", 60))
265
+ )
266
+
267
+ #: Whether to show the Fluent GUI when launching the server, defaults to the value of ``PYFLUENT_SHOW_SERVER_GUI`` environment variable.
268
+ show_fluent_gui = _ConfigDescriptor["Config"](
269
+ lambda instance: instance._env.get("PYFLUENT_SHOW_SERVER_GUI") == "1"
270
+ )
271
+
272
+ #: Whether to launch Fluent in debug mode, defaults to the value of ``PYFLUENT_FLUENT_DEBUG`` environment variable.
273
+ fluent_debug = _ConfigDescriptor["Config"](
274
+ lambda instance: instance._env.get("PYFLUENT_FLUENT_DEBUG") == "1"
275
+ )
276
+
277
+ #: Whether to skip API upgrade advice, defaults to the value of ``PYFLUENT_SKIP_API_UPGRADE_ADVICE`` environment variable.
278
+ skip_api_upgrade_advice = _ConfigDescriptor["Config"](
279
+ lambda instance: instance._env.get("PYFLUENT_SKIP_API_UPGRADE_ADVICE") == "1"
280
+ )
281
+
282
+ #: The maximum number of bytes to log in gRPC logs, defaults to the value of ``PYFLUENT_GRPC_LOG_BYTES_LIMIT`` environment variable or 1000 bytes.
283
+ grpc_log_bytes_limit = _ConfigDescriptor["Config"](
284
+ lambda instance: int(instance._env.get("PYFLUENT_GRPC_LOG_BYTES_LIMIT", 1000))
285
+ )
286
+
287
+ #: Whether to disable the fix for returning parameter lists via settings API, defaults to the value of ``PYFLUENT_NO_FIX_PARAMETER_LIST_RETURN`` environment variable.
288
+ disable_parameter_list_return_fix = _ConfigDescriptor["Config"](
289
+ lambda instance: instance._env.get("PYFLUENT_NO_FIX_PARAMETER_LIST_RETURN")
290
+ == "1"
291
+ )
292
+
293
+ #: Whether to use runtime Python classes for settings, defaults to the value of ``PYFLUENT_USE_RUNTIME_PYTHON_CLASSES`` environment variable.
294
+ use_runtime_python_classes = _ConfigDescriptor["Config"](
295
+ lambda instance: instance._env.get("PYFLUENT_USE_RUNTIME_PYTHON_CLASSES") == "1"
296
+ )
297
+
298
+ #: Whether to hide sensitive information in logs, defaults to the value of ``PYFLUENT_HIDE_LOG_SECRETS`` environment variable.
299
+ hide_log_secrets = _ConfigDescriptor["Config"](
300
+ lambda instance: instance._env.get("PYFLUENT_HIDE_LOG_SECRETS") == "1"
301
+ )
302
+
303
+ #: The Fluent root directory to be used for PyFluent, defaults to the value of ``PYFLUENT_FLUENT_ROOT`` environment variable.
304
+ fluent_root = _ConfigDescriptor["Config"](
305
+ lambda instance: instance._env.get("PYFLUENT_FLUENT_ROOT")
306
+ )
307
+
308
+ #: The remoting server address to be used in Fluent, defaults to the value of ``REMOTING_SERVER_ADDRESS`` environment variable.
309
+ remoting_server_address = _ConfigDescriptor["Config"](
310
+ lambda instance: instance._env.get("REMOTING_SERVER_ADDRESS")
311
+ )
312
+
313
+ #: The directory where server info will be written from Fluent, defaults to the value of ``SERVER_INFO_DIR`` environment variable.
314
+ fluent_server_info_dir = _ConfigDescriptor["Config"](
315
+ lambda instance: instance._env.get("SERVER_INFO_DIR")
316
+ )
317
+
318
+ #: Current unit test name, defaults to the value of ``PYFLUENT_TEST_NAME`` environment variable.
319
+ test_name = _ConfigDescriptor["Config"](
320
+ lambda instance: instance._env.get("PYFLUENT_TEST_NAME")
321
+ )
322
+
323
+ #: The default logging level for PyFluent, defaults to the value of ``PYFLUENT_LOGGING`` environment variable.
324
+ logging_level_default = _ConfigDescriptor["Config"](
325
+ lambda instance: instance._env.get("PYFLUENT_LOGGING")
326
+ )
327
+
328
+ def __init__(self):
329
+ """__init__ method of Config class."""
330
+ # Read the environment variable once when pyfluent is imported
331
+ # and reuse it throughout process lifetime.
332
+ self._env = os.environ.copy()
333
+
334
+ @property
335
+ def fluent_release_version(self) -> str:
336
+ """The latest released version of Fluent."""
337
+ return "25.2.0"
338
+
339
+ @property
340
+ def fluent_dev_version(self) -> str:
341
+ """The latest development version of Fluent."""
342
+ return "26.1.0"
343
+
344
+ def print(self):
345
+ """Print all configuration variables."""
346
+ config_dict = {}
347
+ for k, v in inspect.getmembers_static(self):
348
+ if isinstance(v, (_ConfigDescriptor, property)):
349
+ config_dict[k] = v.__get__(self, self.__class__)
350
+ max_key_length = max(len(k) for k in config_dict)
351
+ print("PyFluent Configuration:")
352
+ print("-" * (max_key_length + 20))
353
+ for k, v in config_dict.items():
354
+ print(f"{k.ljust(max_key_length)} : {v}")
355
+
356
+
357
+ #: Global configuration object for PyFluent
358
+ config = Config()
@@ -38,16 +38,22 @@ class PyFluentUserWarning(UserWarning):
38
38
  pass
39
39
 
40
40
 
41
+ class FluentDevVersionWarning(PyFluentUserWarning):
42
+ """Warning raised when a released PyFluent version is used with a development version of Fluent."""
43
+
44
+ pass
45
+
46
+
41
47
  def warning_for_fluent_dev_version(version):
42
48
  """Provides warning if Fluent develop branch is used."""
43
- from ansys.fluent.core import FLUENT_RELEASE_VERSION, FluentVersion
49
+ from ansys.fluent.core import FluentVersion, config
44
50
 
45
- if FluentVersion(version) > FluentVersion(FLUENT_RELEASE_VERSION):
51
+ if FluentVersion(version) > FluentVersion(config.fluent_release_version):
46
52
  warnings.warn(
47
53
  "⚠️ Warning: You are using PyFluent with an unreleased or development version of Fluent.\n"
48
54
  "Compatibility is not guaranteed, and unexpected behavior may occur. Please use a released "
49
55
  "version of Fluent that is officially supported by this version of PyFluent.",
50
- PyFluentUserWarning,
56
+ FluentDevVersionWarning,
51
57
  )
52
58
 
53
59
 
@@ -44,6 +44,8 @@ ANSYS_ENV_VARS = [
44
44
  "PYFLUENT_FLUENT_IP",
45
45
  "PYFLUENT_FLUENT_PORT",
46
46
  "PYFLUENT_FLUENT_ROOT",
47
+ "PYFLUENT_FLUENT_LAUNCH_TIMEOUT",
48
+ "PYFLUENT_FLUENT_AUTOMATIC_TRANSCRIPT",
47
49
  "PYFLUENT_GRPC_LOG_BYTES_LIMIT",
48
50
  "PYFLUENT_LAUNCH_CONTAINER",
49
51
  "PYFLUENT_LOGGING",
@@ -56,8 +58,6 @@ ANSYS_ENV_VARS = [
56
58
  "REMOTING_PORTS",
57
59
  "REMOTING_SERVER_ADDRESS",
58
60
  "SERVER_INFO_DIR",
59
- "PYFLUENT_USE_DOCKER_COMPOSE",
60
- "PYFLUENT_USE_PODMAN_COMPOSE",
61
61
  ]
62
62
 
63
63