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,89 +0,0 @@
1
- import pytest
2
-
3
- from ansys.fluent.core.services.datamodel_se import ReadOnlyObjectError
4
-
5
-
6
- @pytest.mark.codegen_required
7
- def test_solver_preferences(new_solver_session):
8
- solver = new_solver_session
9
- preferred_meshing = solver.preferences.MeshingWorkflow
10
- preferred_meshing.Verbosity = "off"
11
- assert preferred_meshing.Verbosity() == "off"
12
-
13
- with pytest.raises(ReadOnlyObjectError):
14
- preferred_meshing.CheckpointingOption = "Write into memory"
15
- assert preferred_meshing.CheckpointingOption() == "Write mesh files"
16
-
17
- preferred_drawing = preferred_meshing.DrawSettings
18
- preferred_drawing.FacetLimit = 6000000
19
- assert preferred_drawing.FacetLimit() == 6000000
20
- preferred_drawing.FaceZoneLimit = 15000
21
- assert preferred_drawing.FaceZoneLimit() == 15000
22
-
23
- ansys_logo = solver.preferences.Appearance.AnsysLogo
24
- ansys_logo.Color = "white"
25
- assert ansys_logo.Color() == "white"
26
-
27
- ansys_logo.Color = "black"
28
- assert ansys_logo.Color() == "black"
29
-
30
- ansys_logo.Visible = True
31
- assert ansys_logo.Visible() is True
32
-
33
- perfered_graphics = solver.preferences.Graphics
34
- perfered_graphics.AnimationOption = "wireframe"
35
- assert perfered_graphics.AnimationOption() == "wireframe"
36
-
37
- solver.exit()
38
-
39
-
40
- @pytest.mark.codegen_required
41
- def test_meshing_preferences(new_meshing_session):
42
- meshing = new_meshing_session
43
- preferred_meshing = meshing.preferences.MeshingWorkflow
44
- preferred_meshing.Verbosity = "off"
45
- assert preferred_meshing.Verbosity() == "off"
46
-
47
- with pytest.raises(ReadOnlyObjectError):
48
- preferred_meshing.CheckpointingOption = "Write into memory"
49
- assert preferred_meshing.CheckpointingOption() == "Write mesh files"
50
-
51
- preferred_drawing = preferred_meshing.DrawSettings
52
- preferred_drawing.FacetLimit = 6000000
53
- assert preferred_drawing.FacetLimit() == 6000000
54
-
55
- preferred_drawing.FaceZoneLimit = 15000
56
- assert preferred_drawing.FaceZoneLimit() == 15000
57
-
58
- ansys_logo = meshing.preferences.Appearance.AnsysLogo
59
- ansys_logo.Color = "white"
60
- assert ansys_logo.Color() == "white"
61
-
62
- ansys_logo.Color = "black"
63
- assert ansys_logo.Color() == "black"
64
-
65
- ansys_logo.Visible = True
66
- assert ansys_logo.Visible() is True
67
-
68
- preferred_graphics = meshing.preferences.Graphics
69
- preferred_graphics.AnimationOption = "wireframe"
70
- assert preferred_graphics.AnimationOption() == "wireframe"
71
-
72
- meshing.exit()
73
-
74
-
75
- @pytest.mark.codegen_required
76
- def test_read_only_preferences(new_solver_session):
77
- solver = new_solver_session
78
- m = solver.preferences.MeshingWorkflow
79
- m.SaveCheckpointFiles = True
80
- assert m.SaveCheckpointFiles() is True
81
- assert m.CheckpointingOption() == "Write mesh files"
82
- assert m.CheckpointingOption.is_read_only() is True
83
- with pytest.raises(RuntimeError):
84
- m.CheckpointingOption = "Write into memory"
85
- m.SaveCheckpointFiles = False
86
- assert m.SaveCheckpointFiles() is False
87
- assert m.CheckpointingOption.is_read_only() is False
88
- m.CheckpointingOption = "Write into memory"
89
- assert m.CheckpointingOption() == "Write into memory"
@@ -1,101 +0,0 @@
1
- import pytest
2
-
3
- from ansys.fluent.core.examples import download_file
4
-
5
-
6
- @pytest.mark.codegen_required
7
- @pytest.mark.fluent_version(">=23.1")
8
- def test_pure_meshing_mode(mixing_elbow_watertight_pure_meshing_session):
9
- pure_meshing_session = mixing_elbow_watertight_pure_meshing_session
10
- # check a few dir elements
11
- # n.b. 'field_data', 'field_info' need to
12
- # be eliminated from meshing sessions
13
- session_dir = dir(pure_meshing_session)
14
- for attr in ("fields", "meshing", "workflow"):
15
- assert attr in session_dir
16
- workflow = pure_meshing_session.workflow
17
- workflow_dir = dir(workflow)
18
- for attr in ("TaskObject", "InsertNewTask", "Workflow", "setState"):
19
- assert attr in workflow_dir
20
- import_geometry = workflow.TaskObject["Import Geometry"]
21
- import_geometry_dir = dir(import_geometry)
22
- for attr in ("AddChildToTask", "Arguments", "Execute", "setState"):
23
- assert attr in import_geometry_dir
24
- with pytest.raises(AttributeError):
25
- pure_meshing_session.switch_to_solver()
26
-
27
-
28
- @pytest.mark.codegen_required
29
- @pytest.mark.fluent_version(">=23.1")
30
- def test_meshing_mode(new_meshing_session):
31
- meshing_session = new_meshing_session
32
- # check a few dir elements
33
- # n.b. 'field_data', 'field_info' need to
34
- # be eliminated from meshing sessions
35
- session_dir = dir(meshing_session)
36
- for attr in ("fields", "meshing", "workflow"):
37
- assert attr in session_dir
38
- assert meshing_session.workflow.InitializeWorkflow(
39
- WorkflowType="Watertight Geometry"
40
- )
41
- assert meshing_session.switch_to_solver()
42
-
43
-
44
- @pytest.mark.codegen_required
45
- @pytest.mark.fluent_version(">=23.1")
46
- def test_meshing_and_solver_mode_exit(new_meshing_session):
47
- meshing_session = new_meshing_session
48
- solver_session = meshing_session.switch_to_solver()
49
- # Even if exit statement is invoked twice, only one is executed as the channel instance is shared
50
- meshing_session.exit()
51
- solver_session.exit()
52
-
53
-
54
- @pytest.mark.codegen_required
55
- @pytest.mark.fluent_version(">=23.1")
56
- def test_meshing_mode_post_switching_to_solver(new_meshing_session):
57
- meshing_session = new_meshing_session
58
- meshing_session.switch_to_solver()
59
- # Post switching to solver session, meshing session specific attributes are unavailable
60
- with pytest.raises(AttributeError):
61
- meshing_session.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry")
62
-
63
-
64
- # def test_transfer_mesh_to_solvers(
65
- # new_pure_meshing_session, new_solver_session
66
- # ):
67
- # mesh_file_name = download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
68
- # pure_meshing_session = new_pure_meshing_session
69
- # pure_meshing_session.tui.file.read_mesh(mesh_file_name)
70
- # pure_meshing_session.tui.mesh.check_mesh()
71
- # mesh_info = pure_meshing_session.scheme_eval.string_eval(
72
- # "(%tg-length-of-entity-list)"
73
- # )
74
- # pure_meshing_session_cell_count = mesh_info.strip("( )").split()[3]
75
- #
76
- # solver_session = new_solver_session
77
- # pure_meshing_session.transfer_mesh_to_solvers([solver_session], file_type="mesh")
78
- # solver_session.tui.mesh.check()
79
- # mesh_info = solver_session.scheme_eval.string_eval("(inquire-grids)")
80
- # solver_session_cell_count = mesh_info.strip("( )").split()[1]
81
- #
82
- # assert pure_meshing_session_cell_count == solver_session_cell_count
83
-
84
-
85
- def test_transfer_case_to_solvers(new_pure_meshing_session, new_solver_session):
86
- case_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
87
- pure_meshing_session = new_pure_meshing_session
88
- pure_meshing_session.tui.file.read_case(case_file_name)
89
- pure_meshing_session.tui.mesh.check_mesh()
90
- mesh_info = pure_meshing_session.scheme_eval.string_eval(
91
- "(%tg-length-of-entity-list)"
92
- )
93
- pure_meshing_session_cell_count = mesh_info.strip("( )").split()[3]
94
-
95
- solver_session = new_solver_session
96
- pure_meshing_session.transfer_mesh_to_solvers([solver_session], file_type="case")
97
- solver_session.tui.mesh.check()
98
- mesh_info = solver_session.scheme_eval.string_eval("(inquire-grids)")
99
- solver_session_cell_count = mesh_info.strip("( )").split()[1]
100
-
101
- assert pure_meshing_session_cell_count == solver_session_cell_count
@@ -1,484 +0,0 @@
1
- from typing import Any
2
-
3
- import pytest
4
-
5
- from ansys.fluent.core.examples import download_file
6
- from ansys.fluent.core.services.reduction import _locn_names_and_objs
7
- from ansys.fluent.core.solver.function import reduction
8
-
9
-
10
- def _test_locn_extraction(solver1, solver2):
11
- solver1_boundary_conditions = solver1.setup.boundary_conditions
12
- solver2_boundary_conditions = solver2.setup.boundary_conditions
13
- locns = _locn_names_and_objs(["inlet1"])
14
- assert locns == [["inlet1", ["inlet1"]]]
15
-
16
- all_bcs = solver1_boundary_conditions
17
- locns = _locn_names_and_objs(all_bcs)
18
- assert locns == [
19
- ["interior--fluid", all_bcs],
20
- ["outlet", all_bcs],
21
- ["inlet1", all_bcs],
22
- ["inlet2", all_bcs],
23
- ["wall", all_bcs],
24
- ]
25
-
26
- locns = _locn_names_and_objs([all_bcs["inlet1"]])
27
- assert locns == [["inlet1", all_bcs["inlet1"]]]
28
-
29
- all_bcs = solver1_boundary_conditions
30
- all_bcs2 = solver2_boundary_conditions
31
- locns = _locn_names_and_objs([all_bcs, all_bcs2])
32
- assert locns == [
33
- ["interior--fluid", all_bcs],
34
- ["outlet", all_bcs],
35
- ["inlet1", all_bcs],
36
- ["inlet2", all_bcs],
37
- ["wall", all_bcs],
38
- ["interior--fluid", all_bcs2],
39
- ["outlet", all_bcs2],
40
- ["inlet1", all_bcs2],
41
- ["inlet2", all_bcs2],
42
- ["wall", all_bcs2],
43
- ]
44
-
45
-
46
- def _test_context(solver):
47
- solver.solution.initialization.hybrid_initialize()
48
-
49
- assert solver.fields.reduction.area(
50
- locations=[solver.setup.boundary_conditions.velocity_inlet["inlet1"]],
51
- ctxt=solver,
52
- )
53
-
54
- assert solver.fields.reduction.area(locations=["inlet1"], ctxt=solver)
55
-
56
-
57
- def _test_area_average(solver):
58
- solver.solution.initialization.hybrid_initialize()
59
- solver_named_expressions = solver.setup.named_expressions
60
- solver_named_expressions["test_expr_1"] = {}
61
- solver_named_expressions["test_expr_1"].definition = (
62
- "AreaAve(AbsolutePressure, ['inlet1'])"
63
- )
64
- expr_val = solver_named_expressions["test_expr_1"].get_value()
65
- assert isinstance(expr_val, float) and expr_val != 0.0
66
- val = solver.fields.reduction.area_average(
67
- expression="AbsolutePressure",
68
- locations=solver.setup.boundary_conditions.velocity_inlet,
69
- )
70
- assert val == expr_val
71
- solver_named_expressions.pop(key="test_expr_1")
72
-
73
-
74
- def _test_min(solver1, solver2):
75
- s1_min = solver1.fields.reduction.minimum(
76
- expression="AbsolutePressure",
77
- locations=[solver1.setup.boundary_conditions.velocity_inlet],
78
- )
79
- s2_min = solver2.fields.reduction.minimum(
80
- expression="AbsolutePressure",
81
- locations=[solver2.setup.boundary_conditions.velocity_inlet],
82
- )
83
- result = reduction.minimum(
84
- expression="AbsolutePressure",
85
- locations=[
86
- solver1.setup.boundary_conditions.velocity_inlet,
87
- solver2.setup.boundary_conditions.velocity_inlet,
88
- ],
89
- )
90
- assert result == min(s1_min, s2_min)
91
-
92
-
93
- def _test_count(solver):
94
- solver.solution.initialization.hybrid_initialize()
95
- solver_named_expressions = solver.setup.named_expressions
96
- s_velocity_inlet = solver.setup.boundary_conditions.velocity_inlet
97
- solver_named_expressions["test_expr_1"] = {}
98
- solver_named_expressions["test_expr_1"].definition = "Count(['inlet1'])"
99
- expr_val_1 = solver_named_expressions["test_expr_1"].get_value()
100
- solver_named_expressions["test_expr_1"].definition = "Count(['inlet2'])"
101
- expr_val_2 = solver_named_expressions["test_expr_1"].get_value()
102
- solver_named_expressions["test_expr_1"].definition = "Count(['inlet1', 'inlet2'])"
103
- expr_val_3 = solver_named_expressions["test_expr_1"].get_value()
104
- assert expr_val_3 == expr_val_1 + expr_val_2
105
- red_val_1 = solver.fields.reduction.count(locations=[s_velocity_inlet["inlet1"]])
106
- red_val_2 = solver.fields.reduction.count(locations=[s_velocity_inlet["inlet2"]])
107
- red_val_3 = solver.fields.reduction.count(locations=[s_velocity_inlet])
108
- assert red_val_1 == expr_val_1
109
- assert red_val_2 == expr_val_2
110
- assert red_val_3 == expr_val_3
111
- solver_named_expressions.pop(key="test_expr_1")
112
-
113
-
114
- def _test_count_if(solver):
115
- solver.solution.initialization.hybrid_initialize()
116
- solver_named_expressions = solver.setup.named_expressions
117
- s_velocity_inlet = solver.setup.boundary_conditions.velocity_inlet
118
- solver_named_expressions["test_expr_1"] = {}
119
- solver_named_expressions["test_expr_1"].definition = (
120
- "CountIf(AbsolutePressure > 0[Pa], ['inlet1'])"
121
- )
122
- expr_val_1 = solver_named_expressions["test_expr_1"].get_value()
123
- solver_named_expressions["test_expr_1"].definition = (
124
- "CountIf(AbsolutePressure > 0[Pa], ['inlet2'])"
125
- )
126
- expr_val_2 = solver_named_expressions["test_expr_1"].get_value()
127
- solver_named_expressions["test_expr_1"].definition = (
128
- "CountIf(AbsolutePressure > 0[Pa], ['inlet1', 'inlet2'])"
129
- )
130
- expr_val_3 = solver_named_expressions["test_expr_1"].get_value()
131
- assert expr_val_3 == expr_val_1 + expr_val_2
132
- red_val_1 = solver.fields.reduction.count_if(
133
- condition="AbsolutePressure > 0[Pa]", locations=["inlet1"]
134
- )
135
- red_val_2 = solver.fields.reduction.count_if(
136
- condition="AbsolutePressure > 0[Pa]", locations=[s_velocity_inlet["inlet2"]]
137
- )
138
- red_val_3 = solver.fields.reduction.count_if(
139
- condition="AbsolutePressure > 0[Pa]", locations=[s_velocity_inlet]
140
- )
141
- assert red_val_1 == expr_val_1
142
- assert red_val_2 == expr_val_2
143
- assert red_val_3 == expr_val_3
144
- solver_named_expressions.pop(key="test_expr_1")
145
-
146
-
147
- def _test_centroid(solver):
148
- solver.solution.initialization.hybrid_initialize()
149
- solver_named_expressions = solver.setup.named_expressions
150
- velocity_inlet = solver.setup.boundary_conditions.velocity_inlet
151
- solver_named_expressions["test_expr_1"] = {}
152
- solver_named_expressions["test_expr_1"].definition = "Centroid(['inlet1'])"
153
- expr_val_1 = solver_named_expressions["test_expr_1"].get_value()
154
- solver_named_expressions["test_expr_1"].definition = "Centroid(['inlet2'])"
155
- expr_val_2 = solver_named_expressions["test_expr_1"].get_value()
156
- solver_named_expressions["test_expr_1"].definition = (
157
- "Centroid(['inlet1', 'inlet2'])"
158
- )
159
- expr_val_3 = solver_named_expressions["test_expr_1"].get_value()
160
- red_val_1 = solver.fields.reduction.centroid(locations=[velocity_inlet["inlet1"]])
161
- red_val_2 = solver.fields.reduction.centroid(locations=[velocity_inlet["inlet2"]])
162
- red_val_3 = solver.fields.reduction.centroid(locations=[velocity_inlet])
163
- assert [red_val_1[0], red_val_1[1], red_val_1[2]] == expr_val_1
164
- assert [red_val_2[0], red_val_2[1], red_val_2[2]] == expr_val_2
165
- assert [red_val_3[0], red_val_3[1], red_val_3[2]] == expr_val_3
166
- solver_named_expressions.pop(key="test_expr_1")
167
-
168
-
169
- def _test_area_integrated_average(solver1, solver2):
170
- solver1.solution.initialization.hybrid_initialize()
171
- solver2.solution.initialization.hybrid_initialize()
172
- solver1_boundary_conditions = solver1.setup.boundary_conditions
173
- solver2_boundary_conditions = solver2.setup.boundary_conditions
174
- solver1_named_expr = solver1.setup.named_expressions
175
- solver2_named_expr = solver2.setup.named_expressions
176
-
177
- solver1_named_expr["test_expr_1"] = {}
178
- solver1_named_expr["test_expr_1"].definition = (
179
- "AreaInt(AbsolutePressure, ['inlet1'])"
180
- )
181
- expr_val_1 = solver1_named_expr["test_expr_1"].get_value()
182
-
183
- solver1_named_expr["test_expr_1"].definition = (
184
- "AreaInt(AbsolutePressure, ['inlet2'])"
185
- )
186
- expr_val_2 = solver1_named_expr["test_expr_1"].get_value()
187
- solver1_named_expr["test_expr_1"].definition = (
188
- "AreaInt(AbsolutePressure, ['inlet1', 'inlet2'])"
189
- )
190
- expr_val_3 = solver1_named_expr["test_expr_1"].get_value()
191
-
192
- assert expr_val_3 - (expr_val_1 + expr_val_2) <= 0.000000001
193
-
194
- red_val_1 = solver1.fields.reduction.area_integral(
195
- expression="AbsolutePressure",
196
- locations=[solver1_boundary_conditions.velocity_inlet["inlet1"]],
197
- )
198
- red_val_2 = solver1.fields.reduction.area_integral(
199
- expression="AbsolutePressure",
200
- locations=[solver1_boundary_conditions.velocity_inlet["inlet2"]],
201
- )
202
- red_val_3 = solver1.fields.reduction.area_integral(
203
- expression="AbsolutePressure",
204
- locations=[solver1_boundary_conditions.velocity_inlet],
205
- )
206
-
207
- assert red_val_1 == expr_val_1
208
- assert red_val_2 == expr_val_2
209
- assert red_val_3 == expr_val_3
210
-
211
- solver2_named_expr["test_expr_1"] = {}
212
- solver2_named_expr["test_expr_1"].definition = (
213
- "AreaInt(AbsolutePressure, ['inlet1'])"
214
- )
215
- expr_val_4 = solver2_named_expr["test_expr_1"].get_value()
216
-
217
- solver2_named_expr["test_expr_1"].definition = (
218
- "AreaInt(AbsolutePressure, ['inlet2'])"
219
- )
220
- expr_val_5 = solver2_named_expr["test_expr_1"].get_value()
221
- solver2_named_expr["test_expr_1"].definition = (
222
- "AreaInt(AbsolutePressure, ['inlet1', 'inlet2'])"
223
- )
224
- expr_val_6 = solver2_named_expr["test_expr_1"].get_value()
225
-
226
- assert expr_val_6 - (expr_val_4 + expr_val_5) <= 0.000000001
227
-
228
- red_val_4 = solver2.fields.reduction.area_integral(
229
- expression="AbsolutePressure",
230
- locations=[solver2_boundary_conditions.velocity_inlet["inlet1"]],
231
- )
232
- red_val_5 = solver2.fields.reduction.area_integral(
233
- expression="AbsolutePressure",
234
- locations=[solver2_boundary_conditions.velocity_inlet["inlet2"]],
235
- )
236
- red_val_6 = solver2.fields.reduction.area_integral(
237
- expression="AbsolutePressure",
238
- locations=[solver2_boundary_conditions.velocity_inlet],
239
- )
240
-
241
- assert red_val_4 == expr_val_4
242
- assert red_val_5 == expr_val_5
243
- assert red_val_6 == expr_val_6
244
-
245
- red_val_7 = solver2.fields.reduction.area_integral(
246
- expression="AbsolutePressure",
247
- locations=[
248
- solver1_boundary_conditions.velocity_inlet,
249
- solver2_boundary_conditions.velocity_inlet,
250
- ],
251
- )
252
-
253
- assert red_val_7 - (expr_val_3 + expr_val_6) <= 0.000000001
254
-
255
- solver1_named_expr.pop(key="test_expr_1")
256
-
257
-
258
- def _test_error_handling(solver):
259
- if int(solver._version) < 241:
260
- with pytest.raises(RuntimeError):
261
- solver.fields.reduction.area_average(
262
- expression="AbsoluteVelocity", # This is a wrong expression intentionally passed
263
- locations=solver.setup.boundary_conditions.velocity_inlet,
264
- )
265
-
266
-
267
- def _test_force(solver):
268
- solver.solution.initialization.hybrid_initialize()
269
- solver_named_expressions = solver.setup.named_expressions
270
- solver_named_expressions["test_expr_1"] = {}
271
- solver_named_expressions["test_expr_1"].definition = "Force(['wall'])"
272
- expr_val_1 = solver_named_expressions["test_expr_1"].get_value()
273
-
274
- red_total_force = solver.fields.reduction.force(
275
- locations=[solver.setup.boundary_conditions.wall]
276
- )
277
- red_pressure_force = solver.fields.reduction.pressure_force(
278
- locations=[solver.setup.boundary_conditions.wall]
279
- )
280
- red_viscous_force = solver.fields.reduction.viscous_force(
281
- locations=[solver.setup.boundary_conditions.wall]
282
- )
283
-
284
- assert [red_total_force[0], red_total_force[1], red_total_force[2]] == expr_val_1
285
-
286
- assert red_pressure_force[0] + red_viscous_force[0] == red_total_force[0]
287
-
288
- assert red_pressure_force[1] + red_viscous_force[1] == red_total_force[1]
289
-
290
- assert red_pressure_force[2] + red_viscous_force[2] == red_total_force[2]
291
-
292
- solver_named_expressions.pop(key="test_expr_1")
293
-
294
-
295
- def _test_moment(solver):
296
- solver.solution.initialization.hybrid_initialize()
297
- solver_named_expressions = solver.setup.named_expressions
298
- location = solver.setup.boundary_conditions.wall
299
- solver_named_expressions["test_expr_1"] = {}
300
- solver_named_expressions["test_expr_1"].definition = (
301
- "Moment(Force(['wall']),['wall'])"
302
- )
303
- expr_val_1 = solver_named_expressions["test_expr_1"].get_value()
304
-
305
- solver_named_expressions["test_expr_1"].definition = "Moment(['inlet1'],['wall'])"
306
- expr_val_2 = solver_named_expressions["test_expr_1"].get_value()
307
-
308
- red_moment_force = solver.fields.reduction.moment(
309
- expression="Force(['wall'])", locations=[location]
310
- )
311
-
312
- red_moment_location = solver.fields.reduction.moment(
313
- expression="['inlet1']", locations=[location]
314
- )
315
-
316
- assert [red_moment_force[0], red_moment_force[1], red_moment_force[2]] == expr_val_1
317
- assert [
318
- red_moment_location[0],
319
- red_moment_location[1],
320
- red_moment_location[2],
321
- ] == expr_val_2
322
-
323
- solver_named_expressions.pop(key="test_expr_1")
324
-
325
-
326
- def _test_sum(solver):
327
- solver.solution.initialization.hybrid_initialize()
328
- solver.setup.named_expressions["test_expr_1"] = {}
329
- solver.setup.named_expressions["test_expr_1"].definition = (
330
- "Sum(AbsolutePressure, ['inlet1'], Weight=Area)"
331
- )
332
- expr_val = solver.setup.named_expressions["test_expr_1"].get_value()
333
- assert isinstance(expr_val, float) and expr_val != 0.0
334
-
335
- val = solver.fields.reduction.sum(
336
- expression="AbsolutePressure",
337
- locations=[solver.setup.boundary_conditions.velocity_inlet["inlet1"]],
338
- weight="Area",
339
- )
340
-
341
- assert val == expr_val
342
- solver.setup.named_expressions.pop(key="test_expr_1")
343
-
344
-
345
- def _test_sum_if(solver):
346
- solver.solution.initialization.hybrid_initialize()
347
- solver.setup.named_expressions["test_expr_1"] = {}
348
- solver.setup.named_expressions["test_expr_1"].definition = (
349
- "SumIf(AbsolutePressure, AbsolutePressure > 0[Pa], ['inlet1'], Weight=Area)"
350
- )
351
- expr_val = solver.setup.named_expressions["test_expr_1"].get_value()
352
- assert isinstance(expr_val, float) and expr_val != 0.0
353
-
354
- val = solver.fields.reduction.sum_if(
355
- expression="AbsolutePressure",
356
- condition="AbsolutePressure > 0[Pa]",
357
- locations=[solver.setup.boundary_conditions.velocity_inlet["inlet1"]],
358
- weight="Area",
359
- )
360
-
361
- assert val == expr_val
362
- solver.setup.named_expressions.pop(key="test_expr_1")
363
-
364
-
365
- def _test_centroid_2_sources(solver1, solver2):
366
- s1_cent = solver1.fields.reduction.centroid(
367
- locations=[solver1.setup.boundary_conditions.velocity_inlet]
368
- )
369
- s2_cent = solver2.fields.reduction.centroid(
370
- locations=[solver2.setup.boundary_conditions.velocity_inlet]
371
- )
372
-
373
- result = reduction.centroid(
374
- locations=[
375
- solver1.setup.boundary_conditions.velocity_inlet,
376
- solver2.setup.boundary_conditions.velocity_inlet,
377
- ]
378
- )
379
- assert [round(x, 5) for x in result] == [
380
- (round(x, 5) + round(y, 5)) / 2 for x, y in zip(*[s1_cent, s2_cent])
381
- ]
382
-
383
-
384
- @pytest.fixture
385
- def static_mixer_case_session2(static_mixer_case_session: Any):
386
- return static_mixer_case_session
387
-
388
-
389
- @pytest.mark.nightly
390
- @pytest.mark.fluent_version(">=23.1")
391
- def test_reductions(
392
- static_mixer_case_session: Any, static_mixer_case_session2: Any
393
- ) -> None:
394
- solver1 = static_mixer_case_session
395
- solver2 = static_mixer_case_session2
396
- _test_context(solver1)
397
- _test_locn_extraction(solver1, solver2)
398
- _test_area_average(solver1)
399
- _test_count(solver1)
400
- _test_count_if(solver1)
401
- _test_centroid(solver1)
402
- _test_area_integrated_average(solver1, solver2)
403
- _test_error_handling(solver1)
404
- _test_force(solver1)
405
- _test_moment(solver1)
406
- _test_sum(solver1)
407
- _test_sum_if(solver1)
408
- # The case and data are changed after this point to check the functional reduction with multiple solvers
409
- case_path = download_file(
410
- file_name="exhaust_system.cas.h5", directory="pyfluent/exhaust_system"
411
- )
412
- download_file(
413
- file_name="exhaust_system.dat.h5", directory="pyfluent/exhaust_system"
414
- )
415
- solver1.file.read_case_data(file_name=case_path)
416
- case_path1 = download_file("elbow1.cas.h5", "pyfluent/file_session")
417
- download_file("elbow1.dat.h5", "pyfluent/file_session")
418
- solver2.file.read_case_data(file_name=case_path1)
419
- _test_min(solver1, solver2)
420
- _test_centroid_2_sources(solver1, solver2)
421
-
422
-
423
- @pytest.mark.fluent_version(">=24.2")
424
- def test_reduction_does_not_modify_case(static_mixer_case_session: Any):
425
- solver = static_mixer_case_session
426
- # After reading the static-mixer case in Fluent, case-modifed? flag is somehow True
427
- solver.scheme_eval.scheme_eval("(%save-case-id)")
428
- assert not solver.scheme_eval.scheme_eval("(case-modified?)")
429
- solver.reduction.area_average(
430
- expression="AbsolutePressure",
431
- locations=solver.setup.boundary_conditions.velocity_inlet,
432
- )
433
- assert not solver.scheme_eval.scheme_eval("(case-modified?)")
434
-
435
-
436
- @pytest.mark.fluent_version(">=24.2")
437
- def test_fix_for_invalid_location_inputs(static_mixer_case_session: Any):
438
- solver = static_mixer_case_session
439
- solver.solution.initialization.hybrid_initialize()
440
-
441
- assert solver.fields.reduction.area(locations=["inlet1"], ctxt=solver)
442
-
443
- with pytest.raises(ValueError):
444
- assert solver.fields.reduction.area(locations=["inlet-1"], ctxt=solver)
445
-
446
- with pytest.raises(KeyError):
447
- assert solver.fields.reduction.area(
448
- locations=[solver.setup.boundary_conditions.velocity_inlet["inlet-1"]]
449
- )
450
-
451
- assert solver.fields.reduction.area(locations=["inlet1"])
452
-
453
- with pytest.raises(ValueError):
454
- assert solver.fields.reduction.area(locations=["inlet-1"])
455
-
456
-
457
- @pytest.mark.fluent_version(">=25.2")
458
- def test_fix_for_empty_location_inputs(static_mixer_case_session: Any):
459
- solver = static_mixer_case_session
460
- solver.solution.initialization.hybrid_initialize()
461
-
462
- assert solver.fields.reduction.area(locations=["inlet1"])
463
-
464
- with pytest.raises(RuntimeError):
465
- assert reduction.area(locations=[], ctxt=solver)
466
-
467
- with pytest.raises(RuntimeError):
468
- assert reduction.area_average(
469
- expression="AbsolutePressure", locations=[], ctxt=solver
470
- )
471
-
472
- with pytest.raises(RuntimeError):
473
- assert reduction.centroid(locations=[], ctxt=solver)
474
-
475
- with pytest.raises(RuntimeError):
476
- assert solver.fields.reduction.area(locations=[])
477
-
478
- with pytest.raises(RuntimeError):
479
- assert solver.fields.reduction.area_average(
480
- expression="AbsolutePressure", locations=[]
481
- )
482
-
483
- with pytest.raises(RuntimeError):
484
- assert solver.fields.reduction.centroid(locations=[])