ACT wizards enable you to use ACT’s process-compression and automation capabilities in Fluent, regardless of whether Fluent is opened in Workbench or as a stand-alone application. Once launched, a wizard provides guidance within the application workflow, walking users step-by-step through a fluid dynamics simulation.
An ACT wizard is encapsulated in an extension, placed within a
<wizard> block in the extension XML definition file;
one or more wizards can be defined within the same extension. In order to use a
wizard, you must install and load the extension via the Extension Manager, as
described in Extension Manager: Working with Extensions.
To access the Wizards page, click the corresponding icon on the ACT Start Page. The Wizards tool shows all of wizards currently installed for Fluent. You can use the Search field to search for a wizard by the name, description, or author of the extension.
To execute a wizard, click it. Alternatively, you can select Execute Wizard from the wizard's context menu. The wizard interface will open, showing the first step of the wizard.
For more information on wizards in general, see Using Wizards in the ANSYS ACT Developer's Guide.
This example uses a Fluent wizard called SimpleAnalysis. It is defined in the extension FluentDemo (XML Extension Definition File). You can find this extension in the ACT Templates section of the ANSYS Customer Portal.
This example imports a mesh, runs a simple analysis, generates results, and displays the results in a customized panel in the UI. At minimum, an extension consists of an XML Extension Definition File and an IronPython Script.
Note: This example requires you to run Fluent in 3D (selected from the
Fluent Launcher). It also requires you to download the mesh file
final.msh from the ANSYS App Store. When you
click ACT Wizard Templates under ACT
Templates, you will be prompted to download the folder.
This section contains the FluentDemo.xml extension file, as well as explanations of each of the required
fields.
The name and version attributes define the extension name and version. The guid specifies a unique identifier for the extension.
The <script> block specifies the
IronPython script referenced by the extension. This wizard references
the script main.py (IronPython Script).
The <interface> block defines details
of the interface.
The context attribute is
set to Fluent because the extension is
executed in the Fluent application.
The <images> block refers
the extension images folder; the image contained
in this folder is displayed as the icon for the wizard.
The <uidefinition> block allows you to customize the ACT user
interface, by creating specialized views and layouts.
The <layout> block allows
you to define a custom layout. In this example, only a single layout
is defined.
The name attribute is set
to ResultsView, specifying the name of the
layout being defined (a customized view for the display of Fluent
results).
The following child <component> blocks define the details and display properties of each UI component
included in the custom layout: Title, Properties, Report, Chart, and Submit.
The wizard and its steps are defined in the <wizard> block.
The required name and version attributes define the wizard name and version.
The context attribute is
set to Fluent because the wizard will be
executed in the Fluent application.
The icon attribute references
the wizard_icon.png image in the images folder.
The <step> tab is used to define
the steps of the wizard. There are two steps:
Analysis and Results.
For each step:
The name, version, and caption attributes define the step
name, version, and display text for the step.
The <callbacks> block
defines the callbacks to the functions defined in the main.py Python script.
For the Analysis step:
The <onrefresh> callback
executes the ImportMesh function.
The <onupdate> callback
executes the CreateAnalysis function.
For the Results step, the <onrefresh> callback executes the CreateReport function.
The <property> block for
each step defines a single property and its attributes.
XML Example:
<extension name="FluentDemo" version="1"> <guid>A0A3E28C-E094-4B2D-8A91-A0B0884D1AE2</guid> <author>ANSYS Inc.</author> <description>This extension demonstrates how to create a wizard in Fluent.</description> <script src="main.py" /> <interface context="Fluent"> <images>images</images> </interface> <uidefinition> <layout name="ResultsView"> <component name="Title" topAttachment="" topOffset="10" leftAttachment="" leftOffset="10" rightAttachment="" rightOffset="10" bottomOffset="10" bottomAttachment="Properties" widthType="Percentage" width="100" heightType="FitToContent" height="200" componentType="startPageHeaderComponent" /> <component name="Properties" topAttachment="Title" leftAttachment="" leftOffset="10" rightAttachment="" rightOffset="10" bottomAttachment="Report" bottomOffset="10" widthType="Percentage" width="100" heightType="Percentage" height="20" componentType="propertiesComponent" /> <component name="Report" topAttachment="Properties" leftAttachment="" leftOffset="10" rightAttachment="" rightOffset="10" bottomAttachment="Chart" bottomOffset="10" widthType="Percentage" width="100" heightType="Percentage" height="40" componentType="helpContentComponent" /> <component name="Chart" topAttachment="Report" leftAttachment="" leftOffset="10" rightAttachment="" rightOffset="10" bottomAttachment="Submit" bottomOffset="10" widthType="Percentage" width="100" heightType="Percentage" height="40" componentType="chartComponent" /> <component name="Submit" topAttachment="Chart" leftAttachment="" leftOffset="10" rightAttachment="" rightOffset="10" bottomAttachment="" bottomOffset="10" widthType="Percentage" width="100" heightType="FitToContent" height="50" componentType="buttonsComponent" /> </layout> </uidefinition> <wizard name="Simple Analysis" version="1" context="Fluent" icon="wizard_icon"> <description>Generate the mesh and solve the analysis.</description> <!--<step name="Mesh" caption="Mesh" version="1"> <callbacks> <onupdate>CreateMesh</onupdate> </callbacks> <property name="minSize" caption="Minimum element size" control="float" default="0.001" /> <property name="maxSize" caption="Maximum element size" control="float" default="0.01" /> </step>--> <step name="Analysis" caption="Analysis" version="1"> <callbacks> <onrefresh>ImportMesh</onrefresh> <onupdate>CreateAnalysis</onupdate> </callbacks> <property name="velocity" caption="Velocity" control="float" default="3" /> </step> <step name="Results" caption="Results" version="1" layout="ResultsView@FluentDemo"> <callbacks> <onrefresh>CreateReport</onrefresh> </callbacks> <property name="pressure" caption="Pressure Drop" control="text" readonly="true" /> </step> </wizard> </extension>
This section contains the IronPython script, main.py. It is located in the FluentDemo extension
folder.
This script defines all of the functions executed by the callbacks
in the XML extension file: ImportMesh, CreateAnalysis, and CreateReport. Each step defined in the XML file may include multiple actions.
Note: The ImportMesh function references
the input file final.msh. It is located in
the FluentDemo extension folder, along with the main.py script.
def CreateMesh(step):
tui = ExtAPI.Application.ScriptByName("TUI")
tui.SendCommand("""switch-to-meshing-mode""")
tui.SendCommand("""/file/import/cad yes "{0}" 40 yes m""".format(r"e:\models\cyl.agdb"))
tui.SendCommand("""/objects/separate-faces-by-angle/solid () 90""")
tui.SendCommand("""/size-functions/set-global-controls 0.001 0.01 1.2""")
tui.SendCommand("""/scoped-sizing/create "control-1" curvature object-faces-and-edges yes
no "*" 0.001 0.01 1.2 18""")
tui.SendCommand("""/scoped-sizing/create "control-2" proximity object-faces-and-edges yes
no "*" 0.001 0.01 1.2 10 face-face no yes""")
tui.SendCommand("""/scoped/compute""")
tui.SendCommand("""/objects/change-object-type solid () mesh yes""")
tui.SendCommand("""/objects/improve-object-quality solid () surface-remesh""")
tui.SendCommand("""/boundary/manage/name solid "inlet" """)
tui.SendCommand("""/boundary/manage/name solid:5 "outlet" """)
tui.SendCommand("""/boundary/manage/name solid:6 "wall" """)
tui.SendCommand("""/boundary/manage/type (*) wall""")
tui.SendCommand("""/boundary/manage/type outlet () pressure-outlet""")
tui.SendCommand("""/boundary/manage/type inlet () velocity-inlet""")
tui.SendCommand("""/objects/join-intersect/compute-regions "solid" no""")
tui.SendCommand("""/objects/join-intersect/change-region-type "solid" (*) fluid""")
tui.SendCommand("""/mesh/scoped-prisms/create "control-3" aspect-ratio 10 5 1.2 solid fluid-regions
only-wall""")
tui.SendCommand("""/mesh/auto-mesh "solid" no scoped pyramids tet""")
def ImportMesh(step):
tui = ExtAPI.Application.ScriptByName("TUI")
tui.SendCommand("""switch-to-meshing-mode""")
tui.SendCommand("""/file/read-mesh "{0}" """
.format(System.IO.Path.Combine(ExtAPI.Extension.InstallDir,"final.msh")))
tui.SendCommand("""switch-to-solution-mode yes yes""")
tui.SendCommand("""/display/mesh ok""")
tui.SendCommand("""/display/views/restore-view right""")
def CreateAnalysis(step):
tui = ExtAPI.Application.ScriptByName("TUI")
res = System.IO.Path.GetTempFileName()
img = System.IO.Path.GetTempFileName()+".jpg"
curve = System.IO.Path.GetTempFileName()
tui.SendCommand("""/define/boundary-conditions/velocity-inlet inlet no no yes yes
no {0} no 0""".format(step.Properties["velocity"].Value), True)
tui.SendCommand("""/solve/initialize/hyb-initialization""", True)
tui.SendCommand("""/solve/iterate 50""", True)
tui.SendCommand("""/display/mesh ok""", True)
tui.SendCommand("""/display/views/restore-view right""", True)
tui.SendCommand("""/display/set/contours/filled-contours? yes""", True)
tui.SendCommand("""/display/set/contours/surfaces wall inlet outlet ()""", True)
tui.SendCommand("""/display/contour pressure 0 2""", True)
tui.SendCommand("""/display/save-picture "{0}" """.format(img), True)
#tui.SendCommand("""/surface/delete rake-5""", True)
tui.SendCommand("""/surface/rake-surface rake-5 0 0 0 0 0 1 50""", True)
tui.SendCommand("""/plot/plot-direction 0 0 1""", True)
tui.SendCommand("""/plot/plot yes "{0}" yes yes no no pressure yes 0 0 1 rake-5 ()""".format(curve), True)
tui.SendCommand("""/report/surface-integrals/area-weighted-avg inlet () pressure
yes "{0}" """.format(res), True)
val = 0.
n = 0;
with System.IO.StreamReader(res) as reader:
while n!=5:
line = reader.ReadLine()
if line!=None:
n+=1
str = line.Substring(32)
val = System.Double.Parse(str, System.Globalization.CultureInfo.InvariantCulture)
x=[]
y=[]
n = 0;
with System.IO.StreamReader(curve) as reader:
while n!=5:
line = reader.ReadLine()
if line!=None:
n+=1
while not line.StartsWith(")"):
tab = line.Split("\t")
x.Add(System.Double.Parse(tab[0], System.Globalization.CultureInfo.InvariantCulture))
y.Add(System.Double.Parse(tab[1], System.Globalization.CultureInfo.InvariantCulture))
line = reader.ReadLine()
System.IO.File.Delete(res)
System.IO.File.Delete(curve)
step.NextStep.Properties["pressure"].Value = val
step.NextStep.Attributes["img"] = img
step.NextStep.Attributes["x"] = x
step.NextStep.Attributes["y"] = y
def CreateReport(step):
graph = step.UserInterface.GetComponent("Chart")
graph.Title("Static Pressure")
graph.ShowLegend(False)
graph.Plot(step.Attributes["x"], step.Attributes["y"], key="Static Pressure", color='g')
help = step.UserInterface.GetComponent("Report")
help.SetHtmlContent(ExtAPI.Extension.InstallDir,"""<center><img style="height:250px"
src="{0}"></center>""".format(step.Attributes["img"]))