ansys-fluent-core 0.29.dev0__py3-none-any.whl → 0.29.dev2__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 (107) hide show
  1. ansys/fluent/core/__init__.py +1 -1
  2. ansys/fluent/core/_version.py +2 -2
  3. ansys/fluent/core/codegen/tuigen.py +1 -1
  4. ansys/fluent/core/codegen/walk_api.py +45 -18
  5. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  6. ansys/fluent/core/generated/datamodel_252/meshing.py +1 -0
  7. ansys/fluent/core/generated/datamodel_252/preferences.py +7 -0
  8. ansys/fluent/core/generated/fluent_version_252.py +3 -3
  9. ansys/fluent/core/generated/meshing/tui_252.py +395 -390
  10. ansys/fluent/core/generated/solver/settings_252.py +782 -306
  11. ansys/fluent/core/generated/solver/settings_252.pyi +442 -133
  12. ansys/fluent/core/generated/solver/tui_252.py +4046 -3737
  13. ansys/fluent/core/launcher/container_launcher.py +4 -3
  14. ansys/fluent/core/launcher/fluent_container.py +22 -19
  15. ansys/fluent/core/launcher/launcher.py +2 -2
  16. ansys/fluent/core/launcher/pim_launcher.py +2 -2
  17. ansys/fluent/core/launcher/slurm_launcher.py +2 -2
  18. ansys/fluent/core/launcher/standalone_launcher.py +2 -2
  19. ansys/fluent/core/logging.py +2 -0
  20. ansys/fluent/core/logging_config.yaml +3 -0
  21. ansys/fluent/core/services/app_utilities.py +2 -1
  22. ansys/fluent/core/services/datamodel_se.py +141 -61
  23. ansys/fluent/core/services/field_data.py +252 -0
  24. ansys/fluent/core/services/interceptors.py +28 -2
  25. ansys/fluent/core/session.py +7 -2
  26. ansys/fluent/core/session_solver.py +21 -0
  27. ansys/fluent/core/streaming_services/datamodel_event_streaming.py +12 -12
  28. {ansys_fluent_core-0.29.dev0.dist-info → ansys_fluent_core-0.29.dev2.dist-info}/LICENSE +1 -1
  29. {ansys_fluent_core-0.29.dev0.dist-info → ansys_fluent_core-0.29.dev2.dist-info}/METADATA +53 -31
  30. {ansys_fluent_core-0.29.dev0.dist-info → ansys_fluent_core-0.29.dev2.dist-info}/RECORD +65 -141
  31. {ansys_fluent_core-0.29.dev0.dist-info → ansys_fluent_core-0.29.dev2.dist-info}/WHEEL +1 -1
  32. ansys/fluent/core/docs/README.rst +0 -155
  33. ansys/fluent/tests/conftest.py +0 -415
  34. ansys/fluent/tests/fluent_fixtures.py +0 -195
  35. ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
  36. ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
  37. ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
  38. ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
  39. ansys/fluent/tests/test_aero_session.py +0 -88
  40. ansys/fluent/tests/test_batch_ops.py +0 -39
  41. ansys/fluent/tests/test_builtin_settings.py +0 -761
  42. ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
  43. ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
  44. ansys/fluent/tests/test_casereader.py +0 -324
  45. ansys/fluent/tests/test_codegen.py +0 -783
  46. ansys/fluent/tests/test_creatable.py +0 -31
  47. ansys/fluent/tests/test_data_model_cache.py +0 -434
  48. ansys/fluent/tests/test_datamodel_api.py +0 -449
  49. ansys/fluent/tests/test_datamodel_service.py +0 -814
  50. ansys/fluent/tests/test_datareader.py +0 -103
  51. ansys/fluent/tests/test_error_handling.py +0 -24
  52. ansys/fluent/tests/test_events_manager.py +0 -214
  53. ansys/fluent/tests/test_field_data.py +0 -466
  54. ansys/fluent/tests/test_file_session.py +0 -355
  55. ansys/fluent/tests/test_file_transfer_service.py +0 -165
  56. ansys/fluent/tests/test_fix_doc.py +0 -29
  57. ansys/fluent/tests/test_flobject.py +0 -1235
  58. ansys/fluent/tests/test_fluent_fixes.py +0 -106
  59. ansys/fluent/tests/test_fluent_session.py +0 -270
  60. ansys/fluent/tests/test_fluent_version.py +0 -66
  61. ansys/fluent/tests/test_fluent_version_marker.py +0 -65
  62. ansys/fluent/tests/test_icing_session.py +0 -9
  63. ansys/fluent/tests/test_launcher.py +0 -529
  64. ansys/fluent/tests/test_launcher_remote.py +0 -272
  65. ansys/fluent/tests/test_lispy.py +0 -40
  66. ansys/fluent/tests/test_logging.py +0 -16
  67. ansys/fluent/tests/test_mapped_api.py +0 -774
  68. ansys/fluent/tests/test_meshing_utilities.py +0 -2436
  69. ansys/fluent/tests/test_meshing_workflow.py +0 -421
  70. ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
  71. ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
  72. ansys/fluent/tests/test_preferences.py +0 -89
  73. ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
  74. ansys/fluent/tests/test_reduction.py +0 -484
  75. ansys/fluent/tests/test_rp_vars.py +0 -77
  76. ansys/fluent/tests/test_scheduler.py +0 -471
  77. ansys/fluent/tests/test_scheme_eval_222.py +0 -338
  78. ansys/fluent/tests/test_scheme_eval_231.py +0 -243
  79. ansys/fluent/tests/test_search.py +0 -344
  80. ansys/fluent/tests/test_session.py +0 -594
  81. ansys/fluent/tests/test_settings_api.py +0 -606
  82. ansys/fluent/tests/test_settings_reader.py +0 -85
  83. ansys/fluent/tests/test_slurm_future.py +0 -67
  84. ansys/fluent/tests/test_solution_variables.py +0 -241
  85. ansys/fluent/tests/test_solver_monitors.py +0 -83
  86. ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
  87. ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
  88. ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
  89. ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
  90. ansys/fluent/tests/test_solvermode/test_general.py +0 -109
  91. ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
  92. ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
  93. ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
  94. ansys/fluent/tests/test_solvermode/test_models.py +0 -99
  95. ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
  96. ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
  97. ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
  98. ansys/fluent/tests/test_streaming_services.py +0 -52
  99. ansys/fluent/tests/test_systemcoupling.py +0 -44
  100. ansys/fluent/tests/test_topy.py +0 -179
  101. ansys/fluent/tests/test_tui_api.py +0 -70
  102. ansys/fluent/tests/test_type_stub.py +0 -37
  103. ansys/fluent/tests/test_utils.py +0 -82
  104. ansys/fluent/tests/util/__init__.py +0 -36
  105. ansys/fluent/tests/util/meshing_workflow.py +0 -33
  106. ansys/fluent/tests/util/solver.py +0 -72
  107. ansys_fluent_core-0.29.dev0.dist-info/AUTHORS +0 -12
@@ -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
- )