ansys-fluent-core 0.28.2__py3-none-any.whl → 0.29.dev1__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 (103) 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/fluent_version_252.py +3 -3
  8. ansys/fluent/core/generated/solver/settings_252.py +251 -160
  9. ansys/fluent/core/generated/solver/settings_252.pyi +146 -54
  10. ansys/fluent/core/generated/solver/tui_252.py +48 -24
  11. ansys/fluent/core/launcher/container_launcher.py +4 -3
  12. ansys/fluent/core/launcher/fluent_container.py +22 -19
  13. ansys/fluent/core/launcher/launcher.py +2 -2
  14. ansys/fluent/core/launcher/pim_launcher.py +2 -2
  15. ansys/fluent/core/launcher/slurm_launcher.py +2 -2
  16. ansys/fluent/core/launcher/standalone_launcher.py +2 -2
  17. ansys/fluent/core/logging.py +2 -0
  18. ansys/fluent/core/logging_config.yaml +3 -0
  19. ansys/fluent/core/services/datamodel_se.py +4 -1
  20. ansys/fluent/core/services/field_data.py +252 -0
  21. ansys/fluent/core/services/interceptors.py +28 -2
  22. ansys/fluent/core/session.py +7 -2
  23. ansys/fluent/core/session_solver.py +21 -0
  24. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.dev1.dist-info}/LICENSE +1 -1
  25. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.dev1.dist-info}/METADATA +53 -32
  26. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.dev1.dist-info}/RECORD +61 -137
  27. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.dev1.dist-info}/WHEEL +1 -1
  28. ansys/fluent/core/docs/README.rst +0 -155
  29. ansys/fluent/tests/conftest.py +0 -415
  30. ansys/fluent/tests/fluent_fixtures.py +0 -195
  31. ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
  32. ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
  33. ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
  34. ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
  35. ansys/fluent/tests/test_aero_session.py +0 -88
  36. ansys/fluent/tests/test_batch_ops.py +0 -39
  37. ansys/fluent/tests/test_builtin_settings.py +0 -761
  38. ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
  39. ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
  40. ansys/fluent/tests/test_casereader.py +0 -324
  41. ansys/fluent/tests/test_codegen.py +0 -783
  42. ansys/fluent/tests/test_creatable.py +0 -31
  43. ansys/fluent/tests/test_data_model_cache.py +0 -434
  44. ansys/fluent/tests/test_datamodel_api.py +0 -429
  45. ansys/fluent/tests/test_datamodel_service.py +0 -814
  46. ansys/fluent/tests/test_datareader.py +0 -103
  47. ansys/fluent/tests/test_error_handling.py +0 -24
  48. ansys/fluent/tests/test_events_manager.py +0 -214
  49. ansys/fluent/tests/test_field_data.py +0 -466
  50. ansys/fluent/tests/test_file_session.py +0 -355
  51. ansys/fluent/tests/test_file_transfer_service.py +0 -165
  52. ansys/fluent/tests/test_fix_doc.py +0 -29
  53. ansys/fluent/tests/test_flobject.py +0 -1235
  54. ansys/fluent/tests/test_fluent_fixes.py +0 -106
  55. ansys/fluent/tests/test_fluent_session.py +0 -270
  56. ansys/fluent/tests/test_fluent_version.py +0 -66
  57. ansys/fluent/tests/test_fluent_version_marker.py +0 -65
  58. ansys/fluent/tests/test_icing_session.py +0 -9
  59. ansys/fluent/tests/test_launcher.py +0 -529
  60. ansys/fluent/tests/test_launcher_remote.py +0 -272
  61. ansys/fluent/tests/test_lispy.py +0 -40
  62. ansys/fluent/tests/test_logging.py +0 -16
  63. ansys/fluent/tests/test_mapped_api.py +0 -766
  64. ansys/fluent/tests/test_meshing_utilities.py +0 -2436
  65. ansys/fluent/tests/test_meshing_workflow.py +0 -421
  66. ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
  67. ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
  68. ansys/fluent/tests/test_preferences.py +0 -89
  69. ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
  70. ansys/fluent/tests/test_reduction.py +0 -484
  71. ansys/fluent/tests/test_rp_vars.py +0 -77
  72. ansys/fluent/tests/test_scheduler.py +0 -471
  73. ansys/fluent/tests/test_scheme_eval_222.py +0 -338
  74. ansys/fluent/tests/test_scheme_eval_231.py +0 -243
  75. ansys/fluent/tests/test_search.py +0 -344
  76. ansys/fluent/tests/test_session.py +0 -594
  77. ansys/fluent/tests/test_settings_api.py +0 -606
  78. ansys/fluent/tests/test_settings_reader.py +0 -85
  79. ansys/fluent/tests/test_slurm_future.py +0 -67
  80. ansys/fluent/tests/test_solution_variables.py +0 -241
  81. ansys/fluent/tests/test_solver_monitors.py +0 -83
  82. ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
  83. ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
  84. ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
  85. ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
  86. ansys/fluent/tests/test_solvermode/test_general.py +0 -109
  87. ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
  88. ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
  89. ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
  90. ansys/fluent/tests/test_solvermode/test_models.py +0 -99
  91. ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
  92. ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
  93. ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
  94. ansys/fluent/tests/test_streaming_services.py +0 -52
  95. ansys/fluent/tests/test_systemcoupling.py +0 -44
  96. ansys/fluent/tests/test_topy.py +0 -179
  97. ansys/fluent/tests/test_tui_api.py +0 -70
  98. ansys/fluent/tests/test_type_stub.py +0 -37
  99. ansys/fluent/tests/test_utils.py +0 -82
  100. ansys/fluent/tests/util/__init__.py +0 -36
  101. ansys/fluent/tests/util/meshing_workflow.py +0 -33
  102. ansys/fluent/tests/util/solver.py +0 -72
  103. ansys_fluent_core-0.28.2.dist-info/AUTHORS +0 -12
@@ -1,35 +0,0 @@
1
- import pytest
2
-
3
-
4
- @pytest.mark.settings_only
5
- @pytest.mark.fluent_version(">=24.1")
6
- def test_expression(mixing_elbow_settings_session):
7
- solver_session = mixing_elbow_settings_session
8
- # Case file already has energy model turned on
9
- # solver_session.setup.models.energy.enabled = True
10
- expressions = solver_session.setup.named_expressions
11
- expressions["r"] = {}
12
- expressions["r"] = {"definition": "(Position.z**2.0 +Position.x**2.0)**0.5"}
13
- expressions["r1"] = {}
14
- expressions["r1"] = {"definition": "1-(r/0.014[m])"}
15
- expressions["v1"] = {}
16
- expressions["v1"] = {"definition": "r1**(1.0/6.0)"}
17
- expressions["vel_cold"] = {}
18
- expressions["vel_cold"] = {"definition": "1.264 * 1.43 [m s^-1] * max(0,v1)"}
19
-
20
- assert expressions["r"].definition() == "(Position.z**2.0 +Position.x**2.0)**0.5"
21
- assert expressions["r1"].definition() == "1-(r/0.014[m])"
22
- assert expressions["v1"].definition() == "r1**(1.0/6.0)"
23
- assert expressions["vel_cold"].definition() == "1.264 * 1.43 [m s^-1] * max(0,v1)"
24
-
25
- velocity_inlet = solver_session.setup.boundary_conditions.velocity_inlet
26
- velocity_inlet["cold-inlet"].momentum = {"velocity": "vel_cold"}
27
- velocity_inlet["hot-inlet"].momentum = {"velocity": "max(vel_cold, 1.5 [m/s])"}
28
- assert velocity_inlet["cold-inlet"].momentum.velocity() == {
29
- "option": "value",
30
- "value": "vel_cold",
31
- }
32
- assert velocity_inlet["hot-inlet"].momentum.velocity() == {
33
- "option": "value",
34
- "value": "max(vel_cold, 1.5 [m/s])",
35
- }
@@ -1,22 +0,0 @@
1
- import pytest
2
-
3
-
4
- @pytest.mark.settings_only
5
- @pytest.mark.fluent_version("latest")
6
- def test_post_elbow(mixing_elbow_settings_session):
7
- mixing_elbow_settings_session.results.graphics.vector[
8
- "velocity_vector_symmetry"
9
- ] = {}
10
- vector_graphics = mixing_elbow_settings_session.results.graphics.vector[
11
- "velocity_vector_symmetry"
12
- ]
13
- vector_graphics.field = "temperature"
14
- vector_graphics.surfaces_list = ["symmetry-xyplane"]
15
- vector_graphics.scale.scale_f = 4
16
- vector_graphics.style = "arrow"
17
- vel_vector = vector_graphics()
18
- assert vel_vector.get("name") == "velocity_vector_symmetry"
19
- assert vel_vector.get("field") == "temperature"
20
- assert vel_vector.get("surfaces_list") == ["symmetry-xyplane"]
21
- assert vel_vector.get("scale") == {"auto_scale": True, "scale_f": 4.0}
22
- assert vel_vector.get("style") == "arrow"
@@ -1,67 +0,0 @@
1
- import pytest
2
-
3
-
4
- @pytest.mark.settings_only
5
- @pytest.mark.fluent_version(">=24.1")
6
- def test_change_create_mixture(mixing_elbow_settings_session):
7
- solver_session = mixing_elbow_settings_session
8
-
9
- # Test turning on species transport model
10
- species_mdl = solver_session.setup.models.species.model
11
-
12
- assert species_mdl.option() == "off"
13
- species_mdl.option = "species-transport"
14
- assert species_mdl.option() == "species-transport"
15
-
16
- # Test command names list
17
- materials = solver_session.setup.materials
18
- assert sorted(materials.mixture.command_names) == sorted(
19
- ["delete", "list", "list_properties", "make_a_copy", "rename"]
20
- )
21
-
22
- # Test change/creating a mixture with custom species from template
23
- custom_species_1 = materials.fluid.create("custom-species-1")
24
- custom_species_2 = materials.fluid.create("custom-species-2")
25
- solver_session.tui.define.materials.change_create(
26
- "mixture-template", # Change/create mixture-template
27
- "custom-mixture", # Rename to `custom-mixture`
28
- "yes", # Change mixture species
29
- "2", # Set number of species to 2
30
- custom_species_1.name(), # Set species 1
31
- custom_species_2.name(), # Set species 2
32
- "0", # No surface species
33
- "0", # No site species
34
- "no", # Do not change density
35
- "no", # Do not change specific heat
36
- "no", # Do not change thermal conductivity
37
- "no", # Do not change viscosity
38
- "no", # Do not change mass diffusivity
39
- "no", # Do not change speed of sound
40
- "yes", # Overwrite mixture-template
41
- )
42
- assert "custom-mixture" in materials.mixture.keys()
43
- assert "mixture-template" not in materials.mixture.keys()
44
-
45
- # Test that mixture contains correct species
46
- mix_species = solver_session.setup.materials.mixture[
47
- "custom-mixture"
48
- ].species.volumetric_species.keys()
49
- assert "custom-species-1" in mix_species
50
- assert "custom-species-2" in mix_species
51
-
52
- # Test copying a mixture
53
- materials.mixture.make_a_copy(
54
- from_="custom-mixture",
55
- to="custom-mixture-copy",
56
- )
57
- assert "custom-mixture-copy" in materials.mixture.keys()
58
-
59
- # Test changing cellzone mixture
60
- elbow_zone = solver_session.setup.cell_zone_conditions.fluid["elbow-fluid"]
61
- assert elbow_zone.material() == "custom-mixture"
62
- elbow_zone.material = "custom-mixture-copy"
63
- assert elbow_zone.material() == "custom-mixture-copy"
64
-
65
- # Test deleting a mixture
66
- materials.mixture.delete(name_list=["custom-mixture"])
67
- assert "custom-mixture" not in materials.mixture.keys()
@@ -1,52 +0,0 @@
1
- import time
2
-
3
- from ansys.fluent.core import connect_to_fluent
4
- from ansys.fluent.core.utils.fluent_version import FluentVersion
5
-
6
-
7
- def transcript(data):
8
- transcript.data = data
9
-
10
-
11
- def run_transcript(i, ip, port, password):
12
- transcript("")
13
- session = connect_to_fluent(
14
- ip=ip, port=port, password=password, cleanup_on_exit=False
15
- )
16
- session.transcript.register_callback(transcript)
17
-
18
- transcript_checked = False
19
- transcript_passed = False
20
-
21
- if i % 5 == 0:
22
- time.sleep(0.5)
23
- session.scheme_eval.scheme_eval("(pp 'test)")
24
- time.sleep(0.5)
25
- if not transcript.data:
26
- assert transcript.data == ""
27
- else:
28
- assert transcript.data == "test"
29
- transcript_passed = True
30
- transcript_checked = True
31
-
32
- return transcript_checked, transcript_passed
33
-
34
-
35
- def test_transcript(new_solver_session):
36
- solver = new_solver_session
37
- ip = solver.connection_properties.ip
38
- port = solver.connection_properties.port
39
- password = solver.connection_properties.password
40
-
41
- total_checked_transcripts = 0
42
- total_passed_transcripts = 0
43
-
44
- for i in range(100):
45
- transcript_checked, transcript_passed = run_transcript(i, ip, port, password)
46
- total_checked_transcripts += int(transcript_checked)
47
- total_passed_transcripts += int(transcript_passed)
48
-
49
- if solver.get_fluent_version() >= FluentVersion.v232:
50
- assert total_checked_transcripts == total_passed_transcripts
51
- else:
52
- assert total_checked_transcripts >= total_passed_transcripts
@@ -1,44 +0,0 @@
1
- import pytest
2
-
3
-
4
- @pytest.mark.fluent_version(">=25.1")
5
- def test_systemcoupling_mixing_elbow_settings_apis(mixing_elbow_case_data_session):
6
- """Test System Coupling related settings APIs"""
7
- solver = mixing_elbow_case_data_session
8
- # enable the feature flag to be able to make the queries
9
- solver.scheme_eval.scheme_eval("(enable-feature 'sc/participant-info)")
10
- elbow_fluid = "elbow-fluid"
11
- region_names = solver.settings.setup.models.system_coupling.get_all_regions()
12
- assert elbow_fluid in region_names
13
- # elbow fluid must be a volume
14
- assert (
15
- solver.settings.setup.models.system_coupling.get_topology(
16
- region_name=elbow_fluid
17
- )
18
- == "Volume"
19
- )
20
-
21
-
22
- def _test_systemcoupling_mixing_elbow_settings_common(mixing_elbow_case_data_session):
23
- solver = mixing_elbow_case_data_session
24
- # check participant type, analysis type, regions, and variables
25
- assert solver.system_coupling.participant_type == "FLUENT"
26
- assert solver.system_coupling.get_analysis_type() == "Steady"
27
- regions = solver.system_coupling.get_regions()
28
- variables = solver.system_coupling.get_variables()
29
- # [wall-inlet, wall-elbow, elbow-fluid, hot-inlet, cold-inlet, outlet]
30
- assert len(regions) >= 6
31
- # [force, temp, htc, hflow, nwt, hrate, e-cond, lorentz-force]
32
- assert len(variables) >= 8
33
-
34
-
35
- @pytest.mark.fluent_version(">=25.1")
36
- def test_systemcoupling_mixing_elbow_settings(mixing_elbow_case_data_session):
37
- """Very superficial test of System Coupling related settings."""
38
- _test_systemcoupling_mixing_elbow_settings_common(mixing_elbow_case_data_session)
39
-
40
-
41
- @pytest.mark.fluent_version(">=24.1,<25.1")
42
- def test_systemcoupling_mixing_elbow_settings_legacy(mixing_elbow_case_data_session):
43
- """Test legacy implementation of getting System Coupling related settings."""
44
- _test_systemcoupling_mixing_elbow_settings_common(mixing_elbow_case_data_session)
@@ -1,179 +0,0 @@
1
- import os
2
- from pathlib import Path
3
- import time
4
-
5
- import pytest
6
-
7
- import ansys.fluent.core as pyfluent
8
-
9
-
10
- @pytest.mark.skip(reason="Unable to read generated python journal from fluent.")
11
- def test_single_jou():
12
- file_name = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.jou")
13
-
14
- with open(file_name, "w") as journal:
15
- journal.write('(display "from jou1.jou")')
16
-
17
- solver = pyfluent.launch_fluent(mode="solver", topy=file_name)
18
- solver.exit()
19
-
20
- with open(file_name) as file:
21
- returned = file.readlines()
22
-
23
- if os.path.exists(file_name):
24
- os.remove(file_name)
25
-
26
- assert returned
27
-
28
- gen_file_name = os.path.join(os.getcwd(), f"{Path(file_name).stem}.py")
29
-
30
- with open(gen_file_name) as file:
31
- gen_returned = file.readlines()
32
-
33
- assert gen_returned
34
-
35
- while os.path.exists(gen_file_name):
36
- try:
37
- os.remove(gen_file_name)
38
- except PermissionError:
39
- time.sleep(1)
40
- if not os.path.exists(gen_file_name):
41
- break
42
-
43
-
44
- @pytest.mark.skip(reason="Unable to read generated python journal from fluent.")
45
- def test_single_scm():
46
- file_name = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.scm")
47
-
48
- with open(file_name, "w") as journal:
49
- journal.write('(display "from jou1.scm")')
50
-
51
- solver = pyfluent.launch_fluent(mode="solver", topy=file_name)
52
- solver.exit()
53
-
54
- with open(file_name) as file:
55
- returned = file.readlines()
56
-
57
- if os.path.exists(file_name):
58
- os.remove(file_name)
59
-
60
- assert returned
61
-
62
- gen_file_name = os.path.join(os.getcwd(), f"{Path(file_name).stem}.py")
63
-
64
- with open(gen_file_name) as file:
65
- gen_returned = file.readlines()
66
-
67
- assert gen_returned
68
-
69
- while os.path.exists(gen_file_name):
70
- try:
71
- os.remove(gen_file_name)
72
- except PermissionError:
73
- time.sleep(1)
74
- if not os.path.exists(gen_file_name):
75
- break
76
-
77
-
78
- @pytest.mark.skip(reason="Unable to read generated python journal from fluent.")
79
- def test_2_jou():
80
- file_name_1 = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.jou")
81
- file_name_2 = os.path.join(pyfluent.EXAMPLES_PATH, "jou2.jou")
82
-
83
- with open(file_name_1, "w") as journal:
84
- journal.write('(display "from jou1.jou")')
85
-
86
- with open(file_name_2, "w") as journal:
87
- journal.write('(display "from jou2.jou")')
88
-
89
- solver = pyfluent.launch_fluent(mode="solver", topy=[file_name_1, file_name_2])
90
- solver.exit()
91
-
92
- with open(file_name_1) as file:
93
- returned1 = file.readlines()
94
-
95
- if os.path.exists(file_name_1):
96
- os.remove(file_name_1)
97
-
98
- assert returned1
99
-
100
- with open(file_name_2) as file:
101
- returned2 = file.readlines()
102
-
103
- if os.path.exists(file_name_2):
104
- os.remove(file_name_2)
105
-
106
- assert returned2
107
-
108
- gen_file_name = (
109
- Path(file_name_1).stem.split(".")[0]
110
- + "_"
111
- + Path(file_name_2).stem.split(".")[0]
112
- + ".py"
113
- )
114
- gen_file_name = os.path.join(os.getcwd(), gen_file_name)
115
-
116
- with open(gen_file_name) as file:
117
- gen_returned = file.readlines()
118
-
119
- assert gen_returned
120
-
121
- while os.path.exists(gen_file_name):
122
- try:
123
- os.remove(gen_file_name)
124
- except PermissionError:
125
- time.sleep(1)
126
- if not os.path.exists(gen_file_name):
127
- break
128
-
129
-
130
- @pytest.mark.skip(reason="Unable to read generated python journal from fluent.")
131
- def test_2_scm():
132
- file_name_1 = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.scm")
133
- file_name_2 = os.path.join(pyfluent.EXAMPLES_PATH, "jou2.scm")
134
-
135
- with open(file_name_1, "w") as journal:
136
- journal.write('(display "from jou1.scm")')
137
-
138
- with open(file_name_2, "w") as journal:
139
- journal.write('(display "from jou2.scm")')
140
-
141
- solver = pyfluent.launch_fluent(mode="solver", topy=[file_name_1, file_name_2])
142
- solver.exit()
143
-
144
- with open(file_name_1) as file:
145
- returned1 = file.readlines()
146
-
147
- if os.path.exists(file_name_1):
148
- os.remove(file_name_1)
149
-
150
- assert returned1
151
-
152
- with open(file_name_2) as file:
153
- returned2 = file.readlines()
154
-
155
- if os.path.exists(file_name_2):
156
- os.remove(file_name_2)
157
-
158
- assert returned2
159
-
160
- gen_file_name = (
161
- Path(file_name_1).stem.split(".")[0]
162
- + "_"
163
- + Path(file_name_2).stem.split(".")[0]
164
- + ".py"
165
- )
166
- gen_file_name = os.path.join(os.getcwd(), gen_file_name)
167
-
168
- with open(gen_file_name) as file:
169
- gen_returned = file.readlines()
170
-
171
- assert gen_returned
172
-
173
- while os.path.exists(gen_file_name):
174
- try:
175
- os.remove(gen_file_name)
176
- except PermissionError:
177
- time.sleep(1)
178
- if not os.path.exists(gen_file_name):
179
- break
@@ -1,70 +0,0 @@
1
- import os
2
-
3
- import pytest
4
-
5
- from ansys.fluent.core import FluentVersion
6
- from ansys.fluent.core.examples.downloads import download_file
7
- from ansys.fluent.core.services.datamodel_tui import TUIMenu
8
-
9
-
10
- @pytest.mark.skip("Failing in github")
11
- def test_report_system_proc_stats_tui(new_solver_session, capsys) -> None:
12
- new_solver_session.tui.report.system.sys_stats()
13
- captured = capsys.readouterr()
14
- assert "CPU" in captured.out
15
-
16
-
17
- def test_runtime_tui_menus(static_mixer_case_session) -> None:
18
- solver = static_mixer_case_session
19
- solver.tui.define.models.addon_module(3)
20
- rmf = solver.tui.define.models.resolved_MEA_fuelcells
21
- assert rmf is not None
22
- assert rmf.__class__ == TUIMenu
23
-
24
-
25
- @pytest.mark.codegen_required
26
- def test_python_keyword_menu_name(new_meshing_session):
27
- meshing = new_meshing_session
28
- assert "cad_options" in dir(meshing.tui.file.import_)
29
- assert "create_cad_assemblies" in dir(meshing.tui.file.import_.cad_options)
30
- meshing.tui.file.import_.cad_options.create_cad_assemblies("yes")
31
-
32
-
33
- @pytest.mark.skip("Failing in github")
34
- def test_api_upgrade_message(new_solver_session):
35
- solver = new_solver_session
36
- case_name = download_file(
37
- "Static_Mixer_main.cas.h5", "pyfluent/static_mixer", save_path=os.getcwd()
38
- )
39
- from contextlib import redirect_stdout
40
- import io
41
-
42
- f = io.StringIO()
43
- with redirect_stdout(f):
44
- solver.tui.file.read_case(case_name)
45
- s = f.getvalue()
46
- if solver.get_fluent_version() >= FluentVersion.v251:
47
- assert (
48
- s.split("\n")[-2].split("(")[0]
49
- == r"<solver_session>.settings.file.read_case"
50
- )
51
- else:
52
- assert s.split("\n")[-2].split("(")[0] == r"<solver_session>.file.read_case"
53
-
54
-
55
- def test_exit_not_in_meshing_tui(new_meshing_session):
56
- meshing = new_meshing_session
57
-
58
- assert "exit" not in dir(meshing.tui)
59
-
60
- with pytest.raises(AttributeError):
61
- meshing.tui.exit()
62
-
63
-
64
- def test_commands_not_in_solver_tui(new_solver_session):
65
- solver = new_solver_session
66
-
67
- for command in ["exit", "switch_to_meshing_mode"]:
68
- assert command not in dir(solver.tui)
69
- with pytest.raises(AttributeError):
70
- getattr(solver.tui, command)
@@ -1,37 +0,0 @@
1
- import ast
2
-
3
- import pytest
4
-
5
- from ansys.fluent.core import CODEGEN_OUTDIR
6
-
7
-
8
- @pytest.mark.codegen_required
9
- @pytest.mark.fluent_version("==25.1")
10
- def test_settings_stub():
11
- # The type-stub files, which are generated for settings API, are parsed by the
12
- # intellisense engine while typing in editors like vscode. This test validates the
13
- # information contained in a type-stub file.
14
- version = "251"
15
- stub_file = CODEGEN_OUTDIR / "solver" / f"settings_{version}.pyi"
16
- assert stub_file.exists()
17
- with open(stub_file) as f:
18
- module_def = ast.parse(f.read())
19
- assert isinstance(module_def, ast.Module)
20
- assert any(isinstance(x, ast.ImportFrom) for x in module_def.body)
21
- class_def = next(
22
- x for x in module_def.body if isinstance(x, ast.ClassDef) and x.name == "export"
23
- )
24
- assert len(class_def.bases) > 0
25
- assigns = [x for x in class_def.body if isinstance(x, ast.AnnAssign)]
26
- for class_attr in [
27
- "version",
28
- "fluent_name",
29
- "_python_name",
30
- "child_names",
31
- "command_names",
32
- ]:
33
- print(class_attr)
34
- assert any(x.target.id == class_attr for x in assigns)
35
- fn_def = next(x for x in class_def.body if isinstance(x, ast.FunctionDef))
36
- assert ast.get_docstring(fn_def)
37
- assert all(x.annotation for x in fn_def.args.args[1:])
@@ -1,82 +0,0 @@
1
- import time
2
-
3
- import pytest
4
-
5
- from ansys.fluent.core.utils.dictionary_operations import get_first_dict_key_for_value
6
- from ansys.fluent.core.utils.execution import (
7
- InvalidArgument,
8
- timeout_exec,
9
- timeout_loop,
10
- )
11
-
12
-
13
- def test_timeout_exec():
14
- ret = timeout_exec(time.sleep, timeout=0.25, args=(0.5,))
15
- assert ret is False
16
- ret = timeout_exec(time.sleep, timeout=0.5, args=(0.25,))
17
- assert ret is True
18
-
19
-
20
- def test_timeout_loop():
21
- class ExpectedAfterFive:
22
- def __init__(self, expected):
23
- self._counter = 0
24
- self._expected = expected
25
-
26
- def __call__(self):
27
- self._counter += 1
28
- if self._counter >= 5:
29
- return self._expected
30
- else:
31
- return not self._expected
32
-
33
- class Waiter:
34
- def __init__(self, func, expected):
35
- self._func = func(expected)
36
- self._expected = expected
37
-
38
- def __call__(self):
39
- returned = self._func()
40
- if returned == self._expected:
41
- return returned
42
- else:
43
- return returned
44
-
45
- waiter = Waiter(ExpectedAfterFive, expected=True)
46
- ret = timeout_loop(waiter, timeout=1, expected="truthy", idle_period=0.1)
47
- assert ret is True
48
-
49
- waiter = Waiter(ExpectedAfterFive, expected=False)
50
- ret = timeout_loop(waiter, timeout=1, expected="falsy", idle_period=0.1)
51
- assert ret is False
52
-
53
- waiter = Waiter(ExpectedAfterFive, expected=True)
54
- ret = timeout_loop(waiter, timeout=0.2, expected="truthy", idle_period=0.1)
55
- assert ret is False
56
-
57
- with pytest.raises(InvalidArgument):
58
- timeout_loop(waiter, timeout=0.2, expected=True, idle_period=0.1)
59
-
60
-
61
- def count_key_recursive(dictionary, key):
62
- count = 0
63
- for k, v in dictionary.items():
64
- if k == key:
65
- count += 1
66
- elif isinstance(v, dict):
67
- count += count_key_recursive(v, key)
68
- return count
69
-
70
-
71
- def test_get_first_dict_key_for_value():
72
- assert get_first_dict_key_for_value({1: 2}, 2) == 1
73
- assert get_first_dict_key_for_value({1: 2, 3: 4}, 2) == 1
74
- with pytest.raises(ValueError):
75
- get_first_dict_key_for_value({1: 2}, 1)
76
-
77
-
78
- PYTEST_RELATIVE_TOLERANCE = 1e-3
79
-
80
-
81
- def pytest_approx(expected):
82
- return pytest.approx(expected=expected, rel=PYTEST_RELATIVE_TOLERANCE)
@@ -1,36 +0,0 @@
1
- from pathlib import Path
2
- from tempfile import TemporaryDirectory
3
- import uuid
4
-
5
- from pytest import MonkeyPatch
6
-
7
- import ansys.fluent.core as pyfluent
8
- from ansys.fluent.core.codegen import StaticInfoType, datamodelgen
9
- from ansys.fluent.core.utils import load_module
10
-
11
-
12
- def create_datamodel_root_in_server(session, rules_str, app_name) -> None:
13
- rules_file_name = f"{uuid.uuid4()}.fdl"
14
- session.scheme_eval.scheme_eval(
15
- f'(with-output-to-file "{rules_file_name}" (lambda () (format "~a" "{rules_str}")))',
16
- )
17
- session.scheme_eval.scheme_eval(
18
- f'(state/register-new-state-engine "{app_name}" "{rules_file_name}")'
19
- )
20
- session.scheme_eval.scheme_eval(f'(remove-file "{rules_file_name}")')
21
- assert session.scheme_eval.scheme_eval(f'(state/find-root "{app_name}")') > 0
22
-
23
-
24
- def create_root_using_datamodelgen(service, app_name):
25
- version = "252"
26
- static_info = service.get_static_info(app_name)
27
- with TemporaryDirectory() as temp_dir:
28
- with MonkeyPatch.context() as m:
29
- m.setattr(pyfluent, "CODEGEN_OUTDIR", Path(temp_dir))
30
- # TODO: Refactor datamdodelgen so we don't need to hardcode StaticInfoType
31
- datamodelgen.generate(
32
- version, static_infos={StaticInfoType.DATAMODEL_WORKFLOW: static_info}
33
- )
34
- gen_file = Path(temp_dir) / f"datamodel_{version}" / "workflow.py"
35
- module = load_module("datamodel", gen_file)
36
- return module.Root(service, app_name, [])
@@ -1,33 +0,0 @@
1
- def assign_task_arguments(
2
- workflow, check_state: bool, task_name: str, **kwargs
3
- ) -> None:
4
- task = workflow.TaskObject[task_name]
5
- task.Arguments = kwargs
6
- if check_state:
7
- # the state that we have set must be a subset of the total state
8
- assert kwargs.items() <= task.Arguments().items()
9
-
10
-
11
- def check_task_execute_preconditions(task) -> None:
12
- assert task.State() == "Out-of-date"
13
- assert not task.Errors() or not len(task.Errors())
14
-
15
-
16
- def check_task_execute_postconditions(task) -> None:
17
- assert task.State() == "Up-to-date"
18
- assert not task.Errors() or not len(task.Errors())
19
-
20
-
21
- def execute_task_with_pre_and_postcondition_checks(workflow, task_name: str) -> None:
22
- task = workflow.TaskObject[task_name]
23
- check_task_execute_preconditions(task)
24
- # Some tasks are wrongly returning False in meshing workflow itself
25
- # so we add a temporary caveat below
26
- result = task.Execute()
27
- if task_name not in (
28
- "Add Local Sizing",
29
- "Add Boundary Layers",
30
- "Import CAD and Part Management",
31
- ):
32
- assert result is True
33
- check_task_execute_postconditions(task)