ansys-fluent-core 0.28.2__py3-none-any.whl → 0.29.0__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 +26 -1
- ansys/fluent/core/_stand_alone_datamodel_client/_datamodel_client.py +22 -0
- ansys/fluent/core/_version.py +24 -2
- ansys/fluent/core/codegen/__init__.py +22 -0
- ansys/fluent/core/codegen/allapigen.py +38 -5
- ansys/fluent/core/codegen/builtin_settingsgen.py +22 -0
- ansys/fluent/core/codegen/data/__init__.py +21 -0
- ansys/fluent/core/codegen/data/fluent_gui_help_patch.py +22 -0
- ansys/fluent/core/codegen/data/meshing_utilities_examples.py +22 -0
- ansys/fluent/core/codegen/datamodelgen.py +40 -4
- ansys/fluent/core/codegen/print_fluent_version.py +22 -0
- ansys/fluent/core/codegen/settingsgen.py +67 -4
- ansys/fluent/core/codegen/tuigen.py +44 -6
- ansys/fluent/core/codegen/walk_api.py +67 -18
- ansys/fluent/core/codegen/write_settings_yaml.py +22 -0
- ansys/fluent/core/data_model_cache.py +22 -0
- ansys/fluent/core/examples/__init__.py +22 -0
- ansys/fluent/core/examples/downloads.py +22 -0
- ansys/fluent/core/exceptions.py +22 -0
- ansys/fluent/core/file_session.py +22 -0
- ansys/fluent/core/filereader/__init__.py +21 -0
- ansys/fluent/core/filereader/case_file.py +22 -0
- ansys/fluent/core/filereader/casereader.py +22 -0
- ansys/fluent/core/filereader/data_file.py +22 -0
- ansys/fluent/core/filereader/lispy.py +22 -0
- ansys/fluent/core/fluent_connection.py +23 -1
- ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
- ansys/fluent/core/generated/datamodel_252/meshing.py +32 -0
- ansys/fluent/core/generated/fluent_version_252.py +3 -3
- ansys/fluent/core/generated/solver/settings_222.py +0 -72
- ansys/fluent/core/generated/solver/settings_222.pyi +0 -307
- ansys/fluent/core/generated/solver/settings_231.py +0 -574
- ansys/fluent/core/generated/solver/settings_231.pyi +0 -561
- ansys/fluent/core/generated/solver/settings_232.py +0 -527
- ansys/fluent/core/generated/solver/settings_232.pyi +0 -2803
- ansys/fluent/core/generated/solver/settings_241.py +0 -478
- ansys/fluent/core/generated/solver/settings_241.pyi +0 -522
- ansys/fluent/core/generated/solver/settings_242.py +0 -361
- ansys/fluent/core/generated/solver/settings_242.pyi +0 -591
- ansys/fluent/core/generated/solver/settings_251.py +0 -399
- ansys/fluent/core/generated/solver/settings_251.pyi +0 -629
- ansys/fluent/core/generated/solver/settings_252.py +7794 -4185
- ansys/fluent/core/generated/solver/settings_252.pyi +6986 -3213
- ansys/fluent/core/generated/solver/tui_252.py +537 -181
- ansys/fluent/core/get_build_details.py +22 -0
- ansys/fluent/core/journaling.py +38 -0
- ansys/fluent/core/launcher/__init__.py +22 -0
- ansys/fluent/core/launcher/container_launcher.py +65 -56
- ansys/fluent/core/launcher/error_handler.py +30 -0
- ansys/fluent/core/launcher/fluent_container.py +45 -20
- ansys/fluent/core/launcher/launcher.py +53 -5
- ansys/fluent/core/launcher/launcher_utils.py +22 -0
- ansys/fluent/core/launcher/pim_launcher.py +120 -86
- ansys/fluent/core/launcher/process_launch_string.py +22 -0
- ansys/fluent/core/launcher/pyfluent_enums.py +22 -0
- ansys/fluent/core/launcher/server_info.py +45 -3
- ansys/fluent/core/launcher/slurm_launcher.py +25 -3
- ansys/fluent/core/launcher/standalone_launcher.py +68 -63
- ansys/fluent/core/launcher/watchdog.py +22 -0
- ansys/fluent/core/logging.py +24 -0
- ansys/fluent/core/logging_config.yaml +3 -0
- ansys/fluent/core/meshing/meshing_workflow.py +22 -0
- ansys/fluent/core/parametric.py +22 -0
- ansys/fluent/core/post_objects/__init__.py +21 -0
- ansys/fluent/core/post_objects/check_in_notebook.py +22 -0
- ansys/fluent/core/post_objects/meta.py +22 -0
- ansys/fluent/core/post_objects/post_helper.py +22 -0
- ansys/fluent/core/post_objects/post_object_definitions.py +22 -0
- ansys/fluent/core/post_objects/post_objects_container.py +22 -0
- ansys/fluent/core/post_objects/singleton_meta.py +22 -0
- ansys/fluent/core/post_objects/timing_decorator.py +22 -0
- ansys/fluent/core/report.py +77 -0
- ansys/fluent/core/rpvars.py +22 -0
- ansys/fluent/core/scheduler/__init__.py +22 -0
- ansys/fluent/core/scheduler/load_machines.py +22 -0
- ansys/fluent/core/scheduler/machine_list.py +22 -0
- ansys/fluent/core/search.py +22 -0
- ansys/fluent/core/services/__init__.py +22 -0
- ansys/fluent/core/services/api_upgrade.py +22 -0
- ansys/fluent/core/services/app_utilities.py +38 -0
- ansys/fluent/core/services/batch_ops.py +22 -0
- ansys/fluent/core/services/datamodel_se.py +26 -1
- ansys/fluent/core/services/datamodel_tui.py +22 -0
- ansys/fluent/core/services/deprecated_field_data.py +23 -1
- ansys/fluent/core/services/events.py +22 -0
- ansys/fluent/core/services/field_data.py +285 -2
- ansys/fluent/core/services/health_check.py +22 -0
- ansys/fluent/core/services/interceptors.py +50 -2
- ansys/fluent/core/services/monitor.py +22 -0
- ansys/fluent/core/services/reduction.py +22 -0
- ansys/fluent/core/services/scheme_eval.py +22 -0
- ansys/fluent/core/services/settings.py +22 -0
- ansys/fluent/core/services/solution_variables.py +22 -0
- ansys/fluent/core/services/streaming.py +22 -0
- ansys/fluent/core/services/transcript.py +22 -0
- ansys/fluent/core/session.py +39 -2
- ansys/fluent/core/session_base_meshing.py +22 -0
- ansys/fluent/core/session_meshing.py +22 -0
- ansys/fluent/core/session_meshing.pyi +22 -0
- ansys/fluent/core/session_pure_meshing.py +22 -0
- ansys/fluent/core/session_pure_meshing.pyi +22 -0
- ansys/fluent/core/session_shared.py +22 -0
- ansys/fluent/core/session_solver.py +43 -0
- ansys/fluent/core/session_solver.pyi +22 -0
- ansys/fluent/core/session_solver_aero.py +22 -0
- ansys/fluent/core/session_solver_icing.py +22 -0
- ansys/fluent/core/session_solver_lite.py +22 -0
- ansys/fluent/core/solver/__init__.py +22 -0
- ansys/fluent/core/solver/error_message.py +22 -0
- ansys/fluent/core/solver/flobject.py +22 -0
- ansys/fluent/core/solver/flunits.py +22 -0
- ansys/fluent/core/solver/function/__init__.py +22 -0
- ansys/fluent/core/solver/function/reduction.py +22 -0
- ansys/fluent/core/solver/settings_builtin_bases.py +22 -0
- ansys/fluent/core/solver/settings_builtin_data.py +22 -0
- ansys/fluent/core/solver/settings_external.py +22 -0
- ansys/fluent/core/streaming_services/__init__.py +21 -0
- ansys/fluent/core/streaming_services/datamodel_event_streaming.py +22 -0
- ansys/fluent/core/streaming_services/datamodel_streaming.py +22 -0
- ansys/fluent/core/streaming_services/events_streaming.py +22 -0
- ansys/fluent/core/streaming_services/field_data_streaming.py +22 -0
- ansys/fluent/core/streaming_services/monitor_streaming.py +23 -1
- ansys/fluent/core/streaming_services/streaming.py +22 -0
- ansys/fluent/core/streaming_services/transcript_streaming.py +22 -0
- ansys/fluent/core/systemcoupling.py +22 -0
- ansys/fluent/core/utils/__init__.py +22 -0
- ansys/fluent/core/utils/data_transfer.py +22 -0
- ansys/fluent/core/utils/deprecate.py +24 -1
- ansys/fluent/core/utils/dictionary_operations.py +22 -0
- ansys/fluent/core/utils/dump_session_data.py +22 -0
- ansys/fluent/core/utils/event_loop.py +22 -0
- ansys/fluent/core/utils/execution.py +22 -0
- ansys/fluent/core/utils/file_transfer_service.py +22 -0
- ansys/fluent/core/utils/fix_doc.py +22 -0
- ansys/fluent/core/utils/fldoc.py +22 -0
- ansys/fluent/core/utils/fluent_version.py +22 -0
- ansys/fluent/core/utils/networking.py +22 -0
- ansys/fluent/core/utils/setup_for_fluent.py +22 -0
- ansys/fluent/core/warnings.py +22 -0
- ansys/fluent/core/workflow.py +22 -0
- {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/LICENSE +8 -8
- {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/METADATA +56 -33
- ansys_fluent_core-0.29.0.dist-info/RECORD +219 -0
- {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/WHEEL +1 -1
- ansys/fluent/core/docs/README.rst +0 -155
- ansys/fluent/tests/conftest.py +0 -415
- ansys/fluent/tests/fluent_fixtures.py +0 -195
- ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
- ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
- ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
- ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
- ansys/fluent/tests/test_aero_session.py +0 -88
- ansys/fluent/tests/test_batch_ops.py +0 -39
- ansys/fluent/tests/test_builtin_settings.py +0 -761
- ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
- ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
- ansys/fluent/tests/test_casereader.py +0 -324
- ansys/fluent/tests/test_codegen.py +0 -783
- ansys/fluent/tests/test_creatable.py +0 -31
- ansys/fluent/tests/test_data_model_cache.py +0 -434
- ansys/fluent/tests/test_datamodel_api.py +0 -429
- ansys/fluent/tests/test_datamodel_service.py +0 -814
- ansys/fluent/tests/test_datareader.py +0 -103
- ansys/fluent/tests/test_error_handling.py +0 -24
- ansys/fluent/tests/test_events_manager.py +0 -214
- ansys/fluent/tests/test_field_data.py +0 -466
- ansys/fluent/tests/test_file_session.py +0 -355
- ansys/fluent/tests/test_file_transfer_service.py +0 -165
- ansys/fluent/tests/test_fix_doc.py +0 -29
- ansys/fluent/tests/test_flobject.py +0 -1235
- ansys/fluent/tests/test_fluent_fixes.py +0 -106
- ansys/fluent/tests/test_fluent_session.py +0 -270
- ansys/fluent/tests/test_fluent_version.py +0 -66
- ansys/fluent/tests/test_fluent_version_marker.py +0 -65
- ansys/fluent/tests/test_icing_session.py +0 -9
- ansys/fluent/tests/test_launcher.py +0 -529
- ansys/fluent/tests/test_launcher_remote.py +0 -272
- ansys/fluent/tests/test_lispy.py +0 -40
- ansys/fluent/tests/test_logging.py +0 -16
- ansys/fluent/tests/test_mapped_api.py +0 -766
- ansys/fluent/tests/test_meshing_utilities.py +0 -2436
- ansys/fluent/tests/test_meshing_workflow.py +0 -421
- ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
- ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
- ansys/fluent/tests/test_preferences.py +0 -89
- ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
- ansys/fluent/tests/test_reduction.py +0 -484
- ansys/fluent/tests/test_rp_vars.py +0 -77
- ansys/fluent/tests/test_scheduler.py +0 -471
- ansys/fluent/tests/test_scheme_eval_222.py +0 -338
- ansys/fluent/tests/test_scheme_eval_231.py +0 -243
- ansys/fluent/tests/test_search.py +0 -344
- ansys/fluent/tests/test_session.py +0 -594
- ansys/fluent/tests/test_settings_api.py +0 -606
- ansys/fluent/tests/test_settings_reader.py +0 -85
- ansys/fluent/tests/test_slurm_future.py +0 -67
- ansys/fluent/tests/test_solution_variables.py +0 -241
- ansys/fluent/tests/test_solver_monitors.py +0 -83
- ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
- ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
- ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
- ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
- ansys/fluent/tests/test_solvermode/test_general.py +0 -109
- ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
- ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
- ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
- ansys/fluent/tests/test_solvermode/test_models.py +0 -99
- ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
- ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
- ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
- ansys/fluent/tests/test_streaming_services.py +0 -52
- ansys/fluent/tests/test_systemcoupling.py +0 -44
- ansys/fluent/tests/test_topy.py +0 -179
- ansys/fluent/tests/test_tui_api.py +0 -70
- ansys/fluent/tests/test_type_stub.py +0 -37
- ansys/fluent/tests/test_utils.py +0 -82
- ansys/fluent/tests/util/__init__.py +0 -36
- ansys/fluent/tests/util/meshing_workflow.py +0 -33
- ansys/fluent/tests/util/solver.py +0 -72
- ansys_fluent_core-0.28.2.dist-info/AUTHORS +0 -12
- ansys_fluent_core-0.28.2.dist-info/RECORD +0 -294
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
from ansys.fluent.core import examples
|
|
2
|
-
from ansys.fluent.core.filereader.case_file import CaseFile
|
|
3
|
-
from ansys.fluent.core.filereader.data_file import DataFile
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def test_data_reader_for_single_phase():
|
|
7
|
-
case_file_name = examples.download_file(
|
|
8
|
-
"elbow1.cas.h5", "pyfluent/file_session", return_without_path=False
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
data_file_name = examples.download_file(
|
|
12
|
-
"elbow1.dat.h5", "pyfluent/file_session", return_without_path=False
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
reader = DataFile(
|
|
16
|
-
data_file_name=data_file_name,
|
|
17
|
-
case_file_handle=CaseFile(case_file_name=case_file_name),
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
assert reader.case_file == "elbow1.cas.h5"
|
|
21
|
-
|
|
22
|
-
assert len(reader.variables()) == 80
|
|
23
|
-
|
|
24
|
-
assert reader.get_phases() == ["phase-1"]
|
|
25
|
-
|
|
26
|
-
assert len(reader.get_face_variables("phase-1")) == 30
|
|
27
|
-
|
|
28
|
-
assert len(reader.get_cell_variables("phase-1")) == 14
|
|
29
|
-
|
|
30
|
-
assert reader.get_cell_variables("phase-1") == [
|
|
31
|
-
"SV_BF_V",
|
|
32
|
-
"SV_D",
|
|
33
|
-
"SV_DENSITY",
|
|
34
|
-
"SV_H",
|
|
35
|
-
"SV_K",
|
|
36
|
-
"SV_LORENTZ_FORCE",
|
|
37
|
-
"SV_MU_LAM",
|
|
38
|
-
"SV_MU_T",
|
|
39
|
-
"SV_P",
|
|
40
|
-
"SV_T",
|
|
41
|
-
"SV_U",
|
|
42
|
-
"SV_V",
|
|
43
|
-
"SV_W",
|
|
44
|
-
"",
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
assert len(reader.get_face_scalar_field_data("phase-1", "SV_DENSITY", 3)) == 3630
|
|
48
|
-
|
|
49
|
-
assert len(reader.get_face_vector_field_data("phase-1", 3)) == 10890
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def test_data_reader_for_multi_phase():
|
|
53
|
-
case_file_name = examples.download_file(
|
|
54
|
-
"mixing_elbow_mul_ph.cas.h5",
|
|
55
|
-
"pyfluent/file_session",
|
|
56
|
-
return_without_path=False,
|
|
57
|
-
)
|
|
58
|
-
data_file_name = examples.download_file(
|
|
59
|
-
"mixing_elbow_mul_ph.dat.h5",
|
|
60
|
-
"pyfluent/file_session",
|
|
61
|
-
return_without_path=False,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
reader = DataFile(
|
|
65
|
-
data_file_name=data_file_name,
|
|
66
|
-
case_file_handle=CaseFile(case_file_name=case_file_name),
|
|
67
|
-
) # Instantiate a DataFile class
|
|
68
|
-
|
|
69
|
-
assert reader.case_file == "mixing_elbow_mul_ph.cas.h5"
|
|
70
|
-
|
|
71
|
-
assert len(reader.variables()) == 80
|
|
72
|
-
|
|
73
|
-
assert reader.get_phases() == [
|
|
74
|
-
"phase-1",
|
|
75
|
-
"phase-2",
|
|
76
|
-
"phase-3",
|
|
77
|
-
"phase-4",
|
|
78
|
-
]
|
|
79
|
-
|
|
80
|
-
assert len(reader.get_face_variables("phase-1")) == 23
|
|
81
|
-
|
|
82
|
-
assert len(reader.get_face_variables("phase-3")) == 13
|
|
83
|
-
|
|
84
|
-
assert len(reader.get_cell_variables("phase-2")) == 14
|
|
85
|
-
|
|
86
|
-
assert reader.get_cell_variables("phase-2") == [
|
|
87
|
-
"SV_BF_V",
|
|
88
|
-
"SV_DENSITY",
|
|
89
|
-
"SV_DENSITY_M1",
|
|
90
|
-
"SV_MU_LAM",
|
|
91
|
-
"SV_MU_T",
|
|
92
|
-
"SV_U",
|
|
93
|
-
"SV_U_M1",
|
|
94
|
-
"SV_V",
|
|
95
|
-
"SV_VOF",
|
|
96
|
-
"SV_VOF_M1",
|
|
97
|
-
"SV_V_M1",
|
|
98
|
-
"SV_W",
|
|
99
|
-
"SV_W_M1",
|
|
100
|
-
"",
|
|
101
|
-
]
|
|
102
|
-
|
|
103
|
-
assert len(reader.get_face_scalar_field_data("phase-1", "SV_DENSITY", 33)) == 268
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import time
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@pytest.mark.fluent_version(">=23.1")
|
|
7
|
-
@pytest.mark.parametrize(
|
|
8
|
-
"error_code,raises",
|
|
9
|
-
[
|
|
10
|
-
(0, pytest.wont_raise()),
|
|
11
|
-
(1, pytest.raises(RuntimeError)),
|
|
12
|
-
],
|
|
13
|
-
)
|
|
14
|
-
def test_fluent_fatal_error(error_code, raises, new_solver_session):
|
|
15
|
-
scheme_eval = new_solver_session.scheme_eval.scheme_eval
|
|
16
|
-
with raises:
|
|
17
|
-
scheme_eval(
|
|
18
|
-
"(events/transmit 'error-event "
|
|
19
|
-
f'(cons (format #f "fatal error: ~a~%" "testing") {error_code}))'
|
|
20
|
-
)
|
|
21
|
-
for _ in range(10):
|
|
22
|
-
# as these are mostly instant, exception should usually be raised on the second gRPC call
|
|
23
|
-
scheme_eval("(pp 'fatal_error_testing)")
|
|
24
|
-
time.sleep(0.1)
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
import ansys.fluent.core as pyfluent
|
|
6
|
-
from ansys.fluent.core import FluentVersion, MeshingEvent, SolverEvent, examples
|
|
7
|
-
from ansys.fluent.core.warnings import PyFluentDeprecationWarning
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def test_receive_events_on_case_loaded(new_solver_session) -> None:
|
|
11
|
-
|
|
12
|
-
def on_case_loaded_old(session_id, event_info):
|
|
13
|
-
on_case_loaded_old.loaded = True
|
|
14
|
-
|
|
15
|
-
on_case_loaded_old.loaded = False
|
|
16
|
-
|
|
17
|
-
def on_case_loaded_old_with_args(x, y, session_id, event_info):
|
|
18
|
-
on_case_loaded_old_with_args.state = dict(x=x, y=y)
|
|
19
|
-
|
|
20
|
-
on_case_loaded_old_with_args.state = None
|
|
21
|
-
|
|
22
|
-
def on_case_loaded(session, event_info):
|
|
23
|
-
on_case_loaded.loaded = True
|
|
24
|
-
if session.get_fluent_version() >= FluentVersion.v232:
|
|
25
|
-
assert Path(event_info.case_file_name).name == Path(case_file_name).name
|
|
26
|
-
with pytest.warns(PyFluentDeprecationWarning):
|
|
27
|
-
assert Path(event_info.casefilepath).name == Path(case_file_name).name
|
|
28
|
-
|
|
29
|
-
on_case_loaded.loaded = False
|
|
30
|
-
|
|
31
|
-
def on_case_loaded_with_args_optional_first(x, y, session, event_info):
|
|
32
|
-
on_case_loaded_with_args_optional_first.state = dict(x=x, y=y)
|
|
33
|
-
|
|
34
|
-
on_case_loaded_with_args_optional_first.state = None
|
|
35
|
-
|
|
36
|
-
def on_case_loaded_with_args(session, event_info, x, y):
|
|
37
|
-
on_case_loaded_with_args.state = dict(x=x, y=y)
|
|
38
|
-
|
|
39
|
-
on_case_loaded_with_args.state = None
|
|
40
|
-
|
|
41
|
-
solver = new_solver_session
|
|
42
|
-
|
|
43
|
-
solver.events.register_callback(SolverEvent.CASE_LOADED, on_case_loaded_old)
|
|
44
|
-
|
|
45
|
-
solver.events.register_callback(
|
|
46
|
-
SolverEvent.CASE_LOADED, on_case_loaded_old_with_args, 12, y=42
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
solver.events.register_callback(SolverEvent.CASE_LOADED, on_case_loaded)
|
|
50
|
-
|
|
51
|
-
solver.events.register_callback(
|
|
52
|
-
SolverEvent.CASE_LOADED, on_case_loaded_with_args_optional_first, 12, y=42
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
solver.events.register_callback(
|
|
56
|
-
SolverEvent.CASE_LOADED, on_case_loaded_with_args, 12, y=42
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
case_file_name = examples.download_file(
|
|
60
|
-
"mixing_elbow.cas.h5", "pyfluent/mixing_elbow"
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
assert not on_case_loaded_old.loaded
|
|
64
|
-
assert not on_case_loaded.loaded
|
|
65
|
-
assert not on_case_loaded_old_with_args.state
|
|
66
|
-
assert not on_case_loaded_with_args_optional_first.state
|
|
67
|
-
assert not on_case_loaded_with_args.state
|
|
68
|
-
|
|
69
|
-
try:
|
|
70
|
-
solver.settings.file.read_case(file_name=case_file_name)
|
|
71
|
-
except AttributeError:
|
|
72
|
-
solver.tui.file.read_case(case_file_name)
|
|
73
|
-
|
|
74
|
-
assert on_case_loaded_old.loaded
|
|
75
|
-
assert on_case_loaded.loaded
|
|
76
|
-
assert on_case_loaded_old_with_args.state == dict(x=12, y=42)
|
|
77
|
-
assert on_case_loaded_with_args_optional_first.state == dict(x=12, y=42)
|
|
78
|
-
assert on_case_loaded_with_args.state == dict(x=12, y=42)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def test_receive_meshing_events_on_case_loaded(new_meshing_session) -> None:
|
|
82
|
-
|
|
83
|
-
case_file_name = examples.download_file(
|
|
84
|
-
"mixing_elbow.cas.h5", "pyfluent/mixing_elbow"
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
def on_case_loaded(session, event_info):
|
|
88
|
-
on_case_loaded.loaded = True
|
|
89
|
-
|
|
90
|
-
on_case_loaded.loaded = False
|
|
91
|
-
|
|
92
|
-
meshing = new_meshing_session
|
|
93
|
-
|
|
94
|
-
meshing.events.register_callback(MeshingEvent.CASE_LOADED, on_case_loaded)
|
|
95
|
-
|
|
96
|
-
assert not on_case_loaded.loaded
|
|
97
|
-
|
|
98
|
-
meshing.tui.file.read_case(case_file_name)
|
|
99
|
-
|
|
100
|
-
# this is not working in meshing mode
|
|
101
|
-
# assert on_case_loaded.loaded
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
@pytest.mark.fluent_version(">=23.1")
|
|
105
|
-
def test_iteration_ended_sync_event(static_mixer_case_session):
|
|
106
|
-
solver = static_mixer_case_session
|
|
107
|
-
solver.settings.solution.initialization.hybrid_initialize()
|
|
108
|
-
count = 0
|
|
109
|
-
|
|
110
|
-
def cb(session, event_info):
|
|
111
|
-
assert event_info.index == session.scheme_eval.scheme_eval(
|
|
112
|
-
"(get-current-iteration)"
|
|
113
|
-
)
|
|
114
|
-
nonlocal count
|
|
115
|
-
count += 1
|
|
116
|
-
|
|
117
|
-
cb_id = solver.events.register_callback(pyfluent.SolverEvent.ITERATION_ENDED, cb)
|
|
118
|
-
solver.settings.solution.run_calculation.iterate(iter_count=10)
|
|
119
|
-
assert count == 10
|
|
120
|
-
solver.events.unregister_callback(cb_id)
|
|
121
|
-
solver.settings.solution.run_calculation.iterate(iter_count=5)
|
|
122
|
-
assert count == 10
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
@pytest.mark.fluent_version(">=23.1")
|
|
126
|
-
def test_iteration_ended_sync_event_multiple_connections(static_mixer_case_session):
|
|
127
|
-
solver1 = static_mixer_case_session
|
|
128
|
-
solver2 = pyfluent.connect_to_fluent(
|
|
129
|
-
ip=solver1.connection_properties.ip,
|
|
130
|
-
port=solver1.connection_properties.port,
|
|
131
|
-
password=solver1.connection_properties.password,
|
|
132
|
-
)
|
|
133
|
-
solver1.settings.solution.initialization.hybrid_initialize()
|
|
134
|
-
solver1_count = 0
|
|
135
|
-
solver2_count = 0
|
|
136
|
-
|
|
137
|
-
def solver1_cb(session, event_info):
|
|
138
|
-
assert session == solver1
|
|
139
|
-
if event_info.index % 2 == 0:
|
|
140
|
-
nonlocal solver1_count
|
|
141
|
-
solver1_count += 1
|
|
142
|
-
|
|
143
|
-
def solver2_cb(session, event_info):
|
|
144
|
-
assert session == solver2
|
|
145
|
-
if event_info.index % 2 == 1:
|
|
146
|
-
nonlocal solver2_count
|
|
147
|
-
solver2_count += 1
|
|
148
|
-
|
|
149
|
-
solver1.events.register_callback(pyfluent.SolverEvent.ITERATION_ENDED, solver1_cb)
|
|
150
|
-
solver2.events.register_callback(pyfluent.SolverEvent.ITERATION_ENDED, solver2_cb)
|
|
151
|
-
solver2.settings.solution.run_calculation.iterate(iter_count=5)
|
|
152
|
-
assert solver1_count == 2
|
|
153
|
-
assert solver2_count == 3
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
@pytest.mark.fluent_version(">=23.1")
|
|
157
|
-
def test_timestep_ended_sync_event(static_mixer_case_session):
|
|
158
|
-
solver = static_mixer_case_session
|
|
159
|
-
solver.settings.setup.general.solver.time = "unsteady-2nd-order"
|
|
160
|
-
solver.settings.solution.initialization.hybrid_initialize()
|
|
161
|
-
count = 0
|
|
162
|
-
|
|
163
|
-
def cb(session, event_info):
|
|
164
|
-
assert event_info.index == solver.rp_vars("time-step")
|
|
165
|
-
nonlocal count
|
|
166
|
-
count += 1
|
|
167
|
-
|
|
168
|
-
cb_id = solver.events.register_callback(pyfluent.SolverEvent.TIMESTEP_ENDED, cb)
|
|
169
|
-
solver.settings.solution.run_calculation.dual_time_iterate(
|
|
170
|
-
time_step_count=10, max_iter_per_step=2
|
|
171
|
-
)
|
|
172
|
-
assert count == 10
|
|
173
|
-
solver.events.unregister_callback(cb_id)
|
|
174
|
-
solver.settings.solution.run_calculation.dual_time_iterate(
|
|
175
|
-
time_step_count=5, max_iter_per_step=2
|
|
176
|
-
)
|
|
177
|
-
assert count == 10
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
@pytest.mark.fluent_version(">=23.1")
|
|
181
|
-
def test_sync_event_exception_in_callback(static_mixer_case_session, caplog):
|
|
182
|
-
solver = static_mixer_case_session
|
|
183
|
-
solver.settings.solution.initialization.hybrid_initialize()
|
|
184
|
-
|
|
185
|
-
def cb(session, event_info):
|
|
186
|
-
raise RuntimeError
|
|
187
|
-
|
|
188
|
-
cb_id = solver.events.register_callback(pyfluent.SolverEvent.ITERATION_ENDED, cb)
|
|
189
|
-
with caplog.at_level("ERROR", logger="pyfluent.networking"):
|
|
190
|
-
solver.settings.solution.run_calculation.iterate(iter_count=10)
|
|
191
|
-
assert (
|
|
192
|
-
len(
|
|
193
|
-
[
|
|
194
|
-
record
|
|
195
|
-
for record in caplog.records
|
|
196
|
-
if "Error in callback" in record.message
|
|
197
|
-
]
|
|
198
|
-
)
|
|
199
|
-
== 10
|
|
200
|
-
)
|
|
201
|
-
caplog.clear()
|
|
202
|
-
solver.events.unregister_callback(cb_id)
|
|
203
|
-
with caplog.at_level("ERROR", logger="pyfluent.networking"):
|
|
204
|
-
solver.settings.solution.run_calculation.iterate(iter_count=5)
|
|
205
|
-
assert (
|
|
206
|
-
len(
|
|
207
|
-
[
|
|
208
|
-
record
|
|
209
|
-
for record in caplog.records
|
|
210
|
-
if "Error in callback" in record.message
|
|
211
|
-
]
|
|
212
|
-
)
|
|
213
|
-
== 0
|
|
214
|
-
)
|