ansys-fluent-core 0.28.1__py3-none-any.whl → 0.29.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansys-fluent-core might be problematic. Click here for more details.

Files changed (223) hide show
  1. ansys/fluent/core/__init__.py +26 -1
  2. ansys/fluent/core/_stand_alone_datamodel_client/_datamodel_client.py +22 -0
  3. ansys/fluent/core/_version.py +24 -2
  4. ansys/fluent/core/codegen/__init__.py +22 -0
  5. ansys/fluent/core/codegen/allapigen.py +38 -5
  6. ansys/fluent/core/codegen/builtin_settingsgen.py +22 -0
  7. ansys/fluent/core/codegen/data/__init__.py +21 -0
  8. ansys/fluent/core/codegen/data/fluent_gui_help_patch.py +22 -0
  9. ansys/fluent/core/codegen/data/meshing_utilities_examples.py +22 -0
  10. ansys/fluent/core/codegen/datamodelgen.py +40 -4
  11. ansys/fluent/core/codegen/print_fluent_version.py +22 -0
  12. ansys/fluent/core/codegen/settingsgen.py +67 -4
  13. ansys/fluent/core/codegen/tuigen.py +44 -6
  14. ansys/fluent/core/codegen/walk_api.py +67 -18
  15. ansys/fluent/core/codegen/write_settings_yaml.py +22 -0
  16. ansys/fluent/core/data_model_cache.py +22 -0
  17. ansys/fluent/core/examples/__init__.py +22 -0
  18. ansys/fluent/core/examples/downloads.py +22 -0
  19. ansys/fluent/core/exceptions.py +22 -0
  20. ansys/fluent/core/file_session.py +22 -0
  21. ansys/fluent/core/filereader/__init__.py +21 -0
  22. ansys/fluent/core/filereader/case_file.py +22 -0
  23. ansys/fluent/core/filereader/casereader.py +22 -0
  24. ansys/fluent/core/filereader/data_file.py +22 -0
  25. ansys/fluent/core/filereader/lispy.py +22 -0
  26. ansys/fluent/core/fluent_connection.py +23 -1
  27. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  28. ansys/fluent/core/generated/datamodel_252/meshing.py +32 -0
  29. ansys/fluent/core/generated/datamodel_252/preferences.py +7 -0
  30. ansys/fluent/core/generated/fluent_version_252.py +3 -3
  31. ansys/fluent/core/generated/meshing/tui_252.py +395 -390
  32. ansys/fluent/core/generated/solver/settings_222.py +0 -72
  33. ansys/fluent/core/generated/solver/settings_222.pyi +0 -307
  34. ansys/fluent/core/generated/solver/settings_231.py +0 -574
  35. ansys/fluent/core/generated/solver/settings_231.pyi +0 -561
  36. ansys/fluent/core/generated/solver/settings_232.py +0 -527
  37. ansys/fluent/core/generated/solver/settings_232.pyi +0 -2803
  38. ansys/fluent/core/generated/solver/settings_241.py +0 -478
  39. ansys/fluent/core/generated/solver/settings_241.pyi +0 -522
  40. ansys/fluent/core/generated/solver/settings_242.py +0 -361
  41. ansys/fluent/core/generated/solver/settings_242.pyi +0 -591
  42. ansys/fluent/core/generated/solver/settings_251.py +0 -399
  43. ansys/fluent/core/generated/solver/settings_251.pyi +0 -629
  44. ansys/fluent/core/generated/solver/settings_252.py +8118 -4206
  45. ansys/fluent/core/generated/solver/settings_252.pyi +7229 -3259
  46. ansys/fluent/core/generated/solver/tui_252.py +4508 -3877
  47. ansys/fluent/core/get_build_details.py +22 -0
  48. ansys/fluent/core/journaling.py +38 -0
  49. ansys/fluent/core/launcher/__init__.py +22 -0
  50. ansys/fluent/core/launcher/container_launcher.py +65 -56
  51. ansys/fluent/core/launcher/error_handler.py +30 -0
  52. ansys/fluent/core/launcher/fluent_container.py +45 -20
  53. ansys/fluent/core/launcher/launcher.py +53 -5
  54. ansys/fluent/core/launcher/launcher_utils.py +22 -0
  55. ansys/fluent/core/launcher/pim_launcher.py +120 -86
  56. ansys/fluent/core/launcher/process_launch_string.py +22 -0
  57. ansys/fluent/core/launcher/pyfluent_enums.py +22 -0
  58. ansys/fluent/core/launcher/server_info.py +45 -3
  59. ansys/fluent/core/launcher/slurm_launcher.py +25 -3
  60. ansys/fluent/core/launcher/standalone_launcher.py +68 -63
  61. ansys/fluent/core/launcher/watchdog.py +22 -0
  62. ansys/fluent/core/logging.py +24 -0
  63. ansys/fluent/core/logging_config.yaml +3 -0
  64. ansys/fluent/core/meshing/meshing_workflow.py +22 -0
  65. ansys/fluent/core/parametric.py +22 -0
  66. ansys/fluent/core/post_objects/__init__.py +21 -0
  67. ansys/fluent/core/post_objects/check_in_notebook.py +22 -0
  68. ansys/fluent/core/post_objects/meta.py +22 -0
  69. ansys/fluent/core/post_objects/post_helper.py +22 -0
  70. ansys/fluent/core/post_objects/post_object_definitions.py +22 -0
  71. ansys/fluent/core/post_objects/post_objects_container.py +22 -0
  72. ansys/fluent/core/post_objects/singleton_meta.py +22 -0
  73. ansys/fluent/core/post_objects/timing_decorator.py +22 -0
  74. ansys/fluent/core/report.py +77 -0
  75. ansys/fluent/core/rpvars.py +22 -0
  76. ansys/fluent/core/scheduler/__init__.py +22 -0
  77. ansys/fluent/core/scheduler/load_machines.py +22 -0
  78. ansys/fluent/core/scheduler/machine_list.py +22 -0
  79. ansys/fluent/core/search.py +22 -0
  80. ansys/fluent/core/services/__init__.py +22 -0
  81. ansys/fluent/core/services/api_upgrade.py +22 -0
  82. ansys/fluent/core/services/app_utilities.py +38 -0
  83. ansys/fluent/core/services/batch_ops.py +22 -0
  84. ansys/fluent/core/services/datamodel_se.py +163 -61
  85. ansys/fluent/core/services/datamodel_tui.py +22 -0
  86. ansys/fluent/core/services/deprecated_field_data.py +23 -1
  87. ansys/fluent/core/services/events.py +22 -0
  88. ansys/fluent/core/services/field_data.py +285 -2
  89. ansys/fluent/core/services/health_check.py +22 -0
  90. ansys/fluent/core/services/interceptors.py +50 -2
  91. ansys/fluent/core/services/monitor.py +22 -0
  92. ansys/fluent/core/services/reduction.py +22 -0
  93. ansys/fluent/core/services/scheme_eval.py +22 -0
  94. ansys/fluent/core/services/settings.py +22 -0
  95. ansys/fluent/core/services/solution_variables.py +22 -0
  96. ansys/fluent/core/services/streaming.py +22 -0
  97. ansys/fluent/core/services/transcript.py +22 -0
  98. ansys/fluent/core/session.py +39 -2
  99. ansys/fluent/core/session_base_meshing.py +22 -0
  100. ansys/fluent/core/session_meshing.py +22 -0
  101. ansys/fluent/core/session_meshing.pyi +22 -0
  102. ansys/fluent/core/session_pure_meshing.py +22 -0
  103. ansys/fluent/core/session_pure_meshing.pyi +22 -0
  104. ansys/fluent/core/session_shared.py +22 -0
  105. ansys/fluent/core/session_solver.py +43 -0
  106. ansys/fluent/core/session_solver.pyi +22 -0
  107. ansys/fluent/core/session_solver_aero.py +22 -0
  108. ansys/fluent/core/session_solver_icing.py +22 -0
  109. ansys/fluent/core/session_solver_lite.py +22 -0
  110. ansys/fluent/core/solver/__init__.py +22 -0
  111. ansys/fluent/core/solver/error_message.py +22 -0
  112. ansys/fluent/core/solver/flobject.py +22 -0
  113. ansys/fluent/core/solver/flunits.py +22 -0
  114. ansys/fluent/core/solver/function/__init__.py +22 -0
  115. ansys/fluent/core/solver/function/reduction.py +22 -0
  116. ansys/fluent/core/solver/settings_builtin_bases.py +22 -0
  117. ansys/fluent/core/solver/settings_builtin_data.py +22 -0
  118. ansys/fluent/core/solver/settings_external.py +22 -0
  119. ansys/fluent/core/streaming_services/__init__.py +21 -0
  120. ansys/fluent/core/streaming_services/datamodel_event_streaming.py +34 -12
  121. ansys/fluent/core/streaming_services/datamodel_streaming.py +22 -0
  122. ansys/fluent/core/streaming_services/events_streaming.py +22 -0
  123. ansys/fluent/core/streaming_services/field_data_streaming.py +22 -0
  124. ansys/fluent/core/streaming_services/monitor_streaming.py +23 -1
  125. ansys/fluent/core/streaming_services/streaming.py +22 -0
  126. ansys/fluent/core/streaming_services/transcript_streaming.py +22 -0
  127. ansys/fluent/core/systemcoupling.py +22 -0
  128. ansys/fluent/core/utils/__init__.py +22 -0
  129. ansys/fluent/core/utils/data_transfer.py +22 -0
  130. ansys/fluent/core/utils/deprecate.py +24 -1
  131. ansys/fluent/core/utils/dictionary_operations.py +22 -0
  132. ansys/fluent/core/utils/dump_session_data.py +22 -0
  133. ansys/fluent/core/utils/event_loop.py +22 -0
  134. ansys/fluent/core/utils/execution.py +22 -0
  135. ansys/fluent/core/utils/file_transfer_service.py +22 -0
  136. ansys/fluent/core/utils/fix_doc.py +22 -0
  137. ansys/fluent/core/utils/fldoc.py +22 -0
  138. ansys/fluent/core/utils/fluent_version.py +22 -0
  139. ansys/fluent/core/utils/networking.py +22 -0
  140. ansys/fluent/core/utils/setup_for_fluent.py +22 -0
  141. ansys/fluent/core/warnings.py +22 -0
  142. ansys/fluent/core/workflow.py +22 -0
  143. {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.29.0.dist-info}/LICENSE +8 -8
  144. {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.29.0.dist-info}/METADATA +56 -33
  145. ansys_fluent_core-0.29.0.dist-info/RECORD +219 -0
  146. {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.29.0.dist-info}/WHEEL +1 -1
  147. ansys/fluent/core/docs/README.rst +0 -155
  148. ansys/fluent/tests/conftest.py +0 -415
  149. ansys/fluent/tests/fluent_fixtures.py +0 -195
  150. ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
  151. ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
  152. ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
  153. ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
  154. ansys/fluent/tests/test_aero_session.py +0 -88
  155. ansys/fluent/tests/test_batch_ops.py +0 -39
  156. ansys/fluent/tests/test_builtin_settings.py +0 -761
  157. ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
  158. ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
  159. ansys/fluent/tests/test_casereader.py +0 -324
  160. ansys/fluent/tests/test_codegen.py +0 -783
  161. ansys/fluent/tests/test_creatable.py +0 -31
  162. ansys/fluent/tests/test_data_model_cache.py +0 -434
  163. ansys/fluent/tests/test_datamodel_api.py +0 -449
  164. ansys/fluent/tests/test_datamodel_service.py +0 -814
  165. ansys/fluent/tests/test_datareader.py +0 -103
  166. ansys/fluent/tests/test_error_handling.py +0 -24
  167. ansys/fluent/tests/test_events_manager.py +0 -214
  168. ansys/fluent/tests/test_field_data.py +0 -466
  169. ansys/fluent/tests/test_file_session.py +0 -355
  170. ansys/fluent/tests/test_file_transfer_service.py +0 -165
  171. ansys/fluent/tests/test_fix_doc.py +0 -29
  172. ansys/fluent/tests/test_flobject.py +0 -1235
  173. ansys/fluent/tests/test_fluent_fixes.py +0 -106
  174. ansys/fluent/tests/test_fluent_session.py +0 -270
  175. ansys/fluent/tests/test_fluent_version.py +0 -66
  176. ansys/fluent/tests/test_fluent_version_marker.py +0 -65
  177. ansys/fluent/tests/test_icing_session.py +0 -9
  178. ansys/fluent/tests/test_launcher.py +0 -529
  179. ansys/fluent/tests/test_launcher_remote.py +0 -272
  180. ansys/fluent/tests/test_lispy.py +0 -40
  181. ansys/fluent/tests/test_logging.py +0 -16
  182. ansys/fluent/tests/test_mapped_api.py +0 -774
  183. ansys/fluent/tests/test_meshing_utilities.py +0 -2436
  184. ansys/fluent/tests/test_meshing_workflow.py +0 -421
  185. ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
  186. ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
  187. ansys/fluent/tests/test_preferences.py +0 -89
  188. ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
  189. ansys/fluent/tests/test_reduction.py +0 -484
  190. ansys/fluent/tests/test_rp_vars.py +0 -77
  191. ansys/fluent/tests/test_scheduler.py +0 -471
  192. ansys/fluent/tests/test_scheme_eval_222.py +0 -338
  193. ansys/fluent/tests/test_scheme_eval_231.py +0 -243
  194. ansys/fluent/tests/test_search.py +0 -344
  195. ansys/fluent/tests/test_session.py +0 -594
  196. ansys/fluent/tests/test_settings_api.py +0 -606
  197. ansys/fluent/tests/test_settings_reader.py +0 -85
  198. ansys/fluent/tests/test_slurm_future.py +0 -67
  199. ansys/fluent/tests/test_solution_variables.py +0 -241
  200. ansys/fluent/tests/test_solver_monitors.py +0 -83
  201. ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
  202. ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
  203. ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
  204. ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
  205. ansys/fluent/tests/test_solvermode/test_general.py +0 -109
  206. ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
  207. ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
  208. ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
  209. ansys/fluent/tests/test_solvermode/test_models.py +0 -99
  210. ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
  211. ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
  212. ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
  213. ansys/fluent/tests/test_streaming_services.py +0 -52
  214. ansys/fluent/tests/test_systemcoupling.py +0 -44
  215. ansys/fluent/tests/test_topy.py +0 -179
  216. ansys/fluent/tests/test_tui_api.py +0 -70
  217. ansys/fluent/tests/test_type_stub.py +0 -37
  218. ansys/fluent/tests/test_utils.py +0 -82
  219. ansys/fluent/tests/util/__init__.py +0 -36
  220. ansys/fluent/tests/util/meshing_workflow.py +0 -33
  221. ansys/fluent/tests/util/solver.py +0 -72
  222. ansys_fluent_core-0.28.1.dist-info/AUTHORS +0 -12
  223. ansys_fluent_core-0.28.1.dist-info/RECORD +0 -294
@@ -1,466 +0,0 @@
1
- import numpy as np
2
- import pytest
3
-
4
- from ansys.fluent.core import examples
5
- from ansys.fluent.core.examples.downloads import download_file
6
- from ansys.fluent.core.exceptions import DisallowedValuesError
7
- from ansys.fluent.core.services.field_data import FieldUnavailable, SurfaceDataType
8
-
9
- HOT_INLET_TEMPERATURE = 313.15
10
-
11
-
12
- @pytest.mark.fluent_version(">=24.1")
13
- def test_field_data(new_solver_session) -> None:
14
- solver = new_solver_session
15
- import_file_name = examples.download_file(
16
- "mixing_elbow.msh.h5", "pyfluent/mixing_elbow"
17
- )
18
- solver.file.read(file_type="case", file_name=import_file_name)
19
- solver.tui.mesh.check()
20
-
21
- solver.setup.models.energy.enabled = True
22
- solver.setup.materials.database.copy_by_name(type="fluid", name="water-liquid")
23
- solver.setup.cell_zone_conditions.fluid["elbow-fluid"].material = "water-liquid"
24
-
25
- # Set up boundary conditions for CFD analysis
26
- cold_inlet = solver.setup.boundary_conditions.velocity_inlet["cold-inlet"]
27
- cold_inlet.momentum.velocity = 0.4
28
- cold_inlet.turbulence.turbulent_specification = "Intensity and Hydraulic Diameter"
29
- cold_inlet.turbulence.turbulent_intensity = 0.05
30
- cold_inlet.turbulence.hydraulic_diameter = "4 [in]"
31
- cold_inlet.thermal.t = 293.15
32
-
33
- hot_inlet = solver.setup.boundary_conditions.velocity_inlet["hot-inlet"]
34
- hot_inlet.momentum.velocity = 1.2
35
- hot_inlet.turbulence.turbulent_specification = "Intensity and Hydraulic Diameter"
36
- hot_inlet.turbulence.hydraulic_diameter = "1 [in]"
37
- hot_inlet.thermal.t = HOT_INLET_TEMPERATURE
38
-
39
- solver.tui.solve.monitors.residual.plot("no")
40
-
41
- # Initialize flow field
42
- solver.solution.initialization.hybrid_initialize()
43
-
44
- iterate = solver.solution.run_calculation.iterate
45
- iterate.get_attr("arguments")
46
- iterate(iter_count=10)
47
-
48
- # Get field data object
49
- field_data = solver.fields.field_data
50
-
51
- transaction = field_data.new_transaction()
52
-
53
- hot_inlet_surf_id = solver.fields.field_info.get_surfaces_info()["hot-inlet"][
54
- "surface_id"
55
- ][0]
56
- transaction.add_surfaces_request(
57
- surfaces=[1, hot_inlet_surf_id],
58
- data_types=[SurfaceDataType.Vertices, SurfaceDataType.FacesCentroid],
59
- )
60
- transaction.add_scalar_fields_request(
61
- surfaces=[1, hot_inlet_surf_id],
62
- field_name="temperature",
63
- node_value=True,
64
- boundary_value=True,
65
- )
66
- transaction.add_pathlines_fields_request(
67
- surfaces=[1, hot_inlet_surf_id],
68
- field_name="temperature",
69
- provide_particle_time_field=True,
70
- )
71
-
72
- data = transaction.get_fields()
73
-
74
- surface_data_tag = (("type", "surface-data"),) # tuple containing surface data info
75
- scalar_field_tag = (
76
- ("type", "scalar-field"),
77
- ("dataLocation", 0),
78
- ("boundaryValues", True),
79
- ) # tuple containing scalar field info
80
- pathline_tag = (("type", "pathlines-field"), ("field", "temperature"))
81
- assert len(data) == 3
82
- assert list(data[surface_data_tag][hot_inlet_surf_id].keys()) == [
83
- "vertices",
84
- "centroid",
85
- ]
86
- assert list(data[scalar_field_tag][hot_inlet_surf_id].keys()) == ["temperature"]
87
- temp_inlet_data = data[scalar_field_tag][hot_inlet_surf_id]["temperature"]
88
- assert (
89
- len(temp_inlet_data)
90
- == len(data[surface_data_tag][hot_inlet_surf_id]["vertices"]) / 3
91
- )
92
- assert round(float(np.average(temp_inlet_data)), 2) == HOT_INLET_TEMPERATURE
93
- assert sorted(list(data[pathline_tag][hot_inlet_surf_id].keys())) == sorted(
94
- [
95
- "vertices",
96
- "lines",
97
- "temperature",
98
- "pathlines-count",
99
- "particle-time",
100
- ]
101
- )
102
-
103
- # multiple surface *names* transaction
104
- transaction2 = field_data.new_transaction()
105
- fields_request = transaction2.add_scalar_fields_request
106
- surface_names = fields_request.surface_names.allowed_values()
107
- fields_request(surfaces=surface_names, field_name="temperature")
108
- data2 = transaction2.get_fields()
109
- assert data2
110
-
111
-
112
- def test_field_data_allowed_values(new_solver_session) -> None:
113
- solver = new_solver_session
114
- import_file_name = examples.download_file(
115
- "mixing_elbow.msh.h5", "pyfluent/mixing_elbow"
116
- )
117
-
118
- field_data = solver.fields.field_data
119
- field_info = solver.fields.field_info
120
- transaction = field_data.new_transaction()
121
- fields_request = transaction.add_scalar_fields_request
122
-
123
- assert [] == field_data.get_scalar_field_data.field_name.allowed_values()
124
-
125
- solver.file.read(file_type="case", file_name=import_file_name)
126
-
127
- allowed_args_no_init = field_data.get_scalar_field_data.field_name.allowed_values()
128
- assert len(allowed_args_no_init) != 0
129
-
130
- assert not field_data.is_data_valid()
131
-
132
- solver.solution.initialization.hybrid_initialize()
133
-
134
- assert field_data.is_data_valid()
135
-
136
- expected_allowed_args = sorted(field_info.get_scalar_fields_info())
137
- allowed_args = field_data.get_scalar_field_data.field_name.allowed_values()
138
- assert expected_allowed_args and (expected_allowed_args == allowed_args)
139
- assert len(allowed_args) > len(allowed_args_no_init)
140
- allowed_args = fields_request.field_name.allowed_values()
141
- assert expected_allowed_args == allowed_args
142
-
143
- expected_allowed_args = sorted(field_info.get_surfaces_info())
144
- allowed_args = field_data.get_scalar_field_data.surface_name.allowed_values()
145
- assert expected_allowed_args and (expected_allowed_args == allowed_args)
146
- allowed_args = fields_request.surface_names.allowed_values()
147
- assert expected_allowed_args == allowed_args
148
-
149
- expected_allowed_args = sorted(field_info.get_surfaces_info())
150
- allowed_args = field_data.get_surface_data.surface_name.allowed_values()
151
- assert expected_allowed_args and (expected_allowed_args == allowed_args)
152
- allowed_args = fields_request.surface_names.allowed_values()
153
- assert expected_allowed_args == allowed_args
154
-
155
- allowed_args = field_data.get_surface_data.surface_ids.allowed_values()
156
- assert len(expected_allowed_args) == len(allowed_args)
157
- allowed_args = fields_request.surface_ids.allowed_values()
158
- assert len(expected_allowed_args) == len(allowed_args)
159
-
160
- expected_allowed_args = sorted(field_info.get_vector_fields_info())
161
- allowed_args = field_data.get_vector_field_data.field_name.allowed_values()
162
- assert expected_allowed_args and (expected_allowed_args == allowed_args)
163
- allowed_args = transaction.add_vector_fields_request.field_name.allowed_values()
164
- assert expected_allowed_args == allowed_args
165
-
166
-
167
- @pytest.mark.fluent_version(">=23.2")
168
- def test_field_data_objects_3d(new_solver_session) -> None:
169
- solver = new_solver_session
170
- import_file_name = examples.download_file(
171
- "mixing_elbow.msh.h5", "pyfluent/mixing_elbow"
172
- )
173
-
174
- field_data = solver.fields.field_data
175
-
176
- assert [] == field_data.get_scalar_field_data.field_name.allowed_values()
177
-
178
- solver.file.read(file_type="case", file_name=import_file_name)
179
-
180
- allowed_args_no_init = field_data.get_scalar_field_data.field_name.allowed_values()
181
- assert len(allowed_args_no_init) != 0
182
-
183
- assert not field_data.is_data_valid()
184
-
185
- solver.solution.initialization.hybrid_initialize()
186
-
187
- assert field_data.is_data_valid()
188
-
189
- # Absolute Pressure data over the cold-inlet (surface_id=3)
190
- abs_press_data = field_data.get_scalar_field_data(
191
- field_name="absolute-pressure", surfaces=["cold-inlet"]
192
- )
193
-
194
- assert abs_press_data["cold-inlet"].shape == (241,)
195
- assert abs_press_data["cold-inlet"][120] == 101325.0
196
-
197
- vertices_data = field_data.get_surface_data(
198
- data_types=[SurfaceDataType.Vertices], surfaces=["cold-inlet"]
199
- )
200
- assert vertices_data["cold-inlet"][SurfaceDataType.Vertices].shape == (241, 3)
201
- assert (
202
- round(float(vertices_data["cold-inlet"][SurfaceDataType.Vertices][5][0]), 2)
203
- == -0.2
204
- )
205
-
206
- vertices_and_faces_centroid_data = field_data.get_surface_data(
207
- data_types=[SurfaceDataType.Vertices, SurfaceDataType.FacesCentroid],
208
- surfaces=["hot-inlet", "cold-inlet"],
209
- )
210
- assert list(vertices_and_faces_centroid_data["cold-inlet"].keys()) == [
211
- SurfaceDataType.Vertices,
212
- SurfaceDataType.FacesCentroid,
213
- ]
214
- assert vertices_and_faces_centroid_data["hot-inlet"][
215
- SurfaceDataType.Vertices
216
- ].shape == (79, 3)
217
- assert list(vertices_and_faces_centroid_data.keys()) == [
218
- "hot-inlet",
219
- "cold-inlet",
220
- ]
221
- assert (
222
- round(
223
- float(
224
- vertices_and_faces_centroid_data["cold-inlet"][
225
- SurfaceDataType.FacesCentroid
226
- ][5][1]
227
- ),
228
- 2,
229
- )
230
- == -0.18
231
- )
232
- assert (
233
- round(
234
- float(
235
- vertices_and_faces_centroid_data["hot-inlet"][
236
- SurfaceDataType.FacesCentroid
237
- ][5][1]
238
- ),
239
- 2,
240
- )
241
- == -0.23
242
- )
243
-
244
- faces_normal_data = field_data.get_surface_data(
245
- data_types=[SurfaceDataType.FacesNormal], surfaces=[3, 5]
246
- )
247
- assert faces_normal_data[3][SurfaceDataType.FacesNormal].shape == (152, 3)
248
- assert faces_normal_data[5][SurfaceDataType.FacesNormal].shape == (2001, 3)
249
-
250
- faces_connectivity_data = field_data.get_surface_data(
251
- data_types=[SurfaceDataType.FacesConnectivity], surfaces=["cold-inlet"]
252
- )
253
- assert (
254
- faces_connectivity_data["cold-inlet"][SurfaceDataType.FacesConnectivity][5]
255
- == [12, 13, 17, 16]
256
- ).all()
257
-
258
- velocity_vector_data = field_data.get_vector_field_data(
259
- field_name="velocity", surfaces=["cold-inlet"]
260
- )
261
-
262
- assert velocity_vector_data["cold-inlet"].shape == (152, 3)
263
-
264
- path_lines_data = field_data.get_pathlines_field_data(
265
- field_name="velocity", surfaces=["cold-inlet", "hot-inlet"]
266
- )
267
-
268
- assert path_lines_data["cold-inlet"]["vertices"].shape == (76152, 3)
269
- assert len(path_lines_data["cold-inlet"]["lines"]) == 76000
270
- assert path_lines_data["cold-inlet"]["velocity"].shape == (76152,)
271
-
272
- assert path_lines_data["hot-inlet"]["vertices"].shape == (27555, 3)
273
- assert len(path_lines_data["hot-inlet"]["lines"]) == 27500
274
- assert path_lines_data["hot-inlet"]["velocity"].shape == (27555,)
275
-
276
- assert all(path_lines_data["cold-inlet"]["lines"][100] == [100, 101])
277
-
278
-
279
- @pytest.mark.fluent_version(">=23.2")
280
- def test_field_data_objects_2d(disk_case_session) -> None:
281
- solver = disk_case_session
282
-
283
- field_data = solver.fields.field_data
284
-
285
- allowed_args_no_init = field_data.get_scalar_field_data.field_name.allowed_values()
286
- assert len(allowed_args_no_init) != 0
287
-
288
- assert not field_data.is_data_valid()
289
-
290
- solver.solution.initialization.hybrid_initialize()
291
-
292
- assert field_data.is_data_valid()
293
-
294
- # Absolute Pressure data over the cold-inlet (surface_id=3)
295
- abs_press_data = field_data.get_scalar_field_data(
296
- field_name="absolute-pressure", surfaces=["velocity-inlet-2"]
297
- )
298
-
299
- assert abs_press_data["velocity-inlet-2"].shape == (11,)
300
- assert abs_press_data["velocity-inlet-2"][5] == 101325.0
301
-
302
- vertices_data = field_data.get_surface_data(
303
- data_types=[SurfaceDataType.Vertices], surfaces=["interior-4"]
304
- )
305
- assert round(vertices_data["interior-4"][SurfaceDataType.Vertices][5][0], 2) == 0.0
306
-
307
- faces_centroid_data = field_data.get_surface_data(
308
- data_types=[SurfaceDataType.FacesCentroid], surfaces=["velocity-inlet-2"]
309
- )
310
- assert (
311
- round(
312
- float(
313
- faces_centroid_data["velocity-inlet-2"][SurfaceDataType.FacesCentroid][
314
- 5
315
- ][1]
316
- ),
317
- 2,
318
- )
319
- == 0.02
320
- )
321
-
322
- faces_connectivity_data = field_data.get_surface_data(
323
- data_types=[SurfaceDataType.FacesConnectivity], surfaces=["velocity-inlet-2"]
324
- )["velocity-inlet-2"][SurfaceDataType.FacesConnectivity][5]
325
- assert (faces_connectivity_data == [5, 6]).all()
326
-
327
- velocity_vector_data = field_data.get_vector_field_data(
328
- field_name="velocity", surfaces=["velocity-inlet-2"]
329
- )
330
-
331
- assert velocity_vector_data["velocity-inlet-2"].shape == (10, 3)
332
-
333
- path_lines_data = field_data.get_pathlines_field_data(
334
- field_name="velocity", surfaces=["velocity-inlet-2"]
335
- )
336
-
337
- assert path_lines_data["velocity-inlet-2"]["vertices"].shape == (5010, 3)
338
- assert len(path_lines_data["velocity-inlet-2"]["lines"]) == 5000
339
- assert path_lines_data["velocity-inlet-2"]["velocity"].shape == (5010,)
340
-
341
- assert all(path_lines_data["velocity-inlet-2"]["lines"][100] == [100, 101])
342
-
343
-
344
- def test_field_data_errors(new_solver_session) -> None:
345
- solver = new_solver_session
346
- import_file_name = examples.download_file(
347
- "mixing_elbow.msh.h5", "pyfluent/mixing_elbow"
348
- )
349
-
350
- with pytest.raises(DisallowedValuesError):
351
- solver.fields.field_data.get_scalar_field_data(
352
- field_name="y-face-area", surfaces=[0]
353
- )
354
-
355
- with pytest.raises(DisallowedValuesError):
356
- solver.fields.field_data.get_scalar_field_data(
357
- field_name="partition-neighbors", surfaces=[0]
358
- )
359
-
360
- solver.file.read(file_type="case", file_name=import_file_name)
361
-
362
- with pytest.raises(FieldUnavailable):
363
- solver.fields.field_data.get_scalar_field_data(
364
- field_name="density", surfaces=[0]
365
- )
366
-
367
- y_face_area = solver.fields.field_data.get_scalar_field_data(
368
- field_name="y-face-area", surfaces=[0]
369
- )
370
- assert y_face_area and isinstance(y_face_area, dict)
371
-
372
- partition_neighbors = solver.fields.field_data.get_scalar_field_data(
373
- field_name="partition-neighbors", surfaces=[0]
374
- )
375
- assert partition_neighbors and isinstance(partition_neighbors, dict)
376
-
377
- # Initialize flow field
378
- solver.solution.initialization.hybrid_initialize()
379
-
380
- # Get field data object
381
- assert solver.fields.field_data
382
-
383
- with pytest.raises(DisallowedValuesError):
384
- solver.fields.field_data.get_scalar_field_data(
385
- field_name="density", surfaces=["bob"]
386
- )
387
-
388
- with pytest.raises(DisallowedValuesError):
389
- solver.fields.field_data.get_scalar_field_data(
390
- field_name="xdensity", surfaces=[0]
391
- )
392
-
393
-
394
- @pytest.mark.fluent_version(">=23.2")
395
- def test_field_info_validators(new_solver_session) -> None:
396
- solver = new_solver_session
397
- import_file_name = examples.download_file(
398
- "mixing_elbow.msh.h5", "pyfluent/mixing_elbow"
399
- )
400
- solver.file.read(file_type="case", file_name=import_file_name)
401
- solver.solution.initialization.hybrid_initialize()
402
-
403
- vector_field_1 = solver.fields.field_info.validate_vector_fields("velocity")
404
- assert vector_field_1 is None
405
-
406
- with pytest.raises(DisallowedValuesError):
407
- solver.fields.field_info.validate_vector_fields("relative-vel")
408
-
409
- scalar_field_1 = solver.fields.field_info.validate_scalar_fields("z-velocity")
410
- assert scalar_field_1 is None
411
-
412
- with pytest.raises(DisallowedValuesError):
413
- solver.fields.field_info.validate_scalar_fields("z-vel")
414
-
415
- surface = solver.fields.field_info.validate_surfaces(["cold-inlet"])
416
- assert surface is None
417
-
418
- with pytest.raises(DisallowedValuesError):
419
- solver.fields.field_info.validate_surfaces(["out"])
420
-
421
-
422
- @pytest.mark.skip("https://github.com/ansys/pyfluent/issues/2404")
423
- @pytest.mark.fluent_version(">=24.2")
424
- def test_field_data_does_not_modify_case(new_solver_session):
425
- solver = new_solver_session
426
- case_path = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
427
- download_file("mixing_elbow.dat.h5", "pyfluent/mixing_elbow")
428
- solver.file.read_case_data(file_name=case_path)
429
- solver.scheme_eval.scheme_eval("(%save-case-id)")
430
- assert not solver.scheme_eval.scheme_eval("(case-modified?)")
431
- solver.fields.field_data.get_scalar_field_data(
432
- field_name="absolute-pressure", surfaces=["cold-inlet"]
433
- )
434
- assert not solver.scheme_eval.scheme_eval("(case-modified?)")
435
-
436
-
437
- @pytest.mark.fluent_version(">=24.1")
438
- def test_field_data_streaming_in_meshing_mode(new_meshing_session):
439
- meshing = new_meshing_session
440
- import_file_name = examples.download_file(
441
- "mixing_elbow.pmdb", "pyfluent/mixing_elbow"
442
- )
443
-
444
- mesh_data = {}
445
-
446
- def plot_mesh(index, field_name, data):
447
- if data is not None:
448
- if index in mesh_data:
449
- mesh_data[index].update({field_name: data})
450
- else:
451
- mesh_data[index] = {field_name: data}
452
-
453
- meshing.fields.field_data_streaming.register_callback(plot_mesh)
454
- meshing.fields.field_data_streaming.start(provideBytesStream=True, chunkSize=1024)
455
-
456
- meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry")
457
- meshing.workflow.TaskObject["Import Geometry"].Arguments = {
458
- "FileName": import_file_name,
459
- "LengthUnit": "in",
460
- }
461
- meshing.workflow.TaskObject["Import Geometry"].Execute()
462
-
463
- assert len(mesh_data[5]["vertices"]) == 66
464
- assert len(mesh_data[5]["faces"]) == 80
465
-
466
- assert list(mesh_data[12].keys()) == ["vertices", "faces"]