ansys-fluent-core 0.34.1__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 (81) 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 +50 -28
  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 +1 -1
  7. ansys/fluent/core/codegen/tuigen.py +4 -4
  8. ansys/fluent/core/data_model_cache.py +2 -2
  9. ansys/fluent/core/docker/docker_compose.py +8 -9
  10. ansys/fluent/core/docker/utils.py +1 -1
  11. ansys/fluent/core/examples/downloads.py +8 -11
  12. ansys/fluent/core/fluent_connection.py +23 -15
  13. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  14. ansys/fluent/core/generated/datamodel_231/flicing.py +55 -55
  15. ansys/fluent/core/generated/datamodel_231/meshing.py +209 -209
  16. ansys/fluent/core/generated/datamodel_232/flicing.py +45 -45
  17. ansys/fluent/core/generated/datamodel_232/meshing.py +205 -205
  18. ansys/fluent/core/generated/datamodel_241/flicing.py +30 -30
  19. ansys/fluent/core/generated/datamodel_241/meshing.py +298 -298
  20. ansys/fluent/core/generated/datamodel_242/flicing.py +35 -35
  21. ansys/fluent/core/generated/datamodel_242/meshing.py +321 -321
  22. ansys/fluent/core/generated/datamodel_242/part_management.py +3 -3
  23. ansys/fluent/core/generated/datamodel_251/flicing.py +40 -40
  24. ansys/fluent/core/generated/datamodel_251/meshing.py +315 -315
  25. ansys/fluent/core/generated/datamodel_251/part_management.py +6 -6
  26. ansys/fluent/core/generated/datamodel_252/flicing.py +45 -45
  27. ansys/fluent/core/generated/datamodel_252/meshing.py +398 -398
  28. ansys/fluent/core/generated/datamodel_261/flicing.py +50 -50
  29. ansys/fluent/core/generated/datamodel_261/meshing.py +406 -406
  30. ansys/fluent/core/generated/datamodel_261/meshing_utilities.py +616 -296
  31. ansys/fluent/core/generated/datamodel_261/part_management.py +10 -10
  32. ansys/fluent/core/generated/fluent_version_252.py +1 -1
  33. ansys/fluent/core/generated/fluent_version_261.py +3 -3
  34. ansys/fluent/core/generated/meshing/tui_261.py +1178 -1133
  35. ansys/fluent/core/generated/solver/settings_261.py +2378 -3023
  36. ansys/fluent/core/generated/solver/settings_261.pyi +1537 -1456
  37. ansys/fluent/core/generated/solver/settings_builtin.py +515 -27
  38. ansys/fluent/core/generated/solver/settings_builtin.pyi +2 -18
  39. ansys/fluent/core/generated/solver/tui_261.py +2606 -3483
  40. ansys/fluent/core/launcher/container_launcher.py +19 -4
  41. ansys/fluent/core/launcher/fluent_container.py +48 -39
  42. ansys/fluent/core/launcher/launch_options.py +5 -4
  43. ansys/fluent/core/launcher/launcher.py +16 -3
  44. ansys/fluent/core/launcher/launcher_utils.py +63 -15
  45. ansys/fluent/core/launcher/pim_launcher.py +17 -3
  46. ansys/fluent/core/launcher/process_launch_string.py +3 -2
  47. ansys/fluent/core/launcher/server_info.py +7 -3
  48. ansys/fluent/core/launcher/slurm_launcher.py +4 -2
  49. ansys/fluent/core/launcher/standalone_launcher.py +6 -3
  50. ansys/fluent/core/launcher/watchdog.py +3 -3
  51. ansys/fluent/core/launcher/watchdog_exec +1 -1
  52. ansys/fluent/core/logger.py +3 -1
  53. ansys/fluent/core/module_config.py +358 -0
  54. ansys/fluent/core/pyfluent_warnings.py +2 -2
  55. ansys/fluent/core/report.py +0 -2
  56. ansys/fluent/core/search.py +31 -18
  57. ansys/fluent/core/services/api_upgrade.py +3 -2
  58. ansys/fluent/core/services/datamodel_se.py +4 -2
  59. ansys/fluent/core/services/health_check.py +3 -1
  60. ansys/fluent/core/services/interceptors.py +8 -6
  61. ansys/fluent/core/session.py +31 -3
  62. ansys/fluent/core/session_pure_meshing.py +1 -1
  63. ansys/fluent/core/session_shared.py +4 -4
  64. ansys/fluent/core/session_solver.py +8 -2
  65. ansys/fluent/core/session_utilities.py +7 -0
  66. ansys/fluent/core/solver/flobject.py +6 -4
  67. ansys/fluent/core/solver/settings_builtin_bases.py +3 -3
  68. ansys/fluent/core/solver/settings_builtin_data.py +2 -14
  69. ansys/fluent/core/streaming_services/datamodel_event_streaming.py +3 -2
  70. ansys/fluent/core/streaming_services/datamodel_streaming.py +3 -1
  71. ansys/fluent/core/streaming_services/events_streaming.py +2 -18
  72. ansys/fluent/core/system_coupling.py +3 -1
  73. ansys/fluent/core/utils/__init__.py +0 -7
  74. ansys/fluent/core/utils/data_transfer.py +3 -3
  75. ansys/fluent/core/utils/file_transfer_service.py +24 -15
  76. ansys/fluent/core/utils/fluent_version.py +3 -3
  77. ansys/fluent/core/utils/networking.py +2 -2
  78. {ansys_fluent_core-0.34.1.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/METADATA +1 -1
  79. {ansys_fluent_core-0.34.1.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/RECORD +81 -80
  80. {ansys_fluent_core-0.34.1.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/LICENSE +0 -0
  81. {ansys_fluent_core-0.34.1.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/WHEEL +0 -0
@@ -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,7 +76,7 @@ def launch(
76
76
  )
77
77
  )
78
78
 
79
- debug_watchdog = os.getenv("PYFLUENT_WATCHDOG_DEBUG") == "1"
79
+ debug_watchdog = pyfluent.config.watchdog_debug
80
80
  if debug_watchdog:
81
81
  logger.debug(
82
82
  f"PYFLUENT_WATCHDOG_DEBUG environment variable found, "
@@ -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") == "1":
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") == "1":
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") == "1":
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()
@@ -46,9 +46,9 @@ class FluentDevVersionWarning(PyFluentUserWarning):
46
46
 
47
47
  def warning_for_fluent_dev_version(version):
48
48
  """Provides warning if Fluent develop branch is used."""
49
- from ansys.fluent.core import FLUENT_RELEASE_VERSION, FluentVersion
49
+ from ansys.fluent.core import FluentVersion, config
50
50
 
51
- if FluentVersion(version) > FluentVersion(FLUENT_RELEASE_VERSION):
51
+ if FluentVersion(version) > FluentVersion(config.fluent_release_version):
52
52
  warnings.warn(
53
53
  "⚠️ Warning: You are using PyFluent with an unreleased or development version of Fluent.\n"
54
54
  "Compatibility is not guaranteed, and unexpected behavior may occur. Please use a released "
@@ -58,8 +58,6 @@ ANSYS_ENV_VARS = [
58
58
  "REMOTING_PORTS",
59
59
  "REMOTING_SERVER_ADDRESS",
60
60
  "SERVER_INFO_DIR",
61
- "PYFLUENT_USE_DOCKER_COMPOSE",
62
- "PYFLUENT_USE_PODMAN_COMPOSE",
63
61
  ]
64
62
 
65
63
 
@@ -41,16 +41,16 @@ from ansys.fluent.core.utils.fluent_version import (
41
41
 
42
42
  def _get_api_tree_data_file_path():
43
43
  """Get API tree data file."""
44
- from ansys.fluent.core import CODEGEN_OUTDIR
44
+ from ansys.fluent.core import config
45
45
 
46
- return (CODEGEN_OUTDIR / "api_tree" / "api_objects.json").resolve()
46
+ return (config.codegen_outdir / "api_tree" / "api_objects.json").resolve()
47
47
 
48
48
 
49
49
  def get_api_tree_file_name(version: str) -> Path:
50
50
  """Get API tree file name."""
51
- from ansys.fluent.core import CODEGEN_OUTDIR
51
+ from ansys.fluent.core import config
52
52
 
53
- return (CODEGEN_OUTDIR / f"api_tree_{version}.pickle").resolve()
53
+ return (config.codegen_outdir / f"api_tree_{version}.pickle").resolve()
54
54
 
55
55
 
56
56
  def _remove_suffix(input: str, suffix):
@@ -127,9 +127,9 @@ def _generate_api_data(
127
127
  from nltk.corpus import wordnet as wn
128
128
 
129
129
  _download_nltk_data()
130
- from ansys.fluent.core import CODEGEN_OUTDIR
130
+ from ansys.fluent.core import config
131
131
 
132
- json_file_folder = Path(os.path.join(CODEGEN_OUTDIR, "api_tree"))
132
+ json_file_folder = Path(os.path.join(config.codegen_outdir, "api_tree"))
133
133
  json_file_folder.mkdir(parents=True, exist_ok=True)
134
134
 
135
135
  all_api_object_name_synsets = dict()
@@ -164,7 +164,10 @@ def _get_api_tree_data():
164
164
 
165
165
 
166
166
  def _print_search_results(
167
- queries: list, api_tree_data: dict | None = None, api_path: str | None = None
167
+ queries: list,
168
+ api_tree_data: dict | None = None,
169
+ api_path: str | None = None,
170
+ match_whole_word: bool | None = None,
168
171
  ):
169
172
  """
170
173
  Print search results.
@@ -178,6 +181,9 @@ def _print_search_results(
178
181
  If None, it is retrieved using _get_api_tree_data().
179
182
  api_path : str, optional
180
183
  Specific path to restrict the search to. If None, searches the entire object hierarchy.
184
+ match_whole_word : bool, optional
185
+ If True, only exact matches are returned. If False, semantic search is performed.
186
+ The default is None, which means semantic search is performed.
181
187
  """
182
188
  api_tree_data = api_tree_data or _get_api_tree_data()
183
189
  api_sources = [api_tree_data["api_objects"], api_tree_data["api_tui_objects"]]
@@ -207,18 +213,22 @@ def _print_search_results(
207
213
  for query in queries:
208
214
  if isinstance(query, tuple):
209
215
  name, score = query
216
+ if (
217
+ name in first_token
218
+ and has_query(name, substrings)
219
+ and name in substrings[-1]
220
+ ):
221
+ if score is not None:
222
+ results.add((api_object, round(score, 2)))
210
223
  else:
211
224
  name = query
212
225
  score = None
213
226
 
214
- if (
215
- name in first_token
216
- and has_query(name, substrings)
217
- and name in substrings[-1]
218
- ):
219
- if score is not None:
220
- results.add((api_object, round(score, 2)))
221
- else:
227
+ if match_whole_word and (
228
+ first_token == name or first_token.endswith(f".{name}")
229
+ ):
230
+ results.add(api_object)
231
+ elif not match_whole_word and name in first_token:
222
232
  results.add(api_object)
223
233
 
224
234
  return sorted(results)
@@ -235,7 +245,7 @@ def _print_search_results(
235
245
  )
236
246
 
237
247
  results = final_results or all_results
238
- if pyfluent.PRINT_SEARCH_RESULTS:
248
+ if pyfluent.config.print_search_results:
239
249
  for result in results:
240
250
  print(result)
241
251
  elif results:
@@ -324,7 +334,7 @@ def _get_exact_match_for_word_from_names(
324
334
  -------
325
335
  List of exact match.
326
336
  """
327
- return list({name for name in names if word == name or word in name})
337
+ return list({name for name in names if word == name})
328
338
 
329
339
 
330
340
  def _get_capitalize_match_for_word_from_names(
@@ -461,7 +471,10 @@ def _search_whole_word(
461
471
  )
462
472
  if queries:
463
473
  return _print_search_results(
464
- queries, api_tree_data=api_tree_data, api_path=api_path
474
+ queries,
475
+ api_tree_data=api_tree_data,
476
+ api_path=api_path,
477
+ match_whole_word=match_whole_word,
465
478
  )
466
479
 
467
480
 
@@ -22,7 +22,6 @@
22
22
 
23
23
  """Provides a module for the API upgrade advisor."""
24
24
 
25
- import os
26
25
  from typing import TypeVar
27
26
 
28
27
  from ansys.fluent.core.services.app_utilities import AppUtilities
@@ -47,8 +46,10 @@ class ApiUpgradeAdvisor:
47
46
  self._id = None
48
47
 
49
48
  def _can_advise(self) -> bool:
49
+ from ansys.fluent.core import config
50
+
50
51
  return (
51
- not os.getenv("PYFLUENT_SKIP_API_UPGRADE_ADVICE")
52
+ not config.skip_api_upgrade_advice
52
53
  and FluentVersion(self._version) >= FluentVersion.v231
53
54
  and self._mode == "solver"
54
55
  )