ansys-fluent-core 0.28.2__py3-none-any.whl → 0.29.0__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 (221) hide show
  1. ansys/fluent/core/__init__.py +26 -1
  2. ansys/fluent/core/_stand_alone_datamodel_client/_datamodel_client.py +22 -0
  3. ansys/fluent/core/_version.py +24 -2
  4. ansys/fluent/core/codegen/__init__.py +22 -0
  5. ansys/fluent/core/codegen/allapigen.py +38 -5
  6. ansys/fluent/core/codegen/builtin_settingsgen.py +22 -0
  7. ansys/fluent/core/codegen/data/__init__.py +21 -0
  8. ansys/fluent/core/codegen/data/fluent_gui_help_patch.py +22 -0
  9. ansys/fluent/core/codegen/data/meshing_utilities_examples.py +22 -0
  10. ansys/fluent/core/codegen/datamodelgen.py +40 -4
  11. ansys/fluent/core/codegen/print_fluent_version.py +22 -0
  12. ansys/fluent/core/codegen/settingsgen.py +67 -4
  13. ansys/fluent/core/codegen/tuigen.py +44 -6
  14. ansys/fluent/core/codegen/walk_api.py +67 -18
  15. ansys/fluent/core/codegen/write_settings_yaml.py +22 -0
  16. ansys/fluent/core/data_model_cache.py +22 -0
  17. ansys/fluent/core/examples/__init__.py +22 -0
  18. ansys/fluent/core/examples/downloads.py +22 -0
  19. ansys/fluent/core/exceptions.py +22 -0
  20. ansys/fluent/core/file_session.py +22 -0
  21. ansys/fluent/core/filereader/__init__.py +21 -0
  22. ansys/fluent/core/filereader/case_file.py +22 -0
  23. ansys/fluent/core/filereader/casereader.py +22 -0
  24. ansys/fluent/core/filereader/data_file.py +22 -0
  25. ansys/fluent/core/filereader/lispy.py +22 -0
  26. ansys/fluent/core/fluent_connection.py +23 -1
  27. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  28. ansys/fluent/core/generated/datamodel_252/meshing.py +32 -0
  29. ansys/fluent/core/generated/fluent_version_252.py +3 -3
  30. ansys/fluent/core/generated/solver/settings_222.py +0 -72
  31. ansys/fluent/core/generated/solver/settings_222.pyi +0 -307
  32. ansys/fluent/core/generated/solver/settings_231.py +0 -574
  33. ansys/fluent/core/generated/solver/settings_231.pyi +0 -561
  34. ansys/fluent/core/generated/solver/settings_232.py +0 -527
  35. ansys/fluent/core/generated/solver/settings_232.pyi +0 -2803
  36. ansys/fluent/core/generated/solver/settings_241.py +0 -478
  37. ansys/fluent/core/generated/solver/settings_241.pyi +0 -522
  38. ansys/fluent/core/generated/solver/settings_242.py +0 -361
  39. ansys/fluent/core/generated/solver/settings_242.pyi +0 -591
  40. ansys/fluent/core/generated/solver/settings_251.py +0 -399
  41. ansys/fluent/core/generated/solver/settings_251.pyi +0 -629
  42. ansys/fluent/core/generated/solver/settings_252.py +7794 -4185
  43. ansys/fluent/core/generated/solver/settings_252.pyi +6986 -3213
  44. ansys/fluent/core/generated/solver/tui_252.py +537 -181
  45. ansys/fluent/core/get_build_details.py +22 -0
  46. ansys/fluent/core/journaling.py +38 -0
  47. ansys/fluent/core/launcher/__init__.py +22 -0
  48. ansys/fluent/core/launcher/container_launcher.py +65 -56
  49. ansys/fluent/core/launcher/error_handler.py +30 -0
  50. ansys/fluent/core/launcher/fluent_container.py +45 -20
  51. ansys/fluent/core/launcher/launcher.py +53 -5
  52. ansys/fluent/core/launcher/launcher_utils.py +22 -0
  53. ansys/fluent/core/launcher/pim_launcher.py +120 -86
  54. ansys/fluent/core/launcher/process_launch_string.py +22 -0
  55. ansys/fluent/core/launcher/pyfluent_enums.py +22 -0
  56. ansys/fluent/core/launcher/server_info.py +45 -3
  57. ansys/fluent/core/launcher/slurm_launcher.py +25 -3
  58. ansys/fluent/core/launcher/standalone_launcher.py +68 -63
  59. ansys/fluent/core/launcher/watchdog.py +22 -0
  60. ansys/fluent/core/logging.py +24 -0
  61. ansys/fluent/core/logging_config.yaml +3 -0
  62. ansys/fluent/core/meshing/meshing_workflow.py +22 -0
  63. ansys/fluent/core/parametric.py +22 -0
  64. ansys/fluent/core/post_objects/__init__.py +21 -0
  65. ansys/fluent/core/post_objects/check_in_notebook.py +22 -0
  66. ansys/fluent/core/post_objects/meta.py +22 -0
  67. ansys/fluent/core/post_objects/post_helper.py +22 -0
  68. ansys/fluent/core/post_objects/post_object_definitions.py +22 -0
  69. ansys/fluent/core/post_objects/post_objects_container.py +22 -0
  70. ansys/fluent/core/post_objects/singleton_meta.py +22 -0
  71. ansys/fluent/core/post_objects/timing_decorator.py +22 -0
  72. ansys/fluent/core/report.py +77 -0
  73. ansys/fluent/core/rpvars.py +22 -0
  74. ansys/fluent/core/scheduler/__init__.py +22 -0
  75. ansys/fluent/core/scheduler/load_machines.py +22 -0
  76. ansys/fluent/core/scheduler/machine_list.py +22 -0
  77. ansys/fluent/core/search.py +22 -0
  78. ansys/fluent/core/services/__init__.py +22 -0
  79. ansys/fluent/core/services/api_upgrade.py +22 -0
  80. ansys/fluent/core/services/app_utilities.py +38 -0
  81. ansys/fluent/core/services/batch_ops.py +22 -0
  82. ansys/fluent/core/services/datamodel_se.py +26 -1
  83. ansys/fluent/core/services/datamodel_tui.py +22 -0
  84. ansys/fluent/core/services/deprecated_field_data.py +23 -1
  85. ansys/fluent/core/services/events.py +22 -0
  86. ansys/fluent/core/services/field_data.py +285 -2
  87. ansys/fluent/core/services/health_check.py +22 -0
  88. ansys/fluent/core/services/interceptors.py +50 -2
  89. ansys/fluent/core/services/monitor.py +22 -0
  90. ansys/fluent/core/services/reduction.py +22 -0
  91. ansys/fluent/core/services/scheme_eval.py +22 -0
  92. ansys/fluent/core/services/settings.py +22 -0
  93. ansys/fluent/core/services/solution_variables.py +22 -0
  94. ansys/fluent/core/services/streaming.py +22 -0
  95. ansys/fluent/core/services/transcript.py +22 -0
  96. ansys/fluent/core/session.py +39 -2
  97. ansys/fluent/core/session_base_meshing.py +22 -0
  98. ansys/fluent/core/session_meshing.py +22 -0
  99. ansys/fluent/core/session_meshing.pyi +22 -0
  100. ansys/fluent/core/session_pure_meshing.py +22 -0
  101. ansys/fluent/core/session_pure_meshing.pyi +22 -0
  102. ansys/fluent/core/session_shared.py +22 -0
  103. ansys/fluent/core/session_solver.py +43 -0
  104. ansys/fluent/core/session_solver.pyi +22 -0
  105. ansys/fluent/core/session_solver_aero.py +22 -0
  106. ansys/fluent/core/session_solver_icing.py +22 -0
  107. ansys/fluent/core/session_solver_lite.py +22 -0
  108. ansys/fluent/core/solver/__init__.py +22 -0
  109. ansys/fluent/core/solver/error_message.py +22 -0
  110. ansys/fluent/core/solver/flobject.py +22 -0
  111. ansys/fluent/core/solver/flunits.py +22 -0
  112. ansys/fluent/core/solver/function/__init__.py +22 -0
  113. ansys/fluent/core/solver/function/reduction.py +22 -0
  114. ansys/fluent/core/solver/settings_builtin_bases.py +22 -0
  115. ansys/fluent/core/solver/settings_builtin_data.py +22 -0
  116. ansys/fluent/core/solver/settings_external.py +22 -0
  117. ansys/fluent/core/streaming_services/__init__.py +21 -0
  118. ansys/fluent/core/streaming_services/datamodel_event_streaming.py +22 -0
  119. ansys/fluent/core/streaming_services/datamodel_streaming.py +22 -0
  120. ansys/fluent/core/streaming_services/events_streaming.py +22 -0
  121. ansys/fluent/core/streaming_services/field_data_streaming.py +22 -0
  122. ansys/fluent/core/streaming_services/monitor_streaming.py +23 -1
  123. ansys/fluent/core/streaming_services/streaming.py +22 -0
  124. ansys/fluent/core/streaming_services/transcript_streaming.py +22 -0
  125. ansys/fluent/core/systemcoupling.py +22 -0
  126. ansys/fluent/core/utils/__init__.py +22 -0
  127. ansys/fluent/core/utils/data_transfer.py +22 -0
  128. ansys/fluent/core/utils/deprecate.py +24 -1
  129. ansys/fluent/core/utils/dictionary_operations.py +22 -0
  130. ansys/fluent/core/utils/dump_session_data.py +22 -0
  131. ansys/fluent/core/utils/event_loop.py +22 -0
  132. ansys/fluent/core/utils/execution.py +22 -0
  133. ansys/fluent/core/utils/file_transfer_service.py +22 -0
  134. ansys/fluent/core/utils/fix_doc.py +22 -0
  135. ansys/fluent/core/utils/fldoc.py +22 -0
  136. ansys/fluent/core/utils/fluent_version.py +22 -0
  137. ansys/fluent/core/utils/networking.py +22 -0
  138. ansys/fluent/core/utils/setup_for_fluent.py +22 -0
  139. ansys/fluent/core/warnings.py +22 -0
  140. ansys/fluent/core/workflow.py +22 -0
  141. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/LICENSE +8 -8
  142. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/METADATA +56 -33
  143. ansys_fluent_core-0.29.0.dist-info/RECORD +219 -0
  144. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/WHEEL +1 -1
  145. ansys/fluent/core/docs/README.rst +0 -155
  146. ansys/fluent/tests/conftest.py +0 -415
  147. ansys/fluent/tests/fluent_fixtures.py +0 -195
  148. ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
  149. ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
  150. ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
  151. ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
  152. ansys/fluent/tests/test_aero_session.py +0 -88
  153. ansys/fluent/tests/test_batch_ops.py +0 -39
  154. ansys/fluent/tests/test_builtin_settings.py +0 -761
  155. ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
  156. ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
  157. ansys/fluent/tests/test_casereader.py +0 -324
  158. ansys/fluent/tests/test_codegen.py +0 -783
  159. ansys/fluent/tests/test_creatable.py +0 -31
  160. ansys/fluent/tests/test_data_model_cache.py +0 -434
  161. ansys/fluent/tests/test_datamodel_api.py +0 -429
  162. ansys/fluent/tests/test_datamodel_service.py +0 -814
  163. ansys/fluent/tests/test_datareader.py +0 -103
  164. ansys/fluent/tests/test_error_handling.py +0 -24
  165. ansys/fluent/tests/test_events_manager.py +0 -214
  166. ansys/fluent/tests/test_field_data.py +0 -466
  167. ansys/fluent/tests/test_file_session.py +0 -355
  168. ansys/fluent/tests/test_file_transfer_service.py +0 -165
  169. ansys/fluent/tests/test_fix_doc.py +0 -29
  170. ansys/fluent/tests/test_flobject.py +0 -1235
  171. ansys/fluent/tests/test_fluent_fixes.py +0 -106
  172. ansys/fluent/tests/test_fluent_session.py +0 -270
  173. ansys/fluent/tests/test_fluent_version.py +0 -66
  174. ansys/fluent/tests/test_fluent_version_marker.py +0 -65
  175. ansys/fluent/tests/test_icing_session.py +0 -9
  176. ansys/fluent/tests/test_launcher.py +0 -529
  177. ansys/fluent/tests/test_launcher_remote.py +0 -272
  178. ansys/fluent/tests/test_lispy.py +0 -40
  179. ansys/fluent/tests/test_logging.py +0 -16
  180. ansys/fluent/tests/test_mapped_api.py +0 -766
  181. ansys/fluent/tests/test_meshing_utilities.py +0 -2436
  182. ansys/fluent/tests/test_meshing_workflow.py +0 -421
  183. ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
  184. ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
  185. ansys/fluent/tests/test_preferences.py +0 -89
  186. ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
  187. ansys/fluent/tests/test_reduction.py +0 -484
  188. ansys/fluent/tests/test_rp_vars.py +0 -77
  189. ansys/fluent/tests/test_scheduler.py +0 -471
  190. ansys/fluent/tests/test_scheme_eval_222.py +0 -338
  191. ansys/fluent/tests/test_scheme_eval_231.py +0 -243
  192. ansys/fluent/tests/test_search.py +0 -344
  193. ansys/fluent/tests/test_session.py +0 -594
  194. ansys/fluent/tests/test_settings_api.py +0 -606
  195. ansys/fluent/tests/test_settings_reader.py +0 -85
  196. ansys/fluent/tests/test_slurm_future.py +0 -67
  197. ansys/fluent/tests/test_solution_variables.py +0 -241
  198. ansys/fluent/tests/test_solver_monitors.py +0 -83
  199. ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
  200. ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
  201. ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
  202. ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
  203. ansys/fluent/tests/test_solvermode/test_general.py +0 -109
  204. ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
  205. ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
  206. ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
  207. ansys/fluent/tests/test_solvermode/test_models.py +0 -99
  208. ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
  209. ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
  210. ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
  211. ansys/fluent/tests/test_streaming_services.py +0 -52
  212. ansys/fluent/tests/test_systemcoupling.py +0 -44
  213. ansys/fluent/tests/test_topy.py +0 -179
  214. ansys/fluent/tests/test_tui_api.py +0 -70
  215. ansys/fluent/tests/test_type_stub.py +0 -37
  216. ansys/fluent/tests/test_utils.py +0 -82
  217. ansys/fluent/tests/util/__init__.py +0 -36
  218. ansys/fluent/tests/util/meshing_workflow.py +0 -33
  219. ansys/fluent/tests/util/solver.py +0 -72
  220. ansys_fluent_core-0.28.2.dist-info/AUTHORS +0 -12
  221. ansys_fluent_core-0.28.2.dist-info/RECORD +0 -294
@@ -1,529 +0,0 @@
1
- import os
2
- from pathlib import Path
3
- import platform
4
- import tempfile
5
- from tempfile import TemporaryDirectory
6
-
7
- import pytest
8
-
9
- import ansys.fluent.core as pyfluent
10
- from ansys.fluent.core import PyFluentDeprecationWarning
11
- from ansys.fluent.core.examples.downloads import download_file
12
- from ansys.fluent.core.exceptions import DisallowedValuesError, InvalidArgument
13
- from ansys.fluent.core.launcher import launcher_utils
14
- from ansys.fluent.core.launcher.error_handler import (
15
- GPUSolverSupportError,
16
- LaunchFluentError,
17
- _raise_non_gui_exception_in_windows,
18
- )
19
- from ansys.fluent.core.launcher.launcher import create_launcher
20
- from ansys.fluent.core.launcher.launcher_utils import (
21
- _build_journal_argument,
22
- is_windows,
23
- )
24
- from ansys.fluent.core.launcher.process_launch_string import (
25
- _build_fluent_launch_args_string,
26
- get_fluent_exe_path,
27
- )
28
- from ansys.fluent.core.launcher.pyfluent_enums import (
29
- FluentLinuxGraphicsDriver,
30
- FluentMode,
31
- FluentWindowsGraphicsDriver,
32
- LaunchMode,
33
- UIMode,
34
- )
35
- from ansys.fluent.core.utils.fluent_version import AnsysVersionNotFound, FluentVersion
36
- import ansys.platform.instancemanagement as pypim
37
-
38
-
39
- def test_gpu_version_error():
40
- with pytest.raises(GPUSolverSupportError):
41
- pyfluent.launch_fluent(
42
- mode="meshing",
43
- dimension=2,
44
- precision="single",
45
- processor_count=5,
46
- ui_mode="gui",
47
- gpu=True,
48
- )
49
- pyfluent.setup_for_fluent(
50
- mode="meshing",
51
- dimension=2,
52
- precision="single",
53
- processor_count=5,
54
- ui_mode="gui",
55
- gpu=True,
56
- )
57
-
58
-
59
- def test_mode():
60
- with pytest.raises(DisallowedValuesError):
61
- pyfluent.launch_fluent(
62
- mode="meshing-solver",
63
- start_container=False,
64
- )
65
-
66
-
67
- @pytest.mark.standalone
68
- def test_unsuccessful_fluent_connection():
69
- # start-timeout is intentionally provided to be 2s for the connection to fail
70
- with pytest.raises(LaunchFluentError) as ex:
71
- pyfluent.launch_fluent(mode="solver", start_timeout=2)
72
- # TimeoutError -> LaunchFluentError
73
- assert isinstance(ex.value.__context__, TimeoutError)
74
-
75
-
76
- @pytest.mark.fluent_version("<24.1")
77
- def test_non_gui_in_windows_throws_exception():
78
- default_windows_flag = launcher_utils.is_windows()
79
- launcher_utils.is_windows = lambda: True
80
- try:
81
- with pytest.raises(InvalidArgument):
82
- _raise_non_gui_exception_in_windows(UIMode.NO_GUI, FluentVersion.v232)
83
- with pytest.raises(InvalidArgument):
84
- _raise_non_gui_exception_in_windows(UIMode.NO_GUI, FluentVersion.v231)
85
- with pytest.raises(InvalidArgument):
86
- _raise_non_gui_exception_in_windows(UIMode.NO_GUI, FluentVersion.v222)
87
- with pytest.raises(InvalidArgument):
88
- _raise_non_gui_exception_in_windows(
89
- UIMode.NO_GUI_OR_GRAPHICS, FluentVersion.v232
90
- )
91
- with pytest.raises(InvalidArgument):
92
- _raise_non_gui_exception_in_windows(
93
- UIMode.NO_GUI_OR_GRAPHICS, FluentVersion.v231
94
- )
95
- with pytest.raises(InvalidArgument):
96
- _raise_non_gui_exception_in_windows(
97
- UIMode.NO_GUI_OR_GRAPHICS, FluentVersion.v222
98
- )
99
- finally:
100
- launcher_utils.is_windows = lambda: default_windows_flag
101
-
102
-
103
- @pytest.mark.fluent_version(">=24.1")
104
- def test_non_gui_in_windows_does_not_throw_exception():
105
- default_windows_flag = launcher_utils.is_windows()
106
- launcher_utils.is_windows = lambda: True
107
- try:
108
- _raise_non_gui_exception_in_windows(UIMode.NO_GUI, FluentVersion.v241)
109
- _raise_non_gui_exception_in_windows(
110
- UIMode.NO_GUI_OR_GRAPHICS, FluentVersion.v241
111
- )
112
- _raise_non_gui_exception_in_windows(UIMode.NO_GUI, FluentVersion.v242)
113
- _raise_non_gui_exception_in_windows(
114
- UIMode.NO_GUI_OR_GRAPHICS, FluentVersion.v242
115
- )
116
- finally:
117
- launcher_utils.is_windows = lambda: default_windows_flag
118
-
119
-
120
- def test_container_launcher():
121
- # test dry_run
122
- container_dict = pyfluent.launch_fluent(start_container=True, dry_run=True)
123
- assert isinstance(container_dict, dict)
124
- assert len(container_dict) > 1
125
-
126
- # test run with configuration dict
127
- session = pyfluent.launch_fluent(container_dict=container_dict)
128
- assert session.health_check.is_serving
129
-
130
-
131
- @pytest.mark.standalone
132
- def test_case_load():
133
- # Test that launch_fluent() works with a case file as an argument
134
- case_name = download_file(
135
- "mixing_elbow.cas.h5",
136
- "pyfluent/mixing_elbow",
137
- )
138
- session = pyfluent.launch_fluent(case_file_name=case_name)
139
-
140
- # Case loaded
141
- assert session.setup.boundary_conditions.is_active()
142
- # Mesh available because not lightweight
143
- if not session.get_fluent_version() < FluentVersion.v231:
144
- assert session.mesh.quality.is_active()
145
- # Data not loaded
146
- assert not session.fields.field_data.is_data_valid()
147
-
148
- session.exit()
149
-
150
-
151
- @pytest.mark.standalone
152
- @pytest.mark.fluent_version(">=23.2")
153
- def test_case_lightweight_setup():
154
- # Test that launch_fluent() correctly performs lightweight setup
155
- case_name = download_file(
156
- "mixing_elbow.cas.h5",
157
- "pyfluent/mixing_elbow",
158
- )
159
- session = pyfluent.launch_fluent(
160
- case_file_name=case_name,
161
- lightweight_mode=True,
162
- )
163
-
164
- # Case loaded
165
- assert session.setup.boundary_conditions.is_active()
166
- # Mesh not available because lightweight
167
- assert not session.mesh.quality.is_active()
168
- # Data not loaded
169
- assert not session.fields.field_data.is_data_valid()
170
-
171
-
172
- @pytest.mark.standalone
173
- def test_case_data_load():
174
- # Test that launch_fluent() works with a case+data file as an argument
175
- case_name = download_file(
176
- "mixing_elbow.cas.h5",
177
- "pyfluent/mixing_elbow",
178
- )
179
- download_file(
180
- "mixing_elbow.dat.h5",
181
- "pyfluent/mixing_elbow",
182
- )
183
- session = pyfluent.launch_fluent(case_data_file_name=case_name)
184
-
185
- # Case loaded
186
- assert session.setup.boundary_conditions.is_active()
187
- # Mesh available because not lightweight
188
- if not session.get_fluent_version() < FluentVersion.v231:
189
- assert session.mesh.quality.is_active()
190
- # Data loaded
191
- assert session.fields.field_data.is_data_valid()
192
-
193
- session.exit()
194
-
195
-
196
- def test_gpu_launch_arg():
197
- assert (
198
- _build_fluent_launch_args_string(
199
- gpu=True, additional_arguments="", processor_count=None
200
- ).strip()
201
- == "3ddp -gpu -hidden"
202
- if is_windows()
203
- else "3ddp -gpu -gu"
204
- )
205
- assert (
206
- _build_fluent_launch_args_string(
207
- gpu=[1, 2, 4], additional_arguments="", processor_count=None
208
- ).strip()
209
- == "3ddp -gpu=1,2,4 -hidden"
210
- if is_windows()
211
- else "3ddp -gpu=1,2,4 -gu"
212
- )
213
-
214
-
215
- def test_gpu_launch_arg_additional_arg():
216
- assert (
217
- _build_fluent_launch_args_string(
218
- additional_arguments="-gpu", processor_count=None
219
- ).strip()
220
- == "3ddp -gpu -hidden"
221
- if is_windows()
222
- else "3ddp -gpu -gu"
223
- )
224
- assert (
225
- _build_fluent_launch_args_string(
226
- additional_arguments="-gpu=1,2,4", processor_count=None
227
- ).strip()
228
- == "3ddp -gpu=1,2,4 -hidden"
229
- if is_windows()
230
- else "3ddp -gpu=1,2,4 -gu"
231
- )
232
-
233
-
234
- def test_get_fluent_exe_path_when_nothing_is_set(helpers):
235
- helpers.delete_all_awp_vars()
236
- with pytest.raises(AnsysVersionNotFound):
237
- get_fluent_exe_path()
238
- with pytest.raises(AnsysVersionNotFound):
239
- FluentVersion.get_latest_installed()
240
-
241
-
242
- def test_get_fluent_exe_path_from_awp_root_222(helpers):
243
- helpers.mock_awp_vars(version="222")
244
- if platform.system() == "Windows":
245
- expected_path = Path("ansys_inc/v222/fluent") / "ntbin" / "win64" / "fluent.exe"
246
- else:
247
- expected_path = Path("ansys_inc/v222/fluent") / "bin" / "fluent"
248
- assert FluentVersion.get_latest_installed() == FluentVersion.v222
249
- assert get_fluent_exe_path() == expected_path
250
-
251
-
252
- def test_get_fluent_exe_path_from_awp_root_231(helpers):
253
- helpers.mock_awp_vars(version="231")
254
- if platform.system() == "Windows":
255
- expected_path = Path("ansys_inc/v231/fluent") / "ntbin" / "win64" / "fluent.exe"
256
- else:
257
- expected_path = Path("ansys_inc/v231/fluent") / "bin" / "fluent"
258
- assert FluentVersion.get_latest_installed() == FluentVersion.v231
259
- assert get_fluent_exe_path() == expected_path
260
-
261
-
262
- def test_get_fluent_exe_path_from_awp_root_232(helpers):
263
- helpers.mock_awp_vars(version="232")
264
- if platform.system() == "Windows":
265
- expected_path = Path("ansys_inc/v232/fluent") / "ntbin" / "win64" / "fluent.exe"
266
- else:
267
- expected_path = Path("ansys_inc/v232/fluent") / "bin" / "fluent"
268
- assert FluentVersion.get_latest_installed() == FluentVersion.v232
269
- assert get_fluent_exe_path() == expected_path
270
-
271
-
272
- def test_get_fluent_exe_path_from_awp_root_241(helpers):
273
- helpers.mock_awp_vars(version="241")
274
- if platform.system() == "Windows":
275
- expected_path = Path("ansys_inc/v241/fluent") / "ntbin" / "win64" / "fluent.exe"
276
- else:
277
- expected_path = Path("ansys_inc/v241/fluent") / "bin" / "fluent"
278
- assert FluentVersion.get_latest_installed() == FluentVersion.v241
279
- assert get_fluent_exe_path() == expected_path
280
-
281
-
282
- def test_get_fluent_exe_path_from_product_version_launcher_arg(helpers):
283
- helpers.mock_awp_vars()
284
- if platform.system() == "Windows":
285
- expected_path = Path("ansys_inc/v231/fluent") / "ntbin" / "win64" / "fluent.exe"
286
- else:
287
- expected_path = Path("ansys_inc/v231/fluent") / "bin" / "fluent"
288
- assert get_fluent_exe_path(product_version=231) == expected_path
289
-
290
-
291
- def test_get_fluent_exe_path_from_pyfluent_fluent_root(helpers, monkeypatch):
292
- helpers.mock_awp_vars()
293
- monkeypatch.setenv("PYFLUENT_FLUENT_ROOT", "dev/vNNN/fluent")
294
- if platform.system() == "Windows":
295
- expected_path = Path("dev/vNNN/fluent") / "ntbin" / "win64" / "fluent.exe"
296
- else:
297
- expected_path = Path("dev/vNNN/fluent") / "bin" / "fluent"
298
- assert get_fluent_exe_path() == expected_path
299
-
300
-
301
- def test_watchdog_launch(monkeypatch):
302
- monkeypatch.setenv("PYFLUENT_WATCHDOG_EXCEPTION_ON_ERROR", "1")
303
- pyfluent.launch_fluent(start_watchdog=True)
304
-
305
-
306
- @pytest.mark.standalone
307
- def test_create_standalone_launcher():
308
- kwargs = dict(
309
- ui_mode=UIMode.NO_GUI,
310
- graphics_driver=(
311
- FluentWindowsGraphicsDriver.AUTO
312
- if is_windows()
313
- else FluentLinuxGraphicsDriver.AUTO
314
- ),
315
- env={},
316
- )
317
-
318
- standalone_meshing_launcher = create_launcher(
319
- LaunchMode.STANDALONE, mode=FluentMode.MESHING, **kwargs
320
- )
321
- standalone_meshing_session = standalone_meshing_launcher()
322
- assert standalone_meshing_session
323
- standalone_meshing_session.exit()
324
-
325
- standalone_solver_launcher = create_launcher(
326
- LaunchMode.STANDALONE, mode=FluentMode.SOLVER, **kwargs
327
- )
328
- standalone_solver_session = standalone_solver_launcher()
329
- assert standalone_solver_session
330
- standalone_solver_session.exit()
331
-
332
-
333
- def test_fluent_launchers():
334
- kwargs = dict(
335
- ui_mode=UIMode.NO_GUI,
336
- graphics_driver=(
337
- FluentWindowsGraphicsDriver.AUTO
338
- if is_windows()
339
- else FluentLinuxGraphicsDriver.AUTO
340
- ),
341
- )
342
- kargs = dict(
343
- ui_mode=kwargs["ui_mode"],
344
- graphics_driver=kwargs["graphics_driver"],
345
- product_version=None,
346
- precision=None,
347
- processor_count=None,
348
- start_timeout=None,
349
- additional_arguments="",
350
- container_dict=None,
351
- dry_run=None,
352
- cleanup_on_exit=None,
353
- start_transcript=None,
354
- py=None,
355
- gpu=None,
356
- start_watchdog=None,
357
- file_transfer_service=None,
358
- )
359
- container_meshing_launcher = create_launcher(
360
- LaunchMode.CONTAINER,
361
- mode=FluentMode.MESHING,
362
- **kargs,
363
- )
364
- container_meshing_session = container_meshing_launcher()
365
- assert container_meshing_session
366
- container_meshing_session.exit()
367
-
368
- container_solver_launcher = create_launcher(
369
- LaunchMode.CONTAINER,
370
- mode=FluentMode.SOLVER,
371
- **kargs,
372
- )
373
- container_solver_session = container_solver_launcher()
374
- assert container_solver_session
375
- container_solver_session.exit()
376
-
377
- if pypim.is_configured():
378
- pim_meshing_launcher = create_launcher(
379
- LaunchMode.PIM, mode=FluentMode.MESHING, **kwargs
380
- )
381
- pim_meshing_session = pim_meshing_launcher()
382
- assert pim_meshing_session
383
- pim_meshing_session.exit()
384
-
385
- pim_solver_launcher = create_launcher(
386
- LaunchMode.PIM, mode=FluentMode.SOLVER, **kwargs
387
- )
388
- pim_solver_session = pim_solver_launcher()
389
- assert pim_solver_session
390
- pim_solver_session.exit()
391
-
392
-
393
- @pytest.mark.parametrize(
394
- "topy,journal_file_names,result,raises",
395
- [
396
- (None, "a.jou", ' -i "a.jou"', pytest.wont_raise()),
397
- (None, ["a.jou", "b.jou"], ' -i "a.jou" -i "b.jou"', pytest.wont_raise()),
398
- (True, "a.jou", ' -i "a.jou" -topy', pytest.wont_raise()),
399
- (True, ["a.jou", "b.jou"], ' -i "a.jou" -i "b.jou" -topy', pytest.wont_raise()),
400
- ("c.py", "a.jou", ' -i "a.jou" -topy="c.py"', pytest.wont_raise()),
401
- (
402
- "c.py",
403
- ["a.jou", "b.jou"],
404
- ' -i "a.jou" -i "b.jou" -topy="c.py"',
405
- pytest.wont_raise(),
406
- ),
407
- (None, 5, None, pytest.raises(TypeError)),
408
- (True, None, None, pytest.raises(InvalidArgument)),
409
- ],
410
- )
411
- def test_build_journal_argument(topy, journal_file_names, result, raises):
412
- with raises:
413
- assert _build_journal_argument(topy, journal_file_names) == result
414
-
415
-
416
- def test_show_gui_raises_warning():
417
- with pytest.warns(PyFluentDeprecationWarning):
418
- pyfluent.launch_fluent(show_gui=True)
419
-
420
-
421
- def test_fluent_enums():
422
- assert UIMode.GUI.value == "gui"
423
- assert UIMode("gui") == UIMode.GUI
424
- with pytest.raises(ValueError):
425
- UIMode("")
426
- with pytest.raises(TypeError):
427
- assert UIMode.NO_GUI < FluentWindowsGraphicsDriver.AUTO
428
-
429
-
430
- def test_exposure_and_graphics_driver_arguments():
431
- with pytest.raises(ValueError):
432
- pyfluent.launch_fluent(ui_mode="gu")
433
- with pytest.raises(ValueError):
434
- pyfluent.launch_fluent(graphics_driver="x11" if is_windows() else "dx11")
435
- for m in UIMode:
436
- string1 = _build_fluent_launch_args_string(
437
- ui_mode=m, additional_arguments="", processor_count=None
438
- ).strip()
439
- string2 = (
440
- f"3ddp -{m.get_fluent_value()[0]}" if m.get_fluent_value()[0] else "3ddp"
441
- )
442
- assert string1 == string2
443
- for e in (FluentWindowsGraphicsDriver, FluentLinuxGraphicsDriver):
444
- for m in e:
445
- msg = _build_fluent_launch_args_string(
446
- graphics_driver=m, additional_arguments="", processor_count=None
447
- ).strip()
448
- if is_windows():
449
- assert (
450
- msg == f"3ddp -hidden -driver {m.get_fluent_value()[0]}"
451
- if m.get_fluent_value()[0]
452
- else " 3ddp -hidden"
453
- )
454
- else:
455
- assert (
456
- msg == f"3ddp -gu -driver {m.get_fluent_value()[0]}"
457
- if m.get_fluent_value()[0]
458
- else " 3ddp -gu"
459
- )
460
-
461
-
462
- def test_additional_arguments_fluent_launch_args_string():
463
- additional_arguments = "-ws -ws-port=5000 -i test.jou"
464
- assert additional_arguments in _build_fluent_launch_args_string(
465
- additional_arguments=additional_arguments,
466
- processor_count=4,
467
- )
468
-
469
-
470
- def test_processor_count():
471
- def get_processor_count(solver):
472
- return int(solver.rp_vars("parallel/nprocs_string").strip('"'))
473
-
474
- with pyfluent.launch_fluent(processor_count=2) as solver:
475
- assert get_processor_count(solver) == 2
476
- # The following check is not yet supported for container launch
477
- # https://github.com/ansys/pyfluent/issues/2624
478
- # with pyfluent.launch_fluent(additional_arguments="-t2") as solver:
479
- # assert get_processor_count(solver) == 2
480
-
481
-
482
- def test_container_warning_for_mount_source(caplog):
483
- container_dict = {
484
- "mount_source": os.getcwd(),
485
- "mount_target": "/mnt/pyfluent/tests",
486
- }
487
- _ = pyfluent.launch_fluent(container_dict=container_dict)
488
- assert container_dict["mount_source"] in caplog.text
489
- assert container_dict["mount_target"] in caplog.text
490
-
491
-
492
- # runs only in container till cwd is supported for container launch
493
- def test_fluent_automatic_transcript(monkeypatch):
494
- with monkeypatch.context() as m:
495
- m.setattr(pyfluent, "FLUENT_AUTOMATIC_TRANSCRIPT", True)
496
- with TemporaryDirectory(dir=pyfluent.EXAMPLES_PATH) as tmp_dir:
497
- with pyfluent.launch_fluent(container_dict=dict(working_dir=tmp_dir)):
498
- assert list(Path(tmp_dir).glob("*.trn"))
499
- with TemporaryDirectory(dir=pyfluent.EXAMPLES_PATH) as tmp_dir:
500
- with pyfluent.launch_fluent(container_dict=dict(working_dir=tmp_dir)):
501
- assert not list(Path(tmp_dir).glob("*.trn"))
502
-
503
-
504
- def test_standalone_launcher_dry_run(monkeypatch):
505
- monkeypatch.setenv("PYFLUENT_LAUNCH_CONTAINER", "0")
506
- fluent_path = r"\x\y\z\fluent.exe"
507
- fluent_launch_string, server_info_file_name = pyfluent.launch_fluent(
508
- fluent_path=fluent_path, dry_run=True, ui_mode="no_gui"
509
- )
510
- assert str(Path(server_info_file_name).parent) == tempfile.gettempdir()
511
- assert (
512
- fluent_launch_string
513
- == f"{fluent_path} 3ddp -gu -sifile={server_info_file_name} -nm"
514
- )
515
-
516
-
517
- def test_standalone_launcher_dry_run_with_server_info_dir(monkeypatch):
518
- monkeypatch.setenv("PYFLUENT_LAUNCH_CONTAINER", "0")
519
- with tempfile.TemporaryDirectory() as tmp_dir:
520
- monkeypatch.setenv("SERVER_INFO_DIR", tmp_dir)
521
- fluent_path = r"\x\y\z\fluent.exe"
522
- fluent_launch_string, server_info_file_name = pyfluent.launch_fluent(
523
- fluent_path=fluent_path, dry_run=True, ui_mode="no_gui"
524
- )
525
- assert str(Path(server_info_file_name).parent) == tmp_dir
526
- assert (
527
- fluent_launch_string
528
- == f"{fluent_path} 3ddp -gu -sifile={Path(server_info_file_name).name} -nm"
529
- )