ansys-fluent-core 0.28.2__py3-none-any.whl → 0.29.dev1__py3-none-any.whl

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

Potentially problematic release.


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

Files changed (103) hide show
  1. ansys/fluent/core/__init__.py +1 -1
  2. ansys/fluent/core/_version.py +2 -2
  3. ansys/fluent/core/codegen/tuigen.py +1 -1
  4. ansys/fluent/core/codegen/walk_api.py +45 -18
  5. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  6. ansys/fluent/core/generated/datamodel_252/meshing.py +1 -0
  7. ansys/fluent/core/generated/fluent_version_252.py +3 -3
  8. ansys/fluent/core/generated/solver/settings_252.py +251 -160
  9. ansys/fluent/core/generated/solver/settings_252.pyi +146 -54
  10. ansys/fluent/core/generated/solver/tui_252.py +48 -24
  11. ansys/fluent/core/launcher/container_launcher.py +4 -3
  12. ansys/fluent/core/launcher/fluent_container.py +22 -19
  13. ansys/fluent/core/launcher/launcher.py +2 -2
  14. ansys/fluent/core/launcher/pim_launcher.py +2 -2
  15. ansys/fluent/core/launcher/slurm_launcher.py +2 -2
  16. ansys/fluent/core/launcher/standalone_launcher.py +2 -2
  17. ansys/fluent/core/logging.py +2 -0
  18. ansys/fluent/core/logging_config.yaml +3 -0
  19. ansys/fluent/core/services/datamodel_se.py +4 -1
  20. ansys/fluent/core/services/field_data.py +252 -0
  21. ansys/fluent/core/services/interceptors.py +28 -2
  22. ansys/fluent/core/session.py +7 -2
  23. ansys/fluent/core/session_solver.py +21 -0
  24. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.dev1.dist-info}/LICENSE +1 -1
  25. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.dev1.dist-info}/METADATA +53 -32
  26. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.dev1.dist-info}/RECORD +61 -137
  27. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.dev1.dist-info}/WHEEL +1 -1
  28. ansys/fluent/core/docs/README.rst +0 -155
  29. ansys/fluent/tests/conftest.py +0 -415
  30. ansys/fluent/tests/fluent_fixtures.py +0 -195
  31. ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
  32. ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
  33. ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
  34. ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
  35. ansys/fluent/tests/test_aero_session.py +0 -88
  36. ansys/fluent/tests/test_batch_ops.py +0 -39
  37. ansys/fluent/tests/test_builtin_settings.py +0 -761
  38. ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
  39. ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
  40. ansys/fluent/tests/test_casereader.py +0 -324
  41. ansys/fluent/tests/test_codegen.py +0 -783
  42. ansys/fluent/tests/test_creatable.py +0 -31
  43. ansys/fluent/tests/test_data_model_cache.py +0 -434
  44. ansys/fluent/tests/test_datamodel_api.py +0 -429
  45. ansys/fluent/tests/test_datamodel_service.py +0 -814
  46. ansys/fluent/tests/test_datareader.py +0 -103
  47. ansys/fluent/tests/test_error_handling.py +0 -24
  48. ansys/fluent/tests/test_events_manager.py +0 -214
  49. ansys/fluent/tests/test_field_data.py +0 -466
  50. ansys/fluent/tests/test_file_session.py +0 -355
  51. ansys/fluent/tests/test_file_transfer_service.py +0 -165
  52. ansys/fluent/tests/test_fix_doc.py +0 -29
  53. ansys/fluent/tests/test_flobject.py +0 -1235
  54. ansys/fluent/tests/test_fluent_fixes.py +0 -106
  55. ansys/fluent/tests/test_fluent_session.py +0 -270
  56. ansys/fluent/tests/test_fluent_version.py +0 -66
  57. ansys/fluent/tests/test_fluent_version_marker.py +0 -65
  58. ansys/fluent/tests/test_icing_session.py +0 -9
  59. ansys/fluent/tests/test_launcher.py +0 -529
  60. ansys/fluent/tests/test_launcher_remote.py +0 -272
  61. ansys/fluent/tests/test_lispy.py +0 -40
  62. ansys/fluent/tests/test_logging.py +0 -16
  63. ansys/fluent/tests/test_mapped_api.py +0 -766
  64. ansys/fluent/tests/test_meshing_utilities.py +0 -2436
  65. ansys/fluent/tests/test_meshing_workflow.py +0 -421
  66. ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
  67. ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
  68. ansys/fluent/tests/test_preferences.py +0 -89
  69. ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
  70. ansys/fluent/tests/test_reduction.py +0 -484
  71. ansys/fluent/tests/test_rp_vars.py +0 -77
  72. ansys/fluent/tests/test_scheduler.py +0 -471
  73. ansys/fluent/tests/test_scheme_eval_222.py +0 -338
  74. ansys/fluent/tests/test_scheme_eval_231.py +0 -243
  75. ansys/fluent/tests/test_search.py +0 -344
  76. ansys/fluent/tests/test_session.py +0 -594
  77. ansys/fluent/tests/test_settings_api.py +0 -606
  78. ansys/fluent/tests/test_settings_reader.py +0 -85
  79. ansys/fluent/tests/test_slurm_future.py +0 -67
  80. ansys/fluent/tests/test_solution_variables.py +0 -241
  81. ansys/fluent/tests/test_solver_monitors.py +0 -83
  82. ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
  83. ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
  84. ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
  85. ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
  86. ansys/fluent/tests/test_solvermode/test_general.py +0 -109
  87. ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
  88. ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
  89. ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
  90. ansys/fluent/tests/test_solvermode/test_models.py +0 -99
  91. ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
  92. ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
  93. ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
  94. ansys/fluent/tests/test_streaming_services.py +0 -52
  95. ansys/fluent/tests/test_systemcoupling.py +0 -44
  96. ansys/fluent/tests/test_topy.py +0 -179
  97. ansys/fluent/tests/test_tui_api.py +0 -70
  98. ansys/fluent/tests/test_type_stub.py +0 -37
  99. ansys/fluent/tests/test_utils.py +0 -82
  100. ansys/fluent/tests/util/__init__.py +0 -36
  101. ansys/fluent/tests/util/meshing_workflow.py +0 -33
  102. ansys/fluent/tests/util/solver.py +0 -72
  103. ansys_fluent_core-0.28.2.dist-info/AUTHORS +0 -12
@@ -1,783 +0,0 @@
1
- import ast
2
- import importlib
3
- from pathlib import Path
4
- import pickle
5
- import shutil
6
- import tempfile
7
-
8
- import pytest
9
-
10
- import ansys.fluent.core as pyfluent
11
- from ansys.fluent.core.codegen import StaticInfoType, allapigen
12
- from ansys.fluent.core.search import get_api_tree_file_name
13
- from ansys.fluent.core.utils.fluent_version import get_version_for_file_name
14
-
15
-
16
- @pytest.mark.codegen_required
17
- def test_allapigen_files(new_solver_session):
18
- version = get_version_for_file_name(session=new_solver_session)
19
- importlib.import_module(f"ansys.fluent.core.generated.fluent_version_{version}")
20
- importlib.import_module(f"ansys.fluent.core.generated.meshing.tui_{version}")
21
- importlib.import_module(f"ansys.fluent.core.generated.solver.tui_{version}")
22
- importlib.import_module(f"ansys.fluent.core.generated.datamodel_{version}.meshing")
23
- importlib.import_module(f"ansys.fluent.core.generated.datamodel_{version}.workflow")
24
- importlib.import_module(
25
- f"ansys.fluent.core.generated.datamodel_{version}.preferences"
26
- )
27
- importlib.import_module(
28
- f"ansys.fluent.core.generated.datamodel_{version}.PartManagement"
29
- )
30
- importlib.import_module(
31
- f"ansys.fluent.core.generated.datamodel_{version}.PMFileManagement"
32
- )
33
- importlib.import_module(f"ansys.fluent.core.generated.solver.settings_{version}")
34
-
35
-
36
- def test_codegen_with_no_static_info(monkeypatch):
37
- codegen_outdir = Path(tempfile.mkdtemp())
38
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
39
- version = "251"
40
- allapigen.generate(version, {})
41
- generated_paths = list(codegen_outdir.iterdir())
42
- assert len(generated_paths) == 1
43
- assert set(p.name for p in generated_paths) == {f"api_tree_{version}.pickle"}
44
- api_tree_file = get_api_tree_file_name(version)
45
- with open(api_tree_file, "rb") as f:
46
- api_tree = pickle.load(f)
47
- assert api_tree == {"<meshing_session>": {}, "<solver_session>": {}}
48
-
49
-
50
- def _get_nth_tui_command_static_info(n):
51
- return {f"C{n}": {"menus": {}, "commands": {}, "help": f"C{n} help"}}
52
-
53
-
54
- def _get_nth_tui_menu_static_info(n, menus_static_info, commands_static_info):
55
- return {
56
- f"M{n}": {
57
- "menus": menus_static_info,
58
- "commands": commands_static_info,
59
- "help": f"M{n} help",
60
- }
61
- }
62
-
63
-
64
- def _get_expected_tui_api_output(mode):
65
- return f'''"""Fluent {mode} TUI commands"""
66
- #
67
- # This is an auto-generated file. DO NOT EDIT!
68
- #
69
- # pylint: disable=line-too-long
70
-
71
- from ansys.fluent.core.services.datamodel_tui import PyMenu, TUIMenu, TUIMethod
72
-
73
-
74
-
75
- class main_menu(TUIMenu):
76
- """
77
- Fluent {mode} main menu.
78
- """
79
- def __init__(self, service, version, mode, path):
80
- self.M1 = self.__class__.M1(service, version, mode, path + ["M1"])
81
- self.C1 = self.__class__.C1(service, version, mode, path + ["C1"])
82
- super().__init__(service, version, mode, path)
83
- class C1(TUIMethod):
84
- """
85
- C1 help.
86
- """
87
-
88
- class M1(TUIMenu):
89
- """
90
- M1 help.
91
- """
92
- def __init__(self, service, version, mode, path):
93
- self.M2 = self.__class__.M2(service, version, mode, path + ["M2"])
94
- self.C2 = self.__class__.C2(service, version, mode, path + ["C2"])
95
- super().__init__(service, version, mode, path)
96
- class C2(TUIMethod):
97
- """
98
- C2 help.
99
- """
100
-
101
- class M2(TUIMenu):
102
- """
103
- M2 help.
104
- """
105
- def __init__(self, service, version, mode, path):
106
- self.C3 = self.__class__.C3(service, version, mode, path + ["C3"])
107
- super().__init__(service, version, mode, path)
108
- class C3(TUIMethod):
109
- """
110
- C3 help.
111
- """'''
112
-
113
-
114
- @pytest.mark.parametrize("mode", ["solver", "meshing"])
115
- def test_codegen_with_tui_solver_static_info(mode, monkeypatch):
116
- codegen_outdir = Path(tempfile.mkdtemp())
117
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
118
- version = "251"
119
- static_infos = {}
120
- static_info_type = (
121
- StaticInfoType.TUI_SOLVER if mode == "solver" else StaticInfoType.TUI_MESHING
122
- )
123
- static_infos[static_info_type] = {
124
- "menus": _get_nth_tui_menu_static_info(
125
- 1,
126
- _get_nth_tui_menu_static_info(2, {}, _get_nth_tui_command_static_info(3)),
127
- _get_nth_tui_command_static_info(2),
128
- ),
129
- "commands": _get_nth_tui_command_static_info(1),
130
- "help": "Root",
131
- }
132
- allapigen.generate(version, static_infos)
133
- generated_paths = list(codegen_outdir.iterdir())
134
- assert len(generated_paths) == 2
135
- assert set(p.name for p in generated_paths) == {f"api_tree_{version}.pickle", mode}
136
- solver_paths = list((codegen_outdir / mode).iterdir())
137
- assert len(solver_paths) == 1
138
- assert set(p.name for p in solver_paths) == {f"tui_{version}.py"}
139
- with open(codegen_outdir / mode / f"tui_{version}.py", "r") as f:
140
- assert f.read().strip() == _get_expected_tui_api_output(mode)
141
- api_tree_file = get_api_tree_file_name(version)
142
- with open(api_tree_file, "rb") as f:
143
- api_tree = pickle.load(f)
144
- tui_tree = {
145
- "tui": {"M1": {"M2": {"C3": "Command"}, "C2": "Command"}, "C1": "Command"}
146
- }
147
- api_tree_expected = {"<meshing_session>": {}, "<solver_session>": {}}
148
- api_tree_expected[f"<{mode}_session>"] = tui_tree
149
- assert api_tree == api_tree_expected
150
- shutil.rmtree(str(codegen_outdir))
151
-
152
-
153
- _static_info_type_by_rules = {
154
- "workflow": StaticInfoType.DATAMODEL_WORKFLOW,
155
- "meshing": StaticInfoType.DATAMODEL_MESHING,
156
- "PartManagement": StaticInfoType.DATAMODEL_PART_MANAGEMENT,
157
- "PMFileManagement": StaticInfoType.DATAMODEL_PM_FILE_MANAGEMENT,
158
- "flicing": StaticInfoType.DATAMODEL_FLICING,
159
- "preferences": StaticInfoType.DATAMODEL_PREFERENCES,
160
- "solverworkflow": StaticInfoType.DATAMODEL_SOLVER_WORKFLOW,
161
- "MeshingUtilities": StaticInfoType.DATAMODEL_MESHING_UTILITIES,
162
- }
163
-
164
-
165
- def _get_datamodel_entity_static_info(
166
- name, singletons, namedobjects, commands, parameters
167
- ):
168
- return {
169
- name: {
170
- "singletons": singletons,
171
- "namedobjects": namedobjects,
172
- "commands": commands,
173
- "parameters": parameters,
174
- }
175
- }
176
-
177
-
178
- def _get_datamodel_command_static_info(name, args, returntype):
179
- args = [{"name": arg[0], "type": arg[1]} for arg in args]
180
- return {name: {"commandinfo": {"args": args, "returntype": returntype}}}
181
-
182
-
183
- _expected_datamodel_api_output = '''#
184
- # This is an auto-generated file. DO NOT EDIT!
185
- #
186
- # pylint: disable=line-too-long
187
-
188
- from ansys.fluent.core.services.datamodel_se import (
189
- PyMenu,
190
- PyParameter,
191
- PyTextual,
192
- PyNumerical,
193
- PyDictionary,
194
- PyNamedObjectContainer,
195
- PyCommand,
196
- PyQuery
197
- )
198
-
199
-
200
- class Root(PyMenu):
201
- """
202
- Singleton Root.
203
- """
204
- def __init__(self, service, rules, path):
205
- self.N1 = self.__class__.N1(service, rules, path + [("N1", "")])
206
- self.S1 = self.__class__.S1(service, rules, path + [("S1", "")])
207
- self.P1 = self.__class__.P1(service, rules, path + [("P1", "")])
208
- self.C1 = self.__class__.C1(service, rules, "C1", path)
209
- super().__init__(service, rules, path)
210
-
211
- class N1(PyNamedObjectContainer):
212
- """
213
- .
214
- """
215
- class _N1(PyMenu):
216
- """
217
- Singleton _N1.
218
- """
219
- def __init__(self, service, rules, path):
220
- self.S3 = self.__class__.S3(service, rules, path + [("S3", "")])
221
- super().__init__(service, rules, path)
222
-
223
- class S3(PyMenu):
224
- """
225
- Singleton S3.
226
- """
227
- def __init__(self, service, rules, path):
228
- super().__init__(service, rules, path)
229
-
230
- def __getitem__(self, key: str) -> _N1:
231
- return super().__getitem__(key)
232
-
233
- class S1(PyMenu):
234
- """
235
- Singleton S1.
236
- """
237
- def __init__(self, service, rules, path):
238
- self.S2 = self.__class__.S2(service, rules, path + [("S2", "")])
239
- self.P2 = self.__class__.P2(service, rules, path + [("P2", "")])
240
- self.C2 = self.__class__.C2(service, rules, "C2", path)
241
- super().__init__(service, rules, path)
242
-
243
- class S2(PyMenu):
244
- """
245
- Singleton S2.
246
- """
247
- def __init__(self, service, rules, path):
248
- super().__init__(service, rules, path)
249
-
250
- class P2(PyNumerical):
251
- """
252
- Parameter P2 of value type float.
253
- """
254
- pass
255
-
256
- class C2(PyCommand):
257
- """
258
- Command C2.
259
-
260
- Parameters
261
- ----------
262
- A2 : float
263
-
264
- Returns
265
- -------
266
- bool
267
- """
268
- pass
269
-
270
- class P1(PyTextual):
271
- """
272
- Parameter P1 of value type str.
273
- """
274
- pass
275
-
276
- class C1(PyCommand):
277
- """
278
- Command C1.
279
-
280
- Parameters
281
- ----------
282
- A1 : str
283
-
284
- Returns
285
- -------
286
- bool
287
- """
288
- pass'''
289
-
290
-
291
- @pytest.mark.parametrize(
292
- "rules",
293
- [
294
- "workflow",
295
- "meshing",
296
- "PartManagement",
297
- "PMFileManagement",
298
- "preferences",
299
- "solverworkflow",
300
- "MeshingUtilities",
301
- ],
302
- )
303
- def test_codegen_with_datamodel_static_info(monkeypatch, rules):
304
- codegen_outdir = Path(tempfile.mkdtemp())
305
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
306
- version = "251"
307
- static_infos = {}
308
- static_info_type = _static_info_type_by_rules[rules]
309
- static_infos[static_info_type] = {
310
- "singletons": _get_datamodel_entity_static_info(
311
- "S1",
312
- _get_datamodel_entity_static_info("S2", {}, {}, {}, {}),
313
- {},
314
- _get_datamodel_command_static_info("C2", [("A2", "Real")], "Logical"),
315
- {"P2": {"type": "Real"}},
316
- ),
317
- "namedobjects": _get_datamodel_entity_static_info(
318
- "N1", _get_datamodel_entity_static_info("S3", {}, {}, {}, {}), {}, {}, {}
319
- ),
320
- "commands": _get_datamodel_command_static_info(
321
- "C1", [("A1", "String")], "Logical"
322
- ),
323
- "parameters": {"P1": {"type": "String"}},
324
- "help": "Root",
325
- }
326
- allapigen.generate(version, static_infos)
327
- generated_paths = list(codegen_outdir.iterdir())
328
- assert len(generated_paths) == 2
329
- assert set(p.name for p in generated_paths) == {
330
- f"api_tree_{version}.pickle",
331
- f"datamodel_{version}",
332
- }
333
- datamodel_paths = list((codegen_outdir / f"datamodel_{version}").iterdir())
334
- assert len(datamodel_paths) == 1 or 2
335
- assert set(p.name for p in datamodel_paths) == {f"{rules}.py"} or {f"{rules}.pyi"}
336
- with open(codegen_outdir / f"datamodel_{version}" / f"{rules}.py", "r") as f:
337
- assert f.read().strip() == _expected_datamodel_api_output
338
- api_tree_file = get_api_tree_file_name(version)
339
- with open(api_tree_file, "rb") as f:
340
- api_tree = pickle.load(f)
341
- datamodel_tree = {
342
- rules: {
343
- "C1": "Command",
344
- "N1:<name>": {"S3": {}},
345
- "P1": "Parameter",
346
- "S1": {"C2": "Command", "P2": "Parameter", "S2": {}},
347
- }
348
- }
349
- api_tree_expected = {"<meshing_session>": {}, "<solver_session>": {}}
350
- if rules in [
351
- "workflow",
352
- "meshing",
353
- "PartManagement",
354
- "PMFileManagement",
355
- "preferences",
356
- "MeshingUtilities",
357
- ]:
358
- api_tree_expected["<meshing_session>"] = datamodel_tree
359
- if rules in ["workflow", "flicing", "preferences", "solverworkflow"]:
360
- api_tree_expected["<solver_session>"] = datamodel_tree
361
- assert api_tree == api_tree_expected
362
- shutil.rmtree(str(codegen_outdir))
363
-
364
-
365
- def _get_group_settings_static_info(name, children, commands, queries):
366
- return {
367
- name: {
368
- "children": children,
369
- "commands": commands,
370
- "queries": queries,
371
- "type": "group",
372
- "help": f"{name} help",
373
- }
374
- }
375
-
376
-
377
- def _get_named_object_settings_static_info(name, object_type, children):
378
- return {
379
- name: {
380
- "object-type": object_type,
381
- "children": children,
382
- "type": "named-object",
383
- "help": f"{name} help",
384
- }
385
- }
386
-
387
-
388
- def _get_parameter_settings_static_info(name, type_):
389
- return {name: {"type": type_, "help": f"{name} help"}}
390
-
391
-
392
- def _get_command_settings_static_info(name, args):
393
- args = {arg[0]: {"type": arg[1], "help": f"{arg[0]} help"} for arg in args}
394
- return {name: {"arguments": args, "type": "command", "help": f"{name} help"}}
395
-
396
-
397
- def _get_query_settings_static_info(name, args):
398
- args = {arg[0]: {"type": arg[1], "help": f"{arg[0]} help"} for arg in args}
399
- return {name: {"arguments": args, "type": "query", "help": f"{name} help"}}
400
-
401
-
402
- _settings_static_info = {
403
- "children": (
404
- _get_group_settings_static_info(
405
- "G1",
406
- (
407
- (
408
- _get_group_settings_static_info(
409
- "G2",
410
- _get_parameter_settings_static_info("P3", "integer"),
411
- {},
412
- {},
413
- )
414
- )
415
- | _get_parameter_settings_static_info("P2", "real")
416
- ),
417
- _get_command_settings_static_info("C2", [("A2", "real")]),
418
- _get_query_settings_static_info("Q2", [("A2", "real")]),
419
- )
420
- | _get_parameter_settings_static_info("P1", "string")
421
- | _get_named_object_settings_static_info(
422
- "N1",
423
- _get_group_settings_static_info("G3", {}, {}, {})["G3"],
424
- _get_parameter_settings_static_info("P4", "string"),
425
- )
426
- ),
427
- "commands": _get_command_settings_static_info("C1", [("A1", "string")]),
428
- "queries": _get_query_settings_static_info("Q1", [("A1", "string")]),
429
- "type": "group",
430
- }
431
-
432
-
433
- _expected_settings_api_output = '''#
434
- # This is an auto-generated file. DO NOT EDIT!
435
- #
436
-
437
- from ansys.fluent.core.solver.flobject import *
438
-
439
- from ansys.fluent.core.solver.flobject import (
440
- _ChildNamedObjectAccessorMixin,
441
- _NonCreatableNamedObjectMixin,
442
- _InputFile,
443
- _OutputFile,
444
- _InOutFile,
445
- )
446
-
447
- SHASH = "3e6d76a4601701388ea8258912d145b7b7c436699a50b6c7fe9a29f41eeff194"
448
-
449
- class P3(Integer):
450
- """
451
- P3 help.
452
- """
453
- version = '251'
454
- fluent_name = 'P3'
455
- _python_name = 'P3'
456
-
457
- class G2(Group):
458
- """
459
- G2 help.
460
- """
461
- version = '251'
462
- fluent_name = 'G2'
463
- _python_name = 'G2'
464
- child_names = ['P3']
465
- _child_classes = dict(
466
- P3=P3,
467
- )
468
-
469
- class P2(Real):
470
- """
471
- P2 help.
472
- """
473
- version = '251'
474
- fluent_name = 'P2'
475
- _python_name = 'P2'
476
-
477
- class A2(Real):
478
- """
479
- A2 help.
480
- """
481
- version = '251'
482
- fluent_name = 'A2'
483
- _python_name = 'A2'
484
-
485
- class C2(Command):
486
- """
487
- C2 help.
488
-
489
- Parameters
490
- ----------
491
- A2 : real
492
- A2 help.
493
- """
494
- version = '251'
495
- fluent_name = 'C2'
496
- _python_name = 'C2'
497
- argument_names = ['A2']
498
- _child_classes = dict(
499
- A2=A2,
500
- )
501
-
502
- class Q2(Query):
503
- """
504
- Q2 help.
505
-
506
- Parameters
507
- ----------
508
- A2 : real
509
- A2 help.
510
- """
511
- version = '251'
512
- fluent_name = 'Q2'
513
- _python_name = 'Q2'
514
- argument_names = ['A2']
515
- _child_classes = dict(
516
- A2=A2,
517
- )
518
-
519
- class G1(Group):
520
- """
521
- G1 help.
522
- """
523
- version = '251'
524
- fluent_name = 'G1'
525
- _python_name = 'G1'
526
- child_names = ['G2', 'P2']
527
- command_names = ['C2']
528
- query_names = ['Q2']
529
- _child_classes = dict(
530
- G2=G2,
531
- P2=P2,
532
- C2=C2,
533
- Q2=Q2,
534
- )
535
-
536
- class P1(String):
537
- """
538
- P1 help.
539
- """
540
- version = '251'
541
- fluent_name = 'P1'
542
- _python_name = 'P1'
543
-
544
- class P4(String):
545
- """
546
- P4 help.
547
- """
548
- version = '251'
549
- fluent_name = 'P4'
550
- _python_name = 'P4'
551
-
552
- class N1_child(Group):
553
- """
554
- 'child_object_type' of N1.
555
- """
556
- version = '251'
557
- fluent_name = 'child-object-type'
558
- _python_name = 'N1_child'
559
-
560
- class N1(NamedObject[N1_child], _NonCreatableNamedObjectMixin[N1_child]):
561
- """
562
- N1 help.
563
- """
564
- version = '251'
565
- fluent_name = 'N1'
566
- _python_name = 'N1'
567
- child_names = ['P4']
568
- _child_classes = dict(
569
- P4=P4,
570
- )
571
- child_object_type = N1_child
572
-
573
- class A1(String):
574
- """
575
- A1 help.
576
- """
577
- version = '251'
578
- fluent_name = 'A1'
579
- _python_name = 'A1'
580
-
581
- class C1(Command):
582
- """
583
- C1 help.
584
-
585
- Parameters
586
- ----------
587
- A1 : str
588
- A1 help.
589
- """
590
- version = '251'
591
- fluent_name = 'C1'
592
- _python_name = 'C1'
593
- argument_names = ['A1']
594
- _child_classes = dict(
595
- A1=A1,
596
- )
597
-
598
- class Q1(Query):
599
- """
600
- Q1 help.
601
-
602
- Parameters
603
- ----------
604
- A1 : str
605
- A1 help.
606
- """
607
- version = '251'
608
- fluent_name = 'Q1'
609
- _python_name = 'Q1'
610
- argument_names = ['A1']
611
- _child_classes = dict(
612
- A1=A1,
613
- )
614
-
615
- class root(Group):
616
- """
617
- 'root' object.
618
- """
619
- version = '251'
620
- fluent_name = ''
621
- _python_name = 'root'
622
- child_names = ['G1', 'P1', 'N1']
623
- command_names = ['C1']
624
- query_names = ['Q1']
625
- _child_classes = dict(
626
- G1=G1,
627
- P1=P1,
628
- N1=N1,
629
- C1=C1,
630
- Q1=Q1,
631
- )''' # noqa: W293
632
-
633
-
634
- def test_codegen_with_settings_static_info(monkeypatch):
635
- codegen_outdir = Path(tempfile.mkdtemp())
636
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
637
- version = "251"
638
- static_infos = {}
639
- static_infos[StaticInfoType.SETTINGS] = _settings_static_info
640
- allapigen.generate(version, static_infos)
641
- generated_paths = list(codegen_outdir.iterdir())
642
- assert len(generated_paths) == 2
643
- assert set(p.name for p in generated_paths) == {
644
- f"api_tree_{version}.pickle",
645
- "solver",
646
- }
647
- solver_paths = list((codegen_outdir / "solver").iterdir())
648
- assert len(solver_paths) == 2
649
- assert set(p.name for p in solver_paths) == {
650
- f"settings_{version}.py",
651
- f"settings_{version}.pyi",
652
- }
653
- with open(codegen_outdir / "solver" / f"settings_{version}.py", "r") as f:
654
- assert f.read().strip() == _expected_settings_api_output
655
- api_tree_file = get_api_tree_file_name(version)
656
- with open(api_tree_file, "rb") as f:
657
- api_tree = pickle.load(f)
658
- settings_tree = {
659
- "C1": "Command",
660
- "G1": {
661
- "C2": "Command",
662
- "G2": {"P3": "Parameter"},
663
- "P2": "Parameter",
664
- "Q2": "Query",
665
- },
666
- "N1:<name>": {"P4": "Parameter"},
667
- "P1": "Parameter",
668
- "Q1": "Query",
669
- }
670
- api_tree_expected = {}
671
- api_tree_expected["<meshing_session>"] = {}
672
- api_tree_expected["<solver_session>"] = settings_tree
673
- assert api_tree == api_tree_expected
674
- shutil.rmtree(str(codegen_outdir))
675
-
676
-
677
- _settings_static_info_duplicate_parameters = {
678
- "children": (
679
- _get_group_settings_static_info(
680
- "G1",
681
- (
682
- (
683
- _get_group_settings_static_info(
684
- "G2",
685
- _get_parameter_settings_static_info("P1", "string"),
686
- {},
687
- {},
688
- )
689
- )
690
- | _get_parameter_settings_static_info("P1", "string")
691
- ),
692
- {},
693
- {},
694
- )
695
- ),
696
- "commands": {},
697
- "queries": {},
698
- "type": "group",
699
- }
700
-
701
- _settings_static_info_different_parameters_with_same_name = {
702
- "children": (
703
- _get_group_settings_static_info(
704
- "G1",
705
- (
706
- (
707
- _get_group_settings_static_info(
708
- "G2",
709
- _get_parameter_settings_static_info("P1", "real"),
710
- {},
711
- {},
712
- )
713
- )
714
- | _get_parameter_settings_static_info("P1", "string")
715
- ),
716
- {},
717
- {},
718
- )
719
- ),
720
- "commands": {},
721
- "queries": {},
722
- "type": "group",
723
- }
724
-
725
-
726
- _settings_static_info_combined_case = {
727
- "children": (
728
- _get_group_settings_static_info(
729
- "G1",
730
- (
731
- (
732
- _get_group_settings_static_info(
733
- "G2",
734
- (
735
- _get_parameter_settings_static_info("P1", "real")
736
- | _get_parameter_settings_static_info("P2", "string")
737
- ),
738
- {},
739
- {},
740
- )
741
- )
742
- | _get_parameter_settings_static_info("P1", "string")
743
- | _get_parameter_settings_static_info("P2", "string")
744
- ),
745
- {},
746
- {},
747
- )
748
- ),
749
- "commands": {},
750
- "queries": {},
751
- "type": "group",
752
- }
753
-
754
-
755
- @pytest.mark.parametrize(
756
- "settings_static_info,class_names",
757
- [
758
- (_settings_static_info_duplicate_parameters, ["P1", "G2", "G1", "root"]),
759
- (
760
- _settings_static_info_different_parameters_with_same_name,
761
- ["P1_1", "G2", "P1", "G1", "root"],
762
- ),
763
- (_settings_static_info_combined_case, ["P1_1", "P2", "G2", "P1", "G1", "root"]),
764
- ],
765
- )
766
- def test_codegen_with_settings_static_info_edge_cases(
767
- monkeypatch, settings_static_info, class_names
768
- ):
769
-
770
- codegen_outdir = Path(tempfile.mkdtemp())
771
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
772
- version = "251"
773
- static_infos = {}
774
- static_infos[StaticInfoType.SETTINGS] = settings_static_info
775
- allapigen.generate(version, static_infos)
776
- with open(codegen_outdir / "solver" / f"settings_{version}.py", "r") as f:
777
- module_def = ast.parse(f.read())
778
- class_names_from_file = [
779
- x.name for x in module_def.body if isinstance(x, ast.ClassDef)
780
- ]
781
- # The order of classes is important.
782
- assert class_names_from_file == class_names
783
- shutil.rmtree(str(codegen_outdir))