Skip to content

Commit

Permalink
fix: nightly tests (#2625)
Browse files Browse the repository at this point in the history
* fix: nightly

* fix: nightly

* fix: nightly

---------

Co-authored-by: Prithwish Mukherjee <[email protected]>
  • Loading branch information
mkundu1 and prmukherj authored Mar 29, 2024
1 parent 80d492e commit 2981771
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 25 deletions.
24 changes: 15 additions & 9 deletions tests/parametric/test_parametric_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
from ansys.fluent.core import examples
from ansys.fluent.core.launcher.fluent_container import DEFAULT_CONTAINER_MOUNT_PATH

PYTEST_RELATIVE_TOLERANCE = 1e-3


def pytest_approx(expected):
return pytest.approx(expected=expected, rel=PYTEST_RELATIVE_TOLERANCE)


@pytest.mark.nightly
@pytest.mark.fluent_version("latest")
Expand Down Expand Up @@ -86,10 +92,10 @@ def test_parametric_workflow():
assert base_dp.input_parameters["inlet1_temp"]() == 300.0
study1.design_points.update_current()
assert len(study1.design_points) == 1
assert base_dp.output_parameters["outlet-temp-avg-op"]() == pytest.approx(
333.348727, rel=1e-5
assert base_dp.output_parameters["outlet-temp-avg-op"]() == pytest_approx(
333.348727
)
assert base_dp.output_parameters["outlet-vel-avg-op"]() == pytest.approx(1.506855)
assert base_dp.output_parameters["outlet-vel-avg-op"]() == pytest_approx(1.506855)
dp1_name = study1.design_points.create_1()
dp1 = study1.design_points[dp1_name]
dp1.input_parameters["inlet1_temp"] = 500
Expand All @@ -111,14 +117,14 @@ def test_parametric_workflow():
assert study1.current_design_point() == dp2_name
study1.design_points.update_all()
assert len(study1.design_points) == 3
assert base_dp.output_parameters["outlet-temp-avg-op"]() == pytest.approx(
assert base_dp.output_parameters["outlet-temp-avg-op"]() == pytest_approx(
333.348727
)
assert base_dp.output_parameters["outlet-vel-avg-op"]() == pytest.approx(1.506855)
assert dp1.output_parameters["outlet-temp-avg-op"]() == pytest.approx(425.004045)
assert dp1.output_parameters["outlet-vel-avg-op"]() == pytest.approx(2.029792)
assert dp2.output_parameters["outlet-temp-avg-op"]() == pytest.approx(425.004045)
assert dp2.output_parameters["outlet-vel-avg-op"]() == pytest.approx(2.029792)
assert base_dp.output_parameters["outlet-vel-avg-op"]() == pytest_approx(1.506855)
assert dp1.output_parameters["outlet-temp-avg-op"]() == pytest_approx(425.004045)
assert dp1.output_parameters["outlet-vel-avg-op"]() == pytest_approx(2.029792)
assert dp2.output_parameters["outlet-temp-avg-op"]() == pytest_approx(425.004045)
assert dp2.output_parameters["outlet-vel-avg-op"]() == pytest_approx(2.029792)

design_point_table = Path(tmp_save_path) / "design_point_table_study_1.csv"
if inside_container:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_datamodel_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,15 @@ def test_named_object_specific_methods(new_mesh_session):
assert not meshing.workflow.TaskObject.get_object_names()


@pytest.mark.codegen_required
@pytest.mark.fluent_version(">=24.1")
def test_command_creation_inside_singleton(new_mesh_session):
meshing = new_mesh_session
read_mesh = meshing.meshing.File.ReadMesh.create_instance()
assert read_mesh.FileName is not None


@pytest.mark.codegen_required
def test_read_ony_set_state(new_mesh_session):
meshing = new_mesh_session
meshing.preferences.MeshingWorkflow.SaveCheckpointFiles = True
Expand Down
48 changes: 32 additions & 16 deletions tests/test_meshing_queries_fdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

import_filename = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")

PYTEST_RELATIVE_TOLERANCE = 0.2


def pytest_approx(expected):
return pytest.approx(expected=expected, rel=PYTEST_RELATIVE_TOLERANCE)


@pytest.mark.codegen_required
@pytest.mark.nightly
@pytest.mark.fluent_version(">=24.2")
def test_meshing_utilities(new_mesh_session):
Expand Down Expand Up @@ -824,14 +831,11 @@ def test_meshing_utilities(new_mesh_session):

assert meshing_session.meshing_utilities.get_region_volume(
object_name="elbow-fluid", sorting_order="ascending"
) == [[152.59942809266, "elbow-fluid"]]
) == [[pytest_approx(152.59942809266), "elbow-fluid"]]

assert (
meshing_session.meshing_utilities.get_region_volume(
object_name="elbow-fluid", region_name="elbow-fluid"
)
== 152.59942809266
)
assert meshing_session.meshing_utilities.get_region_volume(
object_name="elbow-fluid", region_name="elbow-fluid"
) == pytest_approx(152.59942809266)

assert (
meshing_session.meshing_utilities.get_pairs_of_overlapping_face_zones(
Expand Down Expand Up @@ -1025,15 +1029,27 @@ def test_meshing_utilities(new_mesh_session):

assert meshing_session.meshing_utilities.get_edge_size_limits(
face_zone_id_list=[30, 31, 32]
) == [0.02167507486136073, 0.3016698360443115, 0.1515733801031084]
) == [
pytest_approx(0.02167507486136073),
pytest_approx(0.3016698360443115),
pytest_approx(0.1515733801031084),
]

assert meshing_session.meshing_utilities.get_edge_size_limits(
face_zone_name_list=["cold-inlet", "hot-inlet", "outlet"]
) == [0.02167507486136073, 0.3016698360443115, 0.1515733801031084]
) == [
pytest_approx(0.02167507486136073),
pytest_approx(0.3016698360443115),
pytest_approx(0.1515733801031084),
]

assert meshing_session.meshing_utilities.get_edge_size_limits(
face_zone_name_pattern="*"
) == [0.002393084222530175, 0.3613402218724294, 0.1225859010936682]
) == [
pytest_approx(0.002393084222530175),
pytest_approx(0.3613402218724294),
pytest_approx(0.1225859010936682),
]

assert (
meshing_session.meshing_utilities.get_cell_zone_shape(cell_zone_id=87)
Expand Down Expand Up @@ -1072,42 +1088,42 @@ def test_meshing_utilities(new_mesh_session):
measure="Orthogonal Quality",
partitions=2,
range=[0.9, 1],
) == [356, [323, 33], [0, 6]]
) == [322, [225, 97], [0, 40]]

assert meshing_session.meshing_utilities.get_face_mesh_distribution(
face_zone_name_list=["cold-inlet", "hot-inlet", "outlet"],
measure="Orthogonal Quality",
partitions=2,
range=[0.9, 1],
) == [356, [323, 33], [0, 6]]
) == [322, [225, 97], [0, 40]]

assert meshing_session.meshing_utilities.get_face_mesh_distribution(
face_zone_name_pattern="*",
measure="Orthogonal Quality",
partitions=2,
range=[0.9, 1],
) == [83001, [71792, 11209], [0, 8580]]
) == [69656, [53976, 15680], [0, 22455]]

assert meshing_session.meshing_utilities.get_cell_mesh_distribution(
cell_zone_id_list=[87],
measure="Orthogonal Quality",
partitions=2,
range=[0.9, 1],
) == [16016, [11740, 4276], [0, 1806]]
) == [16029, [11794, 4235], [0, 1872]]

assert meshing_session.meshing_utilities.get_cell_mesh_distribution(
cell_zone_name_list=["elbow-fluid"],
measure="Orthogonal Quality",
partitions=2,
range=[0.9, 1],
) == [16016, [11740, 4276], [0, 1806]]
) == [16029, [11794, 4235], [0, 1872]]

assert meshing_session.meshing_utilities.get_cell_mesh_distribution(
cell_zone_name_pattern="*",
measure="Orthogonal Quality",
partitions=2,
range=[0.9, 1],
) == [16016, [11740, 4276], [0, 1806]]
) == [16029, [11794, 4235], [0, 1872]]

# Commented due to variation in 10^-13 th place

Expand Down
2 changes: 2 additions & 0 deletions tests/test_meshing_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def test_modified_workflow(new_mesh_session):
assert set(task_display_names) == task_object_display_names


@pytest.mark.codegen_required
def test_nonexistent_attrs(new_mesh_session):
meshing = new_mesh_session
assert not hasattr(meshing.workflow, "xyz")
Expand All @@ -403,6 +404,7 @@ def test_nonexistent_attrs(new_mesh_session):
assert msg.value.args[0] == "'ClassicMeshingWorkflow' object has no attribute 'xyz'"


@pytest.mark.codegen_required
@pytest.mark.fluent_version(">=23.2")
def test_old_workflow_structure(new_mesh_session):
meshing = new_mesh_session
Expand Down

0 comments on commit 2981771

Please sign in to comment.