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,1235 +0,0 @@
1
- """Unit tests for flobject module."""
2
-
3
- from collections.abc import MutableMapping
4
- import io
5
- import weakref
6
-
7
- import pytest
8
- from test_utils import count_key_recursive
9
-
10
- from ansys.fluent.core.examples import download_file
11
- from ansys.fluent.core.solver import flobject
12
- from ansys.fluent.core.solver.flobject import (
13
- InactiveObjectError,
14
- _gethash,
15
- find_children,
16
- )
17
- from ansys.fluent.core.utils.fluent_version import FluentVersion
18
- import ansys.units
19
-
20
-
21
- class Setting:
22
- """Base class for setting objects."""
23
-
24
- def __init__(self, parent):
25
- self.parent = None if parent is None else weakref.proxy(parent)
26
-
27
- def get_attr(self, attr):
28
- attrs = self.get_attrs([attr])
29
- if attrs.get("active?"):
30
- return attrs[attr]
31
- else:
32
- raise RuntimeError("Object is not active")
33
-
34
- def get_attrs(self, attrs):
35
- active = self.attrs.get("active?", lambda self: True)(self)
36
- if active:
37
- return {attr: self.attrs[attr](self) for attr in attrs}
38
- else:
39
- return {"active?": False}
40
-
41
- attrs = {
42
- "active?": lambda self: True,
43
- "webui-release-active?": lambda self: True,
44
- }
45
-
46
-
47
- class PrimitiveSetting(Setting):
48
- """Primitive setting objects."""
49
-
50
- value = None
51
-
52
- def get_state(self):
53
- return self.value
54
-
55
- def set_state(self, value):
56
- self.value = value
57
-
58
- @classmethod
59
- def get_static_info(cls):
60
- ret = {"type": cls.objtype}
61
- if cls.__doc__:
62
- ret["help"] = cls.__doc__
63
- return ret
64
-
65
-
66
- class Bool(PrimitiveSetting):
67
- objtype = "boolean"
68
-
69
-
70
- class Int(PrimitiveSetting):
71
- objtype = "integer"
72
-
73
-
74
- class Real(PrimitiveSetting):
75
- objtype = "real"
76
-
77
-
78
- class String(PrimitiveSetting):
79
- objtype = "string/symbol"
80
-
81
-
82
- class BoolList(PrimitiveSetting):
83
- objtype = "boolean-list"
84
-
85
-
86
- class IntList(PrimitiveSetting):
87
- objtype = "integer-list"
88
-
89
-
90
- class RealList(PrimitiveSetting):
91
- objtype = "real-list"
92
-
93
-
94
- class StringList(PrimitiveSetting):
95
- objtype = "string-list"
96
-
97
-
98
- class Group(Setting):
99
- """Group objects."""
100
-
101
- objtype = "group"
102
- children = {}
103
- commands = {}
104
-
105
- def __init__(self, parent):
106
- super().__init__(parent)
107
- self.objs = {c: v(self) for c, v in self.children.items()}
108
-
109
- def get_state(self):
110
- ret = {}
111
- for c in self.children:
112
- cobj = self.objs[c]
113
- if cobj.get_attr("active?"):
114
- ret[c] = cobj.get_state()
115
- return ret
116
-
117
- def set_state(self, value):
118
- for c in self.children:
119
- v = value.get(c)
120
- if v is not None:
121
- self.objs[c].set_state(v)
122
-
123
- def get_child(self, c):
124
- return self.objs[c]
125
-
126
- def get_command(self, c):
127
- return self.commands[c](self)
128
-
129
- @classmethod
130
- def get_static_info(cls):
131
- ret = {"type": cls.objtype}
132
- if cls.__doc__:
133
- ret["help"] = cls.__doc__
134
- if cls.children:
135
- ret["children"] = {c: v.get_static_info() for c, v in cls.children.items()}
136
- if cls.commands:
137
- ret["commands"] = {c: v.get_static_info() for c, v in cls.commands.items()}
138
- return ret
139
-
140
-
141
- class NamedObject(Setting, MutableMapping):
142
- """NamedObject class."""
143
-
144
- objtype = "named-object"
145
- commands = {}
146
- # To be overridden by child classes
147
- # child_object_type = None
148
-
149
- def __init__(self, parent):
150
- super().__init__(parent)
151
- self._objs = {}
152
-
153
- def __getitem__(self, name):
154
- return self._objs[name].get_state()
155
-
156
- def __setitem__(self, name, value):
157
- if name not in self._objs:
158
- self._objs[name] = self.child_object_type(self)
159
- return self._objs[name].set_state(value)
160
-
161
- def __delitem__(self, name):
162
- del self._objs[name]
163
-
164
- def __iter__(self):
165
- return iter(self._objs)
166
-
167
- def __len__(self):
168
- return len(self._objs)
169
-
170
- def get_child(self, c):
171
- return self._objs[c]
172
-
173
- def rename(self, new, old):
174
- self._objs = {(new if k == old else k): v for k, v in self._objs.items()}
175
-
176
- def get_object_names(self):
177
- return list(self._objs.keys())
178
-
179
- def get_command(self, c):
180
- return self.commands[c](self)
181
-
182
- def get_state(self):
183
- return {c: v.get_state() for c, v in self._objs.items()}
184
-
185
- def set_state(self, state):
186
- for k, v in state.items():
187
- self[k] = v
188
-
189
- @classmethod
190
- def get_static_info(cls):
191
- ret = {"type": cls.objtype}
192
- if cls.__doc__:
193
- ret["help"] = cls.__doc__
194
- ret["object-type"] = cls.child_object_type.get_static_info()
195
- if cls.commands:
196
- ret["commands"] = {c: v.get_static_info() for c, v in cls.commands.items()}
197
- try:
198
- if cls.user_creatable:
199
- ret["user_creatable"] = cls.user_creatable
200
- except AttributeError:
201
- ret["user_creatable"] = True
202
- return ret
203
-
204
-
205
- class ListObject(Setting):
206
- """ListObject class."""
207
-
208
- objtype = "list-object"
209
- commands = {}
210
- # To be overridden by child classes
211
- # child_object_type = None
212
-
213
- def __init__(self, parent):
214
- super().__init__(parent)
215
- self._objs = []
216
-
217
- def __getitem__(self, index):
218
- return self._objs[index].get_state()
219
-
220
- def __setitem__(self, index, value):
221
- return self._objs[index].set_state(value)
222
-
223
- def __iter__(self):
224
- return iter(self._objs)
225
-
226
- def __len__(self):
227
- return len(self._objs)
228
-
229
- def size(self):
230
- return len(self._objs)
231
-
232
- def resize(self, new_size):
233
- if new_size > len(self._objs):
234
- for _ in range(len(self._objs), new_size):
235
- self._objs.append(self.child_object_type(self))
236
- elif new_size < len(self._objs):
237
- self._objs = self._objs[:new_size]
238
-
239
- def get_child(self, c):
240
- return self._objs[int(c)]
241
-
242
- def get_command(self, c):
243
- return self.commands[c](self)
244
-
245
- def get_state(self):
246
- return [x.get_state() for x in self._objs]
247
-
248
- def set_state(self, value):
249
- self.resize(len(value))
250
- for i, v in enumerate(value):
251
- self[i] = v
252
-
253
- @classmethod
254
- def get_static_info(cls):
255
- ret = {"type": cls.objtype}
256
- if cls.__doc__:
257
- ret["help"] = cls.__doc__
258
- ret["object-type"] = cls.child_object_type.get_static_info()
259
- if cls.commands:
260
- ret["commands"] = {c: v.get_static_info() for c, v in cls.commands.items()}
261
- return ret
262
-
263
-
264
- class Command(Setting):
265
- """Command class."""
266
-
267
- objtype = "command"
268
- # To be overridden by child classes
269
- # arguments = None
270
- # cb = None
271
-
272
- def __init__(self, parent):
273
- self.attrs = super().attrs.copy()
274
- self.attrs["arguments-aliases"] = lambda self: {}
275
- super().__init__(parent)
276
-
277
- def __call__(self, **kwds):
278
- args = []
279
- for k, v in self.arguments.items():
280
- a = kwds.get(k, v(self).get_state())
281
- args.append(a)
282
- return self.cb(*args)
283
-
284
- @classmethod
285
- def get_static_info(cls):
286
- ret = {"type": cls.objtype}
287
- if cls.__doc__:
288
- ret["help"] = cls.__doc__
289
- if cls.arguments:
290
- ret["arguments"] = {
291
- c: v.get_static_info() for c, v in cls.arguments.items()
292
- }
293
- return ret
294
-
295
-
296
- class Root(Group):
297
- """Root class."""
298
-
299
- class G1(Group):
300
- class S1(String):
301
- attrs = {
302
- "active?": lambda self: not self.parent.objs["b-3"].get_state(),
303
- "allowed-values": lambda self: ["foo", "bar"],
304
- "webui-release-active?": lambda self: True,
305
- }
306
-
307
- children = {
308
- "r-1": Real,
309
- "i-2": Int,
310
- "b-3": Bool,
311
- "s-4": S1,
312
- }
313
-
314
- class N1(NamedObject):
315
- class NC(Group):
316
- children = {
317
- "rl-1": RealList,
318
- "sl-1": StringList,
319
- }
320
-
321
- child_object_type = NC
322
-
323
- class L1(ListObject):
324
- class LC(Group):
325
- children = {
326
- "il-1": IntList,
327
- "bl-1": BoolList,
328
- }
329
-
330
- child_object_type = LC
331
-
332
- class Command1(Command):
333
- """Command1 class."""
334
-
335
- class A1(Real):
336
- value = 2.3
337
-
338
- class A2(Bool):
339
- value = True
340
-
341
- arguments = {
342
- "a-1": A1,
343
- "a-2": A2,
344
- }
345
-
346
- def cb(self, a1, a2):
347
- if a2 is True:
348
- self.parent.objs["g-1"].objs["r-1"].value += a1
349
- else:
350
- self.parent.objs["g-1"].objs["r-1"].value -= a1
351
-
352
- children = {
353
- "g-1": G1,
354
- "n-1": N1,
355
- "l-1": L1,
356
- }
357
-
358
- commands = {
359
- "c-1": Command1,
360
- }
361
-
362
-
363
- class Proxy:
364
- """Proxy class."""
365
-
366
- root = Root
367
-
368
- def __init__(self):
369
- self.r = self.root(None)
370
-
371
- def get_obj(self, path):
372
- if not path:
373
- return self.r
374
- obj = self.r
375
- for c in path.split("/"):
376
- try:
377
- obj = obj.get_child(c)
378
- except KeyError:
379
- obj = obj.get_command(c)
380
- return obj
381
-
382
- def get_var(self, path):
383
- return self.get_obj(path).get_state()
384
-
385
- def set_var(self, path, value):
386
- return self.get_obj(path).set_state(value)
387
-
388
- def rename(self, path, new, old):
389
- return self.get_obj(path).rename(new, old)
390
-
391
- def create(self, path, name):
392
- self.get_obj(path)[name] = {}
393
-
394
- def delete(self, path, name):
395
- del self.get_obj(path)[name]
396
-
397
- def resize_list_object(self, path, size):
398
- return self.get_obj(path).resize(size)
399
-
400
- def get_list_size(self, path):
401
- return self.get_obj(path).size()
402
-
403
- def get_object_names(self, path):
404
- return self.get_obj(path).get_object_names()
405
-
406
- def execute_cmd(self, path, command, **kwds):
407
- return self.get_obj(path).get_command(command)(**kwds)
408
-
409
- def get_attrs(self, path, attrs, recursive=False):
410
- return self.get_obj(path).get_attrs(attrs)
411
-
412
- @classmethod
413
- def get_static_info(cls):
414
- return cls.root.get_static_info()
415
-
416
- def is_interactive_mode(self):
417
- return False
418
-
419
- def has_wildcard(self, name: str) -> bool:
420
- return False
421
-
422
-
423
- def test_primitives():
424
- r = flobject.get_root(Proxy())
425
- r.g_1.r_1 = 3.2
426
- assert r.g_1.r_1() == 3.2
427
- r.g_1.i_2 = -3
428
- assert r.g_1.i_2() == -3
429
- r.g_1.b_3 = True
430
- assert r.g_1.b_3() is True
431
- r.g_1.b_3 = False
432
- assert r.g_1.b_3() is False
433
- r.g_1.s_4 = "foo"
434
- assert r.g_1.s_4() == "foo"
435
-
436
-
437
- def test_group():
438
- r = flobject.get_root(Proxy())
439
- r.g_1 = {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "foo"}
440
- assert r.g_1() == {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "foo"}
441
- r.g_1 = {"s_4": "bar"}
442
- assert r.g_1() == {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "bar"}
443
- r.g_1.i_2 = 4
444
- assert r.g_1() == {"r_1": 3.2, "i_2": 4, "b_3": False, "s_4": "bar"}
445
-
446
-
447
- def test_settings_input_set_state():
448
- r = flobject.get_root(Proxy())
449
- r.g_1 = {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "foo"}
450
- r.g_1.set_state(r_1=3.2, i_2=-3, b_3=False, s_4="foo")
451
- assert r.g_1() == {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "foo"}
452
- r.g_1.set_state(s_4="bar")
453
- assert r.g_1() == {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "bar"}
454
- r.g_1.set_state(i_2=4)
455
- assert r.g_1() == {"r_1": 3.2, "i_2": 4, "b_3": False, "s_4": "bar"}
456
-
457
-
458
- def test_settings_input():
459
- r = flobject.get_root(Proxy())
460
- r.g_1 = {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "foo"}
461
- r.g_1(r_1=3.2, i_2=-3, b_3=False, s_4="foo")
462
- assert r.g_1() == {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "foo"}
463
- r.g_1(s_4="bar")
464
- assert r.g_1() == {"r_1": 3.2, "i_2": -3, "b_3": False, "s_4": "bar"}
465
- r.g_1(i_2=4)
466
- assert r.g_1() == {"r_1": 3.2, "i_2": 4, "b_3": False, "s_4": "bar"}
467
-
468
-
469
- def test_named_object():
470
- r = flobject.get_root(Proxy())
471
- assert r.n_1.get_object_names() == []
472
- r.n_1["n1"] = {}
473
- r.n_1["n2"] = {}
474
- assert r.n_1.get_object_names() == ["n1", "n2"]
475
- r.n_1.create("n4")
476
- assert r.n_1.get_object_names() == ["n1", "n2", "n4"]
477
- del r.n_1["n1"]
478
- assert r.n_1.get_object_names() == ["n2", "n4"]
479
- r.n_1["n1"] = {"rl_1": [1.2, 3.4], "sl_1": ["foo", "bar"]}
480
- assert r.n_1["n1"]() == {"rl_1": [1.2, 3.4], "sl_1": ["foo", "bar"]}
481
- r.n_1 = {"n5": {"rl_1": [4.3, 2.1], "sl_1": ["oof", "rab"]}}
482
- assert r.n_1.get_object_names() == ["n2", "n4", "n1", "n5"]
483
- assert r.n_1["n5"]() == {"rl_1": [4.3, 2.1], "sl_1": ["oof", "rab"]}
484
-
485
-
486
- def test_list_object():
487
- r = flobject.get_root(Proxy())
488
- assert r.l_1.get_size() == 0
489
- r.l_1 = [
490
- {"il_1": None, "bl_1": None},
491
- {"il_1": None, "bl_1": None},
492
- ]
493
- r.l_1[1].il_1 = [1, 2]
494
- assert r.l_1() == [
495
- {"il_1": None, "bl_1": None},
496
- {"il_1": [1, 2], "bl_1": None},
497
- ]
498
- r.l_1 = [{"il_1": [3], "bl_1": [True, False]}]
499
- assert r.l_1() == [{"il_1": [3], "bl_1": [True, False]}]
500
-
501
-
502
- def test_command():
503
- r = flobject.get_root(Proxy())
504
- r.g_1.r_1 = 2.4
505
- r.c_1()
506
- assert r.g_1.r_1() == 2.4 + 2.3
507
- r.c_1(a_2=False)
508
- assert r.g_1.r_1() == 2.4 + 2.3 - 2.3
509
- r.c_1(a_1=3.2, a_2=True)
510
- assert r.g_1.r_1() == 2.4 + 2.3 - 2.3 + 3.2
511
- r.c_1(a_1=4.5, a_2=False)
512
- assert r.g_1.r_1() == 2.4 + 2.3 - 2.3 + 3.2 - 4.5
513
-
514
-
515
- def test_attrs():
516
- r = flobject.get_root(Proxy())
517
- r._setattr("version", "251")
518
- assert r.g_1.s_4.get_attr("active?")
519
- assert r.g_1.s_4.get_attr("allowed-values") == ["foo", "bar"]
520
- r.g_1.b_3 = True
521
- assert not r.g_1.s_4.get_attr("active?")
522
- with pytest.raises(InactiveObjectError):
523
- r.g_1.s_4.get_attr("allowed-values")
524
-
525
-
526
- # The following test is commented out as codegen module is not packaged in the
527
- # install
528
- def _disabled_test_settings_gen():
529
- info = Proxy().get_static_info()
530
- cls, _ = flobject.get_cls("", info)
531
- f = io.StringIO()
532
- ansys.fluent.core.codegen.settingsgen.write_settings_classes(f, cls, info)
533
- assert (
534
- f.getvalue()
535
- == '''###
536
- ### THIS FILE IS AUTOGENERATED! DO NOT MODIFY!
537
-
538
- ###
539
- from ansys.fluent.solver.flobject import *
540
-
541
- SHASH = "0392eb93ff1d5f9dd50ef9fddc74581ad3e8f74c34c569b6a1a6f1b57753d5ad"
542
-
543
- class root(Group):
544
- """
545
- Root class
546
- """
547
- fluent_name = ""
548
- child_names = \\
549
- ['g_1', 'n_1', 'l_1']
550
-
551
- class g_1(Group):
552
- """
553
- 'g_1' child of 'root' object
554
- """
555
- fluent_name = "g-1"
556
- child_names = \\
557
- ['r_1', 'i_2', 'b_3', 's_4']
558
-
559
- class r_1(Real):
560
- """
561
- 'r_1' child of 'g_1' object
562
- """
563
- fluent_name = "r-1"
564
-
565
- class i_2(Integer):
566
- """
567
- 'i_2' child of 'g_1' object
568
- """
569
- fluent_name = "i-2"
570
-
571
- class b_3(Boolean):
572
- """
573
- 'b_3' child of 'g_1' object
574
- """
575
- fluent_name = "b-3"
576
-
577
- class s_4(String):
578
- """
579
- 's_4' child of 'g_1' object
580
- """
581
- fluent_name = "s-4"
582
-
583
- class n_1(NamedObject):
584
- """
585
- 'n_1' child of 'root' object
586
- """
587
- fluent_name = "n-1"
588
-
589
- class child_object_type(Group):
590
- """
591
- 'child_object_type' child of 'n_1' object
592
- """
593
- fluent_name = "child-object-type"
594
- child_names = \\
595
- ['rl_1', 'sl_1']
596
-
597
- class rl_1(RealList):
598
- """
599
- 'rl_1' child of 'child_object_type' object
600
- """
601
- fluent_name = "rl-1"
602
-
603
- class sl_1(StringList):
604
- """
605
- 'sl_1' child of 'child_object_type' object
606
- """
607
- fluent_name = "sl-1"
608
-
609
- class l_1(ListObject):
610
- """
611
- 'l_1' child of 'root' object
612
- """
613
- fluent_name = "l-1"
614
-
615
- class child_object_type(Group):
616
- """
617
- 'child_object_type' child of 'l_1' object
618
- """
619
- fluent_name = "child-object-type"
620
- child_names = \\
621
- ['il_1', 'bl_1']
622
-
623
- class il_1(IntegerList):
624
- """
625
- 'il_1' child of 'child_object_type' object
626
- """
627
- fluent_name = "il-1"
628
-
629
- class bl_1(BooleanList):
630
- """
631
- 'bl_1' child of 'child_object_type' object
632
- """
633
- fluent_name = "bl-1"
634
- command_names = \\
635
- ['c_1']
636
-
637
- class c_1(Command):
638
- """
639
- Command1 class
640
-
641
- Parameters
642
- ----------
643
- a_1 : real
644
- 'a_1' child of 'c_1' object
645
- a_2 : bool
646
- 'a_2' child of 'c_1' object
647
-
648
- """
649
- fluent_name = "c-1"
650
- argument_names = \\
651
- ['a_1', 'a_2']
652
-
653
- class a_1(Real):
654
- """
655
- 'a_1' child of 'c_1' object
656
- """
657
- fluent_name = "a-1"
658
-
659
- class a_2(Boolean):
660
- """
661
- 'a_2' child of 'c_1' object
662
- """
663
- fluent_name = "a-2"
664
- '''
665
- ) # noqa: W293
666
-
667
-
668
- @pytest.mark.fluent_version("latest")
669
- def test_accessor_methods_on_settings_object(static_mixer_settings_session):
670
- solver = static_mixer_settings_session
671
-
672
- existing = solver.file.read.file_type.get_attr("allowed-values")
673
- modified = solver.file.read.file_type.allowed_values()
674
- assert existing == modified
675
-
676
- existing = solver.file.read.file_type.get_attr("read-only?", bool)
677
- modified = solver.file.read.file_type.is_read_only()
678
-
679
- assert existing == modified
680
-
681
- velocity_inlet = solver.setup.boundary_conditions.velocity_inlet
682
- existing = velocity_inlet.get_attr("user-creatable?", bool)
683
- modified = velocity_inlet.user_creatable()
684
- assert existing == modified
685
-
686
- if solver.get_fluent_version() < FluentVersion.v242:
687
- turbulent_viscosity_ratio = velocity_inlet[
688
- "inlet1"
689
- ].turbulence.turbulent_viscosity_ratio_real
690
-
691
- path = '<session>.setup.boundary_conditions.velocity_inlet["inlet1"].turbulence.turbulent_viscosity_ratio_real'
692
- name = "turbulent_viscosity_ratio_real"
693
-
694
- else:
695
- turbulent_viscosity_ratio = velocity_inlet[
696
- "inlet1"
697
- ].turbulence.turbulent_viscosity_ratio
698
-
699
- if solver.get_fluent_version() >= FluentVersion.v251:
700
- path = '<session>.settings.setup.boundary_conditions.velocity_inlet["inlet1"].turbulence.turbulent_viscosity_ratio'
701
- else:
702
- path = '<session>.setup.boundary_conditions.velocity_inlet["inlet1"].turbulence.turbulent_viscosity_ratio'
703
- name = "turbulent_viscosity_ratio"
704
-
705
- assert turbulent_viscosity_ratio.python_path == path
706
- assert turbulent_viscosity_ratio.python_name == name
707
-
708
- assert turbulent_viscosity_ratio.default_value() == 10
709
- assert turbulent_viscosity_ratio.get_attr("min") == 0
710
-
711
- assert turbulent_viscosity_ratio.get_attr("max") is False
712
- assert turbulent_viscosity_ratio.max() is None
713
-
714
- default_attrs = solver.setup.boundary_conditions.velocity_inlet["inlet1"].get_attrs(
715
- ["default"], recursive=True
716
- )
717
- assert count_key_recursive(default_attrs, "default") > 5
718
-
719
- mesh = solver.results.graphics.mesh.create("mesh-1")
720
- if solver.get_fluent_version() < FluentVersion.v242:
721
- assert mesh.name.is_read_only()
722
- else:
723
- assert not mesh.name.is_read_only()
724
-
725
- assert solver.results.graphics.mesh.get_object_names() == ["mesh-1"]
726
-
727
- solver.results.graphics.mesh["mesh-1"].rename("mesh_new")
728
- assert solver.results.graphics.mesh.get_object_names() == ["mesh_new"]
729
-
730
- solver.results.graphics.mesh.rename(new="mesh_242", old="mesh_new")
731
- assert solver.results.graphics.mesh.get_object_names() == ["mesh_242"]
732
-
733
-
734
- @pytest.mark.fluent_version("latest")
735
- def test_accessor_methods_on_settings_object_types(static_mixer_settings_session):
736
- solver = static_mixer_settings_session
737
-
738
- assert solver.setup.general.solver.type.allowed_values() == [
739
- "pressure-based",
740
- "density-based-implicit",
741
- "density-based-explicit",
742
- ]
743
- accuracy_control = (
744
- solver.setup.models.discrete_phase.numerics.tracking.accuracy_control
745
- )
746
- if solver.get_fluent_version() < FluentVersion.v241:
747
- max_refinements = accuracy_control.max_number_of_refinements
748
- else:
749
- max_refinements = accuracy_control.max_num_refinements
750
-
751
- assert max_refinements.min() == 0
752
- assert max_refinements.max() == 1000000
753
- assert max_refinements.get_attr("max") == 1000000
754
-
755
-
756
- @pytest.mark.fluent_version("==24.1")
757
- @pytest.mark.codegen_required
758
- def test_find_children_from_settings_root(static_mixer_settings_session):
759
- setup_cls = static_mixer_settings_session.setup.__class__
760
- assert len(find_children(setup_cls())) >= 10000
761
- assert len(find_children(setup_cls(), "gen*")) >= 9
762
- assert set(find_children(setup_cls(), "general*")) >= {
763
- "general",
764
- "models/discrete_phase/general_settings",
765
- "models/virtual_blade_model/rotor/general",
766
- }
767
- assert set(find_children(setup_cls(), "general")) >= {
768
- "general",
769
- "models/virtual_blade_model/rotor/general",
770
- }
771
- assert any(
772
- path
773
- for path in find_children(setup_cls(), "*gen")
774
- if path.endswith("p_backflow_spec_gen")
775
- )
776
-
777
-
778
- @pytest.mark.fluent_version("latest")
779
- def test_find_children_from_fluent_solver_session(static_mixer_settings_session):
780
- setup_children = find_children(static_mixer_settings_session.setup)
781
- load_mixer = static_mixer_settings_session.setup
782
- assert len(setup_children) >= 18514
783
-
784
- viscous = load_mixer.models.viscous
785
- assert len(find_children(viscous, "prod*")) > 0
786
-
787
- assert any(
788
- path
789
- for path in find_children(
790
- load_mixer.boundary_conditions.pressure_outlet, "*_dir_*"
791
- )
792
- if path.endswith("geom_dir_spec")
793
- )
794
-
795
- if static_mixer_settings_session.get_fluent_version() < FluentVersion.v242:
796
- assert set(
797
- find_children(
798
- load_mixer.materials.fluid["air"].density.piecewise_polynomial
799
- )
800
- ) >= {
801
- "minimum",
802
- "maximum",
803
- "coefficients",
804
- }
805
- else:
806
- assert set(
807
- find_children(
808
- load_mixer.materials.fluid["air"].density.piecewise_polynomial
809
- )
810
- ) >= {
811
- "range/minimum",
812
- "range/maximum",
813
- "range/coefficients",
814
- }
815
-
816
-
817
- @pytest.mark.fluent_version(">=24.1")
818
- def test_settings_wild_card_access(new_solver_session) -> None:
819
- solver = new_solver_session
820
-
821
- case_path = download_file("elbow_source_terms.cas.h5", "pyfluent/mixing_elbow")
822
- solver.file.read_case(file_name=case_path)
823
-
824
- solver.solution.initialization.hybrid_initialize()
825
-
826
- if solver.get_fluent_version() >= FluentVersion.v251:
827
- assert (
828
- solver.setup.boundary_conditions.velocity_inlet[
829
- "*1"
830
- ].momentum.velocity_magnitude.value()["inlet1"]["momentum"][
831
- "velocity_magnitude"
832
- ][
833
- "value"
834
- ]
835
- == solver.setup.boundary_conditions.velocity_inlet[
836
- "inlet1"
837
- ].momentum.velocity.value()
838
- )
839
- else:
840
- assert (
841
- solver.setup.boundary_conditions.velocity_inlet[
842
- "*1"
843
- ].momentum.velocity.value()["inlet1"]["momentum"]["velocity"]["value"]
844
- == solver.setup.boundary_conditions.velocity_inlet[
845
- "inlet1"
846
- ].momentum.velocity.value()
847
- )
848
-
849
- assert solver.setup.boundary_conditions.wall["*"]()
850
-
851
- with pytest.raises(AttributeError) as msg:
852
- solver.setup.boundary_conditions.velocity_inlet["*1"].inlet1()
853
- assert msg.value.args[0] == "'velocity_inlet' has no attribute 'inlet1'.\n"
854
-
855
- with pytest.raises(KeyError) as msg:
856
- solver.setup.boundary_conditions.velocity_inlet["inlet-1"]
857
- assert (
858
- msg.value.args[0] == "'velocity_inlet' has no attribute 'inlet-1'.\n"
859
- "The most similar names are: inlet1, inlet2."
860
- )
861
-
862
-
863
- @pytest.mark.skip("https://github.com/ansys/pyfluent/issues/2792")
864
- @pytest.mark.fluent_version("latest")
865
- def test_settings_matching_names(new_solver_session) -> None:
866
- solver = new_solver_session
867
-
868
- case_path = download_file("elbow_source_terms.cas.h5", "pyfluent/mixing_elbow")
869
- solver.file.read_case(file_name=case_path)
870
-
871
- solver.solution.initialization.hybrid_initialize()
872
-
873
- with pytest.raises(AttributeError) as msg:
874
- solver.setup.mod
875
-
876
- assert (
877
- msg.value.args[0] == "'setup' object has no attribute 'mod'.\n"
878
- "The most similar names are: models."
879
- )
880
-
881
- with pytest.raises(ValueError) as msg:
882
- solver.setup.models.viscous.model = "k_epsilon"
883
-
884
- assert (
885
- msg.value.args[0] == "'model' has no attribute 'k_epsilon'.\n"
886
- "The most similar names are: k-epsilon."
887
- )
888
-
889
- energy_parent = solver.setup._get_parent_of_active_child_names("energy")
890
-
891
- assert energy_parent == "\n energy is a child of models \n"
892
-
893
-
894
- @pytest.mark.codegen_required
895
- @pytest.mark.fluent_version(">=23.2")
896
- def test_settings_api_names_exception(new_solver_session):
897
- solver = new_solver_session
898
-
899
- case_path = download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
900
- solver.file.read_case(file_name=case_path)
901
-
902
- with pytest.raises(RuntimeError):
903
- solver.setup.boundary_conditions["cold-inlet"].name = "hot-inlet"
904
-
905
-
906
- @pytest.mark.fluent_version(">=24.2")
907
- def test_accessor_methods_on_settings_objects(new_solver_session):
908
- solver = new_solver_session
909
- root = solver.settings
910
-
911
- nodes = {}
912
- expected_type_list = [
913
- "Boolean",
914
- "String",
915
- "Real",
916
- "Integer",
917
- "RealList",
918
- "ListObject",
919
- ]
920
- type_list = expected_type_list.copy()
921
-
922
- get_child_nodes(root, nodes, type_list)
923
-
924
- for type_data in expected_type_list:
925
- if type_data == "Boolean":
926
- assert {
927
- "is_active",
928
- "is_read_only",
929
- "default_value",
930
- "get_state",
931
- "set_state",
932
- }.issubset(set(dir(nodes[type_data])))
933
- assert nodes[type_data].is_read_only() in [True, False]
934
- assert nodes[type_data].is_active() in [True, False]
935
-
936
- elif type_data in ["Integer", "Real", "IntegerList", "RealList"]:
937
- assert {
938
- "is_active",
939
- "is_read_only",
940
- "default_value",
941
- "get_state",
942
- "set_state",
943
- "min",
944
- "max",
945
- }.issubset(set(dir(nodes[type_data])))
946
- assert not {"allowed_values"}.issubset(set(dir(nodes[type_data])))
947
- assert nodes[type_data].is_read_only() in [True, False]
948
- assert nodes[type_data].is_active() in [True, False]
949
-
950
- elif type_data in ["String", "StringList", "Filename"]:
951
- assert {
952
- "is_active",
953
- "is_read_only",
954
- "default_value",
955
- "get_state",
956
- "set_state",
957
- "allowed_values",
958
- }.issubset(set(dir(nodes[type_data])))
959
- assert not {"min", "max"}.issubset(set(dir(nodes[type_data])))
960
- assert nodes[type_data].is_read_only() in [True, False]
961
- assert nodes[type_data].is_active() in [True, False]
962
-
963
- elif type_data == "ListObject":
964
- assert {"is_active", "is_read_only", "get_state", "set_state"}.issubset(
965
- set(dir(nodes[type_data]))
966
- )
967
- assert nodes[type_data].is_read_only() in [True, False]
968
- assert nodes[type_data].is_active() in [True, False]
969
-
970
-
971
- def get_child_nodes(node, nodes, type_list):
972
- if node.is_active():
973
- if isinstance(node, flobject.Group):
974
- for item in node.child_names:
975
- get_child_nodes(getattr(node, item), nodes, type_list)
976
- else:
977
- node_type = node.__class__.__bases__[0].__name__
978
- if node_type in type_list:
979
- type_list.remove(node_type)
980
- nodes[node_type] = node
981
- if not type_list:
982
- return
983
-
984
-
985
- @pytest.mark.fluent_version("latest")
986
- def test_strings_with_allowed_values(static_mixer_settings_session):
987
- solver = static_mixer_settings_session
988
-
989
- with pytest.raises(AttributeError) as e:
990
- solver.file.auto_save.root_name.allowed_values()
991
- assert e.value.args[0] == "'root_name' object has no attribute 'allowed_values'"
992
-
993
- string_with_allowed_values = solver.setup.general.solver.type.allowed_values()
994
- assert string_with_allowed_values == [
995
- "pressure-based",
996
- "density-based-implicit",
997
- "density-based-explicit",
998
- ]
999
-
1000
-
1001
- @pytest.mark.fluent_version(">=24.2")
1002
- def test_parent_class_attributes(static_mixer_settings_session):
1003
- solver = static_mixer_settings_session
1004
- assert solver.setup.models.energy.enabled
1005
- with pytest.raises(AttributeError):
1006
- solver.setup.models.energy.__class__.enabled
1007
-
1008
-
1009
- def _check_vector_units(obj, units):
1010
- assert obj.units() == units
1011
- state_with_units = obj.state_with_units()
1012
- state = obj.get_state()
1013
- assert len(state_with_units) == 2
1014
- assert len(state) == len(state_with_units[0])
1015
- assert all(x == y for x, y in zip(state, state_with_units[0]))
1016
- assert units == state_with_units[1]
1017
- assert obj.as_quantity() == ansys.units.Quantity(obj.get_state(), units)
1018
-
1019
-
1020
- @pytest.mark.fluent_version(">=24.1")
1021
- def test_ansys_units_integration(mixing_elbow_settings_session):
1022
- solver = mixing_elbow_settings_session
1023
- assert isinstance(solver.settings.state_with_units(), dict)
1024
- hot_inlet = solver.setup.boundary_conditions.velocity_inlet["hot-inlet"]
1025
- turbulence = hot_inlet.turbulence
1026
- turbulence.turbulent_specification = "Intensity and Hydraulic Diameter"
1027
- hydraulic_diameter = turbulence.hydraulic_diameter
1028
- hydraulic_diameter.set_state("1 [in]")
1029
- assert hydraulic_diameter() == "1 [in]"
1030
- assert hydraulic_diameter.as_quantity() is None
1031
- assert hydraulic_diameter.state_with_units() == ("1 [in]", "m")
1032
- assert hydraulic_diameter.units() == "m"
1033
- turbulent_intensity = turbulence.turbulent_intensity
1034
- turbulent_intensity.set_state(0.2)
1035
- assert turbulent_intensity() == 0.2
1036
- assert turbulent_intensity.as_quantity() == ansys.units.Quantity(0.2, "")
1037
- turbulent_intensity.set_state(ansys.units.Quantity(0.1, ""))
1038
- assert turbulent_intensity.state_with_units() == (0.1, "")
1039
- hydraulic_diameter.set_state(1)
1040
- assert hydraulic_diameter.as_quantity() == ansys.units.Quantity(1, "m")
1041
- assert hydraulic_diameter.state_with_units() == (1.0, "m")
1042
- assert hydraulic_diameter.units() == "m"
1043
- hydraulic_diameter.set_state(ansys.units.Quantity(1, "in"))
1044
- assert hydraulic_diameter.as_quantity() == ansys.units.Quantity(0.0254, "m")
1045
- assert hydraulic_diameter.state_with_units() == (0.0254, "m")
1046
- assert hydraulic_diameter.units() == "m"
1047
- assert hydraulic_diameter() == 0.0254
1048
- velocity = ansys.units.Quantity(
1049
- 12.0, ansys.units.UnitRegistry().ft
1050
- ) / ansys.units.Quantity(3.0, ansys.units.UnitRegistry().s)
1051
- hot_inlet.momentum.velocity.value = velocity
1052
- assert hot_inlet.momentum.velocity.value.as_quantity() == velocity
1053
- velocity = (1.0, "m s^-1")
1054
- hot_inlet.momentum.velocity = velocity
1055
- assert hot_inlet.momentum.velocity.value.state_with_units() == velocity
1056
- velocity = ansys.units.Quantity(12.0, "m s^-1")
1057
- hot_inlet.momentum.velocity = velocity
1058
- assert hot_inlet.momentum.velocity.value() == velocity.value
1059
- assert hot_inlet.momentum.velocity.value.as_quantity() == velocity
1060
- assert hot_inlet.momentum.velocity.state_with_units() == {
1061
- "option": "value",
1062
- "value": (12.0, "m s^-1"),
1063
- }
1064
- clip_factor = solver.setup.models.viscous.options.production_limiter.clip_factor
1065
- clip_factor.set_state(1.2)
1066
- assert clip_factor() == 1.2
1067
- assert clip_factor.as_quantity() == ansys.units.Quantity(1.2, "")
1068
- assert clip_factor.state_with_units() == (1.2, "")
1069
- assert clip_factor.units() == ""
1070
- clip_factor.set_state(ansys.units.Quantity(1.8, ""))
1071
- assert clip_factor.as_quantity() == ansys.units.Quantity(1.8, "")
1072
- assert clip_factor.state_with_units() == (1.8, "")
1073
- assert clip_factor.units() == ""
1074
-
1075
- _check_vector_units(
1076
- solver.setup.general.operating_conditions.reference_pressure_location, "m"
1077
- )
1078
- _check_vector_units(
1079
- solver.setup.reference_frames[
1080
- "global"
1081
- ].initial_state.orientation.first_axis.axis_to.vector,
1082
- "",
1083
- )
1084
-
1085
-
1086
- @pytest.mark.fluent_version(">=24.2")
1087
- def test_ansys_units_integration_nested_state(mixing_elbow_settings_session):
1088
- solver = mixing_elbow_settings_session
1089
-
1090
- hot_inlet = solver.setup.boundary_conditions.velocity_inlet["hot-inlet"]
1091
-
1092
- assert hot_inlet.state_with_units() == {
1093
- "momentum": {
1094
- "initial_gauge_pressure": {"option": "value", "value": (0, "Pa")},
1095
- "reference_frame": "Absolute",
1096
- "velocity": {"option": "value", "value": (0, "m s^-1")},
1097
- "velocity_specification_method": "Magnitude, Normal to Boundary",
1098
- },
1099
- "name": "hot-inlet",
1100
- "turbulence": {
1101
- "turbulent_intensity": (0.05, ""),
1102
- "turbulent_specification": "Intensity and Viscosity Ratio",
1103
- "turbulent_viscosity_ratio": (10, None),
1104
- },
1105
- } or {
1106
- "momentum": {
1107
- "initial_gauge_pressure": {"option": "value", "value": (0, "Pa")},
1108
- "reference_frame": "Absolute",
1109
- "velocity": {"option": "value", "value": (0, "m s^-1")},
1110
- "velocity_specification_method": "Magnitude, Normal to Boundary",
1111
- },
1112
- "name": "hot-inlet",
1113
- "turbulence": {
1114
- "turbulent_specification": "Intensity and Viscosity Ratio",
1115
- "turbulent_intensity": (0.05, ""),
1116
- "turbulent_viscosity_ratio": (10, None),
1117
- },
1118
- }
1119
-
1120
-
1121
- @pytest.mark.fluent_version(">=24.2")
1122
- def test_bug_1001124_quantity_assignment(mixing_elbow_settings_session):
1123
- speed = ansys.units.Quantity(100, "m s^-1")
1124
- solver = mixing_elbow_settings_session
1125
- solver.setup.boundary_conditions.velocity_inlet[
1126
- "hot-inlet"
1127
- ].momentum.velocity.value = speed.value
1128
- assert (
1129
- solver.setup.boundary_conditions.velocity_inlet[
1130
- "hot-inlet"
1131
- ].momentum.velocity.value()
1132
- == speed.value
1133
- )
1134
- solver.setup.boundary_conditions.velocity_inlet["hot-inlet"].momentum.velocity = (
1135
- speed
1136
- )
1137
- assert (
1138
- solver.setup.boundary_conditions.velocity_inlet[
1139
- "hot-inlet"
1140
- ].momentum.velocity.value()
1141
- == speed.value
1142
- )
1143
-
1144
-
1145
- def test_assert_type():
1146
- types = [
1147
- bool,
1148
- int,
1149
- flobject.RealType,
1150
- str,
1151
- flobject.BoolListType,
1152
- flobject.IntListType,
1153
- flobject.RealListType,
1154
- flobject.StringListType,
1155
- flobject.RealVectorType,
1156
- flobject.DictStateType,
1157
- ]
1158
- vals = [
1159
- False,
1160
- 1,
1161
- 1.0,
1162
- "a",
1163
- [False, True],
1164
- [1, 2],
1165
- [1.0, 2.0],
1166
- ["a", "b"],
1167
- (1.0, 2.0, 3.0),
1168
- {"a": 1},
1169
- ]
1170
- subtypes = {
1171
- bool: (int,),
1172
- str: (flobject.RealType,),
1173
- flobject.BoolListType: (flobject.IntListType,),
1174
- flobject.StringListType: (flobject.RealListType,),
1175
- }
1176
- for i_t, tp in enumerate(types):
1177
- for i_v, val in enumerate(vals):
1178
- if i_t == i_v:
1179
- flobject.assert_type(val, tp)
1180
- else:
1181
- subtype = subtypes.get(types[i_v])
1182
- if subtype and types[i_t] in subtype:
1183
- flobject.assert_type(val, tp)
1184
- else:
1185
- with pytest.raises(TypeError):
1186
- flobject.assert_type(val, tp)
1187
-
1188
-
1189
- def test_static_info_hash_identity(new_solver_session):
1190
- solver = new_solver_session
1191
- hash1 = _gethash(solver._settings_service.get_static_info())
1192
- hash2 = _gethash(solver._settings_service.get_static_info())
1193
- assert hash1 == hash2
1194
-
1195
-
1196
- @pytest.mark.codegen_required
1197
- def test_no_hash_mismatch(new_solver_session, caplog):
1198
- caplog.clear()
1199
- new_solver_session.setup
1200
- assert all(["Mismatch" not in record.message for record in caplog.records])
1201
-
1202
-
1203
- @pytest.mark.fluent_version(">=24.2")
1204
- def test_default_argument_names_for_commands(static_mixer_settings_session):
1205
- solver = static_mixer_settings_session
1206
-
1207
- if solver.get_fluent_version() >= FluentVersion.v251:
1208
- assert set(solver.results.graphics.contour.command_names) == {
1209
- "create",
1210
- "delete",
1211
- "rename",
1212
- "list",
1213
- "list_properties",
1214
- "make_a_copy",
1215
- "display",
1216
- "add_to_graphics",
1217
- "clear_history",
1218
- }
1219
- else:
1220
- assert set(solver.results.graphics.contour.command_names) == {
1221
- "delete",
1222
- "rename",
1223
- "list",
1224
- "list_properties",
1225
- "make_a_copy",
1226
- "display",
1227
- "copy",
1228
- "add_to_graphics",
1229
- "clear_history",
1230
- }
1231
-
1232
- assert solver.results.graphics.contour.rename.argument_names == ["new", "old"]
1233
- assert solver.results.graphics.contour.delete.argument_names == ["name_list"]
1234
- # The following is the default behavior when no arguments are associated with the command.
1235
- assert solver.results.graphics.contour.list.argument_names == []