Skip to content

Commit

Permalink
ci: Generate Fluent journals
Browse files Browse the repository at this point in the history
  • Loading branch information
mkundu1 committed Nov 26, 2024
1 parent 935aad9 commit 45ac856
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
26 changes: 4 additions & 22 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,16 @@ def pytest_runtest_setup(item):
pytest.skip()


# Fluent launcher arguments for fixtures which are not "3ddp"
# TODO: Use a decorator
launcher_args_by_fixture = {
"new_meshing_session": "3ddp -meshing",
"new_pure_meshing_session": "3ddp -meshing",
"watertight_workflow_session": "3ddp -meshing",
"fault_tolerant_workflow_session": "3ddp -meshing",
"mixing_elbow_watertight_pure_meshing_session": "3ddp -meshing",
"new_solver_session": "3ddp",
"new_solver_session_sp": "3d",
"new_solver_session_2d": "2ddp",
"static_mixer_settings_session": "3ddp",
"static_mixer_case_session": "3ddp",
"mixing_elbow_settings_session": "3ddp",
"mixing_elbow_case_data_session": "3ddp",
"mixing_elbow_param_case_data_session": "3ddp",
"disk_settings_session": "2ddp",
"disk_case_session": "2ddp",
"periodic_rot_settings_session": "3ddp",
}


def pytest_collection_finish(session):
if session.config.getoption("--write-fluent-journals"):
import_path = Path(__file__).parent
sys.path.append(str(import_path))
import fluent_fixtures

launcher_args_by_fixture = {}
for k, v in fluent_fixtures.__dict__.items():
if hasattr(v, "fluent_launcher_args"):
launcher_args_by_fixture[k] = v.fluent_launcher_args
fluent_test_root = import_path / "fluent"
shutil.rmtree(fluent_test_root, ignore_errors=True)
for item in session.items:
Expand Down
29 changes: 29 additions & 0 deletions tests/fluent_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
from typing import Callable

import pytest

import ansys.fluent.core as pyfluent
from ansys.fluent.core.data_model_cache import DataModelCache
from ansys.fluent.core.examples import download_file


def fluent_launcher_args(args: str):
def fluent_launcher_args_inner(f: Callable):
def wrapper(*args, **kwargs):
return f(*args, **kwargs)

wrapper.fluent_launcher_args = args
return wrapper

return fluent_launcher_args_inner


def mixing_elbow_geometry_filename(globals):
return download_file(
file_name="mixing_elbow.pmdb", directory="pyfluent/mixing_elbow"
Expand All @@ -17,27 +30,32 @@ def exhaust_system_geometry_filename(globals):
)


@fluent_launcher_args("3ddp -meshing")
def new_meshing_session(globals):
meshing = globals["meshing"]
return meshing


@fluent_launcher_args("3ddp -meshing")
def new_pure_meshing_session(globals):
return new_meshing_session(globals)


@fluent_launcher_args("3ddp -meshing")
def watertight_workflow_session(globals):
meshing = new_meshing_session(globals)
meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry")
return meshing


@fluent_launcher_args("3ddp -meshing")
def fault_tolerant_workflow_session(globals):
meshing = new_meshing_session(globals)
meshing.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing")
return meshing


@fluent_launcher_args("3ddp -meshing")
def mixing_elbow_watertight_pure_meshing_session(globals):
meshing = new_pure_meshing_session(globals)
geometry_filename = mixing_elbow_geometry_filename(globals)
Expand All @@ -48,19 +66,23 @@ def mixing_elbow_watertight_pure_meshing_session(globals):
return meshing


@fluent_launcher_args("3ddp")
def new_solver_session(globals):
solver = globals["solver"]
return solver


@fluent_launcher_args("3d")
def new_solver_session_sp(globals):
return new_solver_session(globals)


@fluent_launcher_args("2ddp")
def new_solver_session_2d(globals):
return new_solver_session(globals)


@fluent_launcher_args("3ddp")
def static_mixer_settings_session(globals):
solver = new_solver_session(globals)
case_name = download_file("Static_Mixer_main.cas.h5", "pyfluent/static_mixer")
Expand All @@ -72,13 +94,15 @@ def static_mixer_settings_session(globals):
return solver


@fluent_launcher_args("3ddp")
def static_mixer_case_session(globals):
solver = new_solver_session(globals)
case_name = download_file("Static_Mixer_main.cas.h5", "pyfluent/static_mixer")
solver.file.read(file_type="case", file_name=case_name)
return solver


@fluent_launcher_args("3ddp")
def mixing_elbow_settings_session(globals):
solver = new_solver_session(globals)
case_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
Expand All @@ -90,6 +114,7 @@ def mixing_elbow_settings_session(globals):
return solver


@fluent_launcher_args("3ddp")
def mixing_elbow_case_data_session(globals):
solver = new_solver_session(globals)
case_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
Expand All @@ -98,6 +123,7 @@ def mixing_elbow_case_data_session(globals):
return solver


@fluent_launcher_args("3ddp")
def mixing_elbow_param_case_data_session(globals):
solver = new_solver_session(globals)
case_name = download_file("elbow_param.cas.h5", "pyfluent/mixing_elbow")
Expand All @@ -106,6 +132,7 @@ def mixing_elbow_param_case_data_session(globals):
return solver


@fluent_launcher_args("2ddp")
def disk_settings_session(globals):
solver = new_solver_session_2d(globals)
case_name = download_file("disk.cas.h5", "pyfluent/rotating_disk")
Expand All @@ -117,13 +144,15 @@ def disk_settings_session(globals):
return solver


@fluent_launcher_args("2ddp")
def disk_case_session(globals):
solver = new_solver_session_2d(globals)
case_name = download_file("disk.cas.h5", "pyfluent/rotating_disk")
solver.file.read(file_type="case", file_name=case_name)
return solver


@fluent_launcher_args("3ddp")
def periodic_rot_settings_session(globals):
solver = new_solver_session(globals)
case_name = download_file(
Expand Down

0 comments on commit 45ac856

Please sign in to comment.