From 68c67cf3ec2c7fdd94c15dd7198e1140ed26a9fc Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Fri, 4 Oct 2024 11:01:19 -0400 Subject: [PATCH] feat: Add the remaining builtin settings --- src/ansys/fluent/core/__init__.py | 2 +- .../core/solver/settings_builtin_bases.py | 1 + .../core/solver/settings_builtin_data.py | 494 ++++++++++++++++++ tests/test_builtin_settings.py | 371 +++++++++++-- 4 files changed, 820 insertions(+), 48 deletions(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index e4e13398cce..b69dda70bd9 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -49,7 +49,7 @@ try: from ansys.fluent.core.generated.solver.settings_builtin import * # noqa: F401, F403 -except (ImportError, AttributeError): +except (ImportError, AttributeError, SyntaxError): pass _VERSION_INFO = None diff --git a/src/ansys/fluent/core/solver/settings_builtin_bases.py b/src/ansys/fluent/core/solver/settings_builtin_bases.py index d04fa122cf7..ae82853e408 100644 --- a/src/ansys/fluent/core/solver/settings_builtin_bases.py +++ b/src/ansys/fluent/core/solver/settings_builtin_bases.py @@ -44,6 +44,7 @@ def _get_settings_obj(settings_source: SettingsBase | Solver, cls_name: str): class _SingletonSetting: + # Covers both groups and named-object containers def __init__(self, settings_source: SettingsBase | Solver | None = None): self.__dict__.update(dict(settings_source=None)) if settings_source is not None: diff --git a/src/ansys/fluent/core/solver/settings_builtin_data.py b/src/ansys/fluent/core/solver/settings_builtin_data.py index c5103c15047..9b1503590f2 100644 --- a/src/ansys/fluent/core/solver/settings_builtin_data.py +++ b/src/ansys/fluent/core/solver/settings_builtin_data.py @@ -331,6 +331,7 @@ FluentVersion.v232: "setup.named_expressions", }, ), + "Solution": ("Singleton", "solution"), "Methods": ("Singleton", "solution.methods"), "Controls": ("Singleton", "solution.controls"), "ReportDefinitions": ("Singleton", "solution.report_definitions"), @@ -452,4 +453,497 @@ }, ), "RunCalculation": ("Singleton", "solution.run_calculation"), + "Results": ("Singleton", "results"), + "Surfaces": ("Singleton", "results.surfaces"), + "PointSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.point_surface", + FluentVersion.v242: "results.surfaces.point_surface", + FluentVersion.v241: "results.surfaces.point_surface", + FluentVersion.v232: "results.surfaces.point_surface", + }, + ), + "PointSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.point_surface", + FluentVersion.v242: "results.surfaces.point_surface", + FluentVersion.v241: "results.surfaces.point_surface", + FluentVersion.v232: "results.surfaces.point_surface", + }, + ), + "LineSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.line_surface", + FluentVersion.v242: "results.surfaces.line_surface", + FluentVersion.v241: "results.surfaces.line_surface", + FluentVersion.v232: "results.surfaces.line_surface", + }, + ), + "LineSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.line_surface", + FluentVersion.v242: "results.surfaces.line_surface", + FluentVersion.v241: "results.surfaces.line_surface", + FluentVersion.v232: "results.surfaces.line_surface", + }, + ), + "RakeSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.rake_surface", + FluentVersion.v242: "results.surfaces.rake_surface", + FluentVersion.v241: "results.surfaces.rake_surface", + FluentVersion.v232: "results.surfaces.rake_surface", + }, + ), + "RakeSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.rake_surface", + FluentVersion.v242: "results.surfaces.rake_surface", + FluentVersion.v241: "results.surfaces.rake_surface", + FluentVersion.v232: "results.surfaces.rake_surface", + }, + ), + "PlaneSurfaces": ("Singleton", "results.surfaces.plane_surface"), + "PlaneSurface": ("NamedObject", "results.surfaces.plane_surface"), + "IsoSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.iso_surface", + FluentVersion.v242: "results.surfaces.iso_surface", + FluentVersion.v241: "results.surfaces.iso_surface", + FluentVersion.v232: "results.surfaces.iso_surface", + }, + ), + "IsoSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.iso_surface", + FluentVersion.v242: "results.surfaces.iso_surface", + FluentVersion.v241: "results.surfaces.iso_surface", + FluentVersion.v232: "results.surfaces.iso_surface", + }, + ), + "IsoClips": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.iso_clip", + FluentVersion.v242: "results.surfaces.iso_clip", + FluentVersion.v241: "results.surfaces.iso_clip", + }, + ), + "IsoClip": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.iso_clip", + FluentVersion.v242: "results.surfaces.iso_clip", + FluentVersion.v241: "results.surfaces.iso_clip", + }, + ), + "ZoneSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.zone_surface", + FluentVersion.v242: "results.surfaces.zone_surface", + FluentVersion.v241: "results.surfaces.zone_surface", + }, + ), + "ZoneSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.zone_surface", + FluentVersion.v242: "results.surfaces.zone_surface", + FluentVersion.v241: "results.surfaces.zone_surface", + }, + ), + "PartitionSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.partition_surface", + FluentVersion.v242: "results.surfaces.partition_surface", + FluentVersion.v241: "results.surfaces.partition_surface", + }, + ), + "PartitionSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.partition_surface", + FluentVersion.v242: "results.surfaces.partition_surface", + FluentVersion.v241: "results.surfaces.partition_surface", + }, + ), + "TransformSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.transform_surface", + FluentVersion.v242: "results.surfaces.transform_surface", + FluentVersion.v241: "results.surfaces.transform_surface", + }, + ), + "TransformSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.transform_surface", + FluentVersion.v242: "results.surfaces.transform_surface", + FluentVersion.v241: "results.surfaces.transform_surface", + }, + ), + "ImprintSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.imprint_surface", + FluentVersion.v242: "results.surfaces.imprint_surface", + FluentVersion.v241: "results.surfaces.imprint_surface", + }, + ), + "ImprintSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.imprint_surface", + FluentVersion.v242: "results.surfaces.imprint_surface", + FluentVersion.v241: "results.surfaces.imprint_surface", + }, + ), + "PlaneSlices": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.plane_slice", + FluentVersion.v242: "results.surfaces.plane_slice", + FluentVersion.v241: "results.surfaces.plane_slice", + }, + ), + "PlaneSlice": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.plane_slice", + FluentVersion.v242: "results.surfaces.plane_slice", + FluentVersion.v241: "results.surfaces.plane_slice", + }, + ), + "SphereSlices": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.sphere_slice", + FluentVersion.v242: "results.surfaces.sphere_slice", + FluentVersion.v241: "results.surfaces.sphere_slice", + }, + ), + "SphereSlice": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.sphere_slice", + FluentVersion.v242: "results.surfaces.sphere_slice", + FluentVersion.v241: "results.surfaces.sphere_slice", + }, + ), + "QuadricSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.quadric_surface", + FluentVersion.v242: "results.surfaces.quadric_surface", + FluentVersion.v241: "results.surfaces.quadric_surface", + }, + ), + "QuadricSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.quadric_surface", + FluentVersion.v242: "results.surfaces.quadric_surface", + FluentVersion.v241: "results.surfaces.quadric_surface", + }, + ), + "SurfaceCells": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.surface_cells", + FluentVersion.v242: "results.surfaces.surface_cells", + FluentVersion.v241: "results.surfaces.surface_cells", + }, + ), + "SurfaceCell": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.surface_cells", + FluentVersion.v242: "results.surfaces.surface_cells", + FluentVersion.v241: "results.surfaces.surface_cells", + }, + ), + "ExpressionVolumes": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.expression_volume", + }, + ), + "ExpressionVolume": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.expression_volume", + }, + ), + "GroupSurfaces": ( + "Singleton", + { + FluentVersion.v251: "results.surfaces.group_surface", + }, + ), + "GroupSurface": ( + "NamedObject", + { + FluentVersion.v251: "results.surfaces.group_surface", + }, + ), + "Graphics": ("Singleton", "results.graphics"), + "Meshes": ("Singleton", "results.graphics.mesh"), + "Mesh": ("NamedObject", "results.graphics.mesh"), + "Contours": ("Singleton", "results.graphics.contour"), + "Contour": ("NamedObject", "results.graphics.contour"), + "Vectors": ("Singleton", "results.graphics.vector"), + "Vector": ("NamedObject", "results.graphics.vector"), + "Pathlines": ( + "Singleton", + { + FluentVersion.v251: "results.graphics.pathline", + FluentVersion.v242: "results.graphics.pathline", + FluentVersion.v241: "results.graphics.pathline", + FluentVersion.v232: "results.graphics.pathline", + FluentVersion.v231: "results.graphics.pathline", + }, + ), + "Pathline": ( + "NamedObject", + { + FluentVersion.v251: "results.graphics.pathline", + FluentVersion.v242: "results.graphics.pathline", + FluentVersion.v241: "results.graphics.pathline", + FluentVersion.v232: "results.graphics.pathline", + FluentVersion.v231: "results.graphics.pathline", + }, + ), + "ParticleTracks": ( + "Singleton", + { + FluentVersion.v251: "results.graphics.particle_track", + FluentVersion.v242: "results.graphics.particle_track", + FluentVersion.v241: "results.graphics.particle_track", + FluentVersion.v232: "results.graphics.particle_track", + FluentVersion.v231: "results.graphics.particle_track", + }, + ), + "ParticleTrack": ( + "NamedObject", + { + FluentVersion.v251: "results.graphics.particle_track", + FluentVersion.v242: "results.graphics.particle_track", + FluentVersion.v241: "results.graphics.particle_track", + FluentVersion.v232: "results.graphics.particle_track", + FluentVersion.v231: "results.graphics.particle_track", + }, + ), + "LICs": ("Singleton", "results.graphics.lic"), + "LIC": ("NamedObject", "results.graphics.lic"), + "Plots": ( + "Singleton", + { + FluentVersion.v251: "results.plot", + FluentVersion.v242: "results.plot", + FluentVersion.v241: "results.plot", + FluentVersion.v232: "results.plot", + FluentVersion.v231: "results.plot", + }, + ), + "XYPlots": ( + "Singleton", + { + FluentVersion.v251: "results.plot.xy_plot", + FluentVersion.v242: "results.plot.xy_plot", + FluentVersion.v241: "results.plot.xy_plot", + FluentVersion.v232: "results.plot.xy_plot", + FluentVersion.v231: "results.plot.xy_plot", + }, + ), + "XYPlot": ( + "NamedObject", + { + FluentVersion.v251: "results.plot.xy_plot", + FluentVersion.v242: "results.plot.xy_plot", + FluentVersion.v241: "results.plot.xy_plot", + FluentVersion.v232: "results.plot.xy_plot", + FluentVersion.v231: "results.plot.xy_plot", + }, + ), + "Histogram": ( + "Singleton", + { + FluentVersion.v251: "results.plot.histogram", + FluentVersion.v242: "results.plot.histogram", + FluentVersion.v241: "results.plot.histogram", + }, + ), + "CumulativePlots": ( + "Singleton", + { + FluentVersion.v251: "results.plot.cumulative_plot", + FluentVersion.v242: "results.plot.cumulative_plot", + FluentVersion.v241: "results.plot.cumulative_plot", + }, + ), + "CumulativePlot": ( + "NamedObject", + { + FluentVersion.v251: "results.plot.cumulative_plot", + FluentVersion.v242: "results.plot.cumulative_plot", + FluentVersion.v241: "results.plot.cumulative_plot", + }, + ), + "ProfileData": ( + "Singleton", + { + FluentVersion.v251: "results.plot.profile_data", + FluentVersion.v242: "results.plot.profile_data", + }, + ), + "InterpolatedData": ( + "Singleton", + { + FluentVersion.v251: "results.plot.interpolated_data", + FluentVersion.v242: "results.plot.interpolated_data", + }, + ), + "Scenes": ( + "Singleton", + { + FluentVersion.v251: "results.scene", + FluentVersion.v242: "results.scene", + FluentVersion.v241: "results.scene", + FluentVersion.v232: "results.scene", + FluentVersion.v231: "results.scene", + }, + ), + "Scene": ( + "NamedObject", + { + FluentVersion.v251: "results.scene", + FluentVersion.v242: "results.scene", + FluentVersion.v241: "results.scene", + FluentVersion.v232: "results.scene", + FluentVersion.v231: "results.scene", + }, + ), + "SceneAnimation": ( + "Singleton", + { + FluentVersion.v251: "results.animations.scene_animation", + FluentVersion.v242: "results.animations.scene_animation", + FluentVersion.v241: "results.animations.scene_animation", + }, + ), + "Report": ( + "Singleton", + { + FluentVersion.v251: "results.report", + FluentVersion.v242: "results.report", + FluentVersion.v241: "results.report", + FluentVersion.v232: "results.report", + FluentVersion.v231: "results.report", + }, + ), + "DiscretePhaseHistogram": ( + "Singleton", + { + FluentVersion.v251: "results.report.discrete_phase.histogram", + FluentVersion.v242: "results.report.discrete_phase.histogram", + FluentVersion.v241: "results.report.discrete_phase.histogram", + FluentVersion.v232: "results.report.discrete_phase.histogram", + FluentVersion.v231: "results.report.discrete_phase.histogram", + }, + ), + "Fluxes": ( + "Singleton", + { + FluentVersion.v251: "results.report.fluxes", + FluentVersion.v242: "results.report.fluxes", + FluentVersion.v241: "results.report.fluxes", + FluentVersion.v232: "results.report.fluxes", + FluentVersion.v231: "results.report.fluxes", + }, + ), + "SurfaceIntegrals": ( + "Singleton", + { + FluentVersion.v251: "results.report.surface_integrals", + FluentVersion.v242: "results.report.surface_integrals", + FluentVersion.v241: "results.report.surface_integrals", + FluentVersion.v232: "results.report.surface_integrals", + FluentVersion.v231: "results.report.surface_integrals", + }, + ), + "VolumeIntegrals": ( + "Singleton", + { + FluentVersion.v251: "results.report.volume_integrals", + FluentVersion.v242: "results.report.volume_integrals", + FluentVersion.v241: "results.report.volume_integrals", + FluentVersion.v232: "results.report.volume_integrals", + FluentVersion.v231: "results.report.volume_integrals", + }, + ), + "InputParameters": ( + "Singleton", + { + FluentVersion.v251: "parameters.input_parameters", + FluentVersion.v242: "parameters.input_parameters", + FluentVersion.v241: "parameters.input_parameters", + }, + ), + "OutputParameters": ( + "Singleton", + { + FluentVersion.v251: "parameters.output_parameters", + FluentVersion.v242: "parameters.output_parameters", + FluentVersion.v241: "parameters.output_parameters", + }, + ), + "CustomFieldFunctions": ( + "Singleton", + { + FluentVersion.v251: "results.custom_field_functions", + }, + ), + "CustomFieldFunction": ( + "NamedObject", + { + FluentVersion.v251: "results.custom_field_functions", + }, + ), + "CustomVectors": ( + "Singleton", + { + FluentVersion.v251: "results.custom_vectors", + FluentVersion.v242: "results.custom_vectors", + FluentVersion.v241: "results.custom_vectors", + }, + ), + "CustomVector": ( + "NamedObject", + { + FluentVersion.v251: "results.custom_vectors", + FluentVersion.v242: "results.custom_vectors", + FluentVersion.v241: "results.custom_vectors", + }, + ), + "SimulationReports": ( + "Singleton", + { + FluentVersion.v251: "results.report.simulation_reports", + FluentVersion.v242: "results.report.simulation_reports", + FluentVersion.v241: "results.report.simulation_reports", + FluentVersion.v232: "results.report.simulation_reports", + FluentVersion.v231: "results.report.simulation_reports", + }, + ), } diff --git a/tests/test_builtin_settings.py b/tests/test_builtin_settings.py index d63b8493ad2..f6f952d091e 100644 --- a/tests/test_builtin_settings.py +++ b/tests/test_builtin_settings.py @@ -12,23 +12,42 @@ CellRegisters, CellZoneCondition, CellZoneConditions, + Contour, + Contours, Controls, ConvergenceConditions, + CumulativePlots, + CustomFieldFunctions, + CustomVectors, DiscretePhase, + DiscretePhaseHistogram, DynamicMesh, EChemistry, Energy, ExecuteCommands, + ExpressionVolumes, FluidCellZone, FluidCellZones, FluidMaterial, FluidMaterials, + Fluxes, General, + Graphics, + GroupSurfaces, + Histogram, + ImprintSurfaces, Initialization, Injections, + InputParameters, InteriorBoundaries, InteriorBoundary, + InterpolatedData, + IsoClips, + IsoSurfaces, + LICs, + LineSurfaces, Materials, + Meshes, MeshInterfaces, Methods, Models, @@ -36,33 +55,60 @@ Multiphase, NamedExpressions, Optics, + OutputParameters, + ParticleTracks, + PartitionSurfaces, + Pathlines, Pemfc, + PlaneSlices, + PlaneSurface, + PlaneSurfaces, + Plots, + PointSurfaces, PressureOutlet, PressureOutlets, + ProfileData, + QuadricSurfaces, Radiation, + RakeSurfaces, ReferenceFrame, ReferenceFrames, ReferenceValues, + Report, ReportDefinitions, ReportFile, ReportFiles, ReportPlot, ReportPlots, Residual, + Results, RunCalculation, + SceneAnimation, + Scenes, Setup, + SimulationReports, Sofc, SolidMaterial, SolidMaterials, + Solution, Species, + SphereSlices, Structure, + SurfaceCells, + SurfaceIntegrals, + Surfaces, SystemCoupling, + TransformSurfaces, + Vectors, VelocityInlet, VelocityInlets, VirtualBladeModel, Viscous, + VolumeIntegrals, WallBoundaries, WallBoundary, + XYPlots, + ZoneSurfaces, ) except ImportError: pass # for no-codegen testing workflow @@ -71,32 +117,33 @@ @pytest.mark.codegen_required -def test_builtin_settings(static_mixer_case_session): - solver = static_mixer_case_session +def test_builtin_settings(mixing_elbow_case_data_session): + solver = mixing_elbow_case_data_session + fluent_version = solver.get_fluent_version() assert Setup(settings_source=solver) == solver.setup assert General(settings_source=solver) == solver.setup.general assert Models(settings_source=solver) == solver.setup.models assert Multiphase(settings_source=solver) == solver.setup.models.multiphase assert Energy(settings_source=solver) == solver.setup.models.energy assert Viscous(settings_source=solver) == solver.setup.models.viscous - if solver.get_fluent_version() >= FluentVersion.v232: + if fluent_version >= FluentVersion.v232: assert Radiation(settings_source=solver) == solver.setup.models.radiation else: with pytest.raises(RuntimeError): Radiation(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v232: + if fluent_version >= FluentVersion.v232: assert Species(settings_source=solver) == solver.setup.models.species else: with pytest.raises(RuntimeError): Species(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert ( DiscretePhase(settings_source=solver) == solver.setup.models.discrete_phase ) else: with pytest.raises(RuntimeError): DiscretePhase(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert ( Injections(settings_source=solver) == solver.setup.models.discrete_phase.injections @@ -104,7 +151,7 @@ def test_builtin_settings(static_mixer_case_session): else: with pytest.raises(RuntimeError): Injections(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert ( VirtualBladeModel(settings_source=solver) == solver.setup.models.virtual_blade_model @@ -112,32 +159,32 @@ def test_builtin_settings(static_mixer_case_session): else: with pytest.raises(RuntimeError): VirtualBladeModel(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert Optics(settings_source=solver) == solver.setup.models.optics else: with pytest.raises(RuntimeError): Optics(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v232: + if fluent_version >= FluentVersion.v232: assert Structure(settings_source=solver) == solver.setup.models.structure else: with pytest.raises(RuntimeError): Structure(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v232: + if fluent_version >= FluentVersion.v232: assert Ablation(settings_source=solver) == solver.setup.models.ablation else: with pytest.raises(RuntimeError): Ablation(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v241: + if fluent_version >= FluentVersion.v241: assert EChemistry(settings_source=solver) == solver.setup.models.echemistry else: with pytest.raises(RuntimeError): EChemistry(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v241: + if fluent_version >= FluentVersion.v241: assert Battery(settings_source=solver) == solver.setup.models.battery else: with pytest.raises(RuntimeError): Battery(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v241: + if fluent_version >= FluentVersion.v241: assert ( SystemCoupling(settings_source=solver) == solver.setup.models.system_coupling @@ -145,12 +192,12 @@ def test_builtin_settings(static_mixer_case_session): else: with pytest.raises(RuntimeError): SystemCoupling(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v241: + if fluent_version >= FluentVersion.v241: assert Sofc(settings_source=solver) == solver.setup.models.sofc else: with pytest.raises(RuntimeError): Sofc(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v242: + if fluent_version >= FluentVersion.v242: assert Pemfc(settings_source=solver) == solver.setup.models.pemfc else: with pytest.raises(RuntimeError): @@ -169,48 +216,50 @@ def test_builtin_settings(static_mixer_case_session): assert ( CellZoneConditions(settings_source=solver) == solver.setup.cell_zone_conditions ) - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert ( - CellZoneCondition(settings_source=solver, name="fluid") - == solver.setup.cell_zone_conditions["fluid"] + CellZoneCondition(settings_source=solver, name="elbow-fluid") + == solver.setup.cell_zone_conditions["elbow-fluid"] ) else: with pytest.raises(RuntimeError): - CellZoneCondition(settings_source=solver, name="fluid") + CellZoneCondition(settings_source=solver, name="elbow-fluid") assert ( FluidCellZones(settings_source=solver) == solver.setup.cell_zone_conditions.fluid ) assert ( - FluidCellZone(settings_source=solver, name="fluid") - == solver.setup.cell_zone_conditions.fluid["fluid"] + FluidCellZone(settings_source=solver, name="elbow-fluid") + == solver.setup.cell_zone_conditions.fluid["elbow-fluid"] ) assert ( BoundaryConditions(settings_source=solver) == solver.setup.boundary_conditions ) - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert ( - BoundaryCondition(settings_source=solver, name="inlet2") - == solver.setup.boundary_conditions["inlet2"] + BoundaryCondition(settings_source=solver, name="cold-inlet") + == solver.setup.boundary_conditions["cold-inlet"] ) else: with pytest.raises(RuntimeError): - BoundaryCondition(settings_source=solver, name="inlet2") + BoundaryCondition(settings_source=solver, name="cold-inlet") + with pytest.raises(TypeError): + BoundaryCondition(settings_source=solver, new_instance_name="bc-1") assert ( VelocityInlets(settings_source=solver) == solver.setup.boundary_conditions.velocity_inlet ) assert ( - VelocityInlet(settings_source=solver, name="inlet2") - == solver.setup.boundary_conditions.velocity_inlet["inlet2"] + VelocityInlet(settings_source=solver, name="cold-inlet") + == solver.setup.boundary_conditions.velocity_inlet["cold-inlet"] ) assert ( InteriorBoundaries(settings_source=solver) == solver.setup.boundary_conditions.interior ) assert ( - InteriorBoundary(settings_source=solver, name="interior--fluid") - == solver.setup.boundary_conditions.interior["interior--fluid"] + InteriorBoundary(settings_source=solver, name="interior--elbow-fluid") + == solver.setup.boundary_conditions.interior["interior--elbow-fluid"] ) assert ( PressureOutlets(settings_source=solver) @@ -224,30 +273,31 @@ def test_builtin_settings(static_mixer_case_session): WallBoundaries(settings_source=solver) == solver.setup.boundary_conditions.wall ) assert ( - WallBoundary(settings_source=solver, name="wall") - == solver.setup.boundary_conditions.wall["wall"] + WallBoundary(settings_source=solver, name="wall-elbow") + == solver.setup.boundary_conditions.wall["wall-elbow"] ) - with pytest.raises(TypeError): - WallBoundary(settings_source=solver, new_instance_name="wall-1") - if solver.get_fluent_version() >= FluentVersion.v232: + if fluent_version >= FluentVersion.v231 and fluent_version < FluentVersion.v251: + with pytest.raises(AttributeError): + WallBoundary(settings_source=solver, new_instance_name="wall-1") + if fluent_version >= FluentVersion.v232: assert MeshInterfaces(settings_source=solver) == solver.setup.mesh_interfaces else: with pytest.raises(RuntimeError): MeshInterfaces(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v251: + if fluent_version >= FluentVersion.v251: assert DynamicMesh(settings_source=solver) == solver.setup.dynamic_mesh else: with pytest.raises(RuntimeError): DynamicMesh(settings_source=solver) assert ReferenceValues(settings_source=solver) == solver.setup.reference_values - if solver.get_fluent_version() >= FluentVersion.v232: + if fluent_version >= FluentVersion.v232: assert ReferenceFrames(settings_source=solver) == solver.setup.reference_frames else: with pytest.raises(RuntimeError): ReferenceFrames(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v232: + if fluent_version >= FluentVersion.v232: # Fluent 25.1 issue - if solver.get_fluent_version() != FluentVersion.v251: + if fluent_version != FluentVersion.v251: assert ( ReferenceFrame(settings_source=solver, name="global") == solver.setup.reference_frames["global"] @@ -255,7 +305,7 @@ def test_builtin_settings(static_mixer_case_session): else: with pytest.raises(RuntimeError): ReferenceFrame(settings_source=solver, name="global") - if solver.get_fluent_version() >= FluentVersion.v232: + if fluent_version >= FluentVersion.v232: assert ( NamedExpressions(settings_source=solver) == solver.setup.named_expressions ) @@ -267,9 +317,9 @@ def test_builtin_settings(static_mixer_case_session): assert ( ReportDefinitions(settings_source=solver) == solver.solution.report_definitions ) - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert Monitor(settings_source=solver) == solver.solution.monitor - if solver.get_fluent_version() >= FluentVersion.v241: + if fluent_version >= FluentVersion.v241: assert Residual(settings_source=solver) == solver.solution.monitor.residual else: with pytest.raises(RuntimeError): @@ -285,7 +335,7 @@ def test_builtin_settings(static_mixer_case_session): ReportFile(settings_source=solver, name="report-file-1") == solver.solution.monitor.report_files["report-file-1"] ) - if solver.get_fluent_version() >= FluentVersion.v251: + if fluent_version >= FluentVersion.v251: assert ( ReportFile(settings_source=solver) == solver.solution.monitor.report_files["report-file-2"] @@ -301,7 +351,7 @@ def test_builtin_settings(static_mixer_case_session): ReportPlot(settings_source=solver, name="report-plot-1") == solver.solution.monitor.report_plots["report-plot-1"] ) - if solver.get_fluent_version() >= FluentVersion.v251: + if fluent_version >= FluentVersion.v251: assert ( ReportPlot(settings_source=solver) == solver.solution.monitor.report_plots["report-plot-2"] @@ -313,7 +363,7 @@ def test_builtin_settings(static_mixer_case_session): else: with pytest.raises(RuntimeError): Monitor(settings_source=solver) - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert CellRegisters(settings_source=solver) == solver.solution.cell_registers assert ( CellRegister(settings_source=solver, new_instance_name="cell_register_1") @@ -323,7 +373,7 @@ def test_builtin_settings(static_mixer_case_session): CellRegister(settings_source=solver, name="cell_register_1") == solver.solution.cell_registers["cell_register_1"] ) - if solver.get_fluent_version() >= FluentVersion.v251: + if fluent_version >= FluentVersion.v251: assert ( CellRegister(settings_source=solver) == solver.solution.cell_registers["cell_register_2"] @@ -332,7 +382,7 @@ def test_builtin_settings(static_mixer_case_session): with pytest.raises(RuntimeError): CellRegisters(settings_source=solver) assert Initialization(settings_source=solver) == solver.solution.initialization - if solver.get_fluent_version() >= FluentVersion.v231: + if fluent_version >= FluentVersion.v231: assert ( CalculationActivity(settings_source=solver) == solver.solution.calculation_activity @@ -341,7 +391,7 @@ def test_builtin_settings(static_mixer_case_session): ExecuteCommands(settings_source=solver) == solver.solution.calculation_activity.execute_commands ) - if solver.get_fluent_version() >= FluentVersion.v241: + if fluent_version >= FluentVersion.v241: assert ( CaseModification(settings_source=solver) == solver.solution.calculation_activity.case_modification @@ -353,6 +403,233 @@ def test_builtin_settings(static_mixer_case_session): with pytest.raises(RuntimeError): CalculationActivity(settings_source=solver) assert RunCalculation(settings_source=solver) == solver.solution.run_calculation + assert Solution(settings_source=solver) == solver.solution + assert Results(settings_source=solver) == solver.results + assert Surfaces(settings_source=solver) == solver.results.surfaces + if fluent_version >= FluentVersion.v232: + assert ( + PointSurfaces(settings_source=solver) + == solver.results.surfaces.point_surface + ) + assert ( + LineSurfaces(settings_source=solver) == solver.results.surfaces.line_surface + ) + assert ( + RakeSurfaces(settings_source=solver) == solver.results.surfaces.rake_surface + ) + assert ( + IsoSurfaces(settings_source=solver) == solver.results.surfaces.iso_surface + ) + else: + with pytest.raises(RuntimeError): + PointSurfaces(settings_source=solver) + with pytest.raises(RuntimeError): + LineSurfaces(settings_source=solver) + with pytest.raises(RuntimeError): + RakeSurfaces(settings_source=solver) + with pytest.raises(RuntimeError): + IsoSurfaces(settings_source=solver) + assert ( + PlaneSurfaces(settings_source=solver) == solver.results.surfaces.plane_surface + ) + assert ( + PlaneSurface(settings_source=solver, new_instance_name="plane-1") + == solver.results.surfaces.plane_surface["plane-1"] + ) + assert ( + PlaneSurface(settings_source=solver, name="plane-1") + == solver.results.surfaces.plane_surface["plane-1"] + ) + if fluent_version >= FluentVersion.v241: + assert IsoClips(settings_source=solver) == solver.results.surfaces.iso_clip + else: + with pytest.raises(RuntimeError): + IsoClips(settings_source=solver) + if fluent_version >= FluentVersion.v241: + assert ( + ZoneSurfaces(settings_source=solver) == solver.results.surfaces.zone_surface + ) + assert ( + PartitionSurfaces(settings_source=solver) + == solver.results.surfaces.partition_surface + ) + assert ( + TransformSurfaces(settings_source=solver) + == solver.results.surfaces.transform_surface + ) + assert ( + ImprintSurfaces(settings_source=solver) + == solver.results.surfaces.imprint_surface + ) + assert ( + PlaneSlices(settings_source=solver) == solver.results.surfaces.plane_slice + ) + assert ( + SphereSlices(settings_source=solver) == solver.results.surfaces.sphere_slice + ) + assert ( + QuadricSurfaces(settings_source=solver) + == solver.results.surfaces.quadric_surface + ) + assert ( + SurfaceCells(settings_source=solver) + == solver.results.surfaces.surface_cells + ) + else: + with pytest.raises(RuntimeError): + ZoneSurfaces(settings_source=solver) + with pytest.raises(RuntimeError): + PartitionSurfaces(settings_source=solver) + with pytest.raises(RuntimeError): + TransformSurfaces(settings_source=solver) + with pytest.raises(RuntimeError): + ImprintSurfaces(settings_source=solver) + with pytest.raises(RuntimeError): + PlaneSlices(settings_source=solver) + with pytest.raises(RuntimeError): + SphereSlices(settings_source=solver) + with pytest.raises(RuntimeError): + QuadricSurfaces(settings_source=solver) + with pytest.raises(RuntimeError): + SurfaceCells(settings_source=solver) + if fluent_version >= FluentVersion.v251: + assert ( + ExpressionVolumes(settings_source=solver) + == solver.results.surfaces.expression_volume + ) + assert ( + GroupSurfaces(settings_source=solver) + == solver.results.surfaces.group_surface + ) + else: + with pytest.raises(RuntimeError): + ExpressionVolumes(settings_source=solver) + with pytest.raises(RuntimeError): + GroupSurfaces(settings_source=solver) + assert Graphics(settings_source=solver) == solver.results.graphics + assert Meshes(settings_source=solver) == solver.results.graphics.mesh + assert Contours(settings_source=solver) == solver.results.graphics.contour + assert ( + Contour(settings_source=solver, new_instance_name="contour-1") + == solver.results.graphics.contour["contour-1"] + ) + assert ( + Contour(settings_source=solver, name="contour-1") + == solver.results.graphics.contour["contour-1"] + ) + assert Vectors(settings_source=solver) == solver.results.graphics.vector + assert LICs(settings_source=solver) == solver.results.graphics.lic + if fluent_version >= FluentVersion.v231: + assert Pathlines(settings_source=solver) == solver.results.graphics.pathline + assert ( + ParticleTracks(settings_source=solver) + == solver.results.graphics.particle_track + ) + assert Plots(settings_source=solver) == solver.results.plot + assert XYPlots(settings_source=solver) == solver.results.plot.xy_plot + else: + with pytest.raises(RuntimeError): + Pathlines(settings_source=solver) + with pytest.raises(RuntimeError): + ParticleTracks(settings_source=solver) + with pytest.raises(RuntimeError): + Plots(settings_source=solver) + with pytest.raises(RuntimeError): + XYPlots(settings_source=solver) + if fluent_version >= FluentVersion.v241: + assert Histogram(settings_source=solver) == solver.results.plot.histogram + assert ( + CumulativePlots(settings_source=solver) + == solver.results.plot.cumulative_plot + ) + else: + with pytest.raises(RuntimeError): + Histogram(settings_source=solver) + with pytest.raises(RuntimeError): + CumulativePlots(settings_source=solver) + if fluent_version >= FluentVersion.v242: + assert ProfileData(settings_source=solver) == solver.results.plot.profile_data + assert ( + InterpolatedData(settings_source=solver) + == solver.results.plot.interpolated_data + ) + else: + with pytest.raises(RuntimeError): + ProfileData(settings_source=solver) + with pytest.raises(RuntimeError): + InterpolatedData(settings_source=solver) + if fluent_version >= FluentVersion.v231: + assert Scenes(settings_source=solver) == solver.results.scene + else: + with pytest.raises(RuntimeError): + Scenes(settings_source=solver) + if fluent_version >= FluentVersion.v241: + assert ( + SceneAnimation(settings_source=solver) + == solver.results.animations.scene_animation + ) + else: + with pytest.raises(RuntimeError): + SceneAnimation(settings_source=solver) + if fluent_version >= FluentVersion.v231: + assert Report(settings_source=solver) == solver.results.report + assert ( + DiscretePhaseHistogram(settings_source=solver) + == solver.results.report.discrete_phase.histogram + ) + assert Fluxes(settings_source=solver) == solver.results.report.fluxes + assert ( + SurfaceIntegrals(settings_source=solver) + == solver.results.report.surface_integrals + ) + assert ( + VolumeIntegrals(settings_source=solver) + == solver.results.report.volume_integrals + ) + assert ( + SimulationReports(settings_source=solver) + == solver.results.report.simulation_reports + ) + else: + with pytest.raises(RuntimeError): + Report(settings_source=solver) + with pytest.raises(RuntimeError): + DiscretePhaseHistogram(settings_source=solver) + with pytest.raises(RuntimeError): + Fluxes(settings_source=solver) + with pytest.raises(RuntimeError): + SurfaceIntegrals(settings_source=solver) + with pytest.raises(RuntimeError): + VolumeIntegrals(settings_source=solver) + with pytest.raises(RuntimeError): + SimulationReports(settings_source=solver) + if fluent_version >= FluentVersion.v241: + assert ( + InputParameters(settings_source=solver) + == solver.parameters.input_parameters + ) + assert ( + OutputParameters(settings_source=solver) + == solver.parameters.output_parameters + ) + else: + with pytest.raises(RuntimeError): + InputParameters(settings_source=solver) + with pytest.raises(RuntimeError): + OutputParameters(settings_source=solver) + if fluent_version >= FluentVersion.v251: + assert ( + CustomFieldFunctions(settings_source=solver) + == solver.results.custom_field_functions + ) + else: + with pytest.raises(RuntimeError): + CustomFieldFunctions(settings_source=solver) + if fluent_version >= FluentVersion.v241: + assert CustomVectors(settings_source=solver) == solver.results.custom_vectors + else: + with pytest.raises(RuntimeError): + CustomVectors(settings_source=solver) @pytest.mark.codegen_required