From a3fbbb9f6ee612a5f0f7d44edf0e80eabab535e2 Mon Sep 17 00:00:00 2001 From: Mainak Kundu <94432368+mkundu1@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:44:28 -0400 Subject: [PATCH] feat: Builtin settings objects from Setup section of Fluent's outline tree (#3127) feat: Initial implementation of settings objects --- pyproject.toml | 2 +- src/ansys/fluent/core/__init__.py | 5 + src/ansys/fluent/core/codegen/allapigen.py | 8 +- .../core/codegen/builtin_settingsgen.py | 46 +++ .../core/solver/settings_builtin_bases.py | 26 ++ .../core/solver/settings_builtin_data.py | 324 ++++++++++++++++++ tests/test_settings_api.py | 217 ++++++++++++ 7 files changed, 626 insertions(+), 2 deletions(-) create mode 100644 src/ansys/fluent/core/codegen/builtin_settingsgen.py create mode 100644 src/ansys/fluent/core/solver/settings_builtin_bases.py create mode 100644 src/ansys/fluent/core/solver/settings_builtin_data.py diff --git a/pyproject.toml b/pyproject.toml index 7ac5b5218b0..fba9f068d34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ classifiers = [ include = [ { path = "src/ansys/fluent/core/generated/fluent_version_*.py", format = ["sdist", "wheel"] }, { path = "src/ansys/fluent/core/generated/meshing/tui_*.py", format = ["sdist", "wheel"] }, - { path = "src/ansys/fluent/core/generated/solver/tui_*.py", format = ["sdist", "wheel"] }, + { path = "src/ansys/fluent/core/generated/solver/*.py", format = ["sdist", "wheel"] }, { path = "src/ansys/fluent/core/generated/datamodel_*/*.py", format = ["sdist", "wheel"] }, { path = "src/ansys/fluent/core/generated/solver/settings_*/*.py", format = ["sdist", "wheel"] }, { path = "src/ansys/fluent/core/generated/solver/settings_*/*.pyi", format = ["sdist", "wheel"] }, diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index efc79784358..cbac5d85f6a 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -47,6 +47,11 @@ warning, ) +try: + from ansys.fluent.core.generated.solver.settings_builtin import * # noqa: F401, F403 +except (ImportError, AttributeError): + pass + _VERSION_INFO = None """Global variable indicating the version of the PyFluent package - Empty by default""" diff --git a/src/ansys/fluent/core/codegen/allapigen.py b/src/ansys/fluent/core/codegen/allapigen.py index a1b80b1aa41..0981b140209 100644 --- a/src/ansys/fluent/core/codegen/allapigen.py +++ b/src/ansys/fluent/core/codegen/allapigen.py @@ -3,7 +3,12 @@ from pathlib import Path import pickle -from ansys.fluent.core.codegen import datamodelgen, settingsgen, tuigen +from ansys.fluent.core.codegen import ( + builtin_settingsgen, + datamodelgen, + settingsgen, + tuigen, +) from ansys.fluent.core.search import get_api_tree_file_name @@ -22,6 +27,7 @@ def generate(version: str, static_infos: dict): Path(api_tree_file).parent.mkdir(parents=True, exist_ok=True) with open(api_tree_file, "wb") as f: pickle.dump(api_tree, f) + builtin_settingsgen.generate() if __name__ == "__main__": diff --git a/src/ansys/fluent/core/codegen/builtin_settingsgen.py b/src/ansys/fluent/core/codegen/builtin_settingsgen.py new file mode 100644 index 00000000000..12b631a47b6 --- /dev/null +++ b/src/ansys/fluent/core/codegen/builtin_settingsgen.py @@ -0,0 +1,46 @@ +"""Generate builtin setting classes.""" + +from ansys.fluent.core import CODEGEN_OUTDIR, FluentVersion +from ansys.fluent.core.solver.settings_builtin_data import DATA + +_PY_FILE = CODEGEN_OUTDIR / "solver" / "settings_builtin.py" +_PYI_FILE = CODEGEN_OUTDIR / "solver" / "settings_builtin.pyi" + + +def generate(): + """Generate builtin setting classes.""" + CODEGEN_OUTDIR.mkdir(exist_ok=True) + with open(_PY_FILE, "w") as f: + f.write('"""Solver settings."""\n\n') + f.write( + "from ansys.fluent.core.solver.settings_builtin_bases import _SingletonSetting, _NamedObjectSetting\n\n\n" + ) + f.write("__all__ = [\n") + for name, _ in DATA.items(): + f.write(f' "{name}",\n') + f.write("]\n\n") + for name, v in DATA.items(): + kind, path = v + f.write(f"class {name}(_{kind}Setting):\n") + f.write(f' """{name} setting."""\n\n') + + with open(_PYI_FILE, "w") as f: + for version in FluentVersion: + f.write( + f"from ansys.fluent.core.generated.solver.settings_{version.number} import root as settings_root_{version.number}\n" + ) + f.write("\n\n") + for name, v in DATA.items(): + kind, path = v + f.write(f"class {name}(\n") + if isinstance(path, str): + path = {v: path for v in FluentVersion} + for v, p in path.items(): + if kind == "NamedObject": + p = f"{p}.child_object_type" + f.write(f" type(settings_root_{v.number}.{p}),\n") + f.write("): ...\n\n") + + +if __name__ == "__main__": + generate() diff --git a/src/ansys/fluent/core/solver/settings_builtin_bases.py b/src/ansys/fluent/core/solver/settings_builtin_bases.py new file mode 100644 index 00000000000..e5084bd9c53 --- /dev/null +++ b/src/ansys/fluent/core/solver/settings_builtin_bases.py @@ -0,0 +1,26 @@ +"""Base classes for builtin setting classes.""" + +from ansys.fluent.core.session_solver import Solver +from ansys.fluent.core.solver.settings_builtin_data import DATA + + +class _SingletonSetting: + def __new__(cls, solver: Solver): + obj = solver.settings + path = DATA[cls.__name__][1] + if isinstance(path, dict): + version = solver.get_fluent_version() + path = path.get(version) + if path is None: + raise RuntimeError( + f"{cls.__name__} is not supported in Fluent version {version}." + ) + for comp in path.split("."): + obj = getattr(obj, comp) + return obj + + +class _NamedObjectSetting(_SingletonSetting): + def __new__(cls, solver: Solver, name: str): + obj = super().__new__(cls, solver) + return obj[name] diff --git a/src/ansys/fluent/core/solver/settings_builtin_data.py b/src/ansys/fluent/core/solver/settings_builtin_data.py new file mode 100644 index 00000000000..77c96dff2cc --- /dev/null +++ b/src/ansys/fluent/core/solver/settings_builtin_data.py @@ -0,0 +1,324 @@ +"""Data for for builtin setting classes.""" + +from ansys.fluent.core import FluentVersion + +# {: (, )} +DATA = { + "Setup": ("Singleton", "setup"), + "General": ("Singleton", "setup.general"), + "Models": ("Singleton", "setup.models"), + "Multiphase": ("Singleton", "setup.models.multiphase"), + "Energy": ("Singleton", "setup.models.energy"), + "Viscous": ("Singleton", "setup.models.viscous"), + "Radiation": ( + "Singleton", + { + FluentVersion.v251: "setup.models.radiation", + FluentVersion.v242: "setup.models.radiation", + FluentVersion.v241: "setup.models.radiation", + FluentVersion.v232: "setup.models.radiation", + }, + ), + "Species": ( + "Singleton", + { + FluentVersion.v251: "setup.models.species", + FluentVersion.v242: "setup.models.species", + FluentVersion.v241: "setup.models.species", + FluentVersion.v232: "setup.models.species", + }, + ), + "DiscretePhase": ( + "Singleton", + { + FluentVersion.v251: "setup.models.discrete_phase", + FluentVersion.v242: "setup.models.discrete_phase", + FluentVersion.v241: "setup.models.discrete_phase", + FluentVersion.v232: "setup.models.discrete_phase", + FluentVersion.v231: "setup.models.discrete_phase", + }, + ), + "Injections": ( + "Singleton", + { + FluentVersion.v251: "setup.models.discrete_phase.injections", + FluentVersion.v242: "setup.models.discrete_phase.injections", + FluentVersion.v241: "setup.models.discrete_phase.injections", + FluentVersion.v232: "setup.models.discrete_phase.injections", + FluentVersion.v231: "setup.models.discrete_phase.injections", + }, + ), + "Injection": ( + "NamedObject", + { + FluentVersion.v251: "setup.models.discrete_phase.injections", + FluentVersion.v242: "setup.models.discrete_phase.injections", + FluentVersion.v241: "setup.models.discrete_phase.injections", + FluentVersion.v232: "setup.models.discrete_phase.injections", + FluentVersion.v231: "setup.models.discrete_phase.injections", + }, + ), + "VirtualBladeModel": ( + "Singleton", + { + FluentVersion.v251: "setup.models.virtual_blade_model", + FluentVersion.v242: "setup.models.virtual_blade_model", + FluentVersion.v241: "setup.models.virtual_blade_model", + FluentVersion.v232: "setup.models.virtual_blade_model", + FluentVersion.v231: "setup.models.virtual_blade_model", + }, + ), + "Optics": ( + "Singleton", + { + FluentVersion.v251: "setup.models.optics", + FluentVersion.v242: "setup.models.optics", + FluentVersion.v241: "setup.models.optics", + FluentVersion.v232: "setup.models.optics", + FluentVersion.v231: "setup.models.optics", + }, + ), + "Structure": ( + "Singleton", + { + FluentVersion.v251: "setup.models.structure", + FluentVersion.v242: "setup.models.structure", + FluentVersion.v241: "setup.models.structure", + FluentVersion.v232: "setup.models.structure", + }, + ), + "Ablation": ( + "Singleton", + { + FluentVersion.v251: "setup.models.ablation", + FluentVersion.v242: "setup.models.ablation", + FluentVersion.v241: "setup.models.ablation", + FluentVersion.v232: "setup.models.ablation", + }, + ), + "EChemistry": ( + "Singleton", + { + FluentVersion.v251: "setup.models.echemistry", + FluentVersion.v242: "setup.models.echemistry", + FluentVersion.v241: "setup.models.echemistry", + }, + ), + "Battery": ( + "Singleton", + { + FluentVersion.v251: "setup.models.battery", + FluentVersion.v242: "setup.models.battery", + FluentVersion.v241: "setup.models.battery", + }, + ), + "SystemCoupling": ( + "Singleton", + { + FluentVersion.v251: "setup.models.system_coupling", + FluentVersion.v242: "setup.models.system_coupling", + FluentVersion.v241: "setup.models.system_coupling", + }, + ), + "Sofc": ( + "Singleton", + { + FluentVersion.v251: "setup.models.sofc", + FluentVersion.v242: "setup.models.sofc", + FluentVersion.v241: "setup.models.sofc", + }, + ), + "Pemfc": ( + "Singleton", + { + FluentVersion.v251: "setup.models.pemfc", + FluentVersion.v242: "setup.models.pemfc", + }, + ), + "Materials": ("Singleton", "setup.materials"), + "FluidMaterials": ("Singleton", "setup.materials.fluid"), + "FluidMaterial": ("NamedObject", "setup.materials.fluid"), + "SolidMaterials": ("Singleton", "setup.materials.solid"), + "SolidMaterial": ("NamedObject", "setup.materials.solid"), + "MixtureMaterials": ("Singleton", "setup.materials.mixture"), + "MixtureMaterial": ("NamedObject", "setup.materials.mixture"), + "InertParticles": ("Singleton", "setup.materials.inert_particles"), + "InertParticle": ("NamedObject", "setup.materials.inert_particles"), + "DropletParticles": ("Singleton", "setup.materials.droplet_particles"), + "DropletParticle": ("NamedObject", "setup.materials.droplet_particles"), + "CombustingParticles": ("Singleton", "setup.materials.combusting_particles"), + "CombustingParticle": ("NamedObject", "setup.materials.combusting_particles"), + "ParticleMixtureMaterials": ("Singleton", "setup.materials.particle_mixture"), + "ParticleMixtureMaterial": ("NamedObject", "setup.materials.particle_mixture"), + "CellZoneConditions": ("Singleton", "setup.cell_zone_conditions"), + "CellZoneCondition": ( + "NamedObject", + { + FluentVersion.v251: "setup.cell_zone_conditions", + FluentVersion.v242: "setup.cell_zone_conditions", + FluentVersion.v241: "setup.cell_zone_conditions", + FluentVersion.v232: "setup.cell_zone_conditions", + FluentVersion.v231: "setup.cell_zone_conditions", + }, + ), + "FluidCellZones": ("Singleton", "setup.cell_zone_conditions.fluid"), + "FluidCellZone": ("NamedObject", "setup.cell_zone_conditions.fluid"), + "SolidCellZones": ("Singleton", "setup.cell_zone_conditions.solid"), + "SolidCellZone": ("NamedObject", "setup.cell_zone_conditions.solid"), + "BoundaryConditions": ("Singleton", "setup.boundary_conditions"), + "BoundaryCondition": ( + "NamedObject", + { + FluentVersion.v251: "setup.boundary_conditions", + FluentVersion.v242: "setup.boundary_conditions", + FluentVersion.v241: "setup.boundary_conditions", + FluentVersion.v232: "setup.boundary_conditions", + FluentVersion.v231: "setup.boundary_conditions", + }, + ), + "AxisBoundaries": ("Singleton", "setup.boundary_conditions.axis"), + "AxisBoundary": ("NamedObject", "setup.boundary_conditions.axis"), + "DegassingBoundaries": ("Singleton", "setup.boundary_conditions.degassing"), + "DegassingBoundary": ("NamedObject", "setup.boundary_conditions.degassing"), + "ExhaustFanBoundaries": ("Singleton", "setup.boundary_conditions.exhaust_fan"), + "ExhaustFanBoundary": ("NamedObject", "setup.boundary_conditions.exhaust_fan"), + "FanBoundaries": ("Singleton", "setup.boundary_conditions.fan"), + "FanBoundary": ("NamedObject", "setup.boundary_conditions.fan"), + "GeometryBoundaries": ("Singleton", "setup.boundary_conditions.geometry"), + "GeometryBoundary": ("NamedObject", "setup.boundary_conditions.geometry"), + "InletVentBoundaries": ("Singleton", "setup.boundary_conditions.inlet_vent"), + "InletVentBoundary": ("NamedObject", "setup.boundary_conditions.inlet_vent"), + "IntakeFanBoundaries": ("Singleton", "setup.boundary_conditions.intake_fan"), + "IntakeFanBoundary": ("NamedObject", "setup.boundary_conditions.intake_fan"), + "InterfaceBoundaries": ("Singleton", "setup.boundary_conditions.interface"), + "InterfaceBoundary": ("NamedObject", "setup.boundary_conditions.interface"), + "InteriorBoundaries": ("Singleton", "setup.boundary_conditions.interior"), + "InteriorBoundary": ("NamedObject", "setup.boundary_conditions.interior"), + "MassFlowInlets": ("Singleton", "setup.boundary_conditions.mass_flow_inlet"), + "MassFlowInlet": ("NamedObject", "setup.boundary_conditions.mass_flow_inlet"), + "MassFlowOutlets": ("Singleton", "setup.boundary_conditions.mass_flow_outlet"), + "MassFlowOutlet": ("NamedObject", "setup.boundary_conditions.mass_flow_outlet"), + "NetworkBoundaries": ("Singleton", "setup.boundary_conditions.network"), + "NetworkBoundary": ("NamedObject", "setup.boundary_conditions.network"), + "NetworkEndBoundaries": ("Singleton", "setup.boundary_conditions.network_end"), + "NetworkEndBoundary": ("NamedObject", "setup.boundary_conditions.network_end"), + "OutflowBoundaries": ("Singleton", "setup.boundary_conditions.outflow"), + "OutflowBoundary": ("NamedObject", "setup.boundary_conditions.outflow"), + "OutletVentBoundaries": ("Singleton", "setup.boundary_conditions.outlet_vent"), + "OutletVentBoundary": ("NamedObject", "setup.boundary_conditions.outlet_vent"), + "OversetBoundaries": ("Singleton", "setup.boundary_conditions.overset"), + "OversetBoundary": ("NamedObject", "setup.boundary_conditions.overset"), + "PeriodicBoundaries": ("Singleton", "setup.boundary_conditions.periodic"), + "PeriodicBoundary": ("NamedObject", "setup.boundary_conditions.periodic"), + "PorousJumpBoundaries": ("Singleton", "setup.boundary_conditions.porous_jump"), + "PorousJumpBoundary": ("NamedObject", "setup.boundary_conditions.porous_jump"), + "PressureFarFieldBoundaries": ( + "Singleton", + "setup.boundary_conditions.pressure_far_field", + ), + "PressureFarFieldBoundary": ( + "NamedObject", + "setup.boundary_conditions.pressure_far_field", + ), + "PressureInlets": ("Singleton", "setup.boundary_conditions.pressure_inlet"), + "PressureInlet": ("NamedObject", "setup.boundary_conditions.pressure_inlet"), + "PressureOutlets": ("Singleton", "setup.boundary_conditions.pressure_outlet"), + "PressureOutlet": ("NamedObject", "setup.boundary_conditions.pressure_outlet"), + "RadiatorBoundaries": ("Singleton", "setup.boundary_conditions.radiator"), + "RadiatorBoundary": ("NamedObject", "setup.boundary_conditions.radiator"), + "RansLesInterfaceBoundaries": ( + "Singleton", + "setup.boundary_conditions.rans_les_interface", + ), + "RansLesInterfaceBoundary": ( + "NamedObject", + "setup.boundary_conditions.rans_les_interface", + ), + "RecirculationInlets": ( + "Singleton", + "setup.boundary_conditions.recirculation_inlet", + ), + "RecirculationInlet": ( + "NamedObject", + "setup.boundary_conditions.recirculation_inlet", + ), + "RecirculationOutlets": ( + "Singleton", + "setup.boundary_conditions.recirculation_outlet", + ), + "RecirculationOutlet": ( + "NamedObject", + "setup.boundary_conditions.recirculation_outlet", + ), + "ShadowBoundaries": ("Singleton", "setup.boundary_conditions.shadow"), + "ShadowBoundary": ("NamedObject", "setup.boundary_conditions.shadow"), + "SymmetryBoundaries": ("Singleton", "setup.boundary_conditions.symmetry"), + "SymmetryBoundary": ("NamedObject", "setup.boundary_conditions.symmetry"), + "VelocityInlets": ("Singleton", "setup.boundary_conditions.velocity_inlet"), + "VelocityInlet": ("NamedObject", "setup.boundary_conditions.velocity_inlet"), + "WallBoundaries": ("Singleton", "setup.boundary_conditions.wall"), + "WallBoundary": ("NamedObject", "setup.boundary_conditions.wall"), + "NonReflectingBoundaries": ( + "Singleton", + "setup.boundary_conditions.non_reflecting_bc", + ), + "NonReflectingBoundary": ( + "NamedObject", + "setup.boundary_conditions.non_reflecting_bc", + ), + "PerforatedWallBoundaries": ( + "Singleton", + "setup.boundary_conditions.perforated_wall", + ), + "PerforatedWallBoundary": ( + "NamedObject", + "setup.boundary_conditions.perforated_wall", + ), + "MeshInterfaces": ( + "Singleton", + { + FluentVersion.v251: "setup.mesh_interfaces", + FluentVersion.v242: "setup.mesh_interfaces", + FluentVersion.v241: "setup.mesh_interfaces", + FluentVersion.v232: "setup.mesh_interfaces", + }, + ), + "DynamicMesh": ("Singleton", {FluentVersion.v251: "setup.dynamic_mesh"}), + "ReferenceValues": ("Singleton", "setup.reference_values"), + "ReferenceFrames": ( + "Singleton", + { + FluentVersion.v251: "setup.reference_frames", + FluentVersion.v242: "setup.reference_frames", + FluentVersion.v241: "setup.reference_frames", + FluentVersion.v232: "setup.reference_frames", + }, + ), + "ReferenceFrame": ( + "NamedObject", + { + FluentVersion.v251: "setup.reference_frames", + FluentVersion.v242: "setup.reference_frames", + FluentVersion.v241: "setup.reference_frames", + FluentVersion.v232: "setup.reference_frames", + }, + ), + "NamedExpressions": ( + "Singleton", + { + FluentVersion.v251: "setup.named_expressions", + FluentVersion.v242: "setup.named_expressions", + FluentVersion.v241: "setup.named_expressions", + FluentVersion.v232: "setup.named_expressions", + }, + ), + "NamedExpression": ( + "NamedObject", + { + FluentVersion.v251: "setup.named_expressions", + FluentVersion.v242: "setup.named_expressions", + FluentVersion.v241: "setup.named_expressions", + FluentVersion.v232: "setup.named_expressions", + }, + ), +} diff --git a/tests/test_settings_api.py b/tests/test_settings_api.py index 48149e3d99a..14b668ca12e 100644 --- a/tests/test_settings_api.py +++ b/tests/test_settings_api.py @@ -480,3 +480,220 @@ def test_exit_not_in_settings(new_solver_session): with pytest.raises(AttributeError): solver.settings.exit() + + +def test_builtin_settings(static_mixer_case_session): + from ansys.fluent.core import ( + Ablation, + Battery, + BoundaryCondition, + BoundaryConditions, + CellZoneCondition, + CellZoneConditions, + DiscretePhase, + DynamicMesh, + EChemistry, + Energy, + FluidCellZone, + FluidCellZones, + FluidMaterial, + FluidMaterials, + General, + Injections, + InteriorBoundaries, + InteriorBoundary, + Materials, + MeshInterfaces, + Models, + Multiphase, + NamedExpressions, + Optics, + Pemfc, + PressureOutlet, + PressureOutlets, + Radiation, + ReferenceFrame, + ReferenceFrames, + ReferenceValues, + Setup, + Sofc, + SolidMaterial, + SolidMaterials, + Species, + Structure, + SystemCoupling, + VelocityInlet, + VelocityInlets, + VirtualBladeModel, + Viscous, + WallBoundaries, + WallBoundary, + ) + + solver = static_mixer_case_session + assert Setup(solver=solver) == solver.setup + assert General(solver=solver) == solver.setup.general + assert Models(solver=solver) == solver.setup.models + assert Multiphase(solver=solver) == solver.setup.models.multiphase + assert Energy(solver=solver) == solver.setup.models.energy + assert Viscous(solver=solver) == solver.setup.models.viscous + if solver.get_fluent_version() >= FluentVersion.v232: + assert Radiation(solver=solver) == solver.setup.models.radiation + else: + with pytest.raises(RuntimeError): + Radiation(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v232: + assert Species(solver=solver) == solver.setup.models.species + else: + with pytest.raises(RuntimeError): + Species(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v231: + assert DiscretePhase(solver=solver) == solver.setup.models.discrete_phase + else: + with pytest.raises(RuntimeError): + DiscretePhase(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v231: + assert ( + Injections(solver=solver) == solver.setup.models.discrete_phase.injections + ) + else: + with pytest.raises(RuntimeError): + Injections(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v231: + assert ( + VirtualBladeModel(solver=solver) == solver.setup.models.virtual_blade_model + ) + else: + with pytest.raises(RuntimeError): + VirtualBladeModel(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v231: + assert Optics(solver=solver) == solver.setup.models.optics + else: + with pytest.raises(RuntimeError): + Optics(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v232: + assert Structure(solver=solver) == solver.setup.models.structure + else: + with pytest.raises(RuntimeError): + Structure(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v232: + assert Ablation(solver=solver) == solver.setup.models.ablation + else: + with pytest.raises(RuntimeError): + Ablation(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v241: + assert EChemistry(solver=solver) == solver.setup.models.echemistry + else: + with pytest.raises(RuntimeError): + EChemistry(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v241: + assert Battery(solver=solver) == solver.setup.models.battery + else: + with pytest.raises(RuntimeError): + Battery(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v241: + assert SystemCoupling(solver=solver) == solver.setup.models.system_coupling + else: + with pytest.raises(RuntimeError): + SystemCoupling(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v241: + assert Sofc(solver=solver) == solver.setup.models.sofc + else: + with pytest.raises(RuntimeError): + Sofc(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v242: + assert Pemfc(solver=solver) == solver.setup.models.pemfc + else: + with pytest.raises(RuntimeError): + Pemfc(solver=solver) + assert Materials(solver=solver) == solver.setup.materials + assert FluidMaterials(solver=solver) == solver.setup.materials.fluid + assert ( + FluidMaterial(solver=solver, name="air") == solver.setup.materials.fluid["air"] + ) + assert SolidMaterials(solver=solver) == solver.setup.materials.solid + assert ( + SolidMaterial(solver=solver, name="aluminum") + == solver.setup.materials.solid["aluminum"] + ) + assert CellZoneConditions(solver=solver) == solver.setup.cell_zone_conditions + if solver.get_fluent_version() >= FluentVersion.v231: + assert ( + CellZoneCondition(solver=solver, name="fluid") + == solver.setup.cell_zone_conditions["fluid"] + ) + else: + with pytest.raises(RuntimeError): + CellZoneCondition(solver=solver, name="fluid") + assert FluidCellZones(solver=solver) == solver.setup.cell_zone_conditions.fluid + assert ( + FluidCellZone(solver=solver, name="fluid") + == solver.setup.cell_zone_conditions.fluid["fluid"] + ) + assert BoundaryConditions(solver=solver) == solver.setup.boundary_conditions + if solver.get_fluent_version() >= FluentVersion.v231: + assert ( + BoundaryCondition(solver=solver, name="inlet2") + == solver.setup.boundary_conditions["inlet2"] + ) + else: + with pytest.raises(RuntimeError): + BoundaryCondition(solver=solver, name="inlet2") + assert ( + VelocityInlets(solver=solver) == solver.setup.boundary_conditions.velocity_inlet + ) + assert ( + VelocityInlet(solver=solver, name="inlet2") + == solver.setup.boundary_conditions.velocity_inlet["inlet2"] + ) + assert ( + InteriorBoundaries(solver=solver) == solver.setup.boundary_conditions.interior + ) + assert ( + InteriorBoundary(solver=solver, name="interior--fluid") + == solver.setup.boundary_conditions.interior["interior--fluid"] + ) + assert ( + PressureOutlets(solver=solver) + == solver.setup.boundary_conditions.pressure_outlet + ) + assert ( + PressureOutlet(solver=solver, name="outlet") + == solver.setup.boundary_conditions.pressure_outlet["outlet"] + ) + assert WallBoundaries(solver=solver) == solver.setup.boundary_conditions.wall + assert ( + WallBoundary(solver=solver, name="wall") + == solver.setup.boundary_conditions.wall["wall"] + ) + if solver.get_fluent_version() >= FluentVersion.v232: + assert MeshInterfaces(solver=solver) == solver.setup.mesh_interfaces + else: + with pytest.raises(RuntimeError): + MeshInterfaces(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v251: + assert DynamicMesh(solver=solver) == solver.setup.dynamic_mesh + else: + with pytest.raises(RuntimeError): + DynamicMesh(solver=solver) + assert ReferenceValues(solver=solver) == solver.setup.reference_values + if solver.get_fluent_version() >= FluentVersion.v232: + assert ReferenceFrames(solver=solver) == solver.setup.reference_frames + else: + with pytest.raises(RuntimeError): + ReferenceFrames(solver=solver) + if solver.get_fluent_version() >= FluentVersion.v232: + # Fluent 25.1 issue + if solver.get_fluent_version() != FluentVersion.v251: + assert ( + ReferenceFrame(solver=solver, name="global") + == solver.setup.reference_frames["global"] + ) + else: + with pytest.raises(RuntimeError): + ReferenceFrame(solver=solver, name="global") + if solver.get_fluent_version() >= FluentVersion.v232: + assert NamedExpressions(solver=solver) == solver.setup.named_expressions + else: + with pytest.raises(RuntimeError): + NamedExpressions(solver=solver)