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
ansys/fluent/core/__init__.py
CHANGED
|
@@ -4,8 +4,6 @@ import os
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
import pydoc
|
|
6
6
|
|
|
7
|
-
import platformdirs
|
|
8
|
-
|
|
9
7
|
# isort: off
|
|
10
8
|
# Logging has to be imported before importing other PyFluent modules
|
|
11
9
|
from ansys.fluent.core.logging import set_console_logging_level # noqa: F401
|
|
@@ -38,7 +36,7 @@ from ansys.fluent.core.streaming_services.events_streaming import ( # noqa: F40
|
|
|
38
36
|
MeshingEvent,
|
|
39
37
|
SolverEvent,
|
|
40
38
|
)
|
|
41
|
-
from ansys.fluent.core.utils import fldoc
|
|
39
|
+
from ansys.fluent.core.utils import fldoc, get_examples_download_dir
|
|
42
40
|
from ansys.fluent.core.utils.fluent_version import FluentVersion # noqa: F401
|
|
43
41
|
from ansys.fluent.core.utils.setup_for_fluent import setup_for_fluent # noqa: F401
|
|
44
42
|
from ansys.fluent.core.warnings import ( # noqa: F401
|
|
@@ -52,7 +50,7 @@ try:
|
|
|
52
50
|
except (ImportError, AttributeError, SyntaxError):
|
|
53
51
|
pass
|
|
54
52
|
|
|
55
|
-
_VERSION_INFO = "Build date:
|
|
53
|
+
_VERSION_INFO = "Build date: November 27, 2024 17:14 UTC ShaID: 566bc31"
|
|
56
54
|
"""Global variable indicating the version of the PyFluent package - Empty by default"""
|
|
57
55
|
|
|
58
56
|
_THIS_DIRNAME = os.path.dirname(__file__)
|
|
@@ -78,9 +76,7 @@ def version_info() -> str:
|
|
|
78
76
|
return _VERSION_INFO if _VERSION_INFO is not None else __version__
|
|
79
77
|
|
|
80
78
|
|
|
81
|
-
EXAMPLES_PATH =
|
|
82
|
-
platformdirs.user_documents_dir(), "ansys_fluent_core_examples"
|
|
83
|
-
)
|
|
79
|
+
EXAMPLES_PATH = str(get_examples_download_dir())
|
|
84
80
|
|
|
85
81
|
# Host path which is mounted to the container
|
|
86
82
|
CONTAINER_MOUNT_SOURCE = None
|
|
@@ -117,8 +113,11 @@ CODEGEN_OUTDIR = (Path(__file__) / ".." / "generated").resolve()
|
|
|
117
113
|
# Whether to zip settings API files during codegen
|
|
118
114
|
CODEGEN_ZIP_SETTINGS = os.getenv("PYFLUENT_CODEGEN_ZIP_SETTINGS", False)
|
|
119
115
|
|
|
120
|
-
# Whether to show mesh after case read
|
|
121
|
-
|
|
116
|
+
# Whether to show mesh in Fluent after case read
|
|
117
|
+
FLUENT_SHOW_MESH_AFTER_CASE_READ = False
|
|
118
|
+
|
|
119
|
+
# Whether to write the automatic transcript in Fluent
|
|
120
|
+
FLUENT_AUTOMATIC_TRANSCRIPT = False
|
|
122
121
|
|
|
123
122
|
# Whether to interrupt Fluent solver from PyFluent
|
|
124
123
|
SUPPORT_SOLVER_INTERRUPT = False
|
|
@@ -128,3 +127,17 @@ START_WATCHDOG = None
|
|
|
128
127
|
|
|
129
128
|
# Whether to skip health check
|
|
130
129
|
CHECK_HEALTH = True
|
|
130
|
+
|
|
131
|
+
# Whether to print search results
|
|
132
|
+
PRINT_SEARCH_RESULTS = True
|
|
133
|
+
|
|
134
|
+
# Whether to clear environment variables related to Fluent parallel mode
|
|
135
|
+
CLEAR_FLUENT_PARA_ENVS = False
|
|
136
|
+
|
|
137
|
+
# Set stdout of the launched Fluent process
|
|
138
|
+
# Valid values are same as subprocess.Popen's stdout argument
|
|
139
|
+
LAUNCH_FLUENT_STDOUT = None
|
|
140
|
+
|
|
141
|
+
# Set stderr of the launched Fluent process
|
|
142
|
+
# Valid values are same as subprocess.Popen's stderr argument
|
|
143
|
+
LAUNCH_FLUENT_STDERR = None
|
ansys/fluent/core/_version.py
CHANGED
|
@@ -6,10 +6,13 @@ version_info = 0, 1, 'dev0'
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
# major, minor, patch
|
|
9
|
-
version_info = 0,
|
|
9
|
+
version_info = 0, 28, "dev0"
|
|
10
10
|
|
|
11
11
|
# Nice string for the version
|
|
12
12
|
__version__ = ".".join(map(str, version_info))
|
|
13
13
|
|
|
14
14
|
# Current Fluent version
|
|
15
|
-
fluent_release_version = "24.
|
|
15
|
+
fluent_release_version = "24.2.0"
|
|
16
|
+
|
|
17
|
+
# Dev Fluent version
|
|
18
|
+
fluent_dev_version = "25.2.0"
|
|
@@ -4,7 +4,6 @@ import os
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
import pickle
|
|
6
6
|
|
|
7
|
-
from ansys.fluent.core import codegen
|
|
8
7
|
from ansys.fluent.core.codegen import ( # noqa: F401
|
|
9
8
|
builtin_settingsgen,
|
|
10
9
|
datamodelgen,
|
|
@@ -12,7 +11,6 @@ from ansys.fluent.core.codegen import ( # noqa: F401
|
|
|
12
11
|
tuigen,
|
|
13
12
|
)
|
|
14
13
|
from ansys.fluent.core.search import get_api_tree_file_name
|
|
15
|
-
from ansys.fluent.core.utils.fluent_version import FluentVersion
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
def _update_first_level(d, u):
|
|
@@ -33,9 +31,7 @@ def generate(version: str, static_infos: dict):
|
|
|
33
31
|
Path(api_tree_file).parent.mkdir(parents=True, exist_ok=True)
|
|
34
32
|
with open(api_tree_file, "wb") as f:
|
|
35
33
|
pickle.dump(api_tree, f)
|
|
36
|
-
if
|
|
37
|
-
iter(FluentVersion)
|
|
38
|
-
):
|
|
34
|
+
if os.getenv("PYFLUENT_CODEGEN_SKIP_BUILTIN_SETTINGS") != "1":
|
|
39
35
|
builtin_settingsgen.generate(version)
|
|
40
36
|
|
|
41
37
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"""Generate builtin setting classes."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
+
from zipimport import zipimporter
|
|
4
5
|
|
|
5
6
|
from ansys.fluent.core import CODEGEN_OUTDIR, FluentVersion
|
|
6
|
-
from ansys.fluent.core.solver.flobject import CreatableNamedObjectMixin
|
|
7
|
+
from ansys.fluent.core.solver.flobject import CreatableNamedObjectMixin, NamedObject
|
|
7
8
|
from ansys.fluent.core.solver.settings_builtin_data import DATA
|
|
8
9
|
|
|
9
10
|
_PY_FILE = CODEGEN_OUTDIR / "solver" / "settings_builtin.py"
|
|
@@ -32,12 +33,22 @@ def _get_settings_root(version: str):
|
|
|
32
33
|
return settings.root
|
|
33
34
|
|
|
34
35
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
def _get_named_objects_in_path(root, path, kind):
|
|
37
|
+
named_objects = []
|
|
38
|
+
cls = root
|
|
39
|
+
comps = path.split(".")
|
|
40
|
+
for i, comp in enumerate(comps):
|
|
41
|
+
cls = cls._child_classes[comp]
|
|
42
|
+
if i < len(comps) - 1 and issubclass(cls, NamedObject):
|
|
43
|
+
named_objects.append(comp)
|
|
44
|
+
cls = cls.child_object_type
|
|
45
|
+
final_type = ""
|
|
46
|
+
if kind == "NamedObject":
|
|
47
|
+
if issubclass(cls, CreatableNamedObjectMixin):
|
|
48
|
+
final_type = "Creatable"
|
|
49
|
+
else:
|
|
50
|
+
final_type = "NonCreatable"
|
|
51
|
+
return named_objects, final_type
|
|
41
52
|
|
|
42
53
|
|
|
43
54
|
def generate(version: str):
|
|
@@ -45,10 +56,12 @@ def generate(version: str):
|
|
|
45
56
|
print("Generating builtin settings...")
|
|
46
57
|
CODEGEN_OUTDIR.mkdir(exist_ok=True)
|
|
47
58
|
root = _get_settings_root(version)
|
|
59
|
+
version = FluentVersion(version)
|
|
48
60
|
with open(_PY_FILE, "w") as f:
|
|
49
61
|
f.write('"""Solver settings."""\n\n')
|
|
50
62
|
f.write(
|
|
51
|
-
"from ansys.fluent.core.solver.settings_builtin_bases import _SingletonSetting, _CreatableNamedObjectSetting, _NonCreatableNamedObjectSetting\n
|
|
63
|
+
"from ansys.fluent.core.solver.settings_builtin_bases import _SingletonSetting, _CreatableNamedObjectSetting, _NonCreatableNamedObjectSetting, Solver\n"
|
|
64
|
+
"from ansys.fluent.core.solver.flobject import SettingsBase\n\n\n"
|
|
52
65
|
)
|
|
53
66
|
f.write("__all__ = [\n")
|
|
54
67
|
for name, _ in DATA.items():
|
|
@@ -56,11 +69,32 @@ def generate(version: str):
|
|
|
56
69
|
f.write("]\n\n")
|
|
57
70
|
for name, v in DATA.items():
|
|
58
71
|
kind, path = v
|
|
72
|
+
if isinstance(path, dict):
|
|
73
|
+
if version not in path:
|
|
74
|
+
continue
|
|
75
|
+
path = path[version]
|
|
76
|
+
named_objects, final_type = _get_named_objects_in_path(root, path, kind)
|
|
59
77
|
if kind == "NamedObject":
|
|
60
|
-
|
|
61
|
-
kind = f"{_get_named_object_type(root, path)}NamedObject"
|
|
78
|
+
kind = f"{final_type}NamedObject"
|
|
62
79
|
f.write(f"class {name}(_{kind}Setting):\n")
|
|
63
80
|
f.write(f' """{name} setting."""\n\n')
|
|
81
|
+
f.write(" def __init__(self")
|
|
82
|
+
for named_object in named_objects:
|
|
83
|
+
f.write(f", {named_object}: str")
|
|
84
|
+
f.write(", settings_source: SettingsBase | Solver | None = None")
|
|
85
|
+
if kind == "NonCreatableNamedObject":
|
|
86
|
+
f.write(", name: str = None")
|
|
87
|
+
elif kind == "CreatableNamedObject":
|
|
88
|
+
f.write(", name: str = None, new_instance_name: str = None")
|
|
89
|
+
f.write("):\n")
|
|
90
|
+
f.write(" super().__init__(settings_source=settings_source")
|
|
91
|
+
if kind == "NonCreatableNamedObject":
|
|
92
|
+
f.write(", name=name")
|
|
93
|
+
elif kind == "CreatableNamedObject":
|
|
94
|
+
f.write(", name=name, new_instance_name=new_instance_name")
|
|
95
|
+
for named_object in named_objects:
|
|
96
|
+
f.write(f", {named_object}={named_object}")
|
|
97
|
+
f.write(")\n\n")
|
|
64
98
|
|
|
65
99
|
with open(_PYI_FILE, "w") as f:
|
|
66
100
|
for version in FluentVersion:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Module to generate Fluent datamodel API classes."""
|
|
2
2
|
|
|
3
|
-
from io import FileIO
|
|
3
|
+
from io import FileIO, StringIO
|
|
4
4
|
import os
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
import shutil
|
|
@@ -21,11 +21,11 @@ _ROOT_DIR = Path(__file__) / ".." / ".." / ".." / ".." / ".." / ".."
|
|
|
21
21
|
|
|
22
22
|
_PY_TYPE_BY_DM_TYPE = {
|
|
23
23
|
**dict.fromkeys(["Logical", "Bool"], "bool"),
|
|
24
|
-
**dict.fromkeys(["Logical List", "ListBool"], "
|
|
24
|
+
**dict.fromkeys(["Logical List", "ListBool"], "list[bool]"),
|
|
25
25
|
"String": "str",
|
|
26
|
-
**dict.fromkeys(["String List", "ListString"], "
|
|
26
|
+
**dict.fromkeys(["String List", "ListString"], "list[str]"),
|
|
27
27
|
**dict.fromkeys(["Integer", "Int"], "int"),
|
|
28
|
-
**dict.fromkeys(["Integer List", "ListInt"], "
|
|
28
|
+
**dict.fromkeys(["Integer List", "ListInt"], "list[int]"),
|
|
29
29
|
"Real": "float",
|
|
30
30
|
**dict.fromkeys(
|
|
31
31
|
[
|
|
@@ -36,9 +36,9 @@ _PY_TYPE_BY_DM_TYPE = {
|
|
|
36
36
|
"Real Triplet List",
|
|
37
37
|
"ListRealTriplet",
|
|
38
38
|
],
|
|
39
|
-
"
|
|
39
|
+
"list[float]",
|
|
40
40
|
),
|
|
41
|
-
**dict.fromkeys(["Dict", "ModelObject"], "
|
|
41
|
+
**dict.fromkeys(["Dict", "ModelObject"], "dict[str, Any]"),
|
|
42
42
|
"None": "None",
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -66,6 +66,19 @@ _SOLVER_DM_DOC_DIR = os.path.normpath(
|
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
|
|
69
|
+
def _write_command_query_stub(name: str, info: Any, f: FileIO):
|
|
70
|
+
signature = StringIO()
|
|
71
|
+
indent = " "
|
|
72
|
+
signature.write(f"(\n{indent}self,\n")
|
|
73
|
+
if info.get("args"):
|
|
74
|
+
for arg in info.get("args"):
|
|
75
|
+
signature.write(
|
|
76
|
+
f'{indent}{arg["name"]}: {_PY_TYPE_BY_DM_TYPE[arg["type"]]} | None = None,\n'
|
|
77
|
+
)
|
|
78
|
+
signature.write(f'{indent}) -> {_PY_TYPE_BY_DM_TYPE[info["returntype"]]}: ...')
|
|
79
|
+
f.write(f"\n def {name}{signature.getvalue()}\n")
|
|
80
|
+
|
|
81
|
+
|
|
69
82
|
def _build_singleton_docstring(name: str):
|
|
70
83
|
return f"Singleton {name}."
|
|
71
84
|
|
|
@@ -130,6 +143,8 @@ class DataModelStaticInfo:
|
|
|
130
143
|
datamodel_dir = (pyfluent.CODEGEN_OUTDIR / f"datamodel_{version}").resolve()
|
|
131
144
|
datamodel_dir.mkdir(exist_ok=True)
|
|
132
145
|
self.file_name = (datamodel_dir / f"{rules_save_name}.py").resolve()
|
|
146
|
+
if rules == "MeshingUtilities":
|
|
147
|
+
self.stub_file = (datamodel_dir / "MeshingUtilities.pyi").resolve()
|
|
133
148
|
if len(modes) > 1:
|
|
134
149
|
for mode in modes[1:]:
|
|
135
150
|
DataModelStaticInfo._noindices.append(f"{mode}.datamodel.{rules}")
|
|
@@ -244,7 +259,7 @@ class DataModelGenerator:
|
|
|
244
259
|
print(
|
|
245
260
|
"Information: Icing settings not generated ( R23.1+ is required )\n"
|
|
246
261
|
)
|
|
247
|
-
except:
|
|
262
|
+
except Exception:
|
|
248
263
|
print(
|
|
249
264
|
"Information: Problem accessing flserver datamodel for icing settings\n"
|
|
250
265
|
)
|
|
@@ -316,12 +331,12 @@ class DataModelGenerator:
|
|
|
316
331
|
# print("\t\texcluded", k)
|
|
317
332
|
pass
|
|
318
333
|
for k in parameters:
|
|
319
|
-
k_type =
|
|
320
|
-
if k_type in
|
|
334
|
+
k_type = info["parameters"][k]["type"]
|
|
335
|
+
if k_type in {"String", "String List", "ListString"}:
|
|
321
336
|
f.write(f"{indent} class {k}(PyTextual):\n")
|
|
322
|
-
elif k_type in
|
|
337
|
+
elif k_type in {"Integer", "Int", "Real"}:
|
|
323
338
|
f.write(f"{indent} class {k}(PyNumerical):\n")
|
|
324
|
-
elif k_type in
|
|
339
|
+
elif k_type in {"Dict", "ModelObject"}:
|
|
325
340
|
f.write(f"{indent} class {k}(PyDictionary):\n")
|
|
326
341
|
else:
|
|
327
342
|
f.write(f"{indent} class {k}(PyParameter):\n")
|
|
@@ -333,6 +348,32 @@ class DataModelGenerator:
|
|
|
333
348
|
f.write(f'{indent} """\n')
|
|
334
349
|
f.write(f"{indent} pass\n\n")
|
|
335
350
|
api_tree[k] = "Parameter"
|
|
351
|
+
if "MeshingUtilities" in f.name:
|
|
352
|
+
stub_file = self._static_info["MeshingUtilities"].stub_file
|
|
353
|
+
stub_file.unlink(missing_ok=True)
|
|
354
|
+
with open(stub_file, "w", encoding="utf8") as file:
|
|
355
|
+
file.write("#\n")
|
|
356
|
+
file.write("# This is an auto-generated file. DO NOT EDIT!\n")
|
|
357
|
+
file.write("#\n")
|
|
358
|
+
file.write("# pylint: disable=line-too-long\n\n")
|
|
359
|
+
file.write(
|
|
360
|
+
"from ansys.fluent.core.services.datamodel_se import PyMenu\n"
|
|
361
|
+
)
|
|
362
|
+
file.write("from typing import Any\n")
|
|
363
|
+
file.write("\n\n")
|
|
364
|
+
file.write("class Root(PyMenu):\n")
|
|
365
|
+
for k in commands:
|
|
366
|
+
_write_command_query_stub(
|
|
367
|
+
k,
|
|
368
|
+
info["commands"][k]["commandinfo"],
|
|
369
|
+
file,
|
|
370
|
+
)
|
|
371
|
+
for k in queries:
|
|
372
|
+
_write_command_query_stub(
|
|
373
|
+
k,
|
|
374
|
+
info["queries"][k]["queryinfo"],
|
|
375
|
+
file,
|
|
376
|
+
)
|
|
336
377
|
for k in commands:
|
|
337
378
|
f.write(f"{indent} class {k}(PyCommand):\n")
|
|
338
379
|
f.write(f'{indent} """\n')
|
|
@@ -361,7 +402,7 @@ class DataModelGenerator:
|
|
|
361
402
|
"""Write API classes to files."""
|
|
362
403
|
api_tree = {"<meshing_session>": {}, "<solver_session>": {}}
|
|
363
404
|
for name, info in self._static_info.items():
|
|
364
|
-
if info.static_info
|
|
405
|
+
if info.static_info is None:
|
|
365
406
|
continue
|
|
366
407
|
with open(info.file_name, "w", encoding="utf8") as f:
|
|
367
408
|
f.write("#\n")
|
|
@@ -10,7 +10,12 @@ from typing import IO
|
|
|
10
10
|
import ansys.fluent.core as pyfluent
|
|
11
11
|
from ansys.fluent.core import launch_fluent
|
|
12
12
|
from ansys.fluent.core.codegen import StaticInfoType
|
|
13
|
-
from ansys.fluent.core.solver.flobject import
|
|
13
|
+
from ansys.fluent.core.solver.flobject import (
|
|
14
|
+
ListObject,
|
|
15
|
+
NamedObject,
|
|
16
|
+
get_cls,
|
|
17
|
+
to_python_name,
|
|
18
|
+
)
|
|
14
19
|
from ansys.fluent.core.utils.fix_doc import fix_settings_doc
|
|
15
20
|
from ansys.fluent.core.utils.fluent_version import get_version_for_file_name
|
|
16
21
|
|
|
@@ -142,7 +147,7 @@ def _write_function_stub(name, data, s_stub):
|
|
|
142
147
|
for arg_name in data["argument_names"]:
|
|
143
148
|
arg_type = _arg_type_strings[data["child_classes"][arg_name]["bases"][0]]
|
|
144
149
|
s_stub.write(f", {arg_name}: {arg_type}")
|
|
145
|
-
s_stub.write(
|
|
150
|
+
s_stub.write("):\n")
|
|
146
151
|
# TODO: add return type
|
|
147
152
|
doc = data["doc"]
|
|
148
153
|
doc = doc.strip().replace("\n", "\n ")
|
|
@@ -173,30 +178,32 @@ def _write_data(cls_name: str, python_name: str, data: dict, f: IO, f_stub: IO |
|
|
|
173
178
|
s.write(f" fluent_name = {data['fluent_name']!r}\n")
|
|
174
179
|
# _python_name preserves the original non-suffixed name of the class.
|
|
175
180
|
s.write(f" _python_name = {python_name!r}\n")
|
|
176
|
-
s_stub.write(
|
|
177
|
-
s_stub.write(
|
|
178
|
-
s_stub.write(
|
|
181
|
+
s_stub.write(" version: str\n")
|
|
182
|
+
s_stub.write(" fluent_name: str\n")
|
|
183
|
+
s_stub.write(" _python_name: str\n")
|
|
179
184
|
child_names = data["child_names"]
|
|
180
185
|
if child_names:
|
|
181
186
|
s.write(f" child_names = {child_names}\n")
|
|
182
|
-
s_stub.write(
|
|
187
|
+
s_stub.write(" child_names: list[str]\n")
|
|
183
188
|
command_names = data["command_names"]
|
|
184
189
|
if command_names:
|
|
185
190
|
s.write(f" command_names = {command_names}\n")
|
|
186
|
-
s_stub.write(
|
|
191
|
+
s_stub.write(" command_names: list[str]\n")
|
|
187
192
|
query_names = data["query_names"]
|
|
188
193
|
if query_names:
|
|
189
194
|
s.write(f" query_names = {query_names}\n")
|
|
190
|
-
s_stub.write(
|
|
195
|
+
s_stub.write(" query_names: list[str]\n")
|
|
191
196
|
argument_names = data["argument_names"]
|
|
192
197
|
if argument_names:
|
|
193
198
|
s.write(f" argument_names = {argument_names}\n")
|
|
194
|
-
s_stub.write(
|
|
199
|
+
s_stub.write(" argument_names: list[str]\n")
|
|
195
200
|
classes_to_write = {} # values are (class_name, data, hash, should_write_stub)
|
|
196
201
|
if data["child_classes"]:
|
|
197
202
|
s.write(" _child_classes = dict(\n")
|
|
198
203
|
for k, v in data["child_classes"].items():
|
|
199
204
|
name = v["name"]
|
|
205
|
+
# Retrieving the original python name before get_cls() modifies it.
|
|
206
|
+
child_python_name = to_python_name(v["fluent_name"])
|
|
200
207
|
hash_ = _gethash(v)
|
|
201
208
|
# We are within a tree-traversal, so the global _NAME_BY_HASH dict
|
|
202
209
|
# must be updated immediately at the point of lookup. Same lookup
|
|
@@ -216,10 +223,10 @@ def _write_data(cls_name: str, python_name: str, data: dict, f: IO, f_stub: IO |
|
|
|
216
223
|
# the _CLASS_WRITTEN set.
|
|
217
224
|
if k in command_names + query_names:
|
|
218
225
|
_write_function_stub(k, v, s_stub)
|
|
219
|
-
classes_to_write[unique_name] = (
|
|
226
|
+
classes_to_write[unique_name] = (child_python_name, v, hash_, False)
|
|
220
227
|
else:
|
|
221
228
|
s_stub.write(f" {k}: {unique_name}\n")
|
|
222
|
-
classes_to_write[unique_name] = (
|
|
229
|
+
classes_to_write[unique_name] = (child_python_name, v, hash_, True)
|
|
223
230
|
s.write(" )\n")
|
|
224
231
|
if child_object_name:
|
|
225
232
|
child_object_type = data["child_object_type"]
|
|
@@ -241,7 +248,7 @@ def _write_data(cls_name: str, python_name: str, data: dict, f: IO, f_stub: IO |
|
|
|
241
248
|
return_type = data["return_type"]
|
|
242
249
|
if return_type:
|
|
243
250
|
s.write(f" return_type = {return_type!r}\n")
|
|
244
|
-
s_stub.write(
|
|
251
|
+
s_stub.write(" return_type: str\n")
|
|
245
252
|
s.write("\n")
|
|
246
253
|
for name, (python_name, data, hash_, should_write_stub) in classes_to_write.items():
|
|
247
254
|
if name not in _CLASS_WRITTEN:
|
|
@@ -270,6 +277,8 @@ def generate(version: str, static_infos: dict) -> None:
|
|
|
270
277
|
# _populate_data() collects all strings to write to the file in a nested dict.
|
|
271
278
|
# which is then written to the file using _write_data().
|
|
272
279
|
data = _populate_data(cls, api_tree, version)
|
|
280
|
+
_NAME_BY_HASH.clear()
|
|
281
|
+
_CLASS_WRITTEN.clear()
|
|
273
282
|
with open(output_file, "w") as f, open(output_stub_file, "w") as f_stub:
|
|
274
283
|
header = StringIO()
|
|
275
284
|
header.write("#\n")
|
|
@@ -461,7 +461,7 @@ def _populate_classes(parent_dir):
|
|
|
461
461
|
child_aliases = getattr(cls, "_child_aliases", None)
|
|
462
462
|
if child_aliases:
|
|
463
463
|
f.write(f"{istr1}_child_aliases = dict(\n")
|
|
464
|
-
f.writelines([f
|
|
464
|
+
f.writelines([f"{istr2}{k}={v!r},\n" for k, v in child_aliases.items()])
|
|
465
465
|
f.write(f"{istr1})\n\n")
|
|
466
466
|
|
|
467
467
|
# write object type
|
|
@@ -490,7 +490,7 @@ def _populate_init(parent_dir, hash):
|
|
|
490
490
|
f.write("# This is an auto-generated file. DO NOT EDIT!\n")
|
|
491
491
|
f.write("#\n")
|
|
492
492
|
f.write("\n")
|
|
493
|
-
f.write(
|
|
493
|
+
f.write('"""A package providing Fluent\'s Settings Objects in Python."""')
|
|
494
494
|
f.write("\n")
|
|
495
495
|
f.write("from ansys.fluent.core.solver.flobject import *\n\n")
|
|
496
496
|
f.write(f'SHASH = "{hash}"\n')
|
|
@@ -7,7 +7,6 @@ Usage:
|
|
|
7
7
|
import sys
|
|
8
8
|
|
|
9
9
|
import ansys.fluent.core as pyfluent
|
|
10
|
-
from ansys.fluent.core.services import settings
|
|
11
10
|
|
|
12
11
|
indent_factor = 2
|
|
13
12
|
|
|
@@ -37,9 +36,9 @@ if "__main__" == __name__:
|
|
|
37
36
|
print("Usage: write_settings_yaml.py [outfile]")
|
|
38
37
|
else:
|
|
39
38
|
session = pyfluent.launch_fluent(mode="solver")
|
|
40
|
-
|
|
39
|
+
static_info = session.settings_service.get_static_info()
|
|
41
40
|
if len(sys.argv) == 2:
|
|
42
41
|
with open(sys.argv[1], "w") as f:
|
|
43
|
-
write_yaml(f,
|
|
42
|
+
write_yaml(f, static_info)
|
|
44
43
|
elif len(sys.argv) == 1:
|
|
45
|
-
write_yaml(sys.stdout,
|
|
44
|
+
write_yaml(sys.stdout, static_info)
|