ansys-fluent-core 0.27.dev1__py3-none-any.whl → 0.28.dev0__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.
- ansys/fluent/core/__init__.py +22 -9
- ansys/fluent/core/_version.py +5 -2
- ansys/fluent/core/codegen/__init__.py +0 -3
- ansys/fluent/core/codegen/allapigen.py +1 -5
- ansys/fluent/core/codegen/builtin_settingsgen.py +44 -10
- ansys/fluent/core/codegen/datamodelgen.py +53 -12
- ansys/fluent/core/codegen/settingsgen.py +21 -12
- ansys/fluent/core/codegen/settingsgen_old.py +2 -2
- ansys/fluent/core/codegen/tuigen.py +1 -1
- ansys/fluent/core/codegen/write_settings_yaml.py +3 -4
- ansys/fluent/core/data_model_cache.py +132 -70
- ansys/fluent/core/docs/README.rst +2 -2
- ansys/fluent/core/examples/downloads.py +3 -5
- ansys/fluent/core/exceptions.py +1 -0
- ansys/fluent/core/file_session.py +59 -131
- ansys/fluent/core/filereader/case_file.py +17 -17
- ansys/fluent/core/filereader/casereader.py +2 -1
- ansys/fluent/core/filereader/data_file.py +7 -7
- ansys/fluent/core/filereader/lispy.py +6 -1
- ansys/fluent/core/fluent_connection.py +35 -7
- ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
- ansys/fluent/core/generated/datamodel_222/PMFileManagement.py +2 -2
- ansys/fluent/core/generated/datamodel_222/PartManagement.py +28 -28
- ansys/fluent/core/generated/datamodel_222/meshing.py +301 -301
- ansys/fluent/core/generated/datamodel_222/workflow.py +9 -9
- ansys/fluent/core/generated/datamodel_231/PMFileManagement.py +2 -2
- ansys/fluent/core/generated/datamodel_231/PartManagement.py +55 -55
- ansys/fluent/core/generated/datamodel_231/flicing.py +51 -51
- ansys/fluent/core/generated/datamodel_231/meshing.py +317 -317
- ansys/fluent/core/generated/datamodel_231/solverworkflow.py +51 -51
- ansys/fluent/core/generated/datamodel_231/workflow.py +9 -9
- ansys/fluent/core/generated/datamodel_232/PMFileManagement.py +2 -2
- ansys/fluent/core/generated/datamodel_232/PartManagement.py +55 -55
- ansys/fluent/core/generated/datamodel_232/flicing.py +51 -51
- ansys/fluent/core/generated/datamodel_232/meshing.py +335 -335
- ansys/fluent/core/generated/datamodel_232/solverworkflow.py +58 -58
- ansys/fluent/core/generated/datamodel_232/workflow.py +9 -9
- ansys/fluent/core/generated/datamodel_241/PMFileManagement.py +2 -2
- ansys/fluent/core/generated/datamodel_241/PartManagement.py +57 -57
- ansys/fluent/core/generated/datamodel_241/flicing.py +51 -51
- ansys/fluent/core/generated/datamodel_241/meshing.py +361 -361
- ansys/fluent/core/generated/datamodel_241/solverworkflow.py +58 -58
- ansys/fluent/core/generated/datamodel_241/workflow.py +9 -9
- ansys/fluent/core/generated/datamodel_242/MeshingUtilities.py +240 -240
- ansys/fluent/core/generated/datamodel_242/PMFileManagement.py +2 -2
- ansys/fluent/core/generated/datamodel_242/PartManagement.py +60 -60
- ansys/fluent/core/generated/datamodel_242/flicing.py +51 -51
- ansys/fluent/core/generated/datamodel_242/meshing.py +371 -371
- ansys/fluent/core/generated/datamodel_242/solverworkflow.py +58 -58
- ansys/fluent/core/generated/datamodel_242/workflow.py +9 -9
- ansys/fluent/core/generated/datamodel_251/MeshingUtilities.py +244 -244
- ansys/fluent/core/generated/datamodel_251/PMFileManagement.py +2 -2
- ansys/fluent/core/generated/datamodel_251/PartManagement.py +60 -60
- ansys/fluent/core/generated/datamodel_251/flicing.py +51 -51
- ansys/fluent/core/generated/datamodel_251/meshing.py +384 -382
- ansys/fluent/core/generated/datamodel_251/preferences.py +7 -0
- ansys/fluent/core/generated/datamodel_251/solverworkflow.py +58 -58
- ansys/fluent/core/generated/datamodel_251/workflow.py +10 -10
- ansys/fluent/core/generated/datamodel_252/MeshingUtilities.py +3664 -0
- ansys/fluent/core/generated/datamodel_252/PMFileManagement.py +288 -0
- ansys/fluent/core/generated/datamodel_252/PartManagement.py +2588 -0
- ansys/fluent/core/generated/datamodel_252/flicing.py +7972 -0
- ansys/fluent/core/generated/datamodel_252/meshing.py +2644 -0
- ansys/fluent/core/generated/datamodel_252/preferences.py +2760 -0
- ansys/fluent/core/generated/datamodel_252/solverworkflow.py +479 -0
- ansys/fluent/core/generated/datamodel_252/workflow.py +466 -0
- ansys/fluent/core/generated/fluent_version_251.py +4 -4
- ansys/fluent/core/generated/fluent_version_252.py +5 -0
- ansys/fluent/core/generated/meshing/tui_251.py +1139 -1179
- ansys/fluent/core/generated/meshing/tui_252.py +10181 -0
- ansys/fluent/core/generated/solver/settings_222.py +3 -3
- ansys/fluent/core/generated/solver/settings_231.py +4 -4
- ansys/fluent/core/generated/solver/settings_232.py +5 -5
- ansys/fluent/core/generated/solver/settings_241.py +5 -5
- ansys/fluent/core/generated/solver/settings_242.py +1185 -1185
- ansys/fluent/core/generated/solver/settings_251.py +1847 -1652
- ansys/fluent/core/generated/solver/settings_251.pyi +237 -211
- ansys/fluent/core/generated/solver/settings_252.py +90369 -0
- ansys/fluent/core/generated/solver/settings_252.pyi +63778 -0
- ansys/fluent/core/generated/solver/settings_builtin.py +612 -1
- ansys/fluent/core/generated/solver/settings_builtin.pyi +235 -0
- ansys/fluent/core/generated/solver/tui_251.py +2283 -2103
- ansys/fluent/core/generated/solver/tui_252.py +37720 -0
- ansys/fluent/core/journaling.py +1 -1
- ansys/fluent/core/launcher/error_handler.py +3 -0
- ansys/fluent/core/launcher/fluent_container.py +5 -0
- ansys/fluent/core/launcher/launcher.py +1 -2
- ansys/fluent/core/launcher/launcher_utils.py +17 -6
- ansys/fluent/core/launcher/process_launch_string.py +3 -3
- ansys/fluent/core/launcher/pyfluent_enums.py +1 -1
- ansys/fluent/core/launcher/slurm_launcher.py +2 -1
- ansys/fluent/core/launcher/standalone_launcher.py +11 -5
- ansys/fluent/core/launcher/watchdog.py +1 -1
- ansys/fluent/core/launcher/watchdog_exec +6 -3
- ansys/fluent/core/logging.py +1 -5
- ansys/fluent/core/parametric.py +6 -3
- ansys/fluent/core/post_objects/meta.py +1 -39
- ansys/fluent/core/post_objects/post_helper.py +4 -3
- ansys/fluent/core/post_objects/post_object_definitions.py +12 -7
- ansys/fluent/core/post_objects/post_objects_container.py +39 -2
- ansys/fluent/core/rpvars.py +2 -1
- ansys/fluent/core/scheduler/machine_list.py +3 -1
- ansys/fluent/core/search.py +109 -262
- ansys/fluent/core/services/__init__.py +3 -0
- ansys/fluent/core/services/api_upgrade.py +1 -0
- ansys/fluent/core/services/batch_ops.py +3 -1
- ansys/fluent/core/services/datamodel_se.py +37 -30
- ansys/fluent/core/services/datamodel_tui.py +8 -3
- ansys/fluent/core/services/deprecated_field_data.py +691 -0
- ansys/fluent/core/services/field_data.py +67 -357
- ansys/fluent/core/services/interceptors.py +6 -4
- ansys/fluent/core/services/reduction.py +1 -2
- ansys/fluent/core/services/scheme_eval.py +2 -3
- ansys/fluent/core/services/solution_variables.py +46 -48
- ansys/fluent/core/session.py +6 -4
- ansys/fluent/core/session_meshing.pyi +5 -0
- ansys/fluent/core/session_pure_meshing.pyi +4 -1
- ansys/fluent/core/session_solver_lite.py +2 -1
- ansys/fluent/core/solver/flobject.py +179 -207
- ansys/fluent/core/solver/flunits.py +65 -56
- ansys/fluent/core/solver/function/reduction.py +9 -29
- ansys/fluent/core/solver/settings_builtin_bases.py +28 -22
- ansys/fluent/core/solver/settings_builtin_data.py +105 -1
- ansys/fluent/core/solver/settings_external.py +0 -28
- ansys/fluent/core/streaming_services/field_data_streaming.py +1 -0
- ansys/fluent/core/streaming_services/monitor_streaming.py +0 -1
- ansys/fluent/core/systemcoupling.py +145 -14
- ansys/fluent/core/utils/__init__.py +18 -2
- ansys/fluent/core/utils/dump_session_data.py +7 -4
- ansys/fluent/core/utils/execution.py +2 -2
- ansys/fluent/core/utils/file_transfer_service.py +37 -42
- ansys/fluent/core/utils/fluent_version.py +20 -2
- ansys/fluent/core/utils/networking.py +39 -1
- ansys/fluent/core/workflow.py +3 -15
- ansys/fluent/tests/conftest.py +89 -7
- ansys/fluent/tests/fluent/test_version/test.py +2 -0
- ansys/fluent/tests/fluent_fixtures.py +195 -0
- ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +7 -7
- ansys/fluent/tests/parametric/test_parametric_workflow.py +14 -4
- ansys/fluent/tests/test_builtin_settings.py +28 -0
- ansys/fluent/tests/test_cad_to_post_ftm.py +1 -3
- ansys/fluent/tests/test_cad_to_post_wtm.py +1 -1
- ansys/fluent/tests/test_casereader.py +1 -1
- ansys/fluent/tests/test_codegen.py +116 -6
- ansys/fluent/tests/test_data_model_cache.py +1 -1
- ansys/fluent/tests/test_datamodel_service.py +14 -19
- ansys/fluent/tests/test_field_data.py +93 -45
- ansys/fluent/tests/test_file_session.py +32 -29
- ansys/fluent/tests/test_flobject.py +16 -58
- ansys/fluent/tests/test_fluent_fixes.py +5 -5
- ansys/fluent/tests/test_fluent_session.py +11 -8
- ansys/fluent/tests/test_fluent_version.py +1 -1
- ansys/fluent/tests/test_launcher.py +22 -5
- ansys/fluent/tests/test_launcher_remote.py +80 -4
- ansys/fluent/tests/test_meshing_utilities.py +93 -44
- ansys/fluent/tests/test_meshing_workflow.py +6 -6
- ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +1 -1
- ansys/fluent/tests/test_new_meshing_workflow.py +42 -3
- ansys/fluent/tests/test_preferences.py +6 -6
- ansys/fluent/tests/test_reduction.py +61 -30
- ansys/fluent/tests/test_rp_vars.py +1 -1
- ansys/fluent/tests/test_search.py +53 -200
- ansys/fluent/tests/test_session.py +18 -13
- ansys/fluent/tests/test_settings_api.py +93 -29
- ansys/fluent/tests/test_settings_reader.py +1 -1
- ansys/fluent/tests/test_solver_monitors.py +1 -1
- ansys/fluent/tests/test_solvermode/test_calculationactivities.py +4 -4
- ansys/fluent/tests/test_solvermode/test_controls.py +3 -3
- ansys/fluent/tests/test_solvermode/test_methods.py +1 -1
- ansys/fluent/tests/test_solvermode/test_models.py +3 -3
- ansys/fluent/tests/test_systemcoupling.py +33 -5
- ansys/fluent/tests/test_topy.py +2 -2
- ansys/fluent/tests/test_tui_api.py +5 -5
- ansys/fluent/tests/test_utils.py +1 -1
- {ansys_fluent_core-0.27.dev1.dist-info → ansys_fluent_core-0.28.dev0.dist-info}/METADATA +6 -17
- ansys_fluent_core-0.28.dev0.dist-info/RECORD +291 -0
- ansys/fluent/core/generated/api_tree_222.pickle +0 -0
- ansys/fluent/core/generated/api_tree_231.pickle +0 -0
- ansys/fluent/core/generated/api_tree_232.pickle +0 -0
- ansys/fluent/core/generated/api_tree_241.pickle +0 -0
- ansys/fluent/core/generated/api_tree_242.pickle +0 -0
- ansys/fluent/core/generated/api_tree_251.pickle +0 -0
- ansys/fluent/tests/test_tests_util.py +0 -47
- ansys/fluent/tests/util/__init__.py +0 -38
- ansys_fluent_core-0.27.dev1.dist-info/RECORD +0 -283
- {ansys_fluent_core-0.27.dev1.dist-info → ansys_fluent_core-0.28.dev0.dist-info}/AUTHORS +0 -0
- {ansys_fluent_core-0.27.dev1.dist-info → ansys_fluent_core-0.28.dev0.dist-info}/LICENSE +0 -0
- {ansys_fluent_core-0.27.dev1.dist-info → ansys_fluent_core-0.28.dev0.dist-info}/WHEEL +0 -0
|
@@ -5,7 +5,7 @@ from contextlib import contextmanager
|
|
|
5
5
|
import copy
|
|
6
6
|
from enum import Enum
|
|
7
7
|
from threading import RLock
|
|
8
|
-
from typing import Any, Dict, List
|
|
8
|
+
from typing import Any, Dict, List, Optional
|
|
9
9
|
|
|
10
10
|
from ansys.api.fluent.v0.variant_pb2 import Variant
|
|
11
11
|
from ansys.fluent.core.utils.fluent_version import FluentVersion
|
|
@@ -31,8 +31,8 @@ class NameKey(Enum):
|
|
|
31
31
|
DISPLAY = "_name_"
|
|
32
32
|
|
|
33
33
|
def __invert__(self):
|
|
34
|
-
|
|
35
|
-
return
|
|
34
|
+
lst = list(NameKey)
|
|
35
|
+
return lst[~lst.index(self)]
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
class _CacheImpl:
|
|
@@ -136,6 +136,7 @@ class DataModelCache:
|
|
|
136
136
|
use_display_name = False
|
|
137
137
|
|
|
138
138
|
def __init__(self):
|
|
139
|
+
"""Initialize datamodel cache."""
|
|
139
140
|
self.rules_str_to_cache = defaultdict(dict)
|
|
140
141
|
self.rules_str_to_config = {}
|
|
141
142
|
self._locks = {}
|
|
@@ -205,28 +206,34 @@ class DataModelCache:
|
|
|
205
206
|
source: Dict[str, StateType],
|
|
206
207
|
key: str,
|
|
207
208
|
state: Variant,
|
|
208
|
-
|
|
209
|
+
updater_fn,
|
|
209
210
|
rules_str: str,
|
|
210
211
|
version,
|
|
211
212
|
):
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
213
|
+
# Helper function to update the source with the state value
|
|
214
|
+
def update_source_with_state(state_field):
|
|
215
|
+
if state.HasField(state_field):
|
|
216
|
+
updater_fn(source, key, getattr(state, state_field))
|
|
217
|
+
return True
|
|
218
|
+
return False
|
|
219
|
+
|
|
220
|
+
# Check for basic state types
|
|
221
|
+
for state_type in [
|
|
222
|
+
"bool_state",
|
|
223
|
+
"int64_state",
|
|
224
|
+
"double_state",
|
|
225
|
+
"string_state",
|
|
226
|
+
"bool_vector_state",
|
|
227
|
+
"int64_vector_state",
|
|
228
|
+
"double_vector_state",
|
|
229
|
+
"string_vector_state",
|
|
230
|
+
]:
|
|
231
|
+
if update_source_with_state(state_type):
|
|
232
|
+
return
|
|
233
|
+
|
|
234
|
+
# Handle variant vector state
|
|
235
|
+
if state.HasField("variant_vector_state"):
|
|
236
|
+
updater_fn(source, key, [])
|
|
230
237
|
for item in state.variant_vector_state.item:
|
|
231
238
|
self._update_cache_from_variant_state(
|
|
232
239
|
rules,
|
|
@@ -237,34 +244,28 @@ class DataModelCache:
|
|
|
237
244
|
rules_str + "/" + key.split(":", maxsplit=1)[0],
|
|
238
245
|
version,
|
|
239
246
|
)
|
|
240
|
-
|
|
247
|
+
return
|
|
248
|
+
|
|
249
|
+
# Handle variant map state
|
|
250
|
+
if state.HasField("variant_map_state"):
|
|
241
251
|
internal_names_as_keys = (
|
|
242
252
|
self.get_config(rules, "name_key") == NameKey.INTERNAL
|
|
243
253
|
)
|
|
254
|
+
|
|
255
|
+
# Determine the appropriate key
|
|
244
256
|
if ":" in key:
|
|
245
257
|
type_, iname = key.split(":", maxsplit=1)
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
and isinstance(v1, dict)
|
|
250
|
-
and v1.get(NameKey.INTERNAL.value) == iname
|
|
251
|
-
):
|
|
252
|
-
key = k1
|
|
253
|
-
break
|
|
254
|
-
else: # new named object
|
|
255
|
-
if internal_names_as_keys:
|
|
256
|
-
source[key] = {}
|
|
257
|
-
else:
|
|
258
|
-
name = state.variant_map_state.item[
|
|
259
|
-
NameKey.DISPLAY.value
|
|
260
|
-
].string_state
|
|
261
|
-
key = f"{type_}:{name}"
|
|
262
|
-
source[key] = {NameKey.INTERNAL.value: iname}
|
|
258
|
+
key = self._determine_key(
|
|
259
|
+
source, internal_names_as_keys, key, state, type_, iname
|
|
260
|
+
)
|
|
263
261
|
else:
|
|
264
262
|
if key not in source:
|
|
265
263
|
source[key] = {}
|
|
264
|
+
|
|
266
265
|
if version and _is_dict_parameter_type(version, rules, rules_str):
|
|
267
266
|
source[key] = {}
|
|
267
|
+
|
|
268
|
+
# Update the source with items from the variant map state
|
|
268
269
|
if state.variant_map_state.item:
|
|
269
270
|
source = source[key]
|
|
270
271
|
for k, v in state.variant_map_state.item.items():
|
|
@@ -279,8 +280,40 @@ class DataModelCache:
|
|
|
279
280
|
)
|
|
280
281
|
else:
|
|
281
282
|
source[key] = {}
|
|
283
|
+
|
|
284
|
+
# Default case when no fields are matched
|
|
282
285
|
else:
|
|
283
|
-
|
|
286
|
+
updater_fn(source, key, None)
|
|
287
|
+
|
|
288
|
+
def _determine_key(
|
|
289
|
+
self,
|
|
290
|
+
source: Dict[str, StateType],
|
|
291
|
+
internal_names_as_keys: bool,
|
|
292
|
+
key: str,
|
|
293
|
+
state: Variant,
|
|
294
|
+
type_: str,
|
|
295
|
+
iname: str,
|
|
296
|
+
) -> str:
|
|
297
|
+
"""Determine the appropriate key based on internal naming conventions."""
|
|
298
|
+
for k1, v1 in source.items():
|
|
299
|
+
if (internal_names_as_keys and k1 == key) or (
|
|
300
|
+
(not internal_names_as_keys)
|
|
301
|
+
and isinstance(v1, dict)
|
|
302
|
+
and v1.get(NameKey.INTERNAL.value) == iname
|
|
303
|
+
):
|
|
304
|
+
return k1 # Found a matching key
|
|
305
|
+
|
|
306
|
+
# If no match found and internal naming is used
|
|
307
|
+
if internal_names_as_keys:
|
|
308
|
+
source[key] = {}
|
|
309
|
+
return key
|
|
310
|
+
|
|
311
|
+
# If no match found and external naming is used
|
|
312
|
+
name = state.variant_map_state.item[NameKey.DISPLAY.value].string_state
|
|
313
|
+
new_key = f"{type_}:{name}"
|
|
314
|
+
source[new_key] = {NameKey.INTERNAL.value: iname}
|
|
315
|
+
|
|
316
|
+
return new_key
|
|
284
317
|
|
|
285
318
|
def update_cache(
|
|
286
319
|
self, rules: str, state: Variant, deleted_paths: List[str], version=None
|
|
@@ -299,37 +332,16 @@ class DataModelCache:
|
|
|
299
332
|
Fluent version
|
|
300
333
|
"""
|
|
301
334
|
cache = self.rules_str_to_cache[rules]
|
|
335
|
+
|
|
302
336
|
with self._with_lock(rules):
|
|
303
337
|
internal_names_as_keys = (
|
|
304
338
|
self.get_config(rules, "name_key") == NameKey.INTERNAL
|
|
305
339
|
)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
_, iname = comp.split(":", maxsplit=1)
|
|
312
|
-
key_to_del = None
|
|
313
|
-
for k, v in sub_cache.items():
|
|
314
|
-
if (internal_names_as_keys and k == comp) or (
|
|
315
|
-
(not internal_names_as_keys)
|
|
316
|
-
and isinstance(v, dict)
|
|
317
|
-
and v.get(NameKey.INTERNAL.value) == iname
|
|
318
|
-
):
|
|
319
|
-
if i == len(comps) - 1:
|
|
320
|
-
key_to_del = k
|
|
321
|
-
else:
|
|
322
|
-
sub_cache = v
|
|
323
|
-
break
|
|
324
|
-
else:
|
|
325
|
-
break
|
|
326
|
-
if key_to_del:
|
|
327
|
-
del sub_cache[key_to_del]
|
|
328
|
-
else:
|
|
329
|
-
if comp in sub_cache:
|
|
330
|
-
sub_cache = sub_cache[comp]
|
|
331
|
-
else:
|
|
332
|
-
break
|
|
340
|
+
|
|
341
|
+
# Process deleted paths
|
|
342
|
+
self._process_deleted_paths(cache, deleted_paths, internal_names_as_keys)
|
|
343
|
+
|
|
344
|
+
# Update cache with new state items
|
|
333
345
|
for k, v in state.variant_map_state.item.items():
|
|
334
346
|
self._update_cache_from_variant_state(
|
|
335
347
|
rules,
|
|
@@ -341,6 +353,56 @@ class DataModelCache:
|
|
|
341
353
|
version,
|
|
342
354
|
)
|
|
343
355
|
|
|
356
|
+
def _process_deleted_paths(
|
|
357
|
+
self,
|
|
358
|
+
cache: Dict[str, Any],
|
|
359
|
+
deleted_paths: List[str],
|
|
360
|
+
internal_names_as_keys: bool,
|
|
361
|
+
):
|
|
362
|
+
"""Process and delete paths from the cache based on the deleted paths list."""
|
|
363
|
+
for deleted_path in deleted_paths:
|
|
364
|
+
comps = [x for x in deleted_path.split("/") if x]
|
|
365
|
+
self._delete_from_cache(cache, comps, internal_names_as_keys)
|
|
366
|
+
|
|
367
|
+
def _delete_from_cache(
|
|
368
|
+
self, sub_cache: Dict[str, Any], comps: List[str], internal_names_as_keys: bool
|
|
369
|
+
):
|
|
370
|
+
"""Recursively delete components from the cache."""
|
|
371
|
+
for i, comp in enumerate(comps):
|
|
372
|
+
if ":" in comp:
|
|
373
|
+
_, iname = comp.split(":", maxsplit=1)
|
|
374
|
+
key_to_del = self._find_key_to_delete(
|
|
375
|
+
sub_cache, comp, iname, i == len(comps) - 1, internal_names_as_keys
|
|
376
|
+
)
|
|
377
|
+
if key_to_del:
|
|
378
|
+
del sub_cache[key_to_del]
|
|
379
|
+
return # Exit after deletion
|
|
380
|
+
else:
|
|
381
|
+
if comp in sub_cache:
|
|
382
|
+
sub_cache = sub_cache[comp]
|
|
383
|
+
else:
|
|
384
|
+
break
|
|
385
|
+
|
|
386
|
+
def _find_key_to_delete(
|
|
387
|
+
self,
|
|
388
|
+
sub_cache: Dict[str, Any],
|
|
389
|
+
comp: str,
|
|
390
|
+
iname: str,
|
|
391
|
+
is_last_component: bool,
|
|
392
|
+
internal_names_as_keys: bool,
|
|
393
|
+
) -> Optional[str]:
|
|
394
|
+
"""Find the key to delete from the sub-cache."""
|
|
395
|
+
for k, v in sub_cache.items():
|
|
396
|
+
if (internal_names_as_keys and k == comp) or (
|
|
397
|
+
(not internal_names_as_keys)
|
|
398
|
+
and isinstance(v, dict)
|
|
399
|
+
and v.get(NameKey.INTERNAL.value) == iname
|
|
400
|
+
):
|
|
401
|
+
return (
|
|
402
|
+
k if is_last_component else None
|
|
403
|
+
) # Return key if it's the last component
|
|
404
|
+
return None # No key found to delete
|
|
405
|
+
|
|
344
406
|
@staticmethod
|
|
345
407
|
def _dm_path_comp(comp):
|
|
346
408
|
return ":".join(comp) if comp[1] else comp[0]
|
|
@@ -367,11 +429,11 @@ class DataModelCache:
|
|
|
367
429
|
|
|
368
430
|
Returns
|
|
369
431
|
-------
|
|
370
|
-
|
|
432
|
+
Any
|
|
371
433
|
cached state
|
|
372
434
|
"""
|
|
373
435
|
name_key_in_config = self.get_config(rules, "name_key")
|
|
374
|
-
if name_key
|
|
436
|
+
if name_key is None:
|
|
375
437
|
name_key = name_key_in_config
|
|
376
438
|
cache = self.rules_str_to_cache[rules]
|
|
377
439
|
with self._with_lock(rules):
|
|
@@ -67,7 +67,7 @@ To reach the project support team, email `pyansys.core@ansys.com <pyansys.core@a
|
|
|
67
67
|
Installation
|
|
68
68
|
------------
|
|
69
69
|
The ``ansys-fluent-core`` package supports Python 3.9 through Python
|
|
70
|
-
3.
|
|
70
|
+
3.13 on Windows and Linux.
|
|
71
71
|
|
|
72
72
|
Install the latest release from `PyPI
|
|
73
73
|
<https://pypi.org/project/ansys-fluent-core/>`_ with:
|
|
@@ -99,7 +99,7 @@ example, the installer automatically sets the ``AWP_ROOT232`` environment variab
|
|
|
99
99
|
to ``C:\Program Files\ANSYS Inc\v232``.
|
|
100
100
|
|
|
101
101
|
On Linux, the required environment variable is not set automatically, and can be set for the
|
|
102
|
-
current user in the current shell session, using Fluent 2023
|
|
102
|
+
current user in the current shell session, using Fluent 2023 R2 in the default installation
|
|
103
103
|
directory as an example, before running PyFluent, with:
|
|
104
104
|
|
|
105
105
|
.. code:: console
|
|
@@ -7,9 +7,8 @@ import re
|
|
|
7
7
|
import shutil
|
|
8
8
|
import zipfile
|
|
9
9
|
|
|
10
|
-
import requests
|
|
11
|
-
|
|
12
10
|
import ansys.fluent.core as pyfluent
|
|
11
|
+
from ansys.fluent.core.utils.networking import check_url_exists, get_url_content
|
|
13
12
|
|
|
14
13
|
logger = logging.getLogger("pyfluent.networking")
|
|
15
14
|
|
|
@@ -86,7 +85,7 @@ def _retrieve_file(
|
|
|
86
85
|
|
|
87
86
|
# Download file
|
|
88
87
|
logger.info(f'Downloading URL: "{url}"')
|
|
89
|
-
content =
|
|
88
|
+
content = get_url_content(url)
|
|
90
89
|
with open(local_path, "wb") as f:
|
|
91
90
|
f.write(content)
|
|
92
91
|
|
|
@@ -166,8 +165,7 @@ def download_file(
|
|
|
166
165
|
return_without_path = True
|
|
167
166
|
|
|
168
167
|
url = _get_file_url(file_name, directory)
|
|
169
|
-
|
|
170
|
-
if not head.ok:
|
|
168
|
+
if not check_url_exists(url):
|
|
171
169
|
raise RemoteFileNotFoundError(url)
|
|
172
170
|
return _retrieve_file(url, file_name, save_path, return_without_path)
|
|
173
171
|
|
ansys/fluent/core/exceptions.py
CHANGED
|
@@ -14,6 +14,7 @@ class DisallowedValuesError(ValueError):
|
|
|
14
14
|
name: Any | None = None,
|
|
15
15
|
allowed_values: Any | None = None,
|
|
16
16
|
):
|
|
17
|
+
"""Initialize DisallowedValuesError."""
|
|
17
18
|
super().__init__(
|
|
18
19
|
allowed_name_error_message(
|
|
19
20
|
context=context, trial_name=name, allowed_values=allowed_values
|
|
@@ -9,13 +9,7 @@ from ansys.api.fluent.v0.field_data_pb2 import DataLocation
|
|
|
9
9
|
from ansys.fluent.core import PyFluentDeprecationWarning
|
|
10
10
|
from ansys.fluent.core.filereader.case_file import CaseFile
|
|
11
11
|
from ansys.fluent.core.filereader.data_file import DataFile
|
|
12
|
-
from ansys.fluent.core.services.field_data import
|
|
13
|
-
FacesConnectivity,
|
|
14
|
-
ScalarFieldData,
|
|
15
|
-
SurfaceDataType,
|
|
16
|
-
VectorFieldData,
|
|
17
|
-
Vertices,
|
|
18
|
-
)
|
|
12
|
+
from ansys.fluent.core.services.field_data import SurfaceDataType
|
|
19
13
|
from ansys.fluent.core.utils.deprecate import deprecate_argument, deprecate_arguments
|
|
20
14
|
|
|
21
15
|
|
|
@@ -23,6 +17,7 @@ class InvalidMultiPhaseFieldName(ValueError):
|
|
|
23
17
|
"""Raised when multi-phase field name is inappropriate."""
|
|
24
18
|
|
|
25
19
|
def __init__(self):
|
|
20
|
+
"""Initialize InvalidMultiPhaseFieldName."""
|
|
26
21
|
super().__init__("Multi-phase field name should start with 'phase-'.")
|
|
27
22
|
|
|
28
23
|
|
|
@@ -30,6 +25,7 @@ class InvalidFieldName(ValueError):
|
|
|
30
25
|
"""Raised when a field name is inappropriate."""
|
|
31
26
|
|
|
32
27
|
def __init__(self):
|
|
28
|
+
"""Initialize InvalidFieldName."""
|
|
33
29
|
super().__init__("The only allowed field is 'velocity'.")
|
|
34
30
|
|
|
35
31
|
|
|
@@ -350,6 +346,7 @@ class FileFieldData:
|
|
|
350
346
|
"""File field data."""
|
|
351
347
|
|
|
352
348
|
def __init__(self, file_session, field_info):
|
|
349
|
+
"""Initialize FileFieldData."""
|
|
353
350
|
self._file_session = file_session
|
|
354
351
|
self._field_info = field_info
|
|
355
352
|
|
|
@@ -411,48 +408,32 @@ class FileFieldData:
|
|
|
411
408
|
)
|
|
412
409
|
|
|
413
410
|
if SurfaceDataType.Vertices in data_types:
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
self._file_session._case_file.get_mesh().get_vertices(
|
|
421
|
-
surface_ids[0]
|
|
422
|
-
),
|
|
423
|
-
)
|
|
424
|
-
else:
|
|
425
|
-
return {
|
|
426
|
-
surface_id: Vertices(
|
|
427
|
-
surface_id,
|
|
428
|
-
self._file_session._case_file.get_mesh().get_vertices(
|
|
429
|
-
surface_id
|
|
430
|
-
),
|
|
431
|
-
)
|
|
432
|
-
for surface_id in surface_ids
|
|
433
|
-
}
|
|
411
|
+
return {
|
|
412
|
+
surface: self._file_session._case_file.get_mesh()
|
|
413
|
+
.get_vertices(surface_ids[count])
|
|
414
|
+
.reshape(-1, 3)
|
|
415
|
+
for count, surface in enumerate(surfaces)
|
|
416
|
+
}
|
|
434
417
|
|
|
435
418
|
if SurfaceDataType.FacesConnectivity in data_types:
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
"surface_id"
|
|
439
|
-
]
|
|
440
|
-
return FacesConnectivity(
|
|
441
|
-
surface_ids[0],
|
|
419
|
+
return {
|
|
420
|
+
surface: self._get_faces_connectivity_data(
|
|
442
421
|
self._file_session._case_file.get_mesh().get_connectivity(
|
|
443
|
-
surface_ids[
|
|
444
|
-
),
|
|
445
|
-
)
|
|
446
|
-
else:
|
|
447
|
-
return {
|
|
448
|
-
surface_id: FacesConnectivity(
|
|
449
|
-
surface_id,
|
|
450
|
-
self._file_session._case_file.get_mesh().get_connectivity(
|
|
451
|
-
surface_id
|
|
452
|
-
),
|
|
422
|
+
surface_ids[count]
|
|
453
423
|
)
|
|
454
|
-
|
|
455
|
-
|
|
424
|
+
)
|
|
425
|
+
for count, surface in enumerate(surfaces)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
@staticmethod
|
|
429
|
+
def _get_faces_connectivity_data(data):
|
|
430
|
+
faces_data = []
|
|
431
|
+
i = 0
|
|
432
|
+
while i < len(data):
|
|
433
|
+
end = i + 1 + data[i]
|
|
434
|
+
faces_data.append(data[i + 1 : end])
|
|
435
|
+
i = end
|
|
436
|
+
return faces_data
|
|
456
437
|
|
|
457
438
|
@deprecate_argument(
|
|
458
439
|
old_arg="surface_name",
|
|
@@ -504,53 +485,24 @@ class FileFieldData:
|
|
|
504
485
|
field_info=self._field_info,
|
|
505
486
|
surfaces=surfaces,
|
|
506
487
|
)
|
|
507
|
-
if len(
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
surface_ids[0],
|
|
516
|
-
self._file_session._data_file.get_face_scalar_field_data(
|
|
517
|
-
field_name.split(":")[0],
|
|
518
|
-
field_name.split(":")[1],
|
|
519
|
-
surface_ids[0],
|
|
520
|
-
),
|
|
521
|
-
)
|
|
522
|
-
else:
|
|
523
|
-
return ScalarFieldData(
|
|
524
|
-
surface_ids[0],
|
|
525
|
-
self._file_session._data_file.get_face_scalar_field_data(
|
|
526
|
-
"phase-1", field_name, surface_ids[0]
|
|
527
|
-
),
|
|
488
|
+
if len(self._file_session._data_file.get_phases()) > 1:
|
|
489
|
+
if not field_name.startswith("phase-"):
|
|
490
|
+
raise InvalidMultiPhaseFieldName()
|
|
491
|
+
return {
|
|
492
|
+
surface: self._file_session._data_file.get_face_scalar_field_data(
|
|
493
|
+
field_name.split(":")[0],
|
|
494
|
+
field_name.split(":")[1],
|
|
495
|
+
surface_ids[count],
|
|
528
496
|
)
|
|
497
|
+
for count, surface in enumerate(surfaces)
|
|
498
|
+
}
|
|
529
499
|
else:
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
self._file_session._data_file.get_face_scalar_field_data(
|
|
537
|
-
field_name.split(":")[0],
|
|
538
|
-
field_name.split(":")[1],
|
|
539
|
-
surface_id,
|
|
540
|
-
),
|
|
541
|
-
)
|
|
542
|
-
for surface_id in surface_ids
|
|
543
|
-
}
|
|
544
|
-
else:
|
|
545
|
-
return {
|
|
546
|
-
surface_id: ScalarFieldData(
|
|
547
|
-
surface_id,
|
|
548
|
-
self._file_session._data_file.get_face_scalar_field_data(
|
|
549
|
-
"phase-1", field_name, surface_id
|
|
550
|
-
),
|
|
551
|
-
)
|
|
552
|
-
for surface_id in surface_ids
|
|
553
|
-
}
|
|
500
|
+
return {
|
|
501
|
+
surface: self._file_session._data_file.get_face_scalar_field_data(
|
|
502
|
+
"phase-1", field_name, surface_ids[count]
|
|
503
|
+
)
|
|
504
|
+
for count, surface in enumerate(surfaces)
|
|
505
|
+
}
|
|
554
506
|
|
|
555
507
|
@deprecate_argument(
|
|
556
508
|
old_arg="surface_name",
|
|
@@ -602,47 +554,22 @@ class FileFieldData:
|
|
|
602
554
|
):
|
|
603
555
|
raise InvalidFieldName()
|
|
604
556
|
|
|
605
|
-
if len(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
)
|
|
615
|
-
else:
|
|
616
|
-
vector_data = self._file_session._data_file.get_face_vector_field_data(
|
|
617
|
-
"phase-1", surface_ids[0]
|
|
618
|
-
)
|
|
619
|
-
|
|
620
|
-
return VectorFieldData(surface_ids[0], vector_data, scale=1.0)
|
|
557
|
+
if len(self._file_session._data_file.get_phases()) > 1:
|
|
558
|
+
if not field_name.startswith("phase-"):
|
|
559
|
+
raise InvalidMultiPhaseFieldName()
|
|
560
|
+
return {
|
|
561
|
+
surface: self._file_session._data_file.get_face_vector_field_data(
|
|
562
|
+
field_name.split(":")[0], surface_ids[count]
|
|
563
|
+
).reshape(-1, 3)
|
|
564
|
+
for count, surface in enumerate(surfaces)
|
|
565
|
+
}
|
|
621
566
|
else:
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
self._file_session._data_file.get_face_vector_field_data(
|
|
629
|
-
field_name.split(":")[0], surface_id
|
|
630
|
-
),
|
|
631
|
-
scale=1.0,
|
|
632
|
-
)
|
|
633
|
-
for surface_id in surface_ids
|
|
634
|
-
}
|
|
635
|
-
else:
|
|
636
|
-
return {
|
|
637
|
-
surface_id: VectorFieldData(
|
|
638
|
-
surface_id,
|
|
639
|
-
self._file_session._data_file.get_face_vector_field_data(
|
|
640
|
-
"phase-1", surface_id
|
|
641
|
-
),
|
|
642
|
-
scale=1.0,
|
|
643
|
-
)
|
|
644
|
-
for surface_id in surface_ids
|
|
645
|
-
}
|
|
567
|
+
return {
|
|
568
|
+
surface: self._file_session._data_file.get_face_vector_field_data(
|
|
569
|
+
"phase-1", surface_ids[count]
|
|
570
|
+
).reshape(-1, 3)
|
|
571
|
+
for count, surface in enumerate(surfaces)
|
|
572
|
+
}
|
|
646
573
|
|
|
647
574
|
@deprecate_argument(
|
|
648
575
|
old_arg="surface_name",
|
|
@@ -683,6 +610,7 @@ class FileFieldInfo:
|
|
|
683
610
|
"""File field info."""
|
|
684
611
|
|
|
685
612
|
def __init__(self, file_session):
|
|
613
|
+
"""Initialize FileFieldInfo."""
|
|
686
614
|
self._file_session = file_session
|
|
687
615
|
|
|
688
616
|
def get_scalar_field_range(
|
|
@@ -871,4 +799,4 @@ def _get_surface_ids(
|
|
|
871
799
|
surface_ids.extend(field_info.get_surfaces_info()[surf]["surface_id"])
|
|
872
800
|
else:
|
|
873
801
|
surface_ids.append(surf)
|
|
874
|
-
return
|
|
802
|
+
return surface_ids
|
|
@@ -234,15 +234,15 @@ class Mesh:
|
|
|
234
234
|
Methods
|
|
235
235
|
-------
|
|
236
236
|
|
|
237
|
-
get_surface_ids
|
|
237
|
+
get_surface_ids()
|
|
238
238
|
Get a list of surface ids.
|
|
239
|
-
get_surface_names
|
|
239
|
+
get_surface_names()
|
|
240
240
|
Get a list of surface names.
|
|
241
|
-
get_surface_locs
|
|
241
|
+
get_surface_locs(surface_id)
|
|
242
242
|
Get the min and max location index of surface.
|
|
243
|
-
get_connectivity
|
|
243
|
+
get_connectivity(surface_id)
|
|
244
244
|
Get the surface connectivity.
|
|
245
|
-
get_vertices
|
|
245
|
+
get_vertices(surface_id)
|
|
246
246
|
Get list of vertices of the surface.
|
|
247
247
|
"""
|
|
248
248
|
|
|
@@ -326,35 +326,35 @@ class RPVarProcessor:
|
|
|
326
326
|
|
|
327
327
|
Methods
|
|
328
328
|
-------
|
|
329
|
-
input_parameters
|
|
329
|
+
input_parameters()
|
|
330
330
|
Get a list of input parameter objects
|
|
331
|
-
output_parameters
|
|
331
|
+
output_parameters()
|
|
332
332
|
Get a list of output parameter objects
|
|
333
|
-
num_dimensions
|
|
333
|
+
num_dimensions()
|
|
334
334
|
Get the dimensionality of the case (2 or 3)
|
|
335
|
-
precision
|
|
335
|
+
precision()
|
|
336
336
|
Get the precision (1 or 2 for 1D of 2D)
|
|
337
|
-
iter_count
|
|
337
|
+
iter_count()
|
|
338
338
|
Get the number of iterations
|
|
339
|
-
rp_vars
|
|
339
|
+
rp_vars()
|
|
340
340
|
Get dictionary of all RP vars
|
|
341
|
-
rp_var
|
|
341
|
+
rp_var(name)
|
|
342
342
|
Get specific RP var by name, either by providing
|
|
343
343
|
the Scheme name:
|
|
344
344
|
`reader.rp_var("rad/enable-netm?")`
|
|
345
345
|
or a pythonic version:
|
|
346
346
|
`reader.rp_var.rad.enable_netm__q()`
|
|
347
|
-
has_rp_var
|
|
347
|
+
has_rp_var(name)
|
|
348
348
|
Whether case has particular RP var
|
|
349
|
-
config_vars
|
|
349
|
+
config_vars()
|
|
350
350
|
Get dictionary of all RP vars
|
|
351
|
-
config_var
|
|
351
|
+
config_var(name)
|
|
352
352
|
Get specific config var by name, either by providing
|
|
353
353
|
the Scheme name:
|
|
354
354
|
`reader.config_var("rp-3d?")`
|
|
355
355
|
or a pythonic version:
|
|
356
356
|
`reader.config_var.rp_3d__q()`
|
|
357
|
-
has_config_var
|
|
357
|
+
has_config_var(name)
|
|
358
358
|
Whether case has particular config var
|
|
359
359
|
"""
|
|
360
360
|
|
|
@@ -567,7 +567,7 @@ class CaseFile(RPVarProcessor):
|
|
|
567
567
|
|
|
568
568
|
Methods
|
|
569
569
|
-------
|
|
570
|
-
get_mesh
|
|
570
|
+
get_mesh()
|
|
571
571
|
Get the mesh data.
|
|
572
572
|
"""
|
|
573
573
|
|