Watertight geometry meshing workflow#

This example sets up and solves a three-dimensional turbulent fluid flow and heat transfer problem in a mixing elbow, which is common in piping systems in power plants and process industries. Predicting the flow field and temperature field in the area of the mixing region is important to designing the junction properly.

This example uses the guided workflow for watertight geometry meshing because it is appropriate for geometries that can have no imperfections, such as gaps and leakages.

Workflow tasks

The watertight geometry meshing workflow guides you through these tasks:

  • Import a CAD geometry

  • Generate a surface mesh

  • Describe the geometry

  • Generate a volume mesh

Problem description

A cold fluid at 20 deg C flows into the pipe through a large inlet. It then mixes with a warmer fluid at 40 deg C that enters through a smaller inlet located at the elbow. The pipe dimensions are in inches, and the fluid properties and boundary conditions are given in SI units. Because the Reynolds number for the flow at the larger inlet is 50, 800, a turbulent flow model is required.

# sphinx_gallery_thumbnail_path = '_static/mixing_elbow.png'

Example Setup#

Before you can use the watertight geometry meshing workflow, you must set up the example and initialize this workflow.

Perform required imports#

Perform required imports, which includes downloading and importing the geometry file.

import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples

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

Launch Fluent#

Launch Fluent as a service in meshing mode with double precision running on two processors.

meshing = pyfluent.launch_fluent(precision="double", processor_count=2, mode="meshing")

Initialize workflow#

Initialize the watertight geometry meshing workflow.

meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry")
True

Watertight geometry meshing workflow#

The fault-tolerant meshing workflow guides you through the several tasks that follow.

Import CAD and set length units#

Import the CAD geometry and set the length units to inches.

meshing.workflow.TaskObject["Import Geometry"].Arguments = dict(
    FileName=import_filename, LengthUnit="in"
)

# Import geometry
# ~~~~~~~~~~~~~~~
# Import the geometry.

meshing.workflow.TaskObject["Import Geometry"].Execute()
Warning: PMDB file will not be saved as the same is being imported.

Importing one geom object per program-controlled and one zone per body ...
/ansys_inc/v222/aisol/.workbench: line 175: openssl: command not found
Initializing ANSYS component system ...
running Ansys.Meshing.FieldMesher.exe ...
creating FMComponent instance ...
querying IFieldMesher interface ...
AnsysFieldMesher build date: May 16 2022 16:17:51

argv[0] = /ansys_inc/v222/aisol/CommonFiles/linx64/ansys.meshing.fieldmesher.exe
argv[1] = -B
argv[2] = /ansys_inc/v222/commonfiles/CPython/3_7/linx64/Release/python/../Ansys/TGrid/CADReaders.py
argv[3] = -a
argv[4] = //FM_476e5f9cb8bc_283/options1684456276.425066283.xml
argv[5] = -a
argv[6] = //FM_476e5f9cb8bc_283/options1684456276.425066283.xml
    /ansys_inc/v222/aisol/CommonFiles/linx64/ansys.meshing.fieldmesher.exe started by root on 476e5f9cb8bc linx64 on Fri May 19 00:31:16 2023
    using Python 3.7.13 (default, Apr 28 2022, 08:00:21)
    [GCC 8.2.0]

    using Ansys.Meshing.FieldMesher build May 16 2022 16:12:49

    running ANSYS TGrid CADToTGridConverter ...
    setting up parameters ...
    setting up parameters done.
    running conversion ...
    converting 1 file(s) from Workbench to FLTG using output path '//FM_476e5f9cb8bc_283/out1684456276.425066283.tgf'
    converting file 'mixing_elbow.pmdb' (1 of 1) from Workbench to FLTG using output path '//FM_476e5f9cb8bc_283/'
    importing data ...
    importing meshing model from PartMgr from file '/home/ansys/.local/share/ansys_fluent_core/examples/mixing_elbow.pmdb' ...
    setting enclosure and symmetry processing to False
    setting transfer named selections to True
    setting named selection prefixes to ''
    setting mixed import resolution type to 'SolidAndSurface'
    setting target application to 'FluentMeshing'
    initializing part manager from file ...
    processing assembly 'E:\Fluent_testing\Regressions\elbow_tui_fltg\std\elbow.scdoc' with ID 1 and reference key '<?xml version="1.0" encoding="utf-16"?>
    <IdTable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Table>
        <Entry>
          <Text>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="81ad9b4c-8344-484a-b3a0-56e3834b262e:2" /&gt;</Text>
          <Id>10000</Id>
          <IsExploded>false</IsExploded>
        </Entry>
      </Table>
    </IdTable>'
    length unit = [m]
    processing part 'elbow' with ID 3
    processing named selection 'Symmetry:XYPlane'
    processing named selection 'hot-inlet'
    processing named selection 'cold-inlet'
    processing named selection 'outlet'
    processing named selection 'wall-inlet'
    processing named selection 'wall-elbow'
    processing data ...
    removing named collections of entities ...
    removing named collections of entities stopped, no named collections selected.
    analyzing feature edges ...
    detecting feature edges, feature angle = 40 [deg] ...
        Data information
            Meshing model
                Attributes:
                    'LengthUnit': '[in]'
                Entity summary:
                    Collection: 6
                    Component : 2
                    Body      : 1
                    Shell     : 1
                    Face      : 8
                    Loop      : 8
                    Edge      : 18
                    Vertex    : 12
                    Surface   : 8
                    Curve     : 18
                Tessellation summary:
                    Face facets  : 1250
                    Edge segments: 235
                Bounding box:
                    (-7.874015808105469, -8.858267784118652, 0) x (7.874015808105469, 7.874015808105469, 1.96705949306488)
                Assembly component hierarchy:
                    'E:\Fluent_testing\Regressions\elbow_tui_fltg\std\elbow.scdoc'
                      'elbow'
                NamedCollections:
                    'Symmetry:XYPlane'
                    'hot-inlet'
                    'cold-inlet'
                    'outlet'
                    'wall-inlet'
                    'wall-elbow'


    exporting FLTG data to file '//FM_476e5f9cb8bc_283/out1684456276.425066283.tgf' ...
    writing face-based mesh file '//FM_476e5f9cb8bc_283/out1684456276.425066283.tgf' ...
    ======== Exported Data ========
    Entity summary:
        Object       : 1
        Object region: 7
        Zone         : 15

    running conversion done.
    running ANSYS TGrid CADToTGridConverter done.
    ran ANSYS TGrid CADToTGridConverter in 0.067 [s]

Reading "//FM_476e5f9cb8bc_283/out1684456276.425066283.tgf"...

nodes: 776
edges: 153
faces: 1250
cells: 0
reading 776 storage data (id 1, type 41, double precision binary).
generating pointers...done.
extracting boundary entities...
 776 boundary nodes.
 1250 boundary faces.
 6 boundary face zones.
done.
analyzing boundary connectivity...done.

---------------- Import of mixing_elbow, consisting of one single part/object , complete.


True

Add local sizing#

Add local sizing. This task asks whether you want to add local sizing controls to the faceted geometry. You can keep the default settings and execute the task.

meshing.workflow.TaskObject["Add Local Sizing"].AddChildToTask()
meshing.workflow.TaskObject["Add Local Sizing"].Execute()
True

Generate surface mesh#

Generate the surface mash. In this task, you can set various properties of the surface mesh for the faceted geometry. For "MaxSize", set 0.3.

meshing.workflow.TaskObject["Generate the Surface Mesh"].Arguments = {
    "CFDSurfaceMeshControls": {"MaxSize": 0.3}
}
meshing.workflow.TaskObject["Generate the Surface Mesh"].Execute()
Writing "//FM_476e5f9cb8bc_283/TaskObject3.msh.h5" ...
writing 1 node zones
writing 9 edge zones
writing 6 face zones
done.(SizeFieldFile) not found in dict
(SizeControlFile) not found in dict
(SaveSizeFieldFile) not found in dict

Importing one mesh object per program-controlled and one zone per body ...
/ansys_inc/v222/aisol/.workbench: line 175: openssl: command not found
Initializing ANSYS component system ...
running Ansys.Meshing.FieldMesher.exe ...
creating FMComponent instance ...
querying IFieldMesher interface ...
AnsysFieldMesher build date: May 16 2022 16:17:51

argv[0] = /ansys_inc/v222/aisol/CommonFiles/linx64/ansys.meshing.fieldmesher.exe
argv[1] = -B
argv[2] = /ansys_inc/v222/commonfiles/CPython/3_7/linx64/Release/python/../Ansys/TGrid/CADReaders.py
argv[3] = -a
argv[4] = //FM_476e5f9cb8bc_283/options1684456279.512152283.xml
argv[5] = -a
argv[6] = //FM_476e5f9cb8bc_283/options1684456279.512152283.xml
    /ansys_inc/v222/aisol/CommonFiles/linx64/ansys.meshing.fieldmesher.exe started by root on 476e5f9cb8bc linx64 on Fri May 19 00:31:19 2023
    using Python 3.7.13 (default, Apr 28 2022, 08:00:21)
    [GCC 8.2.0]

    using Ansys.Meshing.FieldMesher build May 16 2022 16:12:49

    running ANSYS TGrid CADToTGridConverter ...
    setting up parameters ...
    setting up parameters done.
    running conversion ...
    converting 1 file(s) from Workbench to FLTG using output path '//FM_476e5f9cb8bc_283/out1684456279.512152283.tgf'
    converting file 'mixing_elbow.pmdb' (1 of 1) from Workbench to FLTG using output path '//FM_476e5f9cb8bc_283/'
    importing data ...
    importing meshing model from PartMgr from file '//FM_476e5f9cb8bc_283//mixing_elbow.pmdb' ...
    setting enclosure and symmetry processing to False
    setting transfer named selections to True
    setting named selection prefixes to ''
    setting mixed import resolution type to 'SolidAndSurface'
    setting target application to 'FluentMeshing'
    initializing part manager from file ...
    processing assembly 'E:\Fluent_testing\Regressions\elbow_tui_fltg\std\elbow.scdoc' with ID 1 and reference key '<?xml version="1.0" encoding="utf-16"?>
    <IdTable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Table>
        <Entry>
          <Text>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="81ad9b4c-8344-484a-b3a0-56e3834b262e:2" /&gt;</Text>
          <Id>10000</Id>
          <IsExploded>false</IsExploded>
        </Entry>
      </Table>
    </IdTable>'
    length unit = [m]
    processing part 'elbow' with ID 3
    processing named selection 'Symmetry:XYPlane'
    processing named selection 'hot-inlet'
    processing named selection 'cold-inlet'
    processing named selection 'outlet'
    processing named selection 'wall-inlet'
    processing named selection 'wall-elbow'
    processing data ...
    saving size function background grid to file '//FM_476e5f9cb8bc_283/mixing_elbow.sf' ...
    writing size function background grid file '//FM_476e5f9cb8bc_283/mixing_elbow.sf' ...
    initializing size function background grid done in 0.04 [s]
    removing named collections of entities ...
    removing named collections of entities stopped, no named collections selected.
    analyzing feature edges ...
    detecting feature edges, feature angle = 40 [deg] ...
        Data information
            Meshing model
                Attributes:
                    'LengthUnit': '[in]'
                Entity summary:
                    Collection: 6
                    Component : 2
                    Body      : 1
                    Shell     : 1
                    Face      : 8
                    Loop      : 8
                    Edge      : 18
                    Vertex    : 12
                    Surface   : 8
                    Curve     : 18
                Tessellation summary:
                    Face facets  : 7862
                    Edge segments: 342
                Bounding box:
                    (-7.874015808105469, -8.858267784118652, 0) x (7.874015808105469, 7.874015808105469, 1.968503832817078)
                Assembly component hierarchy:
                    'E:\Fluent_testing\Regressions\elbow_tui_fltg\std\elbow.scdoc'
                      'elbow'
                NamedCollections:
                    'Symmetry:XYPlane'
                    'hot-inlet'
                    'cold-inlet'
                    'outlet'
                    'wall-inlet'
                    'wall-elbow'


    exporting FLTG data to file '//FM_476e5f9cb8bc_283/out1684456279.512152283.tgf' ...
    writing face-based mesh file '//FM_476e5f9cb8bc_283/out1684456279.512152283.tgf' ...
    ======== Exported Data ========
    Entity summary:
        Object       : 1
        Object region: 7
        Zone         : 15

    running conversion done.
    running ANSYS TGrid CADToTGridConverter done.
    ran ANSYS TGrid CADToTGridConverter in 0.242 [s]

Reading "//FM_476e5f9cb8bc_283/out1684456279.512152283.tgf"...

nodes: 4229
edges: 300
faces: 7862
cells: 0
reading 4229 storage data (id 1, type 41, double precision binary).
appending mesh...
done.
generating pointers...done.
extracting boundary entities...
 5005 boundary nodes.
 9112 boundary faces.
 12 boundary face zones.
done.

Reading "//FM_476e5f9cb8bc_283/mixing_elbow.sf"...

ANSYS(R) TGLib(TM) 3D, revision 18.1.0
 Read 5406 vertices
0 faces marked.

    computing regions...done


------------------------- --------------------- -------------------- ---------------- ----------
                     name skewed-cells (> 0.80)    averaged-skewness maximum-skewness face count
------------------------- --------------------- -------------------- ---------------- ----------
              elbow-fluid                     0          0.017166519       0.41817382       7862

------------------------- --------------------- -------------------- ---------------- ----------
                     name skewed-cells (> 0.80)    averaged-skewness maximum-skewness face count
------------------------- --------------------- -------------------- ---------------- ----------
              elbow-fluid                     0          0.017166519       0.41817382       7862


---------------- After Surface mesh, the model consists of 1 fluid/solid regions and 0 voids.

---------------- Surface Meshing of mixing_elbow complete in  0.02 minutes, with a maximum skewness of  0.42.


True

Describe geometry#

Describe the geometry. In this task, you are prompted with questions relating to the nature of the imported geometry, which defines the fluid region. The geometry consists of only fluid regions.

meshing.workflow.TaskObject["Describe Geometry"].UpdateChildTasks(
    SetupTypeChanged=False
)
meshing.workflow.TaskObject["Describe Geometry"].Arguments = dict(
    SetupType="The geometry consists of only fluid regions with no voids"
)
meshing.workflow.TaskObject["Describe Geometry"].UpdateChildTasks(SetupTypeChanged=True)
meshing.workflow.TaskObject["Describe Geometry"].Execute()
---------------- Velocity-inlet zone type was automatically assigned to zones containing the string 'inlet'.

---------------- Pressure-outlet zone type was automatically assigned to zones containing the string 'outlet'.

---------------- Symmetry zone type was automatically assigned to zones containing the string 'symmetry'.

True

Update boundaries#

Update the boundaries. Set "BoundaryLabelTypeList" to "wall" and update the boundaries.

meshing.workflow.TaskObject["Update Boundaries"].Arguments = {
    "BoundaryLabelList": ["wall-inlet"],
    "BoundaryLabelTypeList": ["wall"],
    "OldBoundaryLabelList": ["wall-inlet"],
    "OldBoundaryLabelTypeList": ["velocity-inlet"],
}
meshing.workflow.TaskObject["Update Boundaries"].Execute()
---------------- Boundary Conditions Updated

True

Update regions#

Update the regions. In this task, you can review the names and types of the various regions that have been generated from your imported geometry and change them as needed. You can keep the default settings.

meshing.workflow.TaskObject["Update Regions"].Execute()
---------------- Regions Updated

True

Add boundary layers#

Add boundary layers, which consist of setting properties for the boundary layer mesh. You can keep the default settings.

meshing.workflow.TaskObject["Add Boundary Layers"].AddChildToTask()
meshing.workflow.TaskObject["Add Boundary Layers"].InsertCompoundChildTask()
meshing.workflow.TaskObject["smooth-transition_1"].Arguments = {
    "BLControlName": "smooth-transition_1",
}
meshing.workflow.TaskObject["Add Boundary Layers"].Arguments = {}
meshing.workflow.TaskObject["smooth-transition_1"].Execute()
Created Scoped Prism: smooth-transition_1

---------------- Inflation control added to elbow-fluid

True

Generate volume mesh#

Generate the volume mesh, which consists of setting properties for the volume mesh. Set "VolumeFill" to "poly-hexcore".

meshing.workflow.TaskObject["Generate the Volume Mesh"].Arguments = {
    "VolumeFill": "poly-hexcore",
    "VolumeFillControls": {
        "HexMaxCellLength": 0.3,
    },
}
meshing.workflow.TaskObject["Generate the Volume Mesh"].Execute()
Writing "//FM_476e5f9cb8bc_283/TaskObject11.msh.h5" ...
writing 2 node zones
writing 18 edge zones
writing 12 face zones
done.
checking object "elbow-fluid"...
    skipping validating regions of mesh object "elbow-fluid"...done.
auto meshing object elbow-fluid...

processing scoped prisms...
    starting orientation...done.
    setting prism growth...done.
done.
Identifying Topology...

The octree hexcore cells will be refined using local surface mesh sizes and body of influence (boi) size controls, if there are any defined.
Generating Prisms...

Generating initial mesh...
.


Refining mesh...

Create polyhedra ...
.

.

.

.

.


delete virtual and dead zones.

Merging zones...

Cleaning up dead entities...


Merging Domains...
done.

Quality Measure has been changed to Orthogonal Quality.
                     name       id cells (quality < 0.10)  minimum quality cell count
------------------------- -------- ---------------------- ---------------- ----------
              elbow-fluid       87                      0       0.21482405      17587

                     name       id cells (quality < 0.10)  minimum quality cell count
------------------------- -------- ---------------------- ---------------- ----------
          Overall Summary     none                      0       0.21482405      17587

Total Number of Cell Zones : 1

[Quality Measure : Orthogonal Quality]

---------------- 17587 cells were created in :  0.07 minutes

---------------- The mesh has a minimum Orthogonal Quality of:  0.21

---------------- The volume meshing of elbow-fluid is complete.


True
../../_images/mixing_elbow_011.png

Check mesh in meshing mode#

Check the mesh in meshing mode

meshing.tui.mesh.check_mesh()
Domain extents.
  x-coordinate: min = -7.874016e+00, max = 7.874016e+00.
  y-coordinate: min = -8.858268e+00, max = 7.874016e+00.
  z-coordinate: min = 0.000000e+00, max = 1.968504e+00.
Volume statistics.
  minimum volume: 1.488576e-05.
  maximum volume: 3.187147e-02.
    total volume: 1.526006e+02.
Face area statistics.
   minimum face area: 5.236740e-05.
   maximum face area: 1.176346e-01.
   average face area: 2.526642e-02.
Checking number of nodes per edge.
Checking number of nodes per face.
Checking number of nodes per cell.
Checking number of faces/neighbors per cell.
Checking cell faces/neighbors.
Checking isolated cells.
Checking face handedness.
Checking periodic face pairs.
Checking face children.
Checking face zone boundary conditions.
Checking for invalid node coordinates.
Checking poly cells.
Checking zones.
Checking neighborhood.
Checking modified centroid.
Checking non-positive or too small area.

Save mesh file#

Save the mesh file (mixing_elbow.msh.h5).

meshing.tui.file.write_mesh("mixing_elbow.msh.h5")
Done.Writing "mixing_elbow.msh.h5" ...
writing 3 node zones
writing 9 edge zones
writing 7 face zones
writing 1 cell zones
done.Copying the required intermediate mesh files into mixing_elbow_workflow_files
Done.

Solve and postprocess#

Once you have completed the watertight geometry meshing workflow, you can solve and postprcess the results.

Switch to solution mode#

Switch to solution mode. Now that a high-quality mesh has been generated using Fluent in meshing mode, you can switch to solver mode to complete the setup of the simulation. Because you have just checked the mesh, set "yes" to switch to the solution mode.

solver = meshing.switch_to_solver()
*********************************************
Info: Your license enables 4-way parallel execution.
For faster simulations, please start the application with the appropriate parallel options.
*********************************************


*********************************************
Info: Your license enables 4-way parallel execution.
For faster simulations, please start the application with the appropriate parallel options.
*********************************************


Preparing...

unused zone boundary-node-19 removed

*********************************************
Info: Your license enables 4-way parallel execution.
For faster simulations, please start the application with the appropriate parallel options.
*********************************************


*********************************************
Info: Your license enables 4-way parallel execution.
For faster simulations, please start the application with the appropriate parallel options.
*********************************************


Transferring mesh
        creating threads... done
        transferring nodes... done
        transferring cells... done
        transferring faces... done
        post mesh transfer operations... done
done

Building...
     mesh
        auto partitioning mesh by Metis (fast),
        distributing mesh
                parts..,
                faces..,
                nodes..,
                cells..,
        bandwidth reduction using Reverse Cuthill-McKee: 8353/259 = 32.251
     materials,
     interface,
     domains,
     zones,
        interior--elbow-fluid
        symmetry-xyplane
        hot-inlet
        cold-inlet
        outlet
        wall-inlet
        wall-elbow
        elbow-fluid
     surfaces,
     parallel,
Done.
Mesh is now scaled to meters.

Check mesh in solver mode#

Check the mesh in solver mode. The mesh check lists the minimum and maximum x, y, and z values from the mesh in the default SI units of meters. It also reports a number of other mesh features that are checked. Any errors in the mesh are reported. Ensure that the minimum volume is not negative because Fluent cannot begin a calculation when this is the case.

solver.tui.mesh.check()
 Domain Extents:
   x-coordinate: min (m) = -2.000000e-01, max (m) = 2.000000e-01
   y-coordinate: min (m) = -2.250000e-01, max (m) = 2.000000e-01
   z-coordinate: min (m) = 0.000000e+00, max (m) = 4.994352e-02
 Volume statistics:
   minimum volume (m3): 2.439339e-10
   maximum volume (m3): 5.222798e-07
     total volume (m3): 2.500675e-03
 Face area statistics:
   minimum face area (m2): 3.378535e-08
   maximum face area (m2): 7.589314e-05
 Checking mesh.....................................
Done.

Set working units for mesh#

Set the working units for the mesh to inches. Because the default SI units are used for everything except length, you do not have to change any other units in this example. If you want working units for length to be other than inches (for example, millimeters), make the appropriate change.

solver.tui.define.units("length", "in")

Enable heat transfer#

Enable heat transfer by activating the energy equation.

solver.tui.define.models.energy("yes", ", ", ", ", ", ", ", ")

Create material#

Create a material named "water-liquid".

solver.tui.define.materials.copy("fluid", "water-liquid")

Set up cell zone conditions#

Set up the cell zone conditions for the fluid zone (elbow-fluid)``. Set the material to "water-liquid".

solver.tui.define.boundary_conditions.fluid(
    "elbow-fluid",
    "yes",
    "water-liquid",
    "no",
    "no",
    "no",
    "no",
    "0",
    "no",
    "0",
    "no",
    "0",
    "no",
    "0",
    "no",
    "0",
    "no",
    "1",
    "no",
    "no",
    "no",
    "no",
    "no",
)
water-liquid copied from database.

(elbow-fluid)

Set up boundary conditions for CFD analysis#

Set up the boundary conditions for the inlets, outlet, and walls for CFD analysis.

# cold inlet (cold-inlet), Setting: Value:
# Velocity Specification Method: Magnitude, Normal to Boundary

solver.tui.define.boundary_conditions.set.velocity_inlet(
    "cold-inlet", [], "vmag", "no", 0.4, "quit"
)
solver.tui.define.boundary_conditions.set.velocity_inlet(
    "cold-inlet", [], "ke-spec", "no", "no", "no", "yes", "quit"
)
solver.tui.define.boundary_conditions.set.velocity_inlet(
    "cold-inlet", [], "turb-intensity", 5, "quit"
)
solver.tui.define.boundary_conditions.set.velocity_inlet(
    "cold-inlet", [], "turb-hydraulic-diam", 4, "quit"
)
solver.tui.define.boundary_conditions.set.velocity_inlet(
    "cold-inlet", [], "temperature", "no", 293.15, "quit"
)

# hot inlet (hot-inlet), Setting: Value:
# Velocity Specification Method: Magnitude, Normal to Boundary

solver.tui.define.boundary_conditions.set.velocity_inlet(
    "hot-inlet", [], "vmag", "no", 1.2, "quit"
)
solver.tui.define.boundary_conditions.set.velocity_inlet(
    "hot-inlet", [], "ke-spec", "no", "no", "no", "yes", "quit"
)
solver.tui.define.boundary_conditions.set.velocity_inlet(
    "hot-inlet", [], "turb-intensity", 5, "quit"
)
solver.tui.define.boundary_conditions.set.velocity_inlet(
    "hot-inlet", [], "turb-hydraulic-diam", 1, "quit"
)
solver.tui.define.boundary_conditions.set.velocity_inlet(
    "hot-inlet", [], "temperature", "no", 313.15, "quit"
)

# pressure outlet (outlet), Setting: Value:
# Backflow Turbulent Intensity: 5 [%]
# Backflow Turbulent Viscosity Ratio: 4

solver.tui.define.boundary_conditions.set.pressure_outlet(
    "outlet", [], "turb-intensity", 5, "quit"
)
solver.tui.define.boundary_conditions.set.pressure_outlet(
    "outlet", [], "turb-viscosity-ratio", 4, "quit"
)

Enable plotting of residuals during calculation#

Enable plotting of residuals during the calculation.

solver.tui.solve.monitors.residual.plot("yes")

Create surface report definition#

Create a surface report definition of the average temperature at the outlet named "outlet-temp-avg".

solver.tui.solve.report_definitions.add(
    "outlet-temp-avg",
    "surface-massavg",
    "field",
    "temperature",
    "surface-names",
    "outlet",
    "()",
    "quit",
)

Create convergence condition#

Create a convergence condition for outlet-temp-avg.

# - Set ``"add"`` to ``"con-outlet-temp-avg"``.
# - Set ``"report-defs"`` to ``"outlet-temp-avg"``.
# - Set ``"stop-criterion"`` to ``"1e-04"``.
# - Set ``"initial-values-to-ignore"`` to ``"20"``.
# - Set ``"previous-values-to-consider"`` to ``"15"``.
# - Set ``"print?"``to ``"yes"``.
# - Set ``"frequency"`` to ``"3"``.
#
# These settings cause Fluent to consider the solution converged when the
# surface report definition value for each of the previous 15 iterations is
# within 0.001% of the current value. Convergence of the values is checked
# every 3 iterations. The first 20 iterations are ignored, allowing for any
# initial solution dynamics to settle out. Note that the value printed to the
# console is the deviation between the current and previous iteration values
# only.

solver.tui.solve.convergence_conditions(
    "conv-reports",
    "add",
    "con-outlet-temp-avg",
    "initial-values-to-ignore",
    "20",
    "previous-values-to-consider",
    "15",
    "print?",
    "yes",
    "report-defs",
    "outlet-temp-avg",
    "stop-criterion",
    "1e-04",
    "quit",
    "quit",
    "condition",
    "1",
    "frequency",
    "3",
    "quit",
)
solver.tui.solve.convergence_conditions("frequency", "3", "quit")

Initialize flow field#

Initialize the flow field using hybrid initialization.

solver.tui.solve.initialize.hyb_initialization()
Initialize using the hybrid initialization method.

Checking case topology...
-This case has both inlets & outlets
-Pressure information is not available at the boundaries.
 Case will be initialized with constant pressure

        iter            scalar-0

        1               1.000000e+00
        2               1.716570e-04
        3               1.059169e-05
        4               1.047261e-05
        5               1.611337e-06
        6               2.010140e-06
        7               3.284479e-07
        8               3.436913e-07
        9               8.342513e-08
        10              8.490056e-08

Hybrid initialization is done.

Save case file#

Solve the case file (mixing_elbow1.cas.h5).

solver.tui.file.write_case("mixing_elbow1.cas.h5")
Fast-loading "/ansys_inc/v222/fluent/fluent22.2.0/addons/afd/lib/hdfio.bin"
Done.

Writing to 476e5f9cb8bc:"/home/ansys/.local/share/ansys_fluent_core/examples/mixing_elbow1.cas.h5" in NODE0 mode and compression level 1 ...
       17587 cells,     1 zone  ...
       90052 faces,     7 zones ...
       60464 nodes,     1 zone  ...
  Done.

  Writing boundary layer flags ...
  Done.
Done.

Solve for 100 iterations#

Solve for 100 iterations.

solver.tui.solve.iterate(100)
  iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega  con-outlet     time/iter
     1  1.0000e+00  4.1470e-03  4.5545e-03  1.1661e-03  8.6394e-05  9.8105e-02  7.0378e-01              0:00:24   99
     2  7.9785e-01  2.5262e-03  3.0895e-03  7.1480e-04  1.0068e-04  5.5536e-02  1.0043e-01              0:00:24   98
     3  7.7102e-01  1.6053e-03  2.3050e-03  6.1009e-04  1.0854e-04  2.0405e-02  6.3149e-02              0:00:23   97
     4  7.3700e-01  1.0760e-03  1.9854e-03  4.9770e-04  1.1757e-04  1.7448e-02  3.9574e-02              0:00:23   96
     5  7.0548e-01  9.1298e-04  1.8361e-03  4.3085e-04  1.2377e-04  1.6190e-02  2.6952e-02              0:00:22   95
     6  6.5137e-01  8.6698e-04  1.7282e-03  3.9345e-04  1.2609e-04  1.5922e-02  2.0486e-02              0:00:22   94
     7  5.9167e-01  8.1493e-04  1.6544e-03  3.6327e-04  1.2587e-04  1.6229e-02  1.6964e-02              0:00:21   93
     8  5.3568e-01  7.5833e-04  1.5901e-03  3.3629e-04  1.2317e-04  1.6953e-02  1.4370e-02              0:00:21   92
     9  4.8595e-01  7.1103e-04  1.5305e-03  3.1543e-04  1.1733e-04  1.7753e-02  1.2409e-02              0:00:21   91
    10  4.4931e-01  6.8112e-04  1.4554e-03  2.9763e-04  1.1027e-04  1.8227e-02  1.0684e-02              0:00:20   90
    11  4.1515e-01  6.5024e-04  1.3748e-03  2.8249e-04  1.0100e-04  1.8260e-02  9.3340e-03              0:00:20   89

  iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega  con-outlet     time/iter
    12  3.8503e-01  6.1808e-04  1.2941e-03  2.6924e-04  9.0101e-05  1.7824e-02  8.2655e-03              0:00:20   88
    13  3.5782e-01  5.8607e-04  1.2065e-03  2.5687e-04  7.7896e-05  1.6927e-02  7.3530e-03              0:00:20   87
    14  3.3230e-01  5.5518e-04  1.1079e-03  2.4495e-04  6.6250e-05  1.5690e-02  6.5561e-03              0:00:19   86
    15  3.0776e-01  5.2527e-04  1.0111e-03  2.3314e-04  5.6117e-05  1.4228e-02  5.8368e-03              0:00:19   85
    16  2.9199e-01  4.9794e-04  9.1858e-04  2.2228e-04  4.8693e-05  1.2697e-02  5.1847e-03              0:00:19   84
    17  2.7801e-01  4.6927e-04  8.2982e-04  2.1216e-04  4.3647e-05  1.1149e-02  4.5979e-03              0:00:19   83
    18  2.6501e-01  4.4113e-04  7.5322e-04  2.0319e-04  4.0291e-05  9.6798e-03  4.0642e-03              0:00:18   82
    19  2.5012e-01  4.1392e-04  6.8458e-04  1.9504e-04  3.7650e-05  8.3495e-03  3.5962e-03              0:00:18   81
    20  2.3810e-01  3.8468e-04  6.2619e-04  1.8733e-04  3.4623e-05  7.1365e-03  3.2223e-03              0:00:18   80
    21  2.2659e-01  3.5759e-04  5.7848e-04  1.8030e-04  3.1196e-05  6.0782e-03  2.9128e-03              0:00:18   79
    22  2.1449e-01  3.3308e-04  5.4095e-04  1.7379e-04  2.7632e-05  5.1665e-03  2.6422e-03              0:00:18   78

  iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega  con-outlet     time/iter
    23  2.0376e-01  3.0865e-04  5.1094e-04  1.6720e-04  2.4144e-05  4.3851e-03  2.4087e-03              0:00:18   77
    24  1.9287e-01  2.8641e-04  4.8680e-04  1.6061e-04  2.1015e-05  3.7538e-03  2.2037e-03              0:00:18   76
    25  1.8271e-01  2.6574e-04  4.6546e-04  1.5369e-04  1.8256e-05  3.2772e-03  2.0288e-03              0:00:18   75
    26  1.7364e-01  2.4665e-04  4.4524e-04  1.4616e-04  1.5743e-05  2.8917e-03  1.8606e-03              0:00:17   74
    27  1.6352e-01  2.2879e-04  4.2468e-04  1.3820e-04  1.3502e-05  2.5618e-03  1.7055e-03              0:00:17   73
    28  1.5316e-01  2.1214e-04  4.0280e-04  1.3019e-04  1.1640e-05  2.2822e-03  1.5682e-03              0:00:17   72
    29  1.4402e-01  1.9657e-04  3.8033e-04  1.2226e-04  1.0099e-05  2.0534e-03  1.4431e-03              0:00:17   71
    30  1.3468e-01  1.8138e-04  3.5713e-04  1.1411e-04  8.7864e-06  1.8656e-03  1.3285e-03              0:00:17   70
    31  1.2556e-01  1.6720e-04  3.3424e-04  1.0609e-04  7.6582e-06  1.7110e-03  1.2294e-03              0:00:17   69
    32  1.1699e-01  1.5384e-04  3.1204e-04  9.8048e-05  6.6871e-06  1.5778e-03  1.1447e-03              0:00:16   68
    33  1.0926e-01  1.4117e-04  2.9048e-04  9.0253e-05  5.8590e-06  1.4581e-03  1.0623e-03              0:00:16   67

  iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega  con-outlet     time/iter
    34  1.0098e-01  1.2915e-04  2.6947e-04  8.2792e-05  5.1493e-06  1.3494e-03  9.8347e-04              0:00:16   66
    35  9.3269e-02  1.1796e-04  2.4979e-04  7.5811e-05  4.5459e-06  1.2551e-03  9.1422e-04              0:00:15   65
    36  8.6323e-02  1.0758e-04  2.3132e-04  6.9296e-05  4.0294e-06  1.1686e-03  8.5118e-04  2.5290e-03  0:00:15   64
    37  8.0056e-02  9.8101e-05  2.1373e-04  6.3323e-05  3.5887e-06  1.0907e-03  7.9183e-04              0:00:15   63
    38  7.4316e-02  8.9288e-05  1.9726e-04  5.7857e-05  3.2095e-06  1.0186e-03  7.3543e-04              0:00:15   62
    39  6.9045e-02  8.1388e-05  1.8221e-04  5.2866e-05  2.8812e-06  9.5305e-04  6.8295e-04  1.6008e-03  0:00:14   61
    40  6.3967e-02  7.4162e-05  1.6830e-04  4.8297e-05  2.5967e-06  8.9289e-04  6.3351e-04              0:00:14   60
    41  5.9395e-02  6.7543e-05  1.5534e-04  4.4132e-05  2.3498e-06  8.3546e-04  5.8692e-04              0:00:14   59
    42  5.5220e-02  6.1470e-05  1.4303e-04  4.0334e-05  2.1320e-06  7.8192e-04  5.4370e-04  1.0092e-03  0:00:14   58
    43  5.1242e-02  5.5992e-05  1.3171e-04  3.6891e-05  1.9421e-06  7.3270e-04  5.0304e-04              0:00:13   57
    44  4.7548e-02  5.1011e-05  1.2120e-04  3.3778e-05  1.7740e-06  6.8385e-04  4.6446e-04              0:00:13   56

  iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega  con-outlet     time/iter
    45  4.4025e-02  4.6514e-05  1.1168e-04  3.0930e-05  1.6252e-06  6.3795e-04  4.2852e-04  6.4710e-04  0:00:13   55
    46  4.0752e-02  4.2502e-05  1.0311e-04  2.8349e-05  1.4926e-06  5.9552e-04  3.9490e-04              0:00:13   54
    47  3.7827e-02  3.8782e-05  9.5048e-05  2.6007e-05  1.3731e-06  5.5461e-04  3.6388e-04              0:00:12   53
    48  3.5104e-02  3.5412e-05  8.7650e-05  2.3884e-05  1.2632e-06  5.1560e-04  3.3598e-04  4.0860e-04  0:00:12   52
    49  3.2629e-02  3.2428e-05  8.0894e-05  2.1945e-05  1.1624e-06  4.7850e-04  3.1025e-04              0:00:12   51
    50  3.0283e-02  2.9689e-05  7.4548e-05  2.0167e-05  1.0698e-06  4.4346e-04  2.8603e-04              0:00:12   50
    51  2.8060e-02  2.7163e-05  6.8656e-05  1.8533e-05  9.8469e-07  4.0963e-04  2.6351e-04  2.5124e-04  0:00:12   49
    52  2.5907e-02  2.4851e-05  6.3140e-05  1.7027e-05  9.0636e-07  3.7740e-04  2.4196e-04              0:00:11   48
    53  2.3949e-02  2.2735e-05  5.7973e-05  1.5645e-05  8.3349e-07  3.4705e-04  2.2134e-04              0:00:11   47
    54  2.2202e-02  2.0789e-05  5.3135e-05  1.4368e-05  7.6535e-07  3.1806e-04  2.0235e-04  1.5158e-04  0:00:11   46
    55  2.0619e-02  1.9015e-05  4.8569e-05  1.3203e-05  7.0215e-07  2.9078e-04  1.8474e-04              0:00:11   45

  iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega  con-outlet     time/iter
    56  1.8980e-02  1.7374e-05  4.4419e-05  1.2139e-05  6.4353e-07  2.6539e-04  1.6845e-04              0:00:10   44
Solution for report definition outlet-temp-avg has converged
    57  1.7428e-02  1.5879e-05  4.0646e-05  1.1155e-05  5.8864e-07  2.4203e-04  1.5347e-04  8.9598e-05  0:00:10   43
    58  1.5949e-02  1.4510e-05  3.7143e-05  1.0254e-05  5.3859e-07  2.2037e-04  1.3967e-04              0:00:10   42
    59  1.4607e-02  1.3257e-05  3.3935e-05  9.4203e-06  4.9187e-07  2.0041e-04  1.2699e-04              0:00:10   41
Solution for report definition outlet-temp-avg has converged
    60  1.3382e-02  1.2112e-05  3.0981e-05  8.6528e-06  4.4842e-07  1.8255e-04  1.1540e-04  5.1353e-05  0:00:09   40
    61  1.2237e-02  1.1060e-05  2.8243e-05  7.9468e-06  4.0791e-07  1.6635e-04  1.0486e-04              0:00:09   39
    62  1.1185e-02  1.0097e-05  2.5711e-05  7.2979e-06  3.7018e-07  1.5138e-04  9.5192e-05              0:00:09   38
Solution for report definition outlet-temp-avg has converged
    63  1.0241e-02  9.2120e-06  2.3386e-05  6.6955e-06  3.3500e-07  1.3761e-04  8.6369e-05  2.8204e-05  0:00:09   37
    64  9.3696e-03  8.4018e-06  2.1250e-05  6.1426e-06  3.0309e-07  1.2514e-04  7.8312e-05              0:00:08   36
    65  8.5800e-03  7.6564e-06  1.9292e-05  5.6327e-06  2.7383e-07  1.1378e-04  7.0979e-05              0:00:08   35
Solution for report definition outlet-temp-avg has converged
    66  7.8589e-03  6.9721e-06  1.7498e-05  5.1611e-06  2.4688e-07  1.0341e-04  6.4279e-05  1.4202e-05  0:00:08   34

  iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega  con-outlet     time/iter
    67  7.2039e-03  6.3449e-06  1.5862e-05  4.7260e-06  2.2222e-07  9.3820e-05  5.8162e-05              0:00:08   33
    68  6.5966e-03  5.7708e-06  1.4373e-05  4.3246e-06  1.9968e-07  8.4948e-05  5.2557e-05              0:00:08   32
Solution for report definition outlet-temp-avg has converged
    69  6.0315e-03  5.2470e-06  1.3018e-05  3.9527e-06  1.7916e-07  7.6957e-05  4.7393e-05  6.2368e-06  0:00:07   31
    70  5.5048e-03  4.7669e-06  1.1781e-05  3.6107e-06  1.6047e-07  6.9665e-05  4.2698e-05              0:00:09   30
    71  5.0166e-03  4.3273e-06  1.0657e-05  3.2949e-06  1.4352e-07  6.2979e-05  3.8410e-05              0:00:09   29
Solution for report definition outlet-temp-avg has converged
    72  4.5659e-03  3.9248e-06  9.6320e-06  3.0036e-06  1.2815e-07  5.6853e-05  3.4517e-05  2.0441e-06  0:00:08   28
    73  4.1537e-03  3.5580e-06  8.6963e-06  2.7344e-06  1.1420e-07  5.1253e-05  3.0987e-05              0:00:07   27
    74  3.7752e-03  3.2230e-06  7.8443e-06  2.4862e-06  1.0159e-07  4.6128e-05  2.7786e-05              0:00:07   26
Solution for report definition outlet-temp-avg has converged
    75  3.4267e-03  2.9177e-06  7.0681e-06  2.2577e-06  9.0232e-08  4.1482e-05  2.4891e-05  6.2796e-07  0:00:06   25
    76  3.1077e-03  2.6393e-06  6.3612e-06  2.0476e-06  8.0010e-08  3.7267e-05  2.2273e-05              0:00:06   24
    77  2.8158e-03  2.3856e-06  5.7184e-06  1.8546e-06  7.0842e-08  3.3443e-05  1.9917e-05              0:00:06   23

  iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega  con-outlet     time/iter
Solution for report definition outlet-temp-avg has converged
    78  2.5502e-03  2.1550e-06  5.1358e-06  1.6778e-06  6.2632e-08  2.9985e-05  1.7797e-05  8.5091e-07  0:00:05   22
    79  2.3059e-03  1.9456e-06  4.6076e-06  1.5159e-06  5.5282e-08  2.6852e-05  1.5891e-05              0:00:05   21
    80  2.0830e-03  1.7556e-06  4.1298e-06  1.3678e-06  4.8716e-08  2.4016e-05  1.4179e-05              0:00:05   20
Solution for report definition outlet-temp-avg has converged
    81  1.8794e-03  1.5831e-06  3.6979e-06  1.2327e-06  4.2853e-08  2.1455e-05  1.2640e-05  1.0341e-06  0:00:05   19
    82  1.6938e-03  1.4266e-06  3.3077e-06  1.1095e-06  3.7631e-08  1.9144e-05  1.1258e-05              0:00:04   18
    83  1.5249e-03  1.2849e-06  2.9554e-06  9.9733e-07  3.2986e-08  1.7064e-05  1.0017e-05              0:00:04   17
Solution for report definition outlet-temp-avg has converged
    84  1.3704e-03  1.1567e-06  2.6397e-06  8.9537e-07  2.8861e-08  1.5191e-05  8.9064e-06  1.0513e-06  0:00:04   16
    85  1.2286e-03  1.0406e-06  2.3575e-06  8.0302e-07  2.5207e-08  1.3508e-05  7.9126e-06              0:00:04   15
    86  1.1008e-03  9.3571e-07  2.1053e-06  7.1935e-07  2.1980e-08  1.1999e-05  7.0252e-06              0:00:04   14
Solution for report definition outlet-temp-avg has converged
!   87 report definition solution is converged
    87  9.8574e-04  8.4097e-07  1.8789e-06  6.4364e-07  1.9132e-08  1.0643e-05  6.2351e-06  9.6929e-07  0:00:03   13
../../_images/mixing_elbow_012.png ../../_images/mixing_elbow_013.png

Save data file#

Save the data file (mixing_elbow1.dat.h5).

solver.tui.file.write_data("mixing_elbow1.dat.h5")
!   87 solution is converged

Writing to 476e5f9cb8bc:"/home/ansys/.local/share/ansys_fluent_core/examples/mixing_elbow1.dat.h5" in NODE0 mode and compression level 1 ...
  Writing results.
Done.

Create definition for velocity magnitude contours#

Create and display a definition for the velocity magnitude contours on the symmetry plane.

  • Set "contour" to "contour-vel".

  • Set "field" to "velocity-magnitude".

  • Set "surfaces-list" to "symmetry-xyplane".

  • Set "display" to "contour-vel contour".

solver.tui.display.objects.create(
    "contour",
    "contour-vel",
    "filled?",
    "yes",
    "node-values?",
    "yes",
    "field",
    "velocity-magnitude",
    "surfaces-list",
    "symmetry-xyplane",
    "()",
    "coloring",
    "banded",
    "quit",
)
../../_images/mixing_elbow_014.png

Create definition for temperature contours#

Create and display a definition for temperature contours on the symmetry plane.

  • Set "contour" to "contour-temp".

  • Set "field" to "temperature".

  • Set "surfaces-list" to "symmetry-xyplane".

  • Set "display" to "contour-temp contour".

solver.tui.display.objects.create(
    "contour",
    "contour-temp",
    "filled?",
    "yes",
    "node-values?",
    "yes",
    "field",
    "temperature",
    "surfaces-list",
    "symmetry-xyplane",
    "()",
    "coloring",
    "smooth",
    "quit",
)
../../_images/mixing_elbow_015.png

Create velocity vectors#

Create and display velocity vectors on the symmetry-xyplane plane.

  • Set "vector" to "vector-vel".

  • Set "style" to "arrow".

  • Set "surface-list" to "symmetry-xyplane".

  • Set "scale" to "4".

  • Set "skip" to "2".

solver.tui.display.objects.create(
    "vector",
    "vector-vel",
    "style",
    "arrow",
    "surface-list",
    "symmetry-xyplane",
    "()",
    "scale",
    "scale-f",
    "4",
    "quit",
    "skip",
    "2",
    "quit",
)
../../_images/mixing_elbow_016.png

Create iso-surface#

Create an iso-surface representing the intersection of the plane z=0 and the surface outlet. Name it "z=0_outlet".

solver.tui.surface.iso_surface(
    "z-coordinate", "z=0_outlet", "outlet", "()", "()", "0", "()"
)
range [0, 1.9628789]

Display and save XY plot#

Display and save an XY plot of the temperature profile across the centerline of the outlet for the initial solution.

solver.tui.display.objects.create(
    "xy",
    "xy-outlet-temp",
    "y-axis-function",
    "temperature",
    "surfaces-list",
    "z=0_outlet",
    "()",
    "quit",
)
../../_images/mixing_elbow_017.png

Write final case file and data#

Write the final case file and the data.

solver.tui.file.write_case_data("mixing_elbow2_tui.cas.h5")
Writing to 476e5f9cb8bc:"/home/ansys/.local/share/ansys_fluent_core/examples/mixing_elbow2_tui.cas.h5" in NODE0 mode and compression level 1 ...
       17587 cells,     1 zone  ...
       90052 faces,     7 zones ...
       60464 nodes,     1 zone  ...
  Done.

  Writing boundary layer flags ...
  Done.
Done.

Writing to 476e5f9cb8bc:"/home/ansys/.local/share/ansys_fluent_core/examples/mixing_elbow2_tui.dat.h5" in NODE0 mode and compression level 1 ...
  Writing results.
Done.

Close Fluent#

Close Fluent.

solver.exit()

Total running time of the script: ( 0 minutes 58.078 seconds)

Gallery generated by Sphinx-Gallery