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,1801 +0,0 @@
1
- import time
2
- from typing import Iterable
3
-
4
- import pytest
5
-
6
- from ansys.fluent.core import FluentVersion, examples
7
- from ansys.fluent.core.workflow import camel_to_snake_case
8
-
9
-
10
- @pytest.mark.nightly
11
- @pytest.mark.codegen_required
12
- @pytest.mark.fluent_version(">=24.1")
13
- def test_new_watertight_workflow(new_meshing_session):
14
- # Import geometry
15
- import_file_name = examples.download_file(
16
- "mixing_elbow.pmdb", "pyfluent/mixing_elbow"
17
- )
18
- watertight = new_meshing_session.watertight()
19
- watertight.import_geometry.file_name.set_state(import_file_name)
20
- assert watertight.import_geometry.length_unit() == "mm"
21
- watertight.import_geometry.length_unit.set_state("in")
22
- assert watertight.import_geometry.length_unit.get_state() == "in"
23
- watertight.import_geometry()
24
-
25
- # Add local sizing
26
- watertight.add_local_sizing.add_child_to_task()
27
- watertight.add_local_sizing()
28
-
29
- # Generate surface mesh
30
- watertight.create_surface_mesh.cfd_surface_mesh_controls.max_size.set_state(0.3)
31
- assert watertight.create_surface_mesh.cfd_surface_mesh_controls.max_size() == 0.3
32
- watertight.create_surface_mesh()
33
-
34
- # Describe geometry
35
- watertight.describe_geometry.update_child_tasks(setup_type_changed=False)
36
- watertight.describe_geometry.setup_type.set_state(
37
- "The geometry consists of only fluid regions with no voids"
38
- )
39
- watertight.describe_geometry.update_child_tasks(setup_type_changed=True)
40
- watertight.describe_geometry()
41
-
42
- # Update boundaries
43
- watertight.update_boundaries.boundary_label_list.set_state(["wall-inlet"])
44
- watertight.update_boundaries.boundary_label_type_list.set_state(["wall"])
45
- watertight.update_boundaries.old_boundary_label_list.set_state(["wall-inlet"])
46
- watertight.update_boundaries.old_boundary_label_type_list.set_state(
47
- ["velocity-inlet"]
48
- )
49
- watertight.update_boundaries()
50
-
51
- # Update regions
52
- watertight.update_regions()
53
-
54
- # Add boundary layers
55
- watertight.add_boundary_layer.add_child_to_task()
56
- watertight.add_boundary_layer.insert_compound_child_task()
57
- watertight.add_boundary_layer.arguments = {}
58
- watertight.add_boundary_layer_child_1.bl_control_name.set_state(
59
- "smooth-transition_1"
60
- )
61
- watertight.add_boundary_layer_child_1()
62
-
63
- # Generate volume mesh
64
- watertight.create_volume_mesh.volume_fill.set_state("poly-hexcore")
65
- watertight.create_volume_mesh.volume_fill_controls.hex_max_cell_length.set_state(
66
- 0.3
67
- )
68
- watertight.create_volume_mesh()
69
-
70
- # Switch to solution mode
71
- solver = new_meshing_session.switch_to_solver()
72
- assert solver
73
-
74
-
75
- @pytest.mark.nightly
76
- @pytest.mark.codegen_required
77
- @pytest.mark.fluent_version(">=24.1")
78
- def test_new_fault_tolerant_workflow(new_meshing_session):
79
- meshing = new_meshing_session
80
-
81
- # Import CAD and part management
82
- import_file_name = examples.download_file(
83
- "exhaust_system.fmd", "pyfluent/exhaust_system"
84
- )
85
- fault_tolerant = meshing.fault_tolerant()
86
- meshing.PartManagement.InputFileChanged(
87
- FilePath=import_file_name, IgnoreSolidNames=False, PartPerBody=False
88
- )
89
- meshing.PMFileManagement.FileManager.LoadFiles()
90
- meshing.PartManagement.Node["Meshing Model"].Copy(
91
- Paths=[
92
- "/dirty_manifold-for-wrapper," + "1/dirty_manifold-for-wrapper,1/main,1",
93
- "/dirty_manifold-for-wrapper,"
94
- + "1/dirty_manifold-for-wrapper,1/flow-pipe,1",
95
- "/dirty_manifold-for-wrapper,"
96
- + "1/dirty_manifold-for-wrapper,1/outpipe3,1",
97
- "/dirty_manifold-for-wrapper," + "1/dirty_manifold-for-wrapper,1/object2,1",
98
- "/dirty_manifold-for-wrapper," + "1/dirty_manifold-for-wrapper,1/object1,1",
99
- ]
100
- )
101
- meshing.PartManagement.ObjectSetting["DefaultObjectSetting"].OneZonePer.set_state(
102
- "part"
103
- )
104
- fault_tolerant.import_cad_and_part_management.context.set_state(0)
105
- fault_tolerant.import_cad_and_part_management.create_object_per.set_state("Custom")
106
- fault_tolerant.import_cad_and_part_management.fmd_file_name.set_state(
107
- import_file_name
108
- )
109
- fault_tolerant.import_cad_and_part_management.file_loaded.set_state("yes")
110
- fault_tolerant.import_cad_and_part_management.object_setting.set_state(
111
- "DefaultObjectSetting"
112
- )
113
- fault_tolerant.import_cad_and_part_management.options.line.set_state(False)
114
- fault_tolerant.import_cad_and_part_management.options.solid.set_state(False)
115
- fault_tolerant.import_cad_and_part_management.options.surface.set_state(False)
116
- fault_tolerant.import_cad_and_part_management()
117
-
118
- # Describe geometry and flow
119
- fault_tolerant.describe_geometry_and_flow.add_enclosure.set_state("No")
120
- fault_tolerant.describe_geometry_and_flow.close_caps.set_state("Yes")
121
- fault_tolerant.describe_geometry_and_flow.flow_type.set_state(
122
- "Internal flow through the object"
123
- )
124
- fault_tolerant.describe_geometry_and_flow.update_child_tasks(
125
- setup_type_changed=False
126
- )
127
-
128
- fault_tolerant.describe_geometry_and_flow.add_enclosure.set_state("No")
129
- fault_tolerant.describe_geometry_and_flow.close_caps.set_state("Yes")
130
- fault_tolerant.describe_geometry_and_flow.describe_geometry_and_flow_options.advanced_options.set_state(
131
- True
132
- )
133
- fault_tolerant.describe_geometry_and_flow.describe_geometry_and_flow_options.extract_edge_features.set_state(
134
- "Yes"
135
- )
136
- fault_tolerant.describe_geometry_and_flow.flow_type.set_state(
137
- "Internal flow through the object"
138
- )
139
- fault_tolerant.describe_geometry_and_flow.update_child_tasks(
140
- setup_type_changed=False
141
- )
142
- fault_tolerant.describe_geometry_and_flow()
143
-
144
- # Enclose fluid regions (capping)
145
- fault_tolerant.enclose_fluid_regions_fault.create_patch_preferences.show_create_patch_preferences.set_state(
146
- False
147
- )
148
- fault_tolerant.enclose_fluid_regions_fault.patch_name.set_state("inlet-1")
149
- fault_tolerant.enclose_fluid_regions_fault.selection_type.set_state("zone")
150
- fault_tolerant.enclose_fluid_regions_fault.zone_selection_list.set_state(
151
- ["inlet.1"]
152
- )
153
-
154
- fault_tolerant.enclose_fluid_regions_fault.create_patch_preferences.show_create_patch_preferences.set_state(
155
- False
156
- )
157
- fault_tolerant.enclose_fluid_regions_fault.patch_name.set_state("inlet-1")
158
- fault_tolerant.enclose_fluid_regions_fault.selection_type.set_state("zone")
159
- fault_tolerant.enclose_fluid_regions_fault.zone_location.set_state(
160
- [
161
- "1",
162
- "351.68205",
163
- "-361.34322",
164
- "-301.88668",
165
- "396.96205",
166
- "-332.84759",
167
- "-266.69751",
168
- "inlet.1",
169
- ]
170
- )
171
- fault_tolerant.enclose_fluid_regions_fault.zone_selection_list.set_state(
172
- ["inlet.1"]
173
- )
174
- fault_tolerant.enclose_fluid_regions_fault.add_child_to_task()
175
- fault_tolerant.enclose_fluid_regions_fault.insert_compound_child_task()
176
- fault_tolerant.enclose_fluid_regions_fault.arguments.set_state({})
177
- fault_tolerant.enclose_fluid_regions_fault_child_1()
178
-
179
- fault_tolerant.enclose_fluid_regions_fault.patch_name.set_state("inlet-2")
180
- fault_tolerant.enclose_fluid_regions_fault.selection_type.set_state("zone")
181
- fault_tolerant.enclose_fluid_regions_fault.zone_selection_list.set_state(
182
- ["inlet.2"]
183
- )
184
-
185
- fault_tolerant.enclose_fluid_regions_fault.patch_name.set_state("inlet-2")
186
- fault_tolerant.enclose_fluid_regions_fault.selection_type.set_state("zone")
187
- fault_tolerant.enclose_fluid_regions_fault.zone_location.set_state(
188
- [
189
- "1",
190
- "441.68205",
191
- "-361.34322",
192
- "-301.88668",
193
- "486.96205",
194
- "-332.84759",
195
- "-266.69751",
196
- "inlet.2",
197
- ]
198
- )
199
- fault_tolerant.enclose_fluid_regions_fault.zone_selection_list.set_state(
200
- ["inlet.2"]
201
- )
202
- fault_tolerant.enclose_fluid_regions_fault.add_child_to_task()
203
- fault_tolerant.enclose_fluid_regions_fault.insert_compound_child_task()
204
- fault_tolerant.enclose_fluid_regions_fault.arguments.set_state({})
205
- fault_tolerant.enclose_fluid_regions_fault_child_2()
206
-
207
- fault_tolerant.enclose_fluid_regions_fault.patch_name.set_state("inlet-3")
208
- fault_tolerant.enclose_fluid_regions_fault.selection_type.set_state("zone")
209
- fault_tolerant.enclose_fluid_regions_fault.zone_selection_list.set_state(["inlet"])
210
-
211
- fault_tolerant.enclose_fluid_regions_fault.patch_name.set_state("inlet-3")
212
- fault_tolerant.enclose_fluid_regions_fault.selection_type.set_state("zone")
213
- fault_tolerant.enclose_fluid_regions_fault.zone_location.set_state(
214
- [
215
- "1",
216
- "261.68205",
217
- "-361.34322",
218
- "-301.88668",
219
- "306.96205",
220
- "-332.84759",
221
- "-266.69751",
222
- "inlet",
223
- ]
224
- )
225
- fault_tolerant.enclose_fluid_regions_fault.zone_selection_list.set_state(["inlet"])
226
- fault_tolerant.enclose_fluid_regions_fault.add_child_to_task()
227
- fault_tolerant.enclose_fluid_regions_fault.insert_compound_child_task()
228
- fault_tolerant.enclose_fluid_regions_fault.arguments.set_state({})
229
- fault_tolerant.enclose_fluid_regions_fault_child_3()
230
-
231
- fault_tolerant.enclose_fluid_regions_fault.patch_name.set_state("outlet-1")
232
- fault_tolerant.enclose_fluid_regions_fault.selection_type.set_state("zone")
233
- fault_tolerant.enclose_fluid_regions_fault.zone_selection_list.set_state(["outlet"])
234
- fault_tolerant.enclose_fluid_regions_fault.zone_type.set_state("pressure-outlet")
235
-
236
- fault_tolerant.enclose_fluid_regions_fault.patch_name.set_state("outlet-1")
237
- fault_tolerant.enclose_fluid_regions_fault.selection_type.set_state("zone")
238
- fault_tolerant.enclose_fluid_regions_fault.zone_location.set_state(
239
- [
240
- "1",
241
- "352.22702",
242
- "-197.8957",
243
- "84.102381",
244
- "394.41707",
245
- "-155.70565",
246
- "84.102381",
247
- "outlet",
248
- ]
249
- )
250
- fault_tolerant.enclose_fluid_regions_fault.zone_selection_list.set_state(["outlet"])
251
- fault_tolerant.enclose_fluid_regions_fault.zone_type.set_state("pressure-outlet")
252
- fault_tolerant.enclose_fluid_regions_fault.add_child_to_task()
253
- fault_tolerant.enclose_fluid_regions_fault.insert_compound_child_task()
254
- fault_tolerant.enclose_fluid_regions_fault.arguments.set_state({})
255
- fault_tolerant.enclose_fluid_regions_fault_child_4()
256
-
257
- # Extract edge features
258
- fault_tolerant.extract_edge_features.extract_method_type.set_state(
259
- "Intersection Loops"
260
- )
261
- fault_tolerant.extract_edge_features.object_selection_list.set_state(
262
- ["flow_pipe", "main"]
263
- )
264
- fault_tolerant.extract_edge_features.add_child_to_task()
265
- fault_tolerant.extract_edge_features.insert_compound_child_task()
266
-
267
- fault_tolerant.extract_edge_features.extract_edges_name.set_state("edge-group-1")
268
- fault_tolerant.extract_edge_features.extract_method_type.set_state(
269
- "Intersection Loops"
270
- )
271
- fault_tolerant.extract_edge_features.object_selection_list.set_state(
272
- ["flow_pipe", "main"]
273
- )
274
-
275
- fault_tolerant.extract_edge_features.arguments.set_state({})
276
- fault_tolerant.extract_edge_features_child_1()
277
-
278
- # Identify regions
279
- fault_tolerant.identify_regions.selection_type.set_state("zone")
280
- fault_tolerant.identify_regions.x.set_state(377.322045740589)
281
- fault_tolerant.identify_regions.y.set_state(-176.800676988458)
282
- fault_tolerant.identify_regions.z.set_state(-37.0764628583475)
283
- fault_tolerant.identify_regions.zone_selection_list.set_state(["main.1"])
284
-
285
- fault_tolerant.identify_regions.selection_type.set_state("zone")
286
- fault_tolerant.identify_regions.x.set_state(377.322045740589)
287
- fault_tolerant.identify_regions.y.set_state(-176.800676988458)
288
- fault_tolerant.identify_regions.z.set_state(-37.0764628583475)
289
- fault_tolerant.identify_regions.zone_location.set_state(
290
- [
291
- "1",
292
- "213.32205",
293
- "-225.28068",
294
- "-158.25531",
295
- "541.32205",
296
- "-128.32068",
297
- "84.102381",
298
- "main.1",
299
- ]
300
- )
301
- fault_tolerant.identify_regions.zone_selection_list.set_state(["main.1"])
302
- fault_tolerant.identify_regions.add_child_to_task()
303
- fault_tolerant.identify_regions.insert_compound_child_task()
304
- fault_tolerant.identify_regions.x.set_state(377.322045740589)
305
- fault_tolerant.identify_regions.y.set_state(-176.800676988458)
306
- fault_tolerant.identify_regions.z.set_state(-37.0764628583475)
307
-
308
- fault_tolerant.identify_regions_child_1.material_points_name.set_state(
309
- "fluid-region-1"
310
- )
311
- fault_tolerant.identify_regions_child_1.selection_type.set_state("zone")
312
- fault_tolerant.identify_regions.zone_location.set_state(
313
- [
314
- "1",
315
- "213.32205",
316
- "-225.28068",
317
- "-158.25531",
318
- "541.32205",
319
- "-128.32068",
320
- "84.102381",
321
- "main.1",
322
- ]
323
- )
324
- fault_tolerant.identify_regions.zone_selection_list.set_state(["main.1"])
325
- fault_tolerant.identify_regions.arguments.set_state({})
326
- fault_tolerant.identify_regions_child_1()
327
-
328
- fault_tolerant.identify_regions.material_points_name.set_state("void-region-1")
329
- fault_tolerant.identify_regions.new_region_type.set_state("void")
330
- fault_tolerant.identify_regions.object_selection_list.set_state(
331
- ["inlet-1", "inlet-2", "inlet-3", "main"]
332
- )
333
- fault_tolerant.identify_regions.x.set_state(374.722045740589)
334
- fault_tolerant.identify_regions.y.set_state(-278.9775145640143)
335
- fault_tolerant.identify_regions.z.set_state(-161.1700719416913)
336
- fault_tolerant.identify_regions.add_child_to_task()
337
- fault_tolerant.identify_regions.insert_compound_child_task()
338
- fault_tolerant.identify_regions.arguments.set_state({})
339
- fault_tolerant.identify_regions_child_2()
340
-
341
- # Define leakage threshold
342
- fault_tolerant.define_leakage_threshold.add_child.set_state("yes")
343
- fault_tolerant.define_leakage_threshold.flip_direction.set_state(True)
344
- fault_tolerant.define_leakage_threshold.plane_direction.set_state("X")
345
- fault_tolerant.define_leakage_threshold.region_selection_single.set_state(
346
- "void-region-1"
347
- )
348
- fault_tolerant.define_leakage_threshold.add_child_to_task()
349
- fault_tolerant.define_leakage_threshold.insert_compound_child_task()
350
-
351
- fault_tolerant.define_leakage_threshold.add_child.set_state("yes")
352
-
353
- fault_tolerant.define_leakage_threshold_child_1.arguments.set_state(
354
- {
355
- "add_child": "yes",
356
- "flip_direction": True,
357
- "leakage_name": "leakage-1",
358
- "plane_direction": "X",
359
- "region_selection_single": "void-region-1",
360
- }
361
- )
362
-
363
- fault_tolerant.define_leakage_threshold_child_1()
364
-
365
- # Update regions settings
366
- fault_tolerant.update_region_settings.all_region_filter_categories.set_state(
367
- ["2"] * 5 + ["1"] * 2
368
- )
369
- fault_tolerant.update_region_settings.all_region_leakage_size_list.set_state(
370
- ["none"] * 6 + ["6.4"]
371
- )
372
- fault_tolerant.update_region_settings.all_region_linked_construction_surface_list.set_state(
373
- ["n/a"] * 6 + ["no"]
374
- )
375
- fault_tolerant.update_region_settings.all_region_mesh_method_list.set_state(
376
- ["none"] * 6 + ["wrap"]
377
- )
378
- fault_tolerant.update_region_settings.all_region_name_list.set_state(
379
- [
380
- "main",
381
- "flow_pipe",
382
- "outpipe3",
383
- "object2",
384
- "object1",
385
- "void-region-1",
386
- "fluid-region-1",
387
- ]
388
- )
389
- fault_tolerant.update_region_settings.all_region_overset_componen_list.set_state(
390
- ["no"] * 7
391
- )
392
- fault_tolerant.update_region_settings.all_region_source_list.set_state(
393
- ["object"] * 5 + ["mpt"] * 2
394
- )
395
- fault_tolerant.update_region_settings.all_region_type_list.set_state(
396
- ["void"] * 6 + ["fluid"]
397
- )
398
- fault_tolerant.update_region_settings.all_region_volume_fill_list.set_state(
399
- ["none"] * 6 + ["tet"]
400
- )
401
- fault_tolerant.update_region_settings.filter_category.set_state(
402
- "Identified Regions"
403
- )
404
- fault_tolerant.update_region_settings.old_region_leakage_size_list.set_state([""])
405
- fault_tolerant.update_region_settings.old_region_mesh_method_list.set_state(
406
- ["wrap"]
407
- )
408
- fault_tolerant.update_region_settings.old_region_name_list.set_state(
409
- ["fluid-region-1"]
410
- )
411
- fault_tolerant.update_region_settings.old_region_overset_componen_list.set_state(
412
- ["no"]
413
- )
414
- fault_tolerant.update_region_settings.old_region_type_list.set_state(["fluid"])
415
- fault_tolerant.update_region_settings.old_region_volume_fill_list.set_state(
416
- ["hexcore"]
417
- )
418
- fault_tolerant.update_region_settings.region_leakage_size_list.set_state([""])
419
- fault_tolerant.update_region_settings.region_mesh_method_list.set_state(["wrap"])
420
- fault_tolerant.update_region_settings.region_name_list.set_state(["fluid-region-1"])
421
- fault_tolerant.update_region_settings.region_overset_componen_list.set_state(["no"])
422
- fault_tolerant.update_region_settings.region_type_list.set_state(["fluid"])
423
- fault_tolerant.update_region_settings.region_volume_fill_list.set_state(["tet"])
424
- fault_tolerant.update_region_settings()
425
-
426
- # Choose mesh control options
427
- fault_tolerant.choose_mesh_control_options()
428
-
429
- # Generate surface mesh
430
- if meshing.get_fluent_version() < FluentVersion.v251:
431
- fault_tolerant.generate_the_surface_mesh()
432
- else:
433
- fault_tolerant.generate_surface_mesh()
434
-
435
- # Update boundaries
436
- fault_tolerant.update_boundaries_ftm()
437
-
438
- # Add boundary layers
439
- fault_tolerant.add_boundary_layer_ftm.add_child_to_task()
440
- fault_tolerant.add_boundary_layer_ftm.insert_compound_child_task()
441
- fault_tolerant.add_boundary_layer_ftm.arguments.set_state({})
442
- fault_tolerant.add_boundary_layer_ftm_child_1.bl_control_name.set_state(
443
- "aspect-ratio_1"
444
- )
445
- fault_tolerant.add_boundary_layer_ftm_child_1()
446
-
447
- # Generate volume mesh
448
- if meshing.get_fluent_version() < FluentVersion.v251:
449
- generate_volume_mesh = fault_tolerant.generate_the_volume_mesh
450
- else:
451
- generate_volume_mesh = fault_tolerant.create_volume_mesh
452
- generate_volume_mesh.all_region_name_list.set_state(
453
- [
454
- "main",
455
- "flow_pipe",
456
- "outpipe3",
457
- "object2",
458
- "object1",
459
- "void-region-1",
460
- "fluid-region-1",
461
- ]
462
- )
463
- generate_volume_mesh.all_region_size_list.set_state(["11.33375"] * 7)
464
- generate_volume_mesh.all_region_volume_fill_list.set_state(["none"] * 6 + ["tet"])
465
- generate_volume_mesh.enable_parallel.set_state(True)
466
- generate_volume_mesh()
467
-
468
- # Generate volume mesh
469
- solver = meshing.switch_to_solver()
470
- assert solver
471
-
472
-
473
- @pytest.mark.nightly
474
- @pytest.mark.codegen_required
475
- @pytest.mark.fluent_version("==24.2")
476
- def test_new_2d_meshing_workflow(new_meshing_session):
477
- # Import geometry
478
- import_file_name = examples.download_file("NACA0012.fmd", "pyfluent/airfoils")
479
- two_dim_mesh = new_meshing_session.two_dimensional_meshing()
480
-
481
- two_dim_mesh.load_cad_geometry_2d.file_name = import_file_name
482
- two_dim_mesh.load_cad_geometry_2d.length_unit = "mm"
483
- two_dim_mesh.load_cad_geometry_2d.refaceting.refacet = False
484
- two_dim_mesh.load_cad_geometry_2d()
485
-
486
- # Set regions and boundaries
487
- two_dim_mesh.update_regions_2d()
488
- two_dim_mesh.update_boundaries_2d.selection_type = "zone"
489
- two_dim_mesh.update_boundaries_2d()
490
-
491
- # Define global sizing
492
- two_dim_mesh.define_global_sizing_2d.curvature_normal_angle = 20
493
- two_dim_mesh.define_global_sizing_2d.max_size = 2000.0
494
- two_dim_mesh.define_global_sizing_2d.min_size = 5.0
495
- two_dim_mesh.define_global_sizing_2d.size_functions = "Curvature"
496
- two_dim_mesh.define_global_sizing_2d()
497
-
498
- # Add local sizing
499
- two_dim_mesh.add_local_sizing_2d.add_child = "yes"
500
- two_dim_mesh.add_local_sizing_2d.boi_control_name = "boi_1"
501
- two_dim_mesh.add_local_sizing_2d.boi_execution = "Body Of Influence"
502
- two_dim_mesh.add_local_sizing_2d.boi_face_label_list = ["boi"]
503
- two_dim_mesh.add_local_sizing_2d.boi_size = 50.0
504
- two_dim_mesh.add_local_sizing_2d.boi_zoneor_label = "label"
505
- two_dim_mesh.add_local_sizing_2d.draw_size_control = True
506
- two_dim_mesh.add_local_sizing_2d.add_child_and_update(defer_update=False)
507
-
508
- two_dim_mesh.add_local_sizing_2d.add_child = "yes"
509
- two_dim_mesh.add_local_sizing_2d.boi_control_name = "edgesize_1"
510
- two_dim_mesh.add_local_sizing_2d.boi_execution = "Edge Size"
511
- two_dim_mesh.add_local_sizing_2d.boi_size = 5.0
512
- two_dim_mesh.add_local_sizing_2d.boi_zoneor_label = "label"
513
- two_dim_mesh.add_local_sizing_2d.draw_size_control = True
514
- two_dim_mesh.add_local_sizing_2d.edge_label_list = ["airfoil-te"]
515
- two_dim_mesh.add_local_sizing_2d.add_child_and_update(defer_update=False)
516
-
517
- two_dim_mesh.add_local_sizing_2d.add_child = "yes"
518
- two_dim_mesh.add_local_sizing_2d.boi_control_name = "curvature_1"
519
- two_dim_mesh.add_local_sizing_2d.boi_curvature_normal_angle = 10
520
- two_dim_mesh.add_local_sizing_2d.boi_execution = "Curvature"
521
- two_dim_mesh.add_local_sizing_2d.boi_max_size = 2
522
- two_dim_mesh.add_local_sizing_2d.boi_min_size = 1.5
523
- two_dim_mesh.add_local_sizing_2d.boi_scope_to = "edges"
524
- two_dim_mesh.add_local_sizing_2d.boi_zoneor_label = "label"
525
- two_dim_mesh.add_local_sizing_2d.draw_size_control = True
526
- two_dim_mesh.add_local_sizing_2d.edge_label_list = ["airfoil"]
527
- two_dim_mesh.add_local_sizing_2d.add_child_and_update(defer_update=False)
528
-
529
- # Add boundary layer
530
- two_dim_mesh.add_2d_boundary_layers.add_child = "yes"
531
- two_dim_mesh.add_2d_boundary_layers.bl_control_name = "aspect-ratio_1"
532
- two_dim_mesh.add_2d_boundary_layers.number_of_layers = 4
533
- two_dim_mesh.add_2d_boundary_layers.offset_method_type = "aspect-ratio"
534
- two_dim_mesh.add_2d_boundary_layers.add_child_and_update(defer_update=False)
535
-
536
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.merge_edge_zones_based_on_labels = (
537
- "no"
538
- )
539
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.merge_face_zones_based_on_labels = (
540
- "no"
541
- )
542
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.show_advanced_options = (
543
- True
544
- )
545
- two_dim_mesh.generate_initial_surface_mesh()
546
-
547
- two_dim_mesh.add_2d_boundary_layers_child_1.revert()
548
- two_dim_mesh.add_2d_boundary_layers_child_1.add_child = "yes"
549
- two_dim_mesh.add_2d_boundary_layers_child_1.bl_control_name = "uniform_1"
550
- two_dim_mesh.add_2d_boundary_layers_child_1.first_layer_height = 2
551
- two_dim_mesh.add_2d_boundary_layers_child_1.number_of_layers = 4
552
- two_dim_mesh.add_2d_boundary_layers_child_1.offset_method_type = "uniform"
553
- two_dim_mesh.add_2d_boundary_layers_child_1()
554
-
555
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.merge_edge_zones_based_on_labels = (
556
- "no"
557
- )
558
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.merge_face_zones_based_on_labels = (
559
- "no"
560
- )
561
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.show_advanced_options = (
562
- True
563
- )
564
- two_dim_mesh.generate_initial_surface_mesh()
565
-
566
- two_dim_mesh._task("uniform_1").revert()
567
- two_dim_mesh._task("uniform_1").add_child = "yes"
568
- two_dim_mesh._task("uniform_1").bl_control_name = "smooth-transition_1"
569
- two_dim_mesh._task("uniform_1").first_layer_height = 2
570
- two_dim_mesh._task("uniform_1").number_of_layers = 7
571
- two_dim_mesh._task("uniform_1").offset_method_type = "smooth-transition"
572
- two_dim_mesh._task("uniform_1")()
573
-
574
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.merge_edge_zones_based_on_labels = (
575
- "no"
576
- )
577
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.merge_face_zones_based_on_labels = (
578
- "no"
579
- )
580
- two_dim_mesh.generate_initial_surface_mesh.surface_2d_preferences.show_advanced_options = (
581
- True
582
- )
583
- two_dim_mesh.generate_initial_surface_mesh()
584
-
585
- # Switch to solution mode
586
- solver = new_meshing_session.switch_to_solver()
587
- assert solver
588
-
589
-
590
- @pytest.mark.codegen_required
591
- @pytest.mark.fluent_version(">=23.2")
592
- def test_updating_state_in_new_meshing_workflow(new_meshing_session):
593
- # Import geometry
594
- import_file_name = examples.download_file(
595
- "mixing_elbow.pmdb", "pyfluent/mixing_elbow"
596
- )
597
- watertight = new_meshing_session.watertight()
598
- assert watertight.import_geometry.length_unit() == "mm"
599
- assert watertight.import_geometry.cad_import_options.feature_angle() == 40.0
600
- assert (
601
- watertight.import_geometry.cad_import_options.one_zone_per.allowed_values()
602
- == ["body", "face", "object"]
603
- )
604
- assert watertight.import_geometry.cad_import_options.one_zone_per() == "body"
605
- watertight.import_geometry.arguments = {
606
- "file_name": import_file_name,
607
- "length_unit": "in",
608
- "cad_import_options": {"feature_angle": 35, "one_zone_per": "object"},
609
- }
610
- assert watertight.import_geometry.cad_import_options.feature_angle() == 35.0
611
- assert (
612
- watertight.import_geometry.cad_import_options.one_zone_per.get_state()
613
- == "object"
614
- )
615
- assert watertight.import_geometry.length_unit.get_state() == "in"
616
- watertight.import_geometry.cad_import_options.feature_angle = 25.0
617
- assert watertight.import_geometry.cad_import_options.feature_angle() == 25.0
618
- watertight.import_geometry.cad_import_options.one_zone_per = "face"
619
- assert watertight.import_geometry.cad_import_options.one_zone_per() == "face"
620
- watertight.import_geometry()
621
-
622
-
623
- def _assert_snake_case_attrs(attrs: Iterable):
624
- for attr in attrs:
625
- assert str(attr).islower()
626
-
627
-
628
- @pytest.mark.codegen_required
629
- @pytest.mark.fluent_version(">=23.2")
630
- def test_snake_case_attrs_in_new_meshing_workflow(new_meshing_session):
631
- # Import geometry
632
- import_file_name = examples.download_file(
633
- "mixing_elbow.pmdb", "pyfluent/mixing_elbow"
634
- )
635
- watertight = new_meshing_session.watertight()
636
- dir_watertight = dir(watertight)
637
- dir_watertight.remove("_FirstTask")
638
- _assert_snake_case_attrs(dir_watertight)
639
- dir_watertight_import_geometry = dir(watertight.import_geometry)
640
- dir_watertight_import_geometry.remove("_NextTask")
641
- _assert_snake_case_attrs(dir_watertight_import_geometry)
642
- _assert_snake_case_attrs(watertight.import_geometry.arguments())
643
- _assert_snake_case_attrs(watertight.import_geometry.cad_import_options())
644
- _assert_snake_case_attrs(dir(watertight.import_geometry.cad_import_options))
645
- watertight.import_geometry.file_name.set_state(import_file_name)
646
- watertight.import_geometry.length_unit = "in"
647
- watertight.import_geometry()
648
-
649
-
650
- @pytest.mark.codegen_required
651
- @pytest.mark.fluent_version(">=24.1")
652
- def test_workflow_and_data_model_methods_new_meshing_workflow(new_meshing_session):
653
- # Import geometry
654
- meshing = new_meshing_session
655
- import_file_name = examples.download_file(
656
- "mixing_elbow.pmdb", "pyfluent/mixing_elbow"
657
- )
658
- watertight = meshing.watertight()
659
-
660
- # Checks if any of the unwanted attrs are present in dir call
661
- assert (set(dir(watertight)) - watertight._unwanted_attrs) == set(dir(watertight))
662
-
663
- for attr in watertight._unwanted_attrs:
664
- with pytest.raises(AttributeError):
665
- getattr(watertight, attr)
666
-
667
- watertight.import_geometry.rename(new_name="import_geom_wtm")
668
- assert "import_geometry" not in watertight.task_names()
669
- assert "import_geom_wtm" in watertight.task_names()
670
- assert len(watertight.tasks()) == 11
671
- watertight.import_geom_wtm.file_name = import_file_name
672
- watertight.import_geom_wtm.length_unit = "in"
673
- watertight.import_geom_wtm()
674
- _next_possible_tasks = [
675
- "<Insertable 'import_boi_geometry' task>",
676
- "<Insertable 'set_up_rotational_periodic_boundaries' task>",
677
- "<Insertable 'create_local_refinement_regions' task>",
678
- "<Insertable 'custom_journal_task' task>",
679
- ]
680
- assert sorted(
681
- [repr(x) for x in watertight.import_geom_wtm.insertable_tasks()]
682
- ) == sorted(_next_possible_tasks)
683
- watertight.import_geom_wtm.insertable_tasks.import_boi_geometry.insert()
684
- assert sorted(
685
- [repr(x) for x in watertight.import_geom_wtm.insertable_tasks()]
686
- ) == sorted(_next_possible_tasks)
687
- watertight.import_geom_wtm.insertable_tasks.set_up_rotational_periodic_boundaries.insert()
688
- assert len(watertight.tasks()) == 13
689
-
690
-
691
- @pytest.mark.fluent_version(">=23.2")
692
- @pytest.mark.codegen_required
693
- def test_watertight_workflow(mixing_elbow_geometry_filename, new_meshing_session):
694
- watertight = new_meshing_session.watertight()
695
- watertight.import_geometry.file_name = mixing_elbow_geometry_filename
696
- watertight.import_geometry()
697
- add_local_sizing = watertight.add_local_sizing
698
- assert not add_local_sizing.tasks()
699
- add_local_sizing._add_child(state={"boi_face_label_list": ["cold-inlet"]})
700
- assert not add_local_sizing.tasks()
701
- added_sizing = add_local_sizing.add_child_and_update(
702
- state={"boi_face_label_list": ["elbow-fluid"]}
703
- )
704
- assert len(add_local_sizing.tasks()) == 1
705
- assert added_sizing
706
- assert added_sizing.boi_face_label_list() == ["elbow-fluid"]
707
-
708
-
709
- @pytest.mark.fluent_version(">=23.2")
710
- @pytest.mark.codegen_required
711
- def test_watertight_workflow_children(
712
- mixing_elbow_geometry_filename, new_meshing_session
713
- ):
714
- watertight = new_meshing_session.watertight()
715
- watertight.import_geometry.file_name = mixing_elbow_geometry_filename
716
- watertight.import_geometry()
717
- add_local_sizing = watertight.add_local_sizing
718
- assert not add_local_sizing.tasks()
719
- add_local_sizing._add_child(state={"boi_face_label_list": ["cold-inlet"]})
720
- assert not add_local_sizing.tasks()
721
- added_sizing = add_local_sizing.add_child_and_update(
722
- state={"boi_face_label_list": ["elbow-fluid"]}
723
- )
724
- assert len(add_local_sizing.tasks()) == 1
725
- assert added_sizing
726
- assert added_sizing.boi_face_label_list() == ["elbow-fluid"]
727
- assert added_sizing.name() == "facesize_1"
728
- assert len(added_sizing.arguments())
729
- added_sizing_by_name = add_local_sizing.compound_child("facesize_1")
730
- added_sizing_by_pos = add_local_sizing.last_child()
731
- assert added_sizing.arguments() == added_sizing_by_name.arguments()
732
- assert added_sizing.arguments() == added_sizing_by_pos.arguments()
733
- assert added_sizing.python_name() == "add_local_sizing_child_1"
734
- describe_geometry = watertight.describe_geometry
735
- describe_geometry_children = describe_geometry.tasks()
736
- assert len(describe_geometry_children) == 2
737
- describe_geometry_child_task_python_names = describe_geometry.task_names()
738
- assert describe_geometry_child_task_python_names == [
739
- "enclose_fluid_regions",
740
- "create_regions",
741
- ]
742
-
743
-
744
- @pytest.mark.fluent_version(">=24.1")
745
- @pytest.mark.codegen_required
746
- def test_watertight_workflow_dynamic_interface(
747
- mixing_elbow_geometry_filename, new_meshing_session
748
- ):
749
- watertight = new_meshing_session.watertight()
750
- watertight.import_geometry.file_name = mixing_elbow_geometry_filename
751
- watertight.import_geometry()
752
- create_volume_mesh = watertight.create_volume_mesh
753
- assert create_volume_mesh is not None
754
- watertight.delete_tasks(list_of_tasks=["create_volume_mesh"])
755
- assert "create_volume_mesh" not in watertight.task_names()
756
-
757
- assert sorted(
758
- [repr(x) for x in watertight.add_boundary_layer.insertable_tasks()]
759
- ) == sorted(
760
- [
761
- "<Insertable 'add_boundary_type' task>",
762
- "<Insertable 'update_boundaries' task>",
763
- "<Insertable 'set_up_rotational_periodic_boundaries' task>",
764
- "<Insertable 'modify_mesh_refinement' task>",
765
- "<Insertable 'improve_surface_mesh' task>",
766
- "<Insertable 'create_volume_mesh' task>",
767
- "<Insertable 'manage_zones_ftm' task>",
768
- "<Insertable 'update_regions' task>",
769
- "<Insertable 'custom_journal_task' task>",
770
- ]
771
- )
772
- watertight.add_boundary_layer.insertable_tasks.create_volume_mesh.insert()
773
- assert "create_volume_mesh" in watertight.task_names()
774
- create_volume_mesh = watertight.create_volume_mesh
775
- assert create_volume_mesh is not None
776
-
777
- assert (
778
- watertight.describe_geometry.create_regions.arguments()[
779
- "number_of_flow_volumes"
780
- ]
781
- == 1
782
- )
783
- watertight.delete_tasks(list_of_tasks=["create_regions"])
784
- assert "create_regions" not in watertight.task_names()
785
- assert watertight.describe_geometry.enclose_fluid_regions
786
- watertight.describe_geometry.enclose_fluid_regions.delete()
787
- assert "enclose_fluid_regions" not in watertight.task_names()
788
- watertight.create_volume_mesh.delete()
789
- assert "create_volume_mesh" not in watertight.task_names()
790
-
791
-
792
- @pytest.mark.fluent_version("==23.2")
793
- @pytest.mark.codegen_required
794
- def test_fault_tolerant_workflow(exhaust_system_geometry_filename, new_meshing_session):
795
- fault_tolerant = new_meshing_session.fault_tolerant()
796
- part_management = fault_tolerant.part_management
797
- file_name = exhaust_system_geometry_filename
798
- part_management.LoadFmdFile(FilePath=file_name)
799
- part_management.MoveCADComponentsToNewObject(
800
- Paths=[r"/Bottom,1", r"/Left,1", r"/Others,1", r"/Right,1", r"/Top,1"]
801
- )
802
- part_management.Node["Object"].Rename(NewName=r"Engine")
803
- import_cad = fault_tolerant.import_cad_and_part_management
804
- import_cad.Arguments.setState(
805
- {
806
- r"CreateObjectPer": r"Custom",
807
- r"FMDFileName": file_name,
808
- r"FileLoaded": r"yes",
809
- r"ObjectSetting": r"DefaultObjectSetting",
810
- }
811
- )
812
- import_cad()
813
-
814
-
815
- @pytest.mark.fluent_version(">=23.2")
816
- @pytest.mark.codegen_required
817
- def test_extended_wrapper(new_meshing_session, mixing_elbow_geometry_filename):
818
- watertight = new_meshing_session.watertight()
819
- import_geometry = watertight.import_geometry
820
- assert import_geometry.Arguments() == {}
821
- import_geometry.Arguments = dict(FileName=mixing_elbow_geometry_filename)
822
- assert 8 < len(import_geometry.arguments.get_state()) < 15
823
- assert len(import_geometry.arguments.get_state(explicit_only=True)) == 1
824
- import_geometry.arguments.set_state(dict(file_name=None))
825
- time.sleep(5)
826
- assert import_geometry.arguments.get_state(explicit_only=True) == dict(
827
- file_name=None
828
- )
829
- assert import_geometry.arguments.get_state()["file_name"] is None
830
- import_geometry.arguments.set_state(dict(file_name=mixing_elbow_geometry_filename))
831
- time.sleep(5)
832
- assert import_geometry.arguments.get_state(explicit_only=True) == dict(
833
- file_name=mixing_elbow_geometry_filename
834
- )
835
- assert import_geometry.file_name() == mixing_elbow_geometry_filename
836
- import_geometry.file_name.set_state("bob")
837
- time.sleep(5)
838
- assert import_geometry.file_name() == "bob"
839
- import_geometry.file_name.set_state(mixing_elbow_geometry_filename)
840
- import_geometry()
841
- add_local_sizing = watertight.add_local_sizing
842
- assert not add_local_sizing.tasks()
843
- # new_meshing_session.workflow.TaskObject["Add Local Sizing"]._add_child(state={"BOIFaceLabelList": ["elbow-fluid"]})
844
- add_local_sizing._add_child(state={"boi_face_label_list": ["cold-inlet"]})
845
- assert not add_local_sizing.tasks()
846
-
847
- added_sizing = add_local_sizing.add_child_and_update(
848
- state={"boi_face_label_list": ["elbow-fluid"]}
849
- )
850
- assert len(add_local_sizing.tasks()) == 1
851
- assert added_sizing
852
- assert added_sizing.boi_face_label_list() == ["elbow-fluid"]
853
- # restart
854
- watertight = new_meshing_session.watertight()
855
- assert import_geometry.state() == "Out-of-date"
856
- import_geometry(FileName=mixing_elbow_geometry_filename, AppendMesh=False)
857
- assert import_geometry.state() == "Up-to-date"
858
- import_geometry_state = import_geometry.arguments()
859
- assert len(import_geometry_state) > 2
860
-
861
-
862
- @pytest.mark.fluent_version(">=23.1")
863
- @pytest.mark.skip
864
- def test_meshing_workflow_structure(new_meshing_session):
865
- """
866
- o Workflow
867
- |
868
- |--o Import Geometry
869
- |
870
- |--o Add Local Sizing
871
- |
872
- |--o Generate the Surface Mesh
873
- |
874
- |--o Describe Geometry
875
- | |
876
- | |--o Enclose Fluid Regions (Capping)
877
- | |
878
- | |--o Create Regions
879
- |
880
- |--o Update Regions
881
- |
882
- |--o Add Boundary Layers
883
- |
884
- |--o Generate the Volume Mesh
885
- """
886
- w = new_meshing_session.workflow
887
- w.InitializeWorkflow(WorkflowType="Watertight Geometry")
888
-
889
- task_names = (
890
- "Import Geometry",
891
- "Add Local Sizing",
892
- "Generate the Surface Mesh",
893
- "Describe Geometry",
894
- "Enclose Fluid Regions (Capping)",
895
- "Create Regions",
896
- "Update Regions",
897
- "Add Boundary Layers",
898
- "Generate the Volume Mesh",
899
- )
900
-
901
- (
902
- import_geom,
903
- add_sizing,
904
- gen_surf_mesh,
905
- describe_geometry,
906
- cap,
907
- create_regions,
908
- update_regions,
909
- add_boundary_layers,
910
- gen_vol_mesh,
911
- ) = all_tasks = [w._task(name) for name in task_names]
912
-
913
- def upstream_names(task):
914
- return {upstream.name() for upstream in task.get_direct_upstream_tasks()}
915
-
916
- def downstream_names(task):
917
- return {downstream.name() for downstream in task.get_direct_downstream_tasks()}
918
-
919
- assert upstream_names(import_geom) == set()
920
- assert downstream_names(import_geom) == {
921
- "Generate the Surface Mesh",
922
- "Add Local Sizing",
923
- }
924
-
925
- assert upstream_names(add_sizing) == {"Import Geometry"}
926
- assert downstream_names(add_sizing) == {"Generate the Surface Mesh"}
927
-
928
- assert upstream_names(gen_surf_mesh) == {"Import Geometry", "Add Local Sizing"}
929
- assert downstream_names(gen_surf_mesh) == {
930
- "Describe Geometry",
931
- "Add Boundary Layers",
932
- "Generate the Volume Mesh",
933
- }
934
-
935
- assert upstream_names(describe_geometry) == {
936
- "Generate the Surface Mesh",
937
- "Add Boundary Layers",
938
- }
939
- assert downstream_names(describe_geometry) == {
940
- "Update Regions",
941
- "Add Boundary Layers",
942
- "Generate the Volume Mesh",
943
- }
944
-
945
- assert upstream_names(cap) == {
946
- "Describe Geometry",
947
- "Add Boundary Layers",
948
- "Generate the Surface Mesh",
949
- }
950
- assert downstream_names(cap) == {
951
- "Describe Geometry",
952
- "Add Boundary Layers",
953
- "Generate the Volume Mesh",
954
- }
955
-
956
- assert upstream_names(create_regions) == {
957
- "Describe Geometry",
958
- "Add Boundary Layers",
959
- "Generate the Surface Mesh",
960
- }
961
- assert downstream_names(create_regions) == {
962
- "Describe Geometry",
963
- "Add Boundary Layers",
964
- "Generate the Volume Mesh",
965
- "Update Regions",
966
- }
967
-
968
- assert upstream_names(update_regions) == {"Describe Geometry"}
969
- assert downstream_names(update_regions) == {"Generate the Volume Mesh"}
970
-
971
- assert upstream_names(add_boundary_layers) == {
972
- "Describe Geometry",
973
- "Generate the Surface Mesh",
974
- }
975
- assert downstream_names(add_boundary_layers) == {
976
- "Describe Geometry",
977
- "Generate the Volume Mesh",
978
- }
979
-
980
- assert upstream_names(gen_vol_mesh) == {
981
- "Update Regions",
982
- "Describe Geometry",
983
- "Add Boundary Layers",
984
- "Generate the Surface Mesh",
985
- }
986
- assert downstream_names(gen_vol_mesh) == set()
987
-
988
- for task in all_tasks:
989
- assert {sub_task.name() for sub_task in task.tasks()} == (
990
- {
991
- "Enclose Fluid Regions (Capping)",
992
- "Create Regions",
993
- }
994
- if task is describe_geometry
995
- else set()
996
- )
997
-
998
- for task in all_tasks:
999
- assert {sub_task.name() for sub_task in task.inactive_tasks()} == (
1000
- {
1001
- "Apply Share Topology",
1002
- "Update Boundaries",
1003
- }
1004
- if task is describe_geometry
1005
- else set()
1006
- )
1007
-
1008
- task_ids = [task.get_id() for task in all_tasks]
1009
- # uniqueness test
1010
- assert len(set(task_ids)) == len(task_ids)
1011
- # ordering test
1012
- idxs = [int(id[len("TaskObject") :]) for id in task_ids]
1013
- assert sorted(idxs) == idxs
1014
- """Given the workflow::
1015
-
1016
- Workflow
1017
- ├── Import Geometry
1018
- ├── Add Local Sizing
1019
- ├── Generate the Surface Mesh ── Insert Next Task
1020
- ├── Add Boundary Type
1021
- ├── Update Boundaries
1022
- ├── ...
1023
- """
1024
- assert set(gen_surf_mesh.GetNextPossibleTasks()) == {
1025
- "AddBoundaryType",
1026
- "UpdateBoundaries",
1027
- "SetUpPeriodicBoundaries",
1028
- "LinearMeshPattern",
1029
- "ManageZones",
1030
- "ModifyMeshRefinement",
1031
- "ImproveSurfaceMesh",
1032
- "RunCustomJournal",
1033
- }
1034
-
1035
- children = w.tasks()
1036
- expected_task_order = (
1037
- "Import Geometry",
1038
- "Add Local Sizing",
1039
- "Generate the Surface Mesh",
1040
- "Describe Geometry",
1041
- "Update Regions",
1042
- "Add Boundary Layers",
1043
- "Generate the Volume Mesh",
1044
- )
1045
-
1046
- actual_task_order = tuple(child.name() for child in children)
1047
-
1048
- assert actual_task_order == expected_task_order
1049
-
1050
- assert [child.name() for child in children[3].tasks()] == [
1051
- "Enclose Fluid Regions (Capping)",
1052
- "Create Regions",
1053
- ]
1054
-
1055
- gen_surf_mesh.InsertNextTask(CommandName="AddBoundaryType")
1056
-
1057
- children = w.tasks()
1058
- expected_task_order = (
1059
- "Import Geometry",
1060
- "Add Local Sizing",
1061
- "Generate the Surface Mesh",
1062
- "Add Boundary Type",
1063
- "Describe Geometry",
1064
- "Update Regions",
1065
- "Add Boundary Layers",
1066
- "Generate the Volume Mesh",
1067
- )
1068
-
1069
- actual_task_order = tuple(child.name() for child in children)
1070
-
1071
- assert actual_task_order == expected_task_order
1072
-
1073
- assert [child.name() for child in children[4].tasks()] == [
1074
- "Enclose Fluid Regions (Capping)",
1075
- "Create Regions",
1076
- ]
1077
-
1078
-
1079
- @pytest.mark.codegen_required
1080
- @pytest.mark.fluent_version(">=23.2")
1081
- def test_new_workflow_structure(new_meshing_session):
1082
- meshing = new_meshing_session
1083
- watertight = meshing.watertight()
1084
- assert watertight.import_geometry.arguments()
1085
- with pytest.raises(AttributeError):
1086
- watertight.TaskObject["Import Geometry"]
1087
-
1088
-
1089
- @pytest.mark.codegen_required
1090
- @pytest.mark.fluent_version(">=23.2")
1091
- def test_attrs_in_watertight_meshing_workflow(new_meshing_session):
1092
- # Import geometry
1093
- import_file_name = examples.download_file(
1094
- "mixing_elbow.pmdb", "pyfluent/mixing_elbow"
1095
- )
1096
- watertight = new_meshing_session.watertight()
1097
- unwanted_attrs = {"fault_tolerant", "part_management", "pm_file_management"}
1098
- assert set(dir(watertight)) - unwanted_attrs == set(dir(watertight))
1099
-
1100
- for attr in unwanted_attrs:
1101
- with pytest.raises(AttributeError):
1102
- getattr(watertight, attr)
1103
-
1104
- watertight.import_geometry.file_name.set_state(import_file_name)
1105
- watertight.import_geometry.length_unit = "in"
1106
- watertight.import_geometry()
1107
-
1108
- assert watertight.import_geometry.file_name()
1109
- # Reinitialize the workflow:
1110
- watertight = new_meshing_session.watertight()
1111
- assert not watertight.import_geometry.file_name()
1112
-
1113
-
1114
- @pytest.mark.codegen_required
1115
- @pytest.mark.fluent_version(">=23.2")
1116
- def test_ordered_children_in_enhanced_meshing_workflow(new_meshing_session):
1117
- watertight = new_meshing_session.watertight()
1118
- assert set([repr(x) for x in watertight.tasks()]) == {
1119
- "<Task 'Add Boundary Layers'>",
1120
- "<Task 'Add Local Sizing'>",
1121
- "<Task 'Apply Share Topology'>",
1122
- "<Task 'Create Regions'>",
1123
- "<Task 'Describe Geometry'>",
1124
- "<Task 'Enclose Fluid Regions (Capping)'>",
1125
- "<Task 'Generate the Surface Mesh'>",
1126
- "<Task 'Generate the Volume Mesh'>",
1127
- "<Task 'Import Geometry'>",
1128
- "<Task 'Update Boundaries'>",
1129
- "<Task 'Update Regions'>",
1130
- }
1131
-
1132
-
1133
- @pytest.mark.codegen_required
1134
- @pytest.mark.fluent_version(">=23.2")
1135
- def test_attrs_in_fault_tolerant_meshing_workflow(new_meshing_session):
1136
- # Import CAD
1137
- import_file_name = examples.download_file(
1138
- "exhaust_system.fmd", "pyfluent/exhaust_system"
1139
- )
1140
-
1141
- fault_tolerant = new_meshing_session.fault_tolerant()
1142
- assert "watertight" not in dir(fault_tolerant)
1143
-
1144
- with pytest.raises(AttributeError):
1145
- fault_tolerant.watertight()
1146
-
1147
- fault_tolerant.import_cad_and_part_management.context.set_state(0)
1148
- fault_tolerant.import_cad_and_part_management.create_object_per.set_state("Custom")
1149
- fault_tolerant.import_cad_and_part_management.fmd_file_name.set_state(
1150
- import_file_name
1151
- )
1152
-
1153
- assert fault_tolerant.import_cad_and_part_management.fmd_file_name()
1154
- # Reinitialize the workflow:
1155
- fault_tolerant = new_meshing_session.fault_tolerant()
1156
- assert not fault_tolerant.import_cad_and_part_management.fmd_file_name()
1157
-
1158
-
1159
- @pytest.mark.codegen_required
1160
- @pytest.mark.fluent_version(">=23.2")
1161
- def test_switch_between_workflows(new_meshing_session):
1162
- meshing = new_meshing_session
1163
-
1164
- # Initialize to watertight and store
1165
- watertight = meshing.watertight()
1166
-
1167
- assert watertight.import_geometry.arguments()
1168
-
1169
- # Wrong Attribute
1170
- with pytest.raises(AttributeError):
1171
- watertight.import_cad_and_part_management.arguments()
1172
-
1173
- # Initialize to fault-tolerant and store
1174
- fault_tolerant = meshing.fault_tolerant()
1175
-
1176
- assert fault_tolerant.import_cad_and_part_management.arguments()
1177
-
1178
- # 'import_geometry' is a watertight workflow command which is not available now
1179
- # since we have changed to fault-tolerant in the backend.
1180
- with pytest.raises(RuntimeError):
1181
- watertight.import_geometry.arguments()
1182
-
1183
- # Re-initialize watertight
1184
- watertight = meshing.watertight()
1185
-
1186
- # 'import_cad_and_part_management' is a fault-tolerant workflow command which is not
1187
- # available now since we have changed to watertight in the backend.
1188
- with pytest.raises(RuntimeError):
1189
- fault_tolerant.import_cad_and_part_management.arguments()
1190
-
1191
- assert watertight.import_geometry.arguments()
1192
-
1193
- meshing.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing")
1194
-
1195
- # 'import_geometry' is a watertight workflow command which is not available now
1196
- # since we have changed to fault-tolerant in the backend.
1197
- with pytest.raises(RuntimeError):
1198
- watertight.import_geometry.arguments()
1199
-
1200
- meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry")
1201
-
1202
- # 'import_cad_and_part_management' is a fault-tolerant workflow command which is not
1203
- # available now since we have changed to watertight in the backend.
1204
- with pytest.raises(RuntimeError):
1205
- fault_tolerant.import_cad_and_part_management.arguments()
1206
-
1207
- # Re-initialize fault-tolerant
1208
- fault_tolerant = meshing.fault_tolerant()
1209
- assert fault_tolerant.import_cad_and_part_management.arguments()
1210
-
1211
-
1212
- @pytest.mark.codegen_required
1213
- @pytest.mark.fluent_version(">=24.2")
1214
- def test_new_meshing_workflow_without_dm_caching(
1215
- disable_datamodel_cache, new_meshing_session
1216
- ):
1217
- import_file_name = examples.download_file(
1218
- "mixing_elbow.pmdb", "pyfluent/mixing_elbow"
1219
- )
1220
-
1221
- watertight = new_meshing_session.watertight()
1222
- watertight.import_geometry.file_name = import_file_name
1223
- watertight.import_geometry.length_unit.set_state("in")
1224
- watertight.import_geometry()
1225
-
1226
- watertight.add_local_sizing.add_child_to_task()
1227
- watertight.add_local_sizing()
1228
-
1229
- watertight.create_volume_mesh()
1230
-
1231
- watertight.import_geometry.rename(new_name="import_geom_wtm")
1232
- time.sleep(2)
1233
- assert "import_geometry" not in watertight.task_names()
1234
- assert "import_geom_wtm" in watertight.task_names()
1235
- assert watertight.import_geom_wtm.arguments()
1236
-
1237
- with pytest.raises(AttributeError):
1238
- watertight.import_geometry
1239
-
1240
- watertight.delete_tasks(list_of_tasks=["add_local_sizing"])
1241
- time.sleep(2)
1242
- assert "add_local_sizing" not in watertight.task_names()
1243
-
1244
- assert sorted(
1245
- [repr(x) for x in watertight.import_geom_wtm.insertable_tasks()]
1246
- ) == sorted(
1247
- [
1248
- "<Insertable 'add_local_sizing' task>",
1249
- "<Insertable 'import_boi_geometry' task>",
1250
- "<Insertable 'set_up_rotational_periodic_boundaries' task>",
1251
- "<Insertable 'create_local_refinement_regions' task>",
1252
- "<Insertable 'custom_journal_task' task>",
1253
- ]
1254
- )
1255
-
1256
- watertight.import_geom_wtm.insertable_tasks.add_local_sizing.insert()
1257
- assert "add_local_sizing" in watertight.task_names()
1258
-
1259
-
1260
- @pytest.mark.codegen_required
1261
- @pytest.mark.fluent_version(">=24.1")
1262
- def test_new_meshing_workflow_switching_without_dm_caching(
1263
- disable_datamodel_cache, new_meshing_session
1264
- ):
1265
- watertight = new_meshing_session.watertight()
1266
-
1267
- fault_tolerant = new_meshing_session.fault_tolerant()
1268
- with pytest.raises(RuntimeError):
1269
- watertight.import_geometry.arguments()
1270
- assert fault_tolerant.import_cad_and_part_management.arguments()
1271
-
1272
- watertight = new_meshing_session.watertight()
1273
- with pytest.raises(RuntimeError):
1274
- fault_tolerant.import_cad_and_part_management.arguments()
1275
- assert watertight.import_geometry.arguments()
1276
-
1277
-
1278
- @pytest.mark.codegen_required
1279
- @pytest.mark.fluent_version(">=24.2")
1280
- def test_new_meshing_workflow_validate_arguments(new_meshing_session):
1281
- watertight = new_meshing_session.watertight()
1282
- watertight.create_regions.number_of_flow_volumes = 1
1283
- with pytest.raises(ValueError):
1284
- watertight.create_regions.number_of_flow_volumes = 1.2
1285
- assert watertight.create_regions.arguments()["number_of_flow_volumes"] == 1
1286
- with pytest.raises(ValueError):
1287
- watertight.create_regions.arguments.update_dict(
1288
- dict(number_of_flow_volumes=1.2)
1289
- )
1290
- assert watertight.create_regions.arguments()["number_of_flow_volumes"] == 1
1291
-
1292
- watertight.create_regions.number_of_flow_volumes = 2
1293
- with pytest.raises(ValueError):
1294
- watertight.create_regions.number_of_flow_volumes = 1.2
1295
- assert watertight.create_regions.arguments()["number_of_flow_volumes"] == 2
1296
- with pytest.raises(ValueError):
1297
- watertight.create_regions.arguments.update_dict(
1298
- dict(number_of_flow_volumes=1.2)
1299
- )
1300
- assert watertight.create_regions.arguments()["number_of_flow_volumes"] == 2
1301
-
1302
- watertight.create_regions.number_of_flow_volumes = None
1303
- with pytest.raises(ValueError):
1304
- watertight.create_regions.number_of_flow_volumes = 1.2
1305
- assert watertight.create_regions.arguments()["number_of_flow_volumes"] == 1
1306
- with pytest.raises(ValueError):
1307
- watertight.create_regions.arguments.update_dict(
1308
- dict(number_of_flow_volumes=1.2)
1309
- )
1310
- assert watertight.create_regions.arguments()["number_of_flow_volumes"] == 1
1311
-
1312
-
1313
- def test_camel_to_snake_case_convertor():
1314
- assert camel_to_snake_case("ImportGeometry") == "import_geometry"
1315
- assert camel_to_snake_case("Prism2dPreferences") == "prism_2d_preferences"
1316
- assert camel_to_snake_case("Abc2DDef") == "abc_2d_def"
1317
- assert camel_to_snake_case("Abc2d") == "abc_2d"
1318
- assert camel_to_snake_case("abc2d") == "abc2d"
1319
- assert camel_to_snake_case("AbC2d5Cb") == "ab_c2d_5_cb"
1320
- assert camel_to_snake_case("abC2d5Cb") == "ab_c2d_5_cb"
1321
- assert camel_to_snake_case("abC2d5Cb555klOp") == "ab_c2d_5_cb_555kl_op"
1322
- assert camel_to_snake_case("a") == "a"
1323
- assert camel_to_snake_case("A") == "a"
1324
- assert camel_to_snake_case("a5$c") == "a5$c"
1325
- assert camel_to_snake_case("A5$C") == "a5$c"
1326
- assert camel_to_snake_case("A5Dc$") == "a5_dc$"
1327
- assert camel_to_snake_case("Abc2DDc$") == "abc_2d_dc$"
1328
- assert camel_to_snake_case("A2DDc$") == "a2d_dc$"
1329
- assert camel_to_snake_case("") == ""
1330
- assert camel_to_snake_case("BOIZoneorLabel") == "boi_zoneor_label"
1331
- assert camel_to_snake_case("BOIZoneOrLabel") == "boi_zone_or_label"
1332
- assert camel_to_snake_case("NumberofLayers") == "numberof_layers"
1333
- assert camel_to_snake_case("NumberOfLayers") == "number_of_layers"
1334
- assert (
1335
- camel_to_snake_case("Set_Up_Rotational_Periodic_Boundaries")
1336
- == "set_up_rotational_periodic_boundaries"
1337
- )
1338
-
1339
-
1340
- @pytest.mark.codegen_required
1341
- @pytest.mark.fluent_version(">=24.1")
1342
- def test_duplicate_tasks_in_workflow(new_meshing_session):
1343
- # Import geometry
1344
- meshing = new_meshing_session
1345
- watertight = meshing.watertight()
1346
-
1347
- assert sorted(
1348
- [repr(x) for x in watertight.import_geometry.insertable_tasks()]
1349
- ) == sorted(
1350
- [
1351
- "<Insertable 'import_boi_geometry' task>",
1352
- "<Insertable 'set_up_rotational_periodic_boundaries' task>",
1353
- "<Insertable 'create_local_refinement_regions' task>",
1354
- "<Insertable 'custom_journal_task' task>",
1355
- ]
1356
- )
1357
- assert "add_local_sizing" in watertight.task_names()
1358
- watertight.add_local_sizing.delete()
1359
- assert "add_local_sizing" not in watertight.task_names()
1360
- assert "<Insertable 'add_local_sizing' task>" in [
1361
- repr(x) for x in watertight.import_geometry.insertable_tasks()
1362
- ]
1363
- watertight.import_geometry.insertable_tasks.add_local_sizing.insert()
1364
- assert "<Insertable 'add_local_sizing' task>" not in [
1365
- repr(x) for x in watertight.import_geometry.insertable_tasks()
1366
- ]
1367
- watertight.import_geometry.insertable_tasks.import_boi_geometry.insert()
1368
- watertight.import_geometry.insertable_tasks.import_boi_geometry.insert()
1369
- watertight.import_geometry.insertable_tasks.import_boi_geometry.insert()
1370
- assert set(watertight.task_names()) == {
1371
- "import_geometry",
1372
- "create_surface_mesh",
1373
- "describe_geometry",
1374
- "apply_share_topology",
1375
- "enclose_fluid_regions",
1376
- "update_boundaries",
1377
- "create_regions",
1378
- "update_regions",
1379
- "add_boundary_layer",
1380
- "create_volume_mesh",
1381
- "add_local_sizing",
1382
- "import_boi_geometry",
1383
- "import_boi_geometry_1",
1384
- "import_boi_geometry_2",
1385
- }
1386
- assert watertight.import_boi_geometry_1.arguments()
1387
-
1388
-
1389
- @pytest.mark.codegen_required
1390
- @pytest.mark.fluent_version(">=24.1")
1391
- def test_object_oriented_task_inserting_in_workflows(new_meshing_session):
1392
- meshing = new_meshing_session
1393
- watertight = meshing.watertight()
1394
- assert sorted(
1395
- [repr(x) for x in watertight.import_geometry.insertable_tasks()]
1396
- ) == sorted(
1397
- [
1398
- "<Insertable 'import_boi_geometry' task>",
1399
- "<Insertable 'set_up_rotational_periodic_boundaries' task>",
1400
- "<Insertable 'create_local_refinement_regions' task>",
1401
- "<Insertable 'custom_journal_task' task>",
1402
- ]
1403
- )
1404
- assert "set_up_rotational_periodic_boundaries" not in watertight.task_names()
1405
- watertight.import_geometry.insertable_tasks.set_up_rotational_periodic_boundaries.insert()
1406
- assert "set_up_rotational_periodic_boundaries" in watertight.task_names()
1407
- assert sorted(
1408
- [repr(x) for x in watertight.import_geometry.insertable_tasks()]
1409
- ) == sorted(
1410
- [
1411
- "<Insertable 'import_boi_geometry' task>",
1412
- "<Insertable 'create_local_refinement_regions' task>",
1413
- "<Insertable 'custom_journal_task' task>",
1414
- ]
1415
- )
1416
- watertight.import_geometry.insertable_tasks.import_boi_geometry.insert()
1417
- watertight.import_geometry.insertable_tasks.import_boi_geometry.insert()
1418
- assert "import_boi_geometry" in watertight.task_names()
1419
- assert "import_boi_geometry_1" in watertight.task_names()
1420
- assert watertight.import_boi_geometry.arguments()
1421
- assert watertight.import_boi_geometry_1.arguments()
1422
-
1423
-
1424
- @pytest.mark.codegen_required
1425
- @pytest.mark.fluent_version(">=24.1")
1426
- def test_loaded_workflow(new_meshing_session):
1427
- meshing = new_meshing_session
1428
- saved_workflow_path = examples.download_file(
1429
- "sample_watertight_workflow.wft", "pyfluent/meshing_workflows"
1430
- )
1431
- loaded_workflow = meshing.load_workflow(file_path=saved_workflow_path)
1432
- assert "set_up_rotational_periodic_boundaries" in loaded_workflow.task_names()
1433
- assert "import_boi_geometry" in loaded_workflow.task_names()
1434
- # The below snippet is randomly failing in CI
1435
- # assert loaded_workflow.import_boi_geometry_1.arguments()
1436
-
1437
-
1438
- @pytest.mark.skip("https://github.com/ansys/pyfluent/issues/3065")
1439
- @pytest.mark.codegen_required
1440
- @pytest.mark.fluent_version(">=24.1")
1441
- def test_created_workflow(new_meshing_session):
1442
- meshing = new_meshing_session
1443
- created_workflow = meshing.create_workflow()
1444
-
1445
- assert sorted([repr(x) for x in created_workflow.insertable_tasks()]) == sorted(
1446
- [
1447
- "<Insertable 'import_geometry' task>",
1448
- "<Insertable 'load_cad_geometry' task>",
1449
- "<Insertable 'import_cad_and_part_management' task>",
1450
- "<Insertable 'custom_journal_task' task>",
1451
- ]
1452
- )
1453
-
1454
- created_workflow.insertable_tasks()[0].insert()
1455
-
1456
- assert created_workflow.insertable_tasks() == []
1457
-
1458
- assert "<Insertable 'add_local_sizing' task>" in [
1459
- repr(x) for x in created_workflow.import_geometry.insertable_tasks()
1460
- ]
1461
- created_workflow.import_geometry.insertable_tasks.add_local_sizing.insert()
1462
- assert "<Insertable 'add_local_sizing' task>" not in [
1463
- repr(x) for x in created_workflow.import_geometry.insertable_tasks()
1464
- ]
1465
- assert sorted(created_workflow.task_names()) == sorted(
1466
- ["import_geometry", "add_local_sizing"]
1467
- )
1468
-
1469
-
1470
- @pytest.fixture
1471
- def new_meshing_session2(new_meshing_session):
1472
- return new_meshing_session
1473
-
1474
-
1475
- @pytest.mark.codegen_required
1476
- @pytest.mark.fluent_version(">=24.1")
1477
- def test_independent_meshing_sessions(new_meshing_session, new_meshing_session2):
1478
- meshing_1 = new_meshing_session
1479
- meshing_2 = new_meshing_session2
1480
-
1481
- watertight = meshing_1.watertight()
1482
- assert watertight.import_geometry.arguments()
1483
-
1484
- ft = meshing_1.fault_tolerant()
1485
- assert ft.import_cad_and_part_management.arguments()
1486
-
1487
- watertight = meshing_1.watertight()
1488
- assert watertight.import_geometry.arguments()
1489
-
1490
- fault_tolerant = meshing_2.fault_tolerant()
1491
- assert fault_tolerant.import_cad_and_part_management.arguments()
1492
-
1493
-
1494
- @pytest.mark.codegen_required
1495
- @pytest.mark.fluent_version(">=24.1")
1496
- def test_independent_meshing_sessions_without_dm_caching(
1497
- disable_datamodel_cache, new_meshing_session, new_meshing_session2
1498
- ):
1499
- meshing_1 = new_meshing_session
1500
- meshing_2 = new_meshing_session2
1501
-
1502
- watertight = meshing_1.watertight()
1503
- assert watertight.import_geometry.arguments()
1504
-
1505
- fault_tolerant = meshing_2.fault_tolerant()
1506
- assert fault_tolerant.import_cad_and_part_management.arguments()
1507
-
1508
-
1509
- @pytest.mark.codegen_required
1510
- @pytest.mark.fluent_version(">=24.2")
1511
- def test_switching_workflow_interface(new_meshing_session):
1512
- wt1 = new_meshing_session.watertight()
1513
- ft = new_meshing_session.fault_tolerant()
1514
- tw = new_meshing_session.two_dimensional_meshing()
1515
- cw = new_meshing_session.create_workflow()
1516
- saved_workflow_path = examples.download_file(
1517
- "sample_watertight_workflow.wft", "pyfluent/meshing_workflows"
1518
- )
1519
- lw = new_meshing_session.load_workflow(file_path=saved_workflow_path)
1520
- wt2 = new_meshing_session.watertight()
1521
- del wt1, ft, tw, cw, lw, wt2
1522
-
1523
-
1524
- @pytest.mark.codegen_required
1525
- @pytest.mark.fluent_version(">=24.1")
1526
- def test_duplicate_children_of_compound_task(
1527
- new_meshing_session, mixing_elbow_geometry_filename
1528
- ):
1529
- watertight = new_meshing_session.watertight()
1530
- watertight.import_geometry.file_name = mixing_elbow_geometry_filename
1531
- watertight.import_geometry()
1532
- watertight.add_local_sizing.add_child_and_update(
1533
- state={
1534
- "boi_control_name": "wall",
1535
- "boi_face_label_list": ["wall-elbow", "wall-inlet"],
1536
- "boi_size": 10,
1537
- }
1538
- )
1539
- watertight.add_local_sizing.add_child_and_update(
1540
- state={
1541
- "boi_control_name": "inlet",
1542
- "boi_face_label_list": ["wall-inlet", "cold-inlet", "hot-inlet"],
1543
- "boi_size": 10,
1544
- }
1545
- )
1546
- watertight.add_local_sizing.add_child_and_update(
1547
- state={
1548
- "boi_control_name": "outlet",
1549
- "boi_face_label_list": ["outlet"],
1550
- "boi_size": 10,
1551
- }
1552
- )
1553
-
1554
- assert {
1555
- "add_local_sizing_child_1",
1556
- "add_local_sizing_child_2",
1557
- "add_local_sizing_child_3",
1558
- }.issubset(set(watertight.task_names()))
1559
-
1560
- assert watertight.add_local_sizing.task_names() == [
1561
- "add_local_sizing_child_1",
1562
- "add_local_sizing_child_2",
1563
- "add_local_sizing_child_3",
1564
- ]
1565
-
1566
- assert watertight.tasks()[-2].name() == "inlet"
1567
- assert watertight.tasks()[-2].python_name() == "add_local_sizing_child_2"
1568
-
1569
- assert watertight.add_local_sizing.tasks()[-1].name() == "outlet"
1570
- assert (
1571
- watertight.add_local_sizing.tasks()[-1].python_name()
1572
- == "add_local_sizing_child_3"
1573
- )
1574
-
1575
-
1576
- @pytest.mark.codegen_required
1577
- @pytest.mark.fluent_version(">=24.1")
1578
- def test_current_workflow(new_meshing_session):
1579
- meshing = new_meshing_session
1580
-
1581
- with pytest.raises(RuntimeError):
1582
- meshing.current_workflow
1583
-
1584
- meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry")
1585
-
1586
- assert meshing.current_workflow.import_geometry
1587
-
1588
- with pytest.raises(AttributeError):
1589
- meshing.current_workflow.import_cad_and_part_management
1590
-
1591
- meshing.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing")
1592
-
1593
- assert meshing.current_workflow.import_cad_and_part_management
1594
-
1595
- with pytest.raises(AttributeError):
1596
- meshing.current_workflow.import_geometry
1597
-
1598
-
1599
- @pytest.mark.codegen_required
1600
- @pytest.mark.fluent_version(">=24.1")
1601
- def test_mark_as_updated(new_meshing_session):
1602
- meshing = new_meshing_session
1603
-
1604
- watertight = meshing.watertight()
1605
-
1606
- assert meshing.workflow.TaskObject["Import Geometry"].State() == "Out-of-date"
1607
- assert meshing.workflow.TaskObject["Describe Geometry"].State() == "Out-of-date"
1608
- assert meshing.workflow.TaskObject["Add Local Sizing"].State() == "Out-of-date"
1609
-
1610
- watertight.import_geometry.mark_as_updated()
1611
- watertight.describe_geometry.mark_as_updated()
1612
- watertight.add_local_sizing.mark_as_updated()
1613
-
1614
- assert meshing.workflow.TaskObject["Import Geometry"].State() == "Forced-up-to-date"
1615
- assert (
1616
- meshing.workflow.TaskObject["Describe Geometry"].State() == "Forced-up-to-date"
1617
- )
1618
- assert (
1619
- meshing.workflow.TaskObject["Add Local Sizing"].State() == "Forced-up-to-date"
1620
- )
1621
-
1622
-
1623
- @pytest.mark.fluent_version(">=24.1")
1624
- @pytest.mark.codegen_required
1625
- def test_accessors_for_argument_sub_items(new_meshing_session):
1626
- meshing = new_meshing_session
1627
- watertight = meshing.watertight()
1628
-
1629
- import_geom = watertight.import_geometry
1630
- assert import_geom.length_unit.default_value() == "mm"
1631
- assert "allowed_values" in dir(import_geom.length_unit)
1632
- assert import_geom.arguments.length_unit.allowed_values() == [
1633
- "m",
1634
- "cm",
1635
- "mm",
1636
- "in",
1637
- "ft",
1638
- "um",
1639
- "nm",
1640
- ]
1641
- assert import_geom.arguments.length_unit() == "mm"
1642
- import_geom.length_unit.set_state("cm")
1643
- assert import_geom.arguments.length_unit.get_state() == "cm"
1644
- import_geom.arguments.length_unit = "in"
1645
- assert import_geom.arguments.length_unit() == "in"
1646
- import_geom.arguments["length_unit"] = "m"
1647
- assert import_geom.arguments["length_unit"] == "m"
1648
- meshing.workflow.TaskObject["Import Geometry"].Arguments = dict(LengthUnit="in")
1649
- assert import_geom.arguments.length_unit() == "in"
1650
-
1651
- assert not import_geom.arguments.mesh_unit.is_read_only()
1652
- assert import_geom.arguments.length_unit.is_active()
1653
- assert not import_geom.arguments.file_name.is_read_only()
1654
- assert not import_geom.arguments.file_name()
1655
- import_geom.arguments.file_name = "xyz.txt"
1656
- assert import_geom.arguments.file_name() == "xyz.txt"
1657
- with pytest.raises(AttributeError) as msg:
1658
- import_geom.arguments.file = "sample.txt"
1659
- assert msg.value.args[0] == "No attribute named 'file' in 'Import Geometry'."
1660
- with pytest.raises(AttributeError):
1661
- import_geom.arguments.CadImportOptions.OneZonePer = "face"
1662
-
1663
- assert import_geom.arguments.cad_import_options()
1664
- assert import_geom.arguments.cad_import_options.one_zone_per()
1665
-
1666
- assert import_geom.arguments.file_format.get_attrib_value("allowedValues") == [
1667
- "CAD",
1668
- "Mesh",
1669
- ]
1670
- assert import_geom.arguments.file_format.allowed_values() == ["CAD", "Mesh"]
1671
-
1672
- assert not import_geom.arguments.cad_import_options.one_zone_per.is_read_only()
1673
- assert import_geom.arguments.cad_import_options.one_zone_per() == "body"
1674
- import_geom.arguments.cad_import_options.one_zone_per.set_state("face")
1675
- assert import_geom.arguments.cad_import_options.one_zone_per() == "face"
1676
- import_geom.arguments.cad_import_options.one_zone_per = "object"
1677
- assert import_geom.arguments.cad_import_options.one_zone_per() == "object"
1678
-
1679
- volume_mesh_gen = watertight.create_volume_mesh
1680
- assert (
1681
- volume_mesh_gen.arguments.volume_fill_controls.type.default_value()
1682
- == "Cartesian"
1683
- )
1684
-
1685
- # Test particular to string type (allowed_values() only available in string types)
1686
- assert volume_mesh_gen.arguments.volume_fill_controls.type.allowed_values() == [
1687
- "Octree",
1688
- "Cartesian",
1689
- ]
1690
- feat_angle = import_geom.arguments.cad_import_options.feature_angle
1691
- assert feat_angle.default_value() == 40.0
1692
-
1693
- # Test particular to numerical type (min() only available in numerical types)
1694
- assert feat_angle.min() == 0.0
1695
-
1696
- # Test intended to fail in numerical type (allowed_values() only available in string types)
1697
- with pytest.raises(AttributeError) as msg:
1698
- assert feat_angle.allowed_values()
1699
- assert (
1700
- msg.value.args[0]
1701
- == "'PyNumericalCommandArgumentsSubItem' object has no attribute 'allowed_values'"
1702
- )
1703
-
1704
- # Test intended to fail in numerical type (allowed_values() only available in string types)
1705
- with pytest.raises(AttributeError) as msg:
1706
- assert import_geom.arguments.num_parts.allowed_values()
1707
- assert (
1708
- msg.value.args[0]
1709
- == "'PyNumericalCommandArgumentsSubItem' object has no attribute 'allowed_values'"
1710
- )
1711
-
1712
- # Test intended to fail in string type (min() only available in numerical types)
1713
- with pytest.raises(AttributeError) as msg:
1714
- assert import_geom.arguments.length_unit.min()
1715
- assert (
1716
- msg.value.args[0]
1717
- == "'PyTextualCommandArgumentsSubItem' object has no attribute 'min'"
1718
- )
1719
-
1720
-
1721
- @pytest.mark.codegen_required
1722
- @pytest.mark.fluent_version(">=25.1")
1723
- def test_scenario_with_common_python_names_from_fdl(new_meshing_session):
1724
- meshing = new_meshing_session
1725
-
1726
- fault_tolerant = meshing.fault_tolerant()
1727
-
1728
- # Check if all task names are unique.
1729
- assert len(fault_tolerant.task_names()) == len(set(fault_tolerant.task_names()))
1730
-
1731
- # APIName from fdl file
1732
- assert "create_volume_mesh" in fault_tolerant.task_names()
1733
- assert "generate_volume_mesh" in fault_tolerant.task_names()
1734
- assert "generate_surface_mesh" in fault_tolerant.task_names()
1735
-
1736
- watertight = meshing.watertight()
1737
- # Check if all task names are unique.
1738
- assert len(watertight.task_names()) == len(set(watertight.task_names()))
1739
-
1740
- two_dimensional = meshing.two_dimensional_meshing()
1741
- # Check if all task names are unique.
1742
- assert len(two_dimensional.task_names()) == len(set(two_dimensional.task_names()))
1743
-
1744
-
1745
- @pytest.mark.skip("Failing in GitHub")
1746
- @pytest.mark.codegen_required
1747
- @pytest.mark.fluent_version(">=25.1")
1748
- def test_return_state_changes(new_meshing_session):
1749
- meshing = new_meshing_session
1750
- wt = meshing.watertight()
1751
-
1752
- import_file_name = examples.download_file(
1753
- "mixing_elbow.pmdb", "pyfluent/mixing_elbow"
1754
- )
1755
-
1756
- wt.import_geometry.file_name.set_state(import_file_name)
1757
-
1758
- # trigger creation of downstream task when this task is updated:
1759
- wt.describe_geometry.multizone.set_state("Yes")
1760
- wt.describe_geometry()
1761
-
1762
- assert wt.add_multizone_controls
1763
-
1764
-
1765
- @pytest.mark.codegen_required
1766
- @pytest.mark.fluent_version(">=25.1")
1767
- def test_recursive_update_dict(new_meshing_session):
1768
- meshing = new_meshing_session
1769
- fault_tolerant = meshing.fault_tolerant()
1770
- import_file_name = examples.download_file(
1771
- "exhaust_system.fmd", "pyfluent/exhaust_system"
1772
- )
1773
-
1774
- import_cad = fault_tolerant.import_cad_and_part_management
1775
- import_cad.feature_angle = 35
1776
- import_cad.fmd_file_name = import_file_name
1777
- import_cad()
1778
-
1779
- descr_geom = fault_tolerant.describe_geometry_and_flow
1780
- descr_geom.arguments()
1781
- descr_geom.flow_type = "Internal flow through the object"
1782
- descr_geom.add_enclosure = "Yes"
1783
- descr_geom.close_caps = "Yes"
1784
- descr_geom.local_refinement_regions = "Yes"
1785
- descr_geom.describe_geometry_and_flow_options.moving_objects = "Yes"
1786
- descr_geom.describe_geometry_and_flow_options.advanced_options = True
1787
- descr_geom.describe_geometry_and_flow_options.porous_regions = "Yes"
1788
- descr_geom.describe_geometry_and_flow_options.enable_overset = "Yes"
1789
- descr_geom.describe_geometry_and_flow_options.extract_edge_features = "Yes"
1790
- descr_geom.describe_geometry_and_flow_options.zero_thickness = "Yes"
1791
- descr_geom.arguments()
1792
- assert meshing.workflow.TaskObject["Describe Geometry and Flow"].Arguments()[
1793
- "DescribeGeometryAndFlowOptions"
1794
- ] == {
1795
- "AdvancedOptions": True,
1796
- "EnableOverset": "Yes",
1797
- "ExtractEdgeFeatures": "Yes",
1798
- "MovingObjects": "Yes",
1799
- "PorousRegions": "Yes",
1800
- "ZeroThickness": "Yes",
1801
- }