Skip to main content
In MechDPF, operators are the fundamental processing units. Every data transformation (reading results, computing norms, averaging, filtering) is done by connecting operators together rather than writing imperative Python loops. A workflow is a named graph of connected operators that Mechanical can execute and optionally display as a contour plot in a Python Result object.

Required setup

Always initialize the Mechanical context before using any operator:
Without mech_dpf.setExtAPI(ExtAPI), operator execution silently fails or raises unexpected errors.

Creating operators

Use the hierarchical dpf.operators namespace to instantiate operators by category:
Operator names match the entries in the API reference.

Connecting inputs

Each operator exposes typed input pins via .inputs. Connect data sources, scopings, and other operator outputs by name:

Getting outputs

Retrieve results from a typed output pin with .GetData():
Operators that consume a FieldsContainer and produce another FieldsContainer follow the same pattern. Use the matching output pin name (for example fields_container) and call .GetData():

Chaining operators

Chain operators by connecting one operator’s output directly to the next operator’s input:

Workflows

A dpf.Workflow groups a connected set of operators into a named, reusable graph. You can evaluate it directly in a scripting window to encapsulate a multi-step computation, or register it with Mechanical for contour rendering inside a Python Result object.

Creating and evaluating a workflow

Workflows can also expose named inputs so that the same graph can be reused with different data sources or scopings without rebuilding every operator each time.

Workflows in Python Result objects

When used inside a define_dpf_workflow(analysis) function, a workflow must additionally be recorded so that Mechanical can render its output as a contour plot. The final operator added to the workflow must expose a FieldsContainer that Mechanical will use for the result display.
Key rules for Python Result workflows: The operator passed to wf.SetOutputContour must produce a FieldsContainer output.

To go further (DPF framework)