From 9941ff33da20c63a1c3356b841954b1dcbfda5d7 Mon Sep 17 00:00:00 2001 From: Yogesh Patel Date: Tue, 5 Apr 2022 20:36:29 -0400 Subject: [PATCH 01/12] (1) Adding Fluent example using Python: FTM Workflow --- examples/00-fluent/exhaust_system_tui_api.py | 769 +++++++++++++++++++ 1 file changed, 769 insertions(+) create mode 100644 examples/00-fluent/exhaust_system_tui_api.py diff --git a/examples/00-fluent/exhaust_system_tui_api.py b/examples/00-fluent/exhaust_system_tui_api.py new file mode 100644 index 000000000000..7eb5c2b31357 --- /dev/null +++ b/examples/00-fluent/exhaust_system_tui_api.py @@ -0,0 +1,769 @@ +""" +.. _ref_exhaust_system_tui_api: + +Exhaust System: Fault-tolerant Meshing +---------------------------------------------- + +This tutorial illustrates the setup and solution of a three-dimensional +turbulent fluid flow in a manifold exhaust system. The manifold configuration +is encountered in the automotive industry. It is often important to predict +the flow field in the area of the mixing region in order to properly design +the junction. You will use the Fault-tolerant Meshing guided workflow, which +unlike the watertight workflow used in Fluid Flow in a Mixing Elbow, is +appropriate for geometries with imperfections, such as gaps and leakages. + +This tutorial demonstrates how to do the following in Ansys Fluent: + + +- Use the Fault-tolerant Meshing guided workflow to: + - Import a CAD geometry and manage individual parts + - Generate a surface mesh + - Cap inlets and outlets + - Extract a fluid region + - Define leakages + - Extract edge features + - Setup size controls + - Generate a volume mesh +- Set up appropriate physics and boundary conditions. +- Calculate a solution. +- Review the results of the simulation. + +Problem Description: + +Air flows through the three inlets with a uniform velocity of 1 m/s, and then +exits through the outlet. A small pipe is placed in the main portion of the +manifold where edge extraction will be considered. There is also a known small +leakage included that will be addressed in the meshing portion of the tutorial +to demonstrate the automatic leakage detection aspects of the meshing workflow. + + +""" + +############################################################################### + +# First, connect with a Fluent server + +import ansys.fluent.core as pyfluent +from ansys.fluent.core import examples + +import_filename = examples.download_file( + "exhaust_system.fmd", "pyfluent/exhaust_system" +) + +############################################################################### + +# Start Fluent in double precision running on 4 processors + +session = pyfluent.launch_fluent( + meshing_mode=True, precision="double", processor_count=4 +) + +############################################################################### + +# Select the Fault Tolerant Meshing Workflow + +session.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing") + +############################################################################### + +# Import the CAD geometry (exhaust_system.fmd). Perform some selective part +# management. + +session.part_management.InputFileChanged( + FilePath=import_filename, IgnoreSolidNames=False, PartPerBody=False +) +session.PMFileManagement.FileManager.LoadFiles() +session.part_management.Node["Meshing Model"].Copy( + Paths=[ + "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/main,1", + "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/flow-pipe,1", + "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/outpipe3,1", + "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/object2,1", + "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/object1,1", + ] +) +session.part_management.ObjectSetting[ + "DefaultObjectSetting" +].OneZonePer.setState("part") +session.workflow.TaskObject[ + "Import CAD and Part Management" +].Arguments.setState( + { + "Context": 0, + "CreateObjectPer": "Custom", + "FMDFileName": "import_filenamed", + "FileLoaded": "yes", + "ObjectSetting": "DefaultObjectSetting", + "Options": { + "Line": False, + "Solid": False, + "Surface": False, + }, + } +) +session.workflow.TaskObject["Import CAD and Part Management"].Execute() + +############################################################################### + +# Provide a description for the geometry and the flow characteristics. + +session.workflow.TaskObject["Describe Geometry and Flow"].Arguments.setState( + { + "AddEnclosure": "No", + "CloseCaps": "Yes", + "FlowType": "Internal flow through the object", + } +) +session.workflow.TaskObject["Describe Geometry and Flow"].UpdateChildTasks( + SetupTypeChanged=False +) +session.workflow.TaskObject["Describe Geometry and Flow"].Arguments.setState( + { + "AddEnclosure": "No", + "CloseCaps": "Yes", + "DescribeGeometryAndFlowOptions": { + "AdvancedOptions": True, + "ExtractEdgeFeatures": "Yes", + }, + "FlowType": "Internal flow through the object", + } +) +session.workflow.TaskObject["Describe Geometry and Flow"].UpdateChildTasks( + SetupTypeChanged=False +) +session.workflow.TaskObject["Describe Geometry and Flow"].Execute() + +############################################################################### + +# Cover any openings in your geometry. + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "CreatePatchPreferences": { + "ShowCreatePatchPreferences": False, + }, + "PatchName": "inlet-1", + "SelectionType": "zone", + "ZoneSelectionList": ["inlet.1"], + } +) +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "CreatePatchPreferences": { + "ShowCreatePatchPreferences": False, + }, + "PatchName": "inlet-1", + "SelectionType": "zone", + "ZoneLocation": [ + "1", + "351.68205", + "-361.34322", + "-301.88668", + "396.96205", + "-332.84759", + "-266.69751", + "inlet.1", + ], + "ZoneSelectionList": ["inlet.1"], + } +) +session.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask() + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].InsertCompoundChildTask() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState({}) +session.workflow.TaskObject["inlet-1"].Execute() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "inlet-2", + "SelectionType": "zone", + "ZoneSelectionList": ["inlet.2"], + } +) +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "inlet-2", + "SelectionType": "zone", + "ZoneLocation": [ + "1", + "441.68205", + "-361.34322", + "-301.88668", + "486.96205", + "-332.84759", + "-266.69751", + "inlet.2", + ], + "ZoneSelectionList": ["inlet.2"], + } +) +session.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask() + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].InsertCompoundChildTask() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState({}) +session.workflow.TaskObject["inlet-2"].Execute() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "inlet-3", + "SelectionType": "zone", + "ZoneSelectionList": ["inlet"], + } +) +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "inlet-3", + "SelectionType": "zone", + "ZoneLocation": [ + "1", + "261.68205", + "-361.34322", + "-301.88668", + "306.96205", + "-332.84759", + "-266.69751", + "inlet", + ], + "ZoneSelectionList": ["inlet"], + } +) +session.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask() + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].InsertCompoundChildTask() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState({}) +session.workflow.TaskObject["inlet-3"].Execute() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "outlet-1", + "SelectionType": "zone", + "ZoneSelectionList": ["outlet"], + "ZoneType": "pressure-outlet", + } +) +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "outlet-1", + "SelectionType": "zone", + "ZoneLocation": [ + "1", + "352.22702", + "-197.8957", + "84.102381", + "394.41707", + "-155.70565", + "84.102381", + "outlet", + ], + "ZoneSelectionList": ["outlet"], + "ZoneType": "pressure-outlet", + } +) +session.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask() + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].InsertCompoundChildTask() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState({}) +session.workflow.TaskObject["outlet-1"].Execute() + +############################################################################### + +# Extract edge features. + +session.workflow.TaskObject["Extract Edge Features"].Arguments.setState( + { + "ExtractMethodType": "Intersection Loops", + "ObjectSelectionList": ["flow_pipe", "main"], + } +) +session.workflow.TaskObject["Extract Edge Features"].AddChildToTask() + +session.workflow.TaskObject["Extract Edge Features"].InsertCompoundChildTask() + +session.workflow.TaskObject["edge-group-1"].Arguments.setState( + { + "ExtractEdgesName": "edge-group-1", + "ExtractMethodType": "Intersection Loops", + "ObjectSelectionList": ["flow_pipe", "main"], + } +) +session.workflow.TaskObject["Extract Edge Features"].Arguments.setState({}) + +session.workflow.TaskObject["edge-group-1"].Execute() + +############################################################################### + +# Identify regions. + +session.workflow.TaskObject["Identify Regions"].Arguments.setState( + { + "SelectionType": "zone", + "X": 377.322045740589, + "Y": -176.800676988458, + "Z": -37.0764628583475, + "ZoneSelectionList": ["main.1"], + } +) +session.workflow.TaskObject["Identify Regions"].Arguments.setState( + { + "SelectionType": "zone", + "X": 377.322045740589, + "Y": -176.800676988458, + "Z": -37.0764628583475, + "ZoneLocation": [ + "1", + "213.32205", + "-225.28068", + "-158.25531", + "541.32205", + "-128.32068", + "84.102381", + "main.1", + ], + "ZoneSelectionList": ["main.1"], + } +) +session.workflow.TaskObject["Identify Regions"].AddChildToTask() + +session.workflow.TaskObject["Identify Regions"].InsertCompoundChildTask() + +session.workflow.TaskObject["fluid-region-1"].Arguments.setState( + { + "MaterialPointsName": "fluid-region-1", + "SelectionType": "zone", + "X": 377.322045740589, + "Y": -176.800676988458, + "Z": -37.0764628583475, + "ZoneLocation": [ + "1", + "213.32205", + "-225.28068", + "-158.25531", + "541.32205", + "-128.32068", + "84.102381", + "main.1", + ], + "ZoneSelectionList": ["main.1"], + } +) +session.workflow.TaskObject["Identify Regions"].Arguments.setState({}) + +session.workflow.TaskObject["fluid-region-1"].Execute() +session.workflow.TaskObject["Identify Regions"].Arguments.setState( + { + "MaterialPointsName": "void-region-1", + "NewRegionType": "void", + "ObjectSelectionList": ["inlet-1", "inlet-2", "inlet-3", "main"], + "X": 374.722045740589, + "Y": -278.9775145640143, + "Z": -161.1700719416913, + } +) +session.workflow.TaskObject["Identify Regions"].AddChildToTask() + +session.workflow.TaskObject["Identify Regions"].InsertCompoundChildTask() + +session.workflow.TaskObject["Identify Regions"].Arguments.setState({}) + +session.workflow.TaskObject["void-region-1"].Execute() + +############################################################################### + +# Define thresholds for any potential leakages. + +session.workflow.TaskObject["Define Leakage Threshold"].Arguments.setState( + { + "AddChild": "yes", + "FlipDirection": True, + "PlaneDirection": "X", + "RegionSelectionSingle": "void-region-1", + } +) +session.workflow.TaskObject["Define Leakage Threshold"].AddChildToTask() + +session.workflow.TaskObject[ + "Define Leakage Threshold" +].InsertCompoundChildTask() +session.workflow.TaskObject["leakage-1"].Arguments.setState( + { + "AddChild": "yes", + "FlipDirection": True, + "LeakageName": "leakage-1", + "PlaneDirection": "X", + "RegionSelectionSingle": "void-region-1", + } +) +session.workflow.TaskObject["Define Leakage Threshold"].Arguments.setState( + { + "AddChild": "yes", + } +) +session.workflow.TaskObject["leakage-1"].Execute() + +############################################################################### + +# Review your region settings. + +session.workflow.TaskObject["Update Region Settings"].Arguments.setState( + { + "AllRegionFilterCategories": [ + "2", + "2", + "2", + "2", + "2", + "1", + "1", + ], + "AllRegionLeakageSizeList": [ + "none", + "none", + "none", + "none", + "none", + "6.4", + "none", + ], + "AllRegionLinkedConstructionSurfaceList": [ + "n/a", + "n/a", + "n/a", + "n/a", + "n/a", + "n/a", + "no", + ], + "AllRegionMeshMethodList": [ + "none", + "none", + "none", + "none", + "none", + "none", + "wrap", + ], + "AllRegionNameList": [ + "main", + "flow_pipe", + "outpipe3", + "object2", + "object1", + "void-region-1", + "fluid-region-1", + ], + "AllRegionOversetComponenList": [ + "no", + "no", + "no", + "no", + "no", + "no", + "no", + ], + "AllRegionSourceList": [ + "object", + "object", + "object", + "object", + "object", + "mpt", + "mpt", + ], + "AllRegionTypeList": [ + "void", + "void", + "void", + "void", + "void", + "void", + "fluid", + ], + "AllRegionVolumeFillList": [ + "none", + "none", + "none", + "none", + "none", + "none", + "tet", + ], + "FilterCategory": "Identified Regions", + "OldRegionLeakageSizeList": [""], + "OldRegionMeshMethodList": ["wrap"], + "OldRegionNameList": ["fluid-region-1"], + "OldRegionOversetComponenList": ["no"], + "OldRegionTypeList": ["fluid"], + "OldRegionVolumeFillList": ["hexcore"], + "RegionLeakageSizeList": [""], + "RegionMeshMethodList": ["wrap"], + "RegionNameList": ["fluid-region-1"], + "RegionOversetComponenList": ["no"], + "RegionTypeList": ["fluid"], + "RegionVolumeFillList": ["tet"], + } +) +session.workflow.TaskObject["Update Region Settings"].Execute() + + +############################################################################### + +# Select options for controlling the mesh. + +session.workflow.TaskObject["Choose Mesh Control Options"].Execute() + +############################################################################### + +# Generate the surface mesh. + +session.workflow.TaskObject["Generate the Surface Mesh"].Execute() + +############################################################################### + +# Confirm and update the boundaries. + +session.workflow.TaskObject["Update Boundaries"].Execute() + +############################################################################### + +# Add boundary layers. + +session.workflow.TaskObject["Add Boundary Layers"].AddChildToTask() + +session.workflow.TaskObject["Add Boundary Layers"].InsertCompoundChildTask() + +session.workflow.TaskObject["aspect-ratio_1"].Arguments.setState( + { + "BLControlName": "aspect-ratio_1", + } +) +session.workflow.TaskObject["Add Boundary Layers"].Arguments.setState({}) + +session.workflow.TaskObject["aspect-ratio_1"].Execute() + +############################################################################### + +# Generate the volume mesh. + +session.workflow.TaskObject["Generate the Volume Mesh"].Arguments.setState( + { + "AllRegionNameList": [ + "main", + "flow_pipe", + "outpipe3", + "object2", + "object1", + "void-region-1", + "fluid-region-1", + ], + "AllRegionSizeList": [ + "11.33375", + "11.33375", + "11.33375", + "11.33375", + "11.33375", + "11.33375", + "11.33375", + ], + "AllRegionVolumeFillList": [ + "none", + "none", + "none", + "none", + "none", + "none", + "tet", + ], + "EnableParallel": True, + } +) +session.workflow.TaskObject["Generate the Volume Mesh"].Execute() + +############################################################################### + +# Check the mesh. + +session.tui.meshing.mesh.check_mesh() + +############################################################################### + +# Switch to Solution mode. + +session.tui.meshing.switch_to_solution_mode("yes") + +session.tui.solver.mesh.check() + +############################################################################### + +# Set the units for length +session.tui.solver.define.units("length", "mm") + +############################################################################### + +# Select kw sst turbulence model + +session.tui.solver.define.models.viscous.kw_sst("yes") + +############################################################################### + +# Set the velocity and turbulence boundary conditions for the first inlet +# (inlet-1). + +session.tui.solver.define.boundary_conditions.set.velocity_inlet( + "inlet-1", [], "vmag", "no", 1, "quit" +) + +############################################################################### + +# Apply the same conditions for the other velocity inlet boundaries (inlet_2, +# and inlet_3). + +session.tui.solver.define.boundary_conditions.copy_bc( + "inlet-1", "inlet-2", "inlet-3", () +) + +############################################################################### + +# Set the boundary conditions at the outlet (outlet-1). + +session.tui.solver.define.boundary_conditions.set.pressure_outlet( + "outlet-1", [], "turb-intensity", 5, "quit" +) +session.tui.solver.solve.monitors.residual.plot("yes") + +############################################################################### + +# Initialize the flow field using the Initialization + +session.tui.solver.solve.initialize.hyb_initialization() + +############################################################################### + +# Start the calculation by requesting 100 iterations + +session.tui.solver.solve.set.number_of_iterations(100) +session.tui.solver.solve.iterate() + +# session.tui.solver.report.volume_integrals.volume("fluid-region-1","()","yes","volume.vrp") + +############################################################################### + +# Display path lines highlighting the flow field + +session.tui.solver.display.objects.create( + "pathlines", + "pathlines-1", + "field", + "time", + "accuracy-control", + "tolerance", + "0.001", + "skip", + "5", + "surfaces-list", + "inlet-1", + "inlet-2", + "inlet-3", + "()", + "quit", +) +session.tui.solver.display.objects.display("pathlines-1") + +############################################################################### + +# Create an iso-surface through the manifold geometry. + +session.tui.solver.surface.iso_surface( + "x-coordinate", + "surf-x-coordinate", + "()", + "fluid-region-1", + "()", + "380", + "()", +) + +############################################################################### + +# Create and define contours of velocity magnitude throughout the manifold +# along with the mesh. + +session.tui.solver.display.objects.create( + "contour", + "contour-velocity", + "field", + "velocity-magnitude", + "surfaces-list", + "surf-x-coordinate", + "()", + "node-values?", + "no", + "range-option", + "auto-range-on", + "global-range?", + "no", + "quit", + "quit", +) +session.tui.solver.display.objects.display("contour-velocity") + +session.tui.solver.display.objects.create( + "mesh", "mesh-1", "surfaces-list", "*", "()", "quit" +) + +############################################################################### + +# Create a scene containing the mesh and the contours. + +session.tui.solver.display.objects.create( + "scene", + "scene-1", + "graphics-objects", + "add", + "mesh-1", + "transparency", + "90", + "quit", + "add", + "contour-velocity", + "quit", + "quit", + "quit", +) +session.tui.solver.display.objects.display("scene-1") + +############################################################################### + +# Save case, data and exit. + +# session.tui.solver.file.write_case_data("exhaust_system.cas.h5") + +session.exit() From db1d25029e923eb51a2602b2b5bf20340d92c9a2 Mon Sep 17 00:00:00 2001 From: Yogesh Patel Date: Tue, 5 Apr 2022 20:50:17 -0400 Subject: [PATCH 02/12] (2) Adding Fluent example using Python: FTM Workflow --- examples/00-fluent/exhaust_system_tui_api.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/00-fluent/exhaust_system_tui_api.py b/examples/00-fluent/exhaust_system_tui_api.py index 7eb5c2b31357..267bc5efecdd 100644 --- a/examples/00-fluent/exhaust_system_tui_api.py +++ b/examples/00-fluent/exhaust_system_tui_api.py @@ -75,11 +75,16 @@ session.PMFileManagement.FileManager.LoadFiles() session.part_management.Node["Meshing Model"].Copy( Paths=[ - "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/main,1", - "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/flow-pipe,1", - "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/outpipe3,1", - "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/object2,1", - "/dirty_manifold-for-wrapper,1/dirty_manifold-for-wrapper,1/object1,1", + "/dirty_manifold-for-wrapper,1/ + dirty_manifold-for-wrapper,1/main,1", + "/dirty_manifold-for-wrapper,1/ + dirty_manifold-for-wrapper,1/flow-pipe,1", + "/dirty_manifold-for-wrapper,1/ + dirty_manifold-for-wrapper,1/outpipe3,1", + "/dirty_manifold-for-wrapper,1/ + dirty_manifold-for-wrapper,1/object2,1", + "/dirty_manifold-for-wrapper,1/ + dirty_manifold-for-wrapper,1/object1,1", ] ) session.part_management.ObjectSetting[ From 371435fda8c76525131fe89f3a8231f6c4d36d83 Mon Sep 17 00:00:00 2001 From: Yogesh Patel Date: Wed, 6 Apr 2022 09:38:38 -0400 Subject: [PATCH 03/12] (3) Remving spaces --- examples/00-fluent/exhaust_system_tui_api.py | 31 +------------------- 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/examples/00-fluent/exhaust_system_tui_api.py b/examples/00-fluent/exhaust_system_tui_api.py index 267bc5efecdd..f792a9eea7e9 100644 --- a/examples/00-fluent/exhaust_system_tui_api.py +++ b/examples/00-fluent/exhaust_system_tui_api.py @@ -40,7 +40,6 @@ """ ############################################################################### - # First, connect with a Fluent server import ansys.fluent.core as pyfluent @@ -51,7 +50,6 @@ ) ############################################################################### - # Start Fluent in double precision running on 4 processors session = pyfluent.launch_fluent( @@ -59,13 +57,11 @@ ) ############################################################################### - # Select the Fault Tolerant Meshing Workflow session.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing") ############################################################################### - # Import the CAD geometry (exhaust_system.fmd). Perform some selective part # management. @@ -109,7 +105,6 @@ session.workflow.TaskObject["Import CAD and Part Management"].Execute() ############################################################################### - # Provide a description for the geometry and the flow characteristics. session.workflow.TaskObject["Describe Geometry and Flow"].Arguments.setState( @@ -139,7 +134,6 @@ session.workflow.TaskObject["Describe Geometry and Flow"].Execute() ############################################################################### - # Cover any openings in your geometry. session.workflow.TaskObject[ @@ -300,7 +294,6 @@ session.workflow.TaskObject["outlet-1"].Execute() ############################################################################### - # Extract edge features. session.workflow.TaskObject["Extract Edge Features"].Arguments.setState( @@ -325,7 +318,6 @@ session.workflow.TaskObject["edge-group-1"].Execute() ############################################################################### - # Identify regions. session.workflow.TaskObject["Identify Regions"].Arguments.setState( @@ -402,7 +394,6 @@ session.workflow.TaskObject["void-region-1"].Execute() ############################################################################### - # Define thresholds for any potential leakages. session.workflow.TaskObject["Define Leakage Threshold"].Arguments.setState( @@ -435,7 +426,6 @@ session.workflow.TaskObject["leakage-1"].Execute() ############################################################################### - # Review your region settings. session.workflow.TaskObject["Update Region Settings"].Arguments.setState( @@ -540,25 +530,21 @@ ############################################################################### - # Select options for controlling the mesh. session.workflow.TaskObject["Choose Mesh Control Options"].Execute() ############################################################################### - # Generate the surface mesh. session.workflow.TaskObject["Generate the Surface Mesh"].Execute() ############################################################################### - # Confirm and update the boundaries. session.workflow.TaskObject["Update Boundaries"].Execute() ############################################################################### - # Add boundary layers. session.workflow.TaskObject["Add Boundary Layers"].AddChildToTask() @@ -575,7 +561,6 @@ session.workflow.TaskObject["aspect-ratio_1"].Execute() ############################################################################### - # Generate the volume mesh. session.workflow.TaskObject["Generate the Volume Mesh"].Arguments.setState( @@ -613,13 +598,11 @@ session.workflow.TaskObject["Generate the Volume Mesh"].Execute() ############################################################################### - # Check the mesh. session.tui.meshing.mesh.check_mesh() ############################################################################### - # Switch to Solution mode. session.tui.meshing.switch_to_solution_mode("yes") @@ -627,18 +610,16 @@ session.tui.solver.mesh.check() ############################################################################### - # Set the units for length + session.tui.solver.define.units("length", "mm") ############################################################################### - # Select kw sst turbulence model session.tui.solver.define.models.viscous.kw_sst("yes") ############################################################################### - # Set the velocity and turbulence boundary conditions for the first inlet # (inlet-1). @@ -647,7 +628,6 @@ ) ############################################################################### - # Apply the same conditions for the other velocity inlet boundaries (inlet_2, # and inlet_3). @@ -656,7 +636,6 @@ ) ############################################################################### - # Set the boundary conditions at the outlet (outlet-1). session.tui.solver.define.boundary_conditions.set.pressure_outlet( @@ -665,13 +644,11 @@ session.tui.solver.solve.monitors.residual.plot("yes") ############################################################################### - # Initialize the flow field using the Initialization session.tui.solver.solve.initialize.hyb_initialization() ############################################################################### - # Start the calculation by requesting 100 iterations session.tui.solver.solve.set.number_of_iterations(100) @@ -680,7 +657,6 @@ # session.tui.solver.report.volume_integrals.volume("fluid-region-1","()","yes","volume.vrp") ############################################################################### - # Display path lines highlighting the flow field session.tui.solver.display.objects.create( @@ -703,7 +679,6 @@ session.tui.solver.display.objects.display("pathlines-1") ############################################################################### - # Create an iso-surface through the manifold geometry. session.tui.solver.surface.iso_surface( @@ -717,7 +692,6 @@ ) ############################################################################### - # Create and define contours of velocity magnitude throughout the manifold # along with the mesh. @@ -745,7 +719,6 @@ ) ############################################################################### - # Create a scene containing the mesh and the contours. session.tui.solver.display.objects.create( @@ -766,9 +739,7 @@ session.tui.solver.display.objects.display("scene-1") ############################################################################### - # Save case, data and exit. - # session.tui.solver.file.write_case_data("exhaust_system.cas.h5") session.exit() From 5ff6fd6e2f4c9017efa6ee74fa9751e32fa6f731 Mon Sep 17 00:00:00 2001 From: Yogesh Patel Date: Wed, 6 Apr 2022 12:21:37 -0400 Subject: [PATCH 04/12] (3) Changes as per PR review suggestions --- examples/00-fluent/exhaust_system_tui_api.py | 120 ++++--------------- 1 file changed, 20 insertions(+), 100 deletions(-) diff --git a/examples/00-fluent/exhaust_system_tui_api.py b/examples/00-fluent/exhaust_system_tui_api.py index f792a9eea7e9..42c506a00b3e 100644 --- a/examples/00-fluent/exhaust_system_tui_api.py +++ b/examples/00-fluent/exhaust_system_tui_api.py @@ -71,16 +71,16 @@ session.PMFileManagement.FileManager.LoadFiles() session.part_management.Node["Meshing Model"].Copy( Paths=[ - "/dirty_manifold-for-wrapper,1/ - dirty_manifold-for-wrapper,1/main,1", - "/dirty_manifold-for-wrapper,1/ - dirty_manifold-for-wrapper,1/flow-pipe,1", - "/dirty_manifold-for-wrapper,1/ - dirty_manifold-for-wrapper,1/outpipe3,1", - "/dirty_manifold-for-wrapper,1/ - dirty_manifold-for-wrapper,1/object2,1", - "/dirty_manifold-for-wrapper,1/ - dirty_manifold-for-wrapper,1/object1,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/main,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/flow-pipe,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/outpipe3,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/object2,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/object1,1", ] ) session.part_management.ObjectSetting[ @@ -430,42 +430,10 @@ session.workflow.TaskObject["Update Region Settings"].Arguments.setState( { - "AllRegionFilterCategories": [ - "2", - "2", - "2", - "2", - "2", - "1", - "1", - ], - "AllRegionLeakageSizeList": [ - "none", - "none", - "none", - "none", - "none", - "6.4", - "none", - ], - "AllRegionLinkedConstructionSurfaceList": [ - "n/a", - "n/a", - "n/a", - "n/a", - "n/a", - "n/a", - "no", - ], - "AllRegionMeshMethodList": [ - "none", - "none", - "none", - "none", - "none", - "none", - "wrap", - ], + "AllRegionFilterCategories": ["2"] * 5 + ["1"] * 2, + "AllRegionLeakageSizeList": ["none"] * 6 + ["6.4"], + "AllRegionLinkedConstructionSurfaceList": ["n/a"] * 6 + ["no"], + "AllRegionMeshMethodList": ["none"] * 6 + ["wrap"], "AllRegionNameList": [ "main", "flow_pipe", @@ -475,42 +443,10 @@ "void-region-1", "fluid-region-1", ], - "AllRegionOversetComponenList": [ - "no", - "no", - "no", - "no", - "no", - "no", - "no", - ], - "AllRegionSourceList": [ - "object", - "object", - "object", - "object", - "object", - "mpt", - "mpt", - ], - "AllRegionTypeList": [ - "void", - "void", - "void", - "void", - "void", - "void", - "fluid", - ], - "AllRegionVolumeFillList": [ - "none", - "none", - "none", - "none", - "none", - "none", - "tet", - ], + "AllRegionOversetComponenList": ["no"] * 7, + "AllRegionSourceList": ["object"] * 5 + ["mpt"] * 2, + "AllRegionTypeList": ["void"] * 6 + ["fluid"], + "AllRegionVolumeFillList": ["none"] * 6 + ["tet"], "FilterCategory": "Identified Regions", "OldRegionLeakageSizeList": [""], "OldRegionMeshMethodList": ["wrap"], @@ -574,24 +510,8 @@ "void-region-1", "fluid-region-1", ], - "AllRegionSizeList": [ - "11.33375", - "11.33375", - "11.33375", - "11.33375", - "11.33375", - "11.33375", - "11.33375", - ], - "AllRegionVolumeFillList": [ - "none", - "none", - "none", - "none", - "none", - "none", - "tet", - ], + "AllRegionSizeList": ["11.33375"] * 7, + "AllRegionVolumeFillList": ["none"] * 6 + ["tet"], "EnableParallel": True, } ) From d823402ad5d92447044452174eb638c198108d65 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Thu, 7 Apr 2022 16:30:57 -0400 Subject: [PATCH 05/12] add FTM workflow based script using the settings api --- .../00-fluent/exhaust_system_settings_api.py | 667 ++++++++++++++++++ 1 file changed, 667 insertions(+) create mode 100755 examples/00-fluent/exhaust_system_settings_api.py diff --git a/examples/00-fluent/exhaust_system_settings_api.py b/examples/00-fluent/exhaust_system_settings_api.py new file mode 100755 index 000000000000..a56e3022bfec --- /dev/null +++ b/examples/00-fluent/exhaust_system_settings_api.py @@ -0,0 +1,667 @@ +""" +.. _ref_exhaust_system_settings_api: + +Exhaust System: Fault-tolerant Meshing +---------------------------------------------- + +This tutorial illustrates the setup and solution of a three-dimensional +turbulent fluid flow in a manifold exhaust system. The manifold configuration +is encountered in the automotive industry. It is often important to predict +the flow field in the area of the mixing region in order to properly design +the junction. You will use the Fault-tolerant Meshing guided workflow, which +unlike the watertight workflow used in Fluid Flow in a Mixing Elbow, is +appropriate for geometries with imperfections, such as gaps and leakages. + +This tutorial demonstrates how to do the following in Ansys Fluent: + + +- Use the Fault-tolerant Meshing guided workflow to: + - Import a CAD geometry and manage individual parts + - Generate a surface mesh + - Cap inlets and outlets + - Extract a fluid region + - Define leakages + - Extract edge features + - Setup size controls + - Generate a volume mesh +- Set up appropriate physics and boundary conditions. +- Calculate a solution. +- Review the results of the simulation. + +Problem Description: + +Air flows through the three inlets with a uniform velocity of 1 m/s, and then +exits through the outlet. A small pipe is placed in the main portion of the +manifold where edge extraction will be considered. There is also a known small +leakage included that will be addressed in the meshing portion of the tutorial +to demonstrate the automatic leakage detection aspects of the meshing workflow. + + +""" + +############################################################################### +# First, connect with a Fluent server + +import ansys.fluent.core as pyfluent +from ansys.fluent.core import examples + +import_filename = examples.download_file( + "exhaust_system.fmd", "pyfluent/exhaust_system" +) + +############################################################################### +# Start Fluent in double precision running on 4 processors + +session = pyfluent.launch_fluent( + meshing_mode=True, precision="double", processor_count=4 +) + +############################################################################### +# Select the Fault Tolerant Meshing Workflow + +session.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing") + +############################################################################### +# Import the CAD geometry (exhaust_system.fmd). Perform some selective part +# management. + +session.part_management.InputFileChanged( + FilePath=import_filename, IgnoreSolidNames=False, PartPerBody=False +) +session.PMFileManagement.FileManager.LoadFiles() +session.part_management.Node["Meshing Model"].Copy( + Paths=[ + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/main,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/flow-pipe,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/outpipe3,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/object2,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/object1,1", + ] +) +session.part_management.ObjectSetting[ + "DefaultObjectSetting" +].OneZonePer.setState("part") +session.workflow.TaskObject[ + "Import CAD and Part Management" +].Arguments.setState( + { + "Context": 0, + "CreateObjectPer": "Custom", + "FMDFileName": "import_filenamed", + "FileLoaded": "yes", + "ObjectSetting": "DefaultObjectSetting", + "Options": { + "Line": False, + "Solid": False, + "Surface": False, + }, + } +) +session.workflow.TaskObject["Import CAD and Part Management"].Execute() + +############################################################################### +# Provide a description for the geometry and the flow characteristics. + +session.workflow.TaskObject["Describe Geometry and Flow"].Arguments.setState( + { + "AddEnclosure": "No", + "CloseCaps": "Yes", + "FlowType": "Internal flow through the object", + } +) +session.workflow.TaskObject["Describe Geometry and Flow"].UpdateChildTasks( + SetupTypeChanged=False +) +session.workflow.TaskObject["Describe Geometry and Flow"].Arguments.setState( + { + "AddEnclosure": "No", + "CloseCaps": "Yes", + "DescribeGeometryAndFlowOptions": { + "AdvancedOptions": True, + "ExtractEdgeFeatures": "Yes", + }, + "FlowType": "Internal flow through the object", + } +) +session.workflow.TaskObject["Describe Geometry and Flow"].UpdateChildTasks( + SetupTypeChanged=False +) +session.workflow.TaskObject["Describe Geometry and Flow"].Execute() + +############################################################################### +# Cover any openings in your geometry. + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "CreatePatchPreferences": { + "ShowCreatePatchPreferences": False, + }, + "PatchName": "inlet-1", + "SelectionType": "zone", + "ZoneSelectionList": ["inlet.1"], + } +) +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "CreatePatchPreferences": { + "ShowCreatePatchPreferences": False, + }, + "PatchName": "inlet-1", + "SelectionType": "zone", + "ZoneLocation": [ + "1", + "351.68205", + "-361.34322", + "-301.88668", + "396.96205", + "-332.84759", + "-266.69751", + "inlet.1", + ], + "ZoneSelectionList": ["inlet.1"], + } +) +session.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask() + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].InsertCompoundChildTask() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState({}) +session.workflow.TaskObject["inlet-1"].Execute() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "inlet-2", + "SelectionType": "zone", + "ZoneSelectionList": ["inlet.2"], + } +) +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "inlet-2", + "SelectionType": "zone", + "ZoneLocation": [ + "1", + "441.68205", + "-361.34322", + "-301.88668", + "486.96205", + "-332.84759", + "-266.69751", + "inlet.2", + ], + "ZoneSelectionList": ["inlet.2"], + } +) +session.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask() + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].InsertCompoundChildTask() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState({}) +session.workflow.TaskObject["inlet-2"].Execute() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "inlet-3", + "SelectionType": "zone", + "ZoneSelectionList": ["inlet"], + } +) +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "inlet-3", + "SelectionType": "zone", + "ZoneLocation": [ + "1", + "261.68205", + "-361.34322", + "-301.88668", + "306.96205", + "-332.84759", + "-266.69751", + "inlet", + ], + "ZoneSelectionList": ["inlet"], + } +) +session.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask() + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].InsertCompoundChildTask() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState({}) +session.workflow.TaskObject["inlet-3"].Execute() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "outlet-1", + "SelectionType": "zone", + "ZoneSelectionList": ["outlet"], + "ZoneType": "pressure-outlet", + } +) +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState( + { + "PatchName": "outlet-1", + "SelectionType": "zone", + "ZoneLocation": [ + "1", + "352.22702", + "-197.8957", + "84.102381", + "394.41707", + "-155.70565", + "84.102381", + "outlet", + ], + "ZoneSelectionList": ["outlet"], + "ZoneType": "pressure-outlet", + } +) +session.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask() + +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].InsertCompoundChildTask() +session.workflow.TaskObject[ + "Enclose Fluid Regions (Capping)" +].Arguments.setState({}) +session.workflow.TaskObject["outlet-1"].Execute() + +############################################################################### +# Extract edge features. + +session.workflow.TaskObject["Extract Edge Features"].Arguments.setState( + { + "ExtractMethodType": "Intersection Loops", + "ObjectSelectionList": ["flow_pipe", "main"], + } +) +session.workflow.TaskObject["Extract Edge Features"].AddChildToTask() + +session.workflow.TaskObject["Extract Edge Features"].InsertCompoundChildTask() + +session.workflow.TaskObject["edge-group-1"].Arguments.setState( + { + "ExtractEdgesName": "edge-group-1", + "ExtractMethodType": "Intersection Loops", + "ObjectSelectionList": ["flow_pipe", "main"], + } +) +session.workflow.TaskObject["Extract Edge Features"].Arguments.setState({}) + +session.workflow.TaskObject["edge-group-1"].Execute() + +############################################################################### +# Identify regions. + +session.workflow.TaskObject["Identify Regions"].Arguments.setState( + { + "SelectionType": "zone", + "X": 377.322045740589, + "Y": -176.800676988458, + "Z": -37.0764628583475, + "ZoneSelectionList": ["main.1"], + } +) +session.workflow.TaskObject["Identify Regions"].Arguments.setState( + { + "SelectionType": "zone", + "X": 377.322045740589, + "Y": -176.800676988458, + "Z": -37.0764628583475, + "ZoneLocation": [ + "1", + "213.32205", + "-225.28068", + "-158.25531", + "541.32205", + "-128.32068", + "84.102381", + "main.1", + ], + "ZoneSelectionList": ["main.1"], + } +) +session.workflow.TaskObject["Identify Regions"].AddChildToTask() + +session.workflow.TaskObject["Identify Regions"].InsertCompoundChildTask() + +session.workflow.TaskObject["fluid-region-1"].Arguments.setState( + { + "MaterialPointsName": "fluid-region-1", + "SelectionType": "zone", + "X": 377.322045740589, + "Y": -176.800676988458, + "Z": -37.0764628583475, + "ZoneLocation": [ + "1", + "213.32205", + "-225.28068", + "-158.25531", + "541.32205", + "-128.32068", + "84.102381", + "main.1", + ], + "ZoneSelectionList": ["main.1"], + } +) +session.workflow.TaskObject["Identify Regions"].Arguments.setState({}) + +session.workflow.TaskObject["fluid-region-1"].Execute() +session.workflow.TaskObject["Identify Regions"].Arguments.setState( + { + "MaterialPointsName": "void-region-1", + "NewRegionType": "void", + "ObjectSelectionList": ["inlet-1", "inlet-2", "inlet-3", "main"], + "X": 374.722045740589, + "Y": -278.9775145640143, + "Z": -161.1700719416913, + } +) +session.workflow.TaskObject["Identify Regions"].AddChildToTask() + +session.workflow.TaskObject["Identify Regions"].InsertCompoundChildTask() + +session.workflow.TaskObject["Identify Regions"].Arguments.setState({}) + +session.workflow.TaskObject["void-region-1"].Execute() + +############################################################################### +# Define thresholds for any potential leakages. + +session.workflow.TaskObject["Define Leakage Threshold"].Arguments.setState( + { + "AddChild": "yes", + "FlipDirection": True, + "PlaneDirection": "X", + "RegionSelectionSingle": "void-region-1", + } +) +session.workflow.TaskObject["Define Leakage Threshold"].AddChildToTask() + +session.workflow.TaskObject[ + "Define Leakage Threshold" +].InsertCompoundChildTask() +session.workflow.TaskObject["leakage-1"].Arguments.setState( + { + "AddChild": "yes", + "FlipDirection": True, + "LeakageName": "leakage-1", + "PlaneDirection": "X", + "RegionSelectionSingle": "void-region-1", + } +) +session.workflow.TaskObject["Define Leakage Threshold"].Arguments.setState( + { + "AddChild": "yes", + } +) +session.workflow.TaskObject["leakage-1"].Execute() + +############################################################################### +# Review your region settings. + +session.workflow.TaskObject["Update Region Settings"].Arguments.setState( + { + "AllRegionFilterCategories": ["2"] * 5 + ["1"] * 2, + "AllRegionLeakageSizeList": ["none"] * 6 + ["6.4"], + "AllRegionLinkedConstructionSurfaceList": ["n/a"] * 6 + ["no"], + "AllRegionMeshMethodList": ["none"] * 6 + ["wrap"], + "AllRegionNameList": [ + "main", + "flow_pipe", + "outpipe3", + "object2", + "object1", + "void-region-1", + "fluid-region-1", + ], + "AllRegionOversetComponenList": ["no"] * 7, + "AllRegionSourceList": ["object"] * 5 + ["mpt"] * 2, + "AllRegionTypeList": ["void"] * 6 + ["fluid"], + "AllRegionVolumeFillList": ["none"] * 6 + ["tet"], + "FilterCategory": "Identified Regions", + "OldRegionLeakageSizeList": [""], + "OldRegionMeshMethodList": ["wrap"], + "OldRegionNameList": ["fluid-region-1"], + "OldRegionOversetComponenList": ["no"], + "OldRegionTypeList": ["fluid"], + "OldRegionVolumeFillList": ["hexcore"], + "RegionLeakageSizeList": [""], + "RegionMeshMethodList": ["wrap"], + "RegionNameList": ["fluid-region-1"], + "RegionOversetComponenList": ["no"], + "RegionTypeList": ["fluid"], + "RegionVolumeFillList": ["tet"], + } +) +session.workflow.TaskObject["Update Region Settings"].Execute() + + +############################################################################### +# Select options for controlling the mesh. + +session.workflow.TaskObject["Choose Mesh Control Options"].Execute() + +############################################################################### +# Generate the surface mesh. + +session.workflow.TaskObject["Generate the Surface Mesh"].Execute() + +############################################################################### +# Confirm and update the boundaries. + +session.workflow.TaskObject["Update Boundaries"].Execute() + +############################################################################### +# Add boundary layers. + +session.workflow.TaskObject["Add Boundary Layers"].AddChildToTask() + +session.workflow.TaskObject["Add Boundary Layers"].InsertCompoundChildTask() + +session.workflow.TaskObject["aspect-ratio_1"].Arguments.setState( + { + "BLControlName": "aspect-ratio_1", + } +) +session.workflow.TaskObject["Add Boundary Layers"].Arguments.setState({}) + +session.workflow.TaskObject["aspect-ratio_1"].Execute() + +############################################################################### +# Generate the volume mesh. + +session.workflow.TaskObject["Generate the Volume Mesh"].Arguments.setState( + { + "AllRegionNameList": [ + "main", + "flow_pipe", + "outpipe3", + "object2", + "object1", + "void-region-1", + "fluid-region-1", + ], + "AllRegionSizeList": ["11.33375"] * 7, + "AllRegionVolumeFillList": ["none"] * 6 + ["tet"], + "EnableParallel": True, + } +) +session.workflow.TaskObject["Generate the Volume Mesh"].Execute() + +############################################################################### +# Check the mesh. + +session.tui.meshing.mesh.check_mesh() + +############################################################################### +# Switch to Solution mode. + +session.tui.meshing.switch_to_solution_mode("yes") + +session.tui.solver.mesh.check() + +############################################################################### +# Set the units for length + +session.tui.solver.define.units("length", "mm") + +############################################################################### +# The settings objects provide a natural way to access and modify settings. +# The top-level settings object for a session can be accessed with the +# get_settings_root() method of the session object. +# Enabling the settings objects (Beta) +root = session.get_settings_root() + +############################################################################### +# Select kw sst turbulence model + +root.setup.models.viscous.k_omega_model = 'sst' + +############################################################################### +# Set the velocity and turbulence boundary conditions for the first inlet +# (inlet-1). + +root.setup.boundary_conditions.velocity_inlet["inlet-1"].vmag = { + "option": "constant or expression", + "constant": 1, +} +############################################################################### +# Apply the same conditions for the other velocity inlet boundaries (inlet_2, +# and inlet_3). + +session.tui.solver.define.boundary_conditions.copy_bc( + "inlet-1", "inlet-2", "inlet-3", () +) + +############################################################################### +# Set the boundary conditions at the outlet (outlet-1). + +root.setup.boundary_conditions.pressure_outlet[ + "outlet-1"].turb_intensity = 0.05 + +############################################################################### +# Enable the plotting of residuals during the calculation. +session.tui.solver.solve.monitors.residual.plot("yes") + +############################################################################### +# Initialize the flow field using the Initialization + +session.tui.solver.solve.initialize.hyb_initialization() + +############################################################################### +# Start the calculation by requesting 100 iterations + +session.tui.solver.solve.set.number_of_iterations(100) +session.tui.solver.solve.iterate() + +root.solution.report_definitions.volume["report-volume-int"] = {} +root.solution.report_definitions.volume["report-volume-int"].report_type = 'volume-integral' +root.solution.report_definitions.volume["report-volume-int"].zone_names = ["fluid-region-1"] +root.solution.report_definitions.compute(report_defs=["report-volume-int"]) + + +############################################################################### +# Display path lines highlighting the flow field + +root.results.graphics.pathlines["pathlines-1"] = {} +root.results.graphics.pathlines["pathlines-1"].print_state() +root.results.graphics.pathlines["pathlines-1"].field = 'time' +root.results.graphics.pathlines["pathlines-1"].skip = 5 +root.results.graphics.pathlines["pathlines-1"].surfaces_list = [ + "inlet-1", + "inlet-2", + "inlet-3" +] + +root.results.graphics.pathlines["pathlines-1"].display() + + +############################################################################### +# Create an iso-surface through the manifold geometry. +# Using TUI API due to Issue #288 + +session.tui.solver.surface.iso_surface( + "x-coordinate", + "surf-x-coordinate", + "()", + "fluid-region-1", + "()", + "380", + "()", +) + +############################################################################### +# Create and define contours of velocity magnitude throughout the manifold +# along with the mesh. + +root.results.graphics.contour["contour-velocity"] = {} +root.results.graphics.contour["contour-velocity"].print_state() +root.results.graphics.contour["contour-velocity"].field = "velocity-magnitude" +root.results.graphics.contour["contour-velocity"].surfaces_list = [ + "surf-x-coordinate" +] +root.results.graphics.contour["contour-velocity"].node_values = False +root.results.graphics.contour["contour-velocity"].range_option.auto_range_on.global_range = False +root.results.graphics.contour["contour-velocity"].display() + +root.results.graphics.mesh["mesh-1"] = {} +surface_list = root.results.graphics.mesh["mesh-1"].surfaces_list.get_attr('allowed-values') +root.results.graphics.mesh["mesh-1"].surfaces_list = surface_list +root.results.graphics.mesh["mesh-1"].display() + + +############################################################################### +# Create a scene containing the mesh and the contours. +# Using the TUI API due to Issue #289 + +session.tui.solver.display.objects.create( + "scene", + "scene-1", + "graphics-objects", + "add", + "mesh-1", + "transparency", + "90", + "quit", + "add", + "contour-velocity", + "quit", + "quit", + "quit", +) +session.tui.solver.display.objects.display("scene-1") + +############################################################################### +# Save case, data and exit. +# session.tui.solver.file.write_case_data("exhaust_system.cas.h5") + +session.exit() From 131a01ab6e66d2173513d18923aa2478387b4b56 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Thu, 7 Apr 2022 16:35:34 -0400 Subject: [PATCH 06/12] add FTM workflow based script using the settings api (add doc for report) --- examples/00-fluent/exhaust_system_settings_api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/00-fluent/exhaust_system_settings_api.py b/examples/00-fluent/exhaust_system_settings_api.py index a56e3022bfec..dc4aed0e840a 100755 --- a/examples/00-fluent/exhaust_system_settings_api.py +++ b/examples/00-fluent/exhaust_system_settings_api.py @@ -583,12 +583,14 @@ session.tui.solver.solve.set.number_of_iterations(100) session.tui.solver.solve.iterate() +############################################################################### +# Monitor the total mass flow rate through the entire domain + root.solution.report_definitions.volume["report-volume-int"] = {} root.solution.report_definitions.volume["report-volume-int"].report_type = 'volume-integral' root.solution.report_definitions.volume["report-volume-int"].zone_names = ["fluid-region-1"] root.solution.report_definitions.compute(report_defs=["report-volume-int"]) - ############################################################################### # Display path lines highlighting the flow field From 93832010e3f0b71e5f1b91344a37f01aa13c8cb5 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Thu, 7 Apr 2022 16:54:46 -0400 Subject: [PATCH 07/12] update style check --- .../00-fluent/exhaust_system_settings_api.py | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/examples/00-fluent/exhaust_system_settings_api.py b/examples/00-fluent/exhaust_system_settings_api.py index dc4aed0e840a..fadc1358a3dd 100755 --- a/examples/00-fluent/exhaust_system_settings_api.py +++ b/examples/00-fluent/exhaust_system_settings_api.py @@ -71,16 +71,16 @@ session.PMFileManagement.FileManager.LoadFiles() session.part_management.Node["Meshing Model"].Copy( Paths=[ - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/main,1", - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/flow-pipe,1", - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/outpipe3,1", - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/object2,1", - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/object1,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/main,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/flow-pipe,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/outpipe3,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/object2,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/object1,1", ] ) session.part_management.ObjectSetting[ @@ -544,7 +544,7 @@ ############################################################################### # Select kw sst turbulence model -root.setup.models.viscous.k_omega_model = 'sst' +root.setup.models.viscous.k_omega_model = "sst" ############################################################################### # Set the velocity and turbulence boundary conditions for the first inlet @@ -566,7 +566,8 @@ # Set the boundary conditions at the outlet (outlet-1). root.setup.boundary_conditions.pressure_outlet[ - "outlet-1"].turb_intensity = 0.05 + "outlet-1" +].turb_intensity = 0.05 ############################################################################### # Enable the plotting of residuals during the calculation. @@ -587,8 +588,12 @@ # Monitor the total mass flow rate through the entire domain root.solution.report_definitions.volume["report-volume-int"] = {} -root.solution.report_definitions.volume["report-volume-int"].report_type = 'volume-integral' -root.solution.report_definitions.volume["report-volume-int"].zone_names = ["fluid-region-1"] +root.solution.report_definitions.volume[ + "report-volume-int" +].report_type = "volume-integral" +root.solution.report_definitions.volume["report-volume-int"].zone_names = [ + "fluid-region-1" +] root.solution.report_definitions.compute(report_defs=["report-volume-int"]) ############################################################################### @@ -596,12 +601,12 @@ root.results.graphics.pathlines["pathlines-1"] = {} root.results.graphics.pathlines["pathlines-1"].print_state() -root.results.graphics.pathlines["pathlines-1"].field = 'time' +root.results.graphics.pathlines["pathlines-1"].field = "time" root.results.graphics.pathlines["pathlines-1"].skip = 5 root.results.graphics.pathlines["pathlines-1"].surfaces_list = [ "inlet-1", "inlet-2", - "inlet-3" + "inlet-3", ] root.results.graphics.pathlines["pathlines-1"].display() @@ -632,11 +637,15 @@ "surf-x-coordinate" ] root.results.graphics.contour["contour-velocity"].node_values = False -root.results.graphics.contour["contour-velocity"].range_option.auto_range_on.global_range = False +root.results.graphics.contour[ + "contour-velocity" +].range_option.auto_range_on.global_range = False root.results.graphics.contour["contour-velocity"].display() root.results.graphics.mesh["mesh-1"] = {} -surface_list = root.results.graphics.mesh["mesh-1"].surfaces_list.get_attr('allowed-values') +surface_list = root.results.graphics.mesh["mesh-1"].surfaces_list.get_attr( + "allowed-values" +) root.results.graphics.mesh["mesh-1"].surfaces_list = surface_list root.results.graphics.mesh["mesh-1"].display() From 1aead7c52e864cf2daecb8ab405c59c9e1198107 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Fri, 8 Apr 2022 16:20:24 -0400 Subject: [PATCH 08/12] fix style check via docformatter --- examples/00-fluent/exhaust_system_settings_api.py | 5 +---- examples/00-fluent/exhaust_system_tui_api.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/00-fluent/exhaust_system_settings_api.py b/examples/00-fluent/exhaust_system_settings_api.py index fadc1358a3dd..8ba25fe90fbb 100755 --- a/examples/00-fluent/exhaust_system_settings_api.py +++ b/examples/00-fluent/exhaust_system_settings_api.py @@ -1,5 +1,4 @@ -""" -.. _ref_exhaust_system_settings_api: +""".. _ref_exhaust_system_settings_api: Exhaust System: Fault-tolerant Meshing ---------------------------------------------- @@ -35,8 +34,6 @@ manifold where edge extraction will be considered. There is also a known small leakage included that will be addressed in the meshing portion of the tutorial to demonstrate the automatic leakage detection aspects of the meshing workflow. - - """ ############################################################################### diff --git a/examples/00-fluent/exhaust_system_tui_api.py b/examples/00-fluent/exhaust_system_tui_api.py index 42c506a00b3e..1af6ee416841 100644 --- a/examples/00-fluent/exhaust_system_tui_api.py +++ b/examples/00-fluent/exhaust_system_tui_api.py @@ -1,5 +1,4 @@ -""" -.. _ref_exhaust_system_tui_api: +""".. _ref_exhaust_system_tui_api: Exhaust System: Fault-tolerant Meshing ---------------------------------------------- @@ -35,8 +34,6 @@ manifold where edge extraction will be considered. There is also a known small leakage included that will be addressed in the meshing portion of the tutorial to demonstrate the automatic leakage detection aspects of the meshing workflow. - - """ ############################################################################### From 3606e6a4ba3b56d71e9e626fb18e1e5fcf8ffc32 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Fri, 8 Apr 2022 16:23:38 -0400 Subject: [PATCH 09/12] fix style check via black --- examples/00-fluent/exhaust_system_tui_api.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/00-fluent/exhaust_system_tui_api.py b/examples/00-fluent/exhaust_system_tui_api.py index 1af6ee416841..de420655e54b 100644 --- a/examples/00-fluent/exhaust_system_tui_api.py +++ b/examples/00-fluent/exhaust_system_tui_api.py @@ -68,16 +68,16 @@ session.PMFileManagement.FileManager.LoadFiles() session.part_management.Node["Meshing Model"].Copy( Paths=[ - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/main,1", - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/flow-pipe,1", - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/outpipe3,1", - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/object2,1", - "/dirty_manifold-for-wrapper," + - "1/dirty_manifold-for-wrapper,1/object1,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/main,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/flow-pipe,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/outpipe3,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/object2,1", + "/dirty_manifold-for-wrapper," + + "1/dirty_manifold-for-wrapper,1/object1,1", ] ) session.part_management.ObjectSetting[ From 5b973c727cf7b90dd2cfab01e90366e4f000d449 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Tue, 19 Apr 2022 14:47:51 -0400 Subject: [PATCH 10/12] change number of processors to 2 --- examples/00-fluent/exhaust_system_settings_api.py | 4 ++-- examples/00-fluent/exhaust_system_tui_api.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/00-fluent/exhaust_system_settings_api.py b/examples/00-fluent/exhaust_system_settings_api.py index 8ba25fe90fbb..8dad181d5fdc 100755 --- a/examples/00-fluent/exhaust_system_settings_api.py +++ b/examples/00-fluent/exhaust_system_settings_api.py @@ -50,7 +50,7 @@ # Start Fluent in double precision running on 4 processors session = pyfluent.launch_fluent( - meshing_mode=True, precision="double", processor_count=4 + meshing_mode=True, precision="double", processor_count=2 ) ############################################################################### @@ -672,4 +672,4 @@ # Save case, data and exit. # session.tui.solver.file.write_case_data("exhaust_system.cas.h5") -session.exit() +# session.exit() diff --git a/examples/00-fluent/exhaust_system_tui_api.py b/examples/00-fluent/exhaust_system_tui_api.py index de420655e54b..492fc69b766a 100644 --- a/examples/00-fluent/exhaust_system_tui_api.py +++ b/examples/00-fluent/exhaust_system_tui_api.py @@ -50,7 +50,7 @@ # Start Fluent in double precision running on 4 processors session = pyfluent.launch_fluent( - meshing_mode=True, precision="double", processor_count=4 + meshing_mode=True, precision="double", processor_count=2 ) ############################################################################### @@ -659,4 +659,4 @@ # Save case, data and exit. # session.tui.solver.file.write_case_data("exhaust_system.cas.h5") -session.exit() +# session.exit() From e98782de4fd37983f0e00d2536aaf2160fc6b817 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Wed, 20 Apr 2022 14:06:24 +0530 Subject: [PATCH 11/12] Fix CI --- doc/source/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/source/conf.py b/doc/source/conf.py index 94c90a985ec6..525f86c64ffb 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -114,6 +114,11 @@ def _start_or_stop_fluent_container(gallery_conf, fname, when): "mixing_elbow_tui_api.py", ]: args = ["3ddp", "-t4", "-meshing"] + elif fname in [ + "exhaust_system_settings_api.py", + "exhaust_system_tui_api.py", + ]: + args = ["3ddp", "-t2", "-meshing"] elif fname in [ "parametric_static_mixer_1.py", "parametric_static_mixer_2.py", From 9e0cb61043b8fa653d29e32fc8b41d869c739ed8 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Wed, 20 Apr 2022 15:41:14 +0530 Subject: [PATCH 12/12] Disable all display calls --- examples/00-fluent/exhaust_system_settings_api.py | 8 ++++---- examples/00-fluent/exhaust_system_tui_api.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/00-fluent/exhaust_system_settings_api.py b/examples/00-fluent/exhaust_system_settings_api.py index 8dad181d5fdc..419616aa7e20 100755 --- a/examples/00-fluent/exhaust_system_settings_api.py +++ b/examples/00-fluent/exhaust_system_settings_api.py @@ -606,7 +606,7 @@ "inlet-3", ] -root.results.graphics.pathlines["pathlines-1"].display() +# root.results.graphics.pathlines["pathlines-1"].display() ############################################################################### @@ -637,14 +637,14 @@ root.results.graphics.contour[ "contour-velocity" ].range_option.auto_range_on.global_range = False -root.results.graphics.contour["contour-velocity"].display() +# root.results.graphics.contour["contour-velocity"].display() root.results.graphics.mesh["mesh-1"] = {} surface_list = root.results.graphics.mesh["mesh-1"].surfaces_list.get_attr( "allowed-values" ) root.results.graphics.mesh["mesh-1"].surfaces_list = surface_list -root.results.graphics.mesh["mesh-1"].display() +# root.results.graphics.mesh["mesh-1"].display() ############################################################################### @@ -666,7 +666,7 @@ "quit", "quit", ) -session.tui.solver.display.objects.display("scene-1") +# session.tui.solver.display.objects.display("scene-1") ############################################################################### # Save case, data and exit. diff --git a/examples/00-fluent/exhaust_system_tui_api.py b/examples/00-fluent/exhaust_system_tui_api.py index 492fc69b766a..5efe5074dbfb 100644 --- a/examples/00-fluent/exhaust_system_tui_api.py +++ b/examples/00-fluent/exhaust_system_tui_api.py @@ -593,7 +593,7 @@ "()", "quit", ) -session.tui.solver.display.objects.display("pathlines-1") +# session.tui.solver.display.objects.display("pathlines-1") ############################################################################### # Create an iso-surface through the manifold geometry. @@ -629,7 +629,7 @@ "quit", "quit", ) -session.tui.solver.display.objects.display("contour-velocity") +# session.tui.solver.display.objects.display("contour-velocity") session.tui.solver.display.objects.create( "mesh", "mesh-1", "surfaces-list", "*", "()", "quit" @@ -653,7 +653,7 @@ "quit", "quit", ) -session.tui.solver.display.objects.display("scene-1") +# session.tui.solver.display.objects.display("scene-1") ############################################################################### # Save case, data and exit.