Skip to main content
Now that you understand how data is organized in DPF (fields, scopings, supports, and collections), you need to learn how to manipulate it. DPF provides two main tools for working with data: operators for individual transformations and workflows for automated processing pipelines.

Understanding operators

What is an operator

An operator is a function that takes input data, performs a specific operation on it, and produces output data. Operators are the building blocks for all data processing in DPF. Why operators matter: Instead of writing custom code to manipulate fields, meshes, or other DPF objects, you use pre-built operators that handle common tasks efficiently. Operators are optimized, tested, and designed to work seamlessly with DPF’s data structures. Real-world analogy: Think of operators like tools in a workshop. A drill performs one specific task (making holes), a saw performs another (cutting). Each tool (operator) takes input (material), performs an operation (drilling, cutting), and produces output (modified material). You don’t build the tools yourself, you use the right tool for each job.

How operators work

Every operator follows the same pattern: Operator structure
  1. Inputs: Data you provide to the operator (fields, meshes, parameters)
  2. Processing: The operation performed on the input data
  3. Outputs: Results produced by the operator
Input and output types:
  • DPF data structures (Field, FieldsContainer, MeshedRegion, Scoping, etc.)
  • Standard Python types (int, float, string, list)
  • Outputs from other operators (enabling operator chaining)

Types of operators by purpose

Operators are organized into categories based on what they do. Here are a few category examples:

Finding operators

DPF provides hundreds of operators. You can explore them in the Operators Reference documentation. How to find the right operator:
  1. Search by keyword: Use the top-right search box (e.g., “average”, “displacement”, “extract”). Filter on Multiphysics, Structures, Fluids and Developer Portal as well as your installation Version. Global keyword search
  2. Browse by category: Look through categories like “math”, “result”, “averaging” Operator documentation browse
  3. Read operator descriptions: Each operator page explains inputs, outputs, and usage Operator documentation page

Using an operator

Using an operator involves three steps:

Step1: Instantiate the operator

Create an instance of the operator you want to use:

Step2: Connect inputs

Provide the required input data to the operator:
How inputs work: Each operator has named input pins (like data_sources, time_scoping, mesh_scoping). You connect data to these pins using the inputs attribute.
The Operator API
Python makes connecting inputs simple by providing named properties like inputs.data_sources() and inputs.time_scoping(). This is a Python-specific convenience feature. The underlying C++ API uses a more direct approach: operator.connect(pin_number, object), where you specify the pin number (0, 1, 2, etc.) instead of a name. For example:
Python hides this detail, making the code more readable and self-documenting. When you write inputs.data_sources(), Python automatically uses the correct pin number behind the scenes. Using raw pin numbers in Python: You can also use the pin number approach directly in Python by calling operator.connect(pin_number, object). This is useful when:
  • Working with operators that don’t have a Python wrapper
  • The Python wrapper hasn’t been updated to expose a new pin
  • You’re porting C++ code to Python and want to match the structure
You can find pin numbers and names in the Operators Reference documentation for each operator.

Step3: Evaluate and get outputs

Execute the operator and retrieve results:

Complete operator example

Here’s a full example that uses the norm operator to calculate displacement magnitudes:
Expected output:
What this shows: The norm operator took a vector field (3 components: X, Y, Z) and produced a scalar field (1 component: magnitude). This is a common pattern: operators transform data from one form to another.

Operator input/output patterns

Understanding common operator patterns helps you chain them together effectively:

Common operators you’ll use

Here are operators you’ll encounter frequently: Result extraction:
  • operators.result.displacement(): Get displacement results
  • operators.result.stress(): Get stress results
  • operators.result.strain(): Get strain results
Mesh extraction:
  • operators.mesh.mesh_provider(): Get mesh data
  • operators.mesh.meshes_provider(): Get mesh data as a collection
Mathematical operations:
  • operators.math.add(): Add two fields
  • operators.math.scale(): Multiply field by scalar
  • operators.math.norm(): Calculate the magnitude of each entity in a single Field
  • operators.math.norm_fc(): Calculate the magnitude of each entity for all fields in a FieldsContainer
Min/Max extraction:
  • operators.min_max.min_max_fc(): Find the minimum and maximum over all fields in a FieldsContainer - exposes two Field outputs: outputs.field_min and outputs.field_max
Filtering and scoping:
  • operators.scoping.rescope(): Changes the scoping of a Field
Averaging:
  • operators.averaging.elemental_nodal_to_nodal(): Average ElementalNodal to Nodal
Utility:
  • operators.serializer.serialize_to_hdf5(): Export data to HDF5
  • operators.utility.forward(): Pass data through unchanged (useful in workflows)

Understanding workflows

What is a workflow

A workflow is a collection of operators chained together to perform a multi-step data processing pipeline. Workflows automate complex analysis tasks by connecting the output of one operator to the input of another. Why workflows matter: Real-world analysis tasks rarely involve just one operation. You might need to extract results, filter specific entities, average values, and compute magnitudes—all in sequence. Workflows let you build these pipelines once and reuse them with different data sources. Real-world analogy: Think of an assembly line in a factory. Raw materials enter at one end, pass through multiple workstations (each performing a specific task), and finished products emerge at the other end. Each workstation is like an operator, and the entire assembly line is the workflow.

How workflows work

Workflows are created by connecting operators together. The output of one operator becomes the input of the next: Workflow concept Key insight: A workflow is itself like a single operator: it has inputs (data sources, parameters) and outputs (processed results). The internal operator chain is hidden, making workflows reusable components. You can think of those as packaging for your analysis process.

Workflow example: Total deformation

Here’s a concrete example showing how operators connect to calculate total deformation (displacement magnitude): Workflow example What this workflow does:
  1. displacement operator: Extracts nodal displacement fields from result file (vector with X, Y, Z components)
  2. norm_fc operator: Calculates magnitude of displacement vector for each field (scalar representing total deformation)
Result: A FieldsContainer with total deformation values at each node.

Creating a workflow

You can create workflows in two ways:

Method 1: Explicit workflow object

Create a Workflow object and add operators to it:
The types module
The second argument to workflow.get_output() (and operator output evaluation) tells DPF what Python type to return. Common values:
  • types.fields_container: returns a FieldsContainer
  • types.field: returns a single Field
  • types.meshed_region: returns a MeshedRegion
Import it with from ansys.dpf.core import types.

Method 2: Implicit chaining

Chain operators directly without creating a workflow object:
Expected output:
What this shows: Method 2 is simpler for short workflows and scripting. Method 1 (explicit Workflow) is useful for complex workflows or when you want to save, share, or visualize a workflow.

Inspecting a workflow

Once you have created a workflow, you can inspect its structure using these properties:
Visualizing a workflow: You can export or display the workflow graph:

Benefits of workflows

Reusability: Build a Workflow object once, apply it to different models or time steps:
What this demonstrates: The Workflow object allows you to define a processing pipeline once, then reuse it with different data sources and parameters without recreating the operator chain. Modularity: Break complex analysis into manageable steps with clear input/output definitions. Efficiency: DPF optimizes operator chains, executing them efficiently on the server. Shareability: Save workflows to files and share them with colleagues or use them across different scripts.

When to use workflows

Use workflows when you:
  • Perform multi-step data processing repeatedly
  • Need to apply the same analysis to different models
  • Want to build reusable analysis templates
  • Have complex processing pipelines with many operators
For simple, one-time operations, directly using a single operator is often sufficient.

Exercises

Practice the core concepts of operators and workflows through these progressive exercises.

Exercise 1: Use a single operator

Practice the basic three-step operator pattern: instantiate, connect inputs, get outputs. Extract displacement results for time step 1 from the simple bar example (examples.find_simple_bar()) using the result.displacement operator. Display the resulting FieldsContainer to verify it worked.

Exercise 2: Chain two operators

Practice operator chaining by connecting one operator’s output directly to another’s input. Extract displacement as in exercise 1, then compute its magnitude using the math.norm_fc operator. Display the magnitude field to verify it’s now scalar (1 component) instead of vector (3 components).

Exercise 3: Create a workflow

Practice creating a reusable Workflow object with named inputs and outputs. Build a workflow that computes displacement magnitude and finds its min/max values. The workflow should have:
  • Named inputs: "data_sources" and "time_scoping"
  • Named outputs: "min_magnitude" and "max_magnitude"
  • Three operators chained: displacement → norm_fc → min_max_fc

Exercise 4: Visualize and reuse a workflow

Practice visualizing a workflow structure and reusing it with different inputs. Take the workflow from Exercise 3 and:
  1. Print its structure using workflow.info dictionary
  2. Reuse it with a different time step (if you had multiple time steps)
  3. Show how the same workflow can be applied repeatedly

Going further

Now that you understand operators and workflows, explore these advanced topics: