The extension GenericMeshTransfer implements two custom
mesh transfer task groups, each with "consuming" and "providing" connections.
The first custom task group references a single custom task. It consumes a mesh from an upstream external task group and passes it to a downstream Workbench task group.
The second custom task group references both a custom task and multiple external tasks. The custom task consumes a mesh from an upstream external task and passes it to a downstream external task.
This example also demonstrates input and output specification, file management capabilities, and the default context menu.
The XML extension definition file GenericMeshTransfer.xml specifies the two custom task groups that are to appear in your custom ACT Workflows task group in the Workbench Toolbox. This XML file performs the following actions:
References the IronPython script generic_mesh_transfer.py.
Defines a single task in the <tasks> block.
Defines the callback <onedit> in the task
block, which automatically creates a default Edit
context menu for the task.
Defines an input and an output in the
<inputs> and
<outputs> blocks.
The input has type set to
MeshingMesh, indicating that the
input data type is a mesh.
Both the input and output have format
set to FluentMesh, specifying that the
input and output files have the same
FluentMesh format.
Defines two custom task groups in the
<taskgroups> block.
The first custom task group,
GenericMeshTransfer, references the
custom task Mesher. It consumes a mesh
from an upstream Mesh task group and
passes it to a downstream Fluent task
group.
The second custom task group,
GenericMeshTransferComplete,
references the custom task Material and
also, by using the attribute external,
the external tasks ANSYS Geometry,
ANSYS Meshing, Fluent
Setup, and Fluent
Solution. The task
Material consumes a mesh from the
upstream task ANSYS Meshing and passes it
to the downstream task Fluent
Setup.
The file GenericMeshTransfer.xml contains the following code:
<extension version="1" name="GenericMeshTransfer">
<guid shortid="GenericMeshTransfer">69d0095b-e138-4841-a13a-de12238c83f7</guid>
<script src="generic_mesh_transfer.py" />
<interface context="Project">
<images>images</images>
</interface>
<workflow name="wf6" context="Project" version="1">
<tasks>
<task name="Mesher" caption="Mesher" icon="GenericMesh_cell" version="1">
<callbacks>
<onupdate>update</onupdate>
<onedit>edit</onedit>
</callbacks>
<inputs>
<input format="FluentMesh" type="MeshingMesh" count="1"/>
<input/>
</inputs>
<outputs>
<output format="FluentMesh" type="SimulationGeneratedMesh"/>
</outputs>
</task>
</tasks>
<taskgroups>
<taskgroup name="GenericMeshTransfer" caption="Generic Mesh" icon="GenericMesh"
category="ACT Custom Workflows" abbreviation="GenMeshXfer" version="1">
<includeTask name="Mesher" caption="Mesher"/>
</taskgroup>
<taskgroup name="GenericMeshTransferComplete" caption="Generic Mesh Complete" icon="GenericMesh"
category="ACT Custom Workflows" abbreviation="GenMeshXferComplete" version="1">
<includeTask external="True" name="GeometryCellTemplate" caption="ANSYS Geometry"/>
<includeTask external="True" name="SimulationMeshingModelCellTemplate" caption="ANSYS Meshing"/>
<includeTask name="Mesher" caption="Custom Mesher"/>
<includeTask external="True" name="FluentSetupCellTemplate" caption="Fluent Setup"/>
<includeTask external="True" name="FluentResultsCellTemplate" caption="Fluent Solution"/>
</taskgroup>
</taskgroups>
</workflow>
</extension>The IronPython script generic_mesh_transfer.py contains the code for passing the mesh data to the downstream task group or task.
import clr
clr.AddReference("Ans.UI.Toolkit")
clr.AddReference("Ans.UI.Toolkit.Base")
import Ansys.UI.Toolkit
def update(task):
container = task.InternalObject
ExtAPI.Log.WriteMessage('in generic_mesh_transfer.py update method')
#obtain input data
upstreamData = container.GetInputDataByType(InputType="MeshingMesh")
meshFileRef = None
upstreamDataCount = upstreamData.Count
if upstreamDataCount > 0:
meshFileRef = upstreamData[0]
#set our output so that we are just a pass through.
outputRefs = container.GetOutputData()
meshOutputSet = outputRefs["SimulationGeneratedMesh"]
meshOutput = meshOutputSet[0]
#meshOutput.MeshFile = meshFileRef
meshOutput.TransferFile = meshFileRef
ExtAPI.Log.WriteMessage(str(meshFileRef))
#if no new data...nothing to process from upstream sources.
def edit(task):
Ansys.UI.Toolkit.MessageBox.Show("Test!")