    

 ## On this page

  

 

 # WorkflowExamples

 Last update: 16.07.2025 

Examples of DPF workflows that compute data.

//

// COPYRIGHT ANSYS. ALL RIGHTS RESERVED.

//

\#include "dpf\_api.h"

\#include &lt;limits&gt;

\#ifdef EXAMPLE

\#include "Example.h"

\#else

\#include &lt;gtest/gtest.h&gt;

\#endif

 

TEST(WorkflowExample, TotalDeformation)

{

 // This elementary workflow allows the user to simply read a displacement vector from an analysis and compute its norm.

 

 // set the result file path to the right path

 std::string fileName("../../../testfiles/mapdl\_files/TwoSolids.rst");

 <a id="_a0" name="_a0"></a>[ansys::dpf::DataSources](classansys_1_1dpf_1_1DataSources.xhtml) my_data_sources;

 my_data_sources.<a id="a1" name="a1"></a>[addResultFile](classansys_1_1dpf_1_1DataSources.xhtml#ad2a5bb6f24ca621ffaaee9e7a47cdc20)(fileName);

 

 <a id="_a2" name="_a2"></a>[ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) u_op("U");

 u_op.<a id="a3" name="a3"></a>connect(<a id="a4" name="a4"></a>[ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), my_data_sources);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) norm_op("norm\_fc");

 norm_op.connect(u_op);

 

 <a id="_a5" name="_a5"></a>[ansys::dpf::FieldsContainer](classansys_1_1dpf_1_1FieldsContainer.xhtml) my_u_norm = norm_op.<a id="a6" name="a6"></a>[getOutputFieldsContainer](classansys_1_1dpf_1_1Operator.xhtml#a9994ffe0f23c4a5de614099abb95286c)(0);

}

 

TEST(WorkflowExample, MinMaxOverTimeOfVonMisesStress)

{

 // This workflow allows users to read the stress tensors for a range of time 

 // steps from an analysis, to implicitly average those elemental nodal tensors to a 

 // nodal location, to compute it's Von Mises equivalent and finally, to compute the 

 // minimum and the maximum over time for each component of the nodal equivalent tensors. 

 // This workflow is an example use case of the time scoping pin. This pin expects a scoping 

 // in input and allows the user to choose the time or frequency sets of his results.

 

 // set the result file path to the right path

 std::string fileName("../../../testfiles/mapdl\_files/TwoSolids.rst");

 [ansys::dpf::DataSources](classansys_1_1dpf_1_1DataSources.xhtml) my_data_sources;

 my_data_sources.[addResultFile](classansys_1_1dpf_1_1DataSources.xhtml#ad2a5bb6f24ca621ffaaee9e7a47cdc20)(fileName);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) stress_op("S");

 stress_op.connect([ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), my_data_sources);

 stress_op.connect(<a id="a7" name="a7"></a>[ansys::dpf::eTimeScopPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1ac390a52dd8c4f1e8ff81a162cdc04d4f), { 1 });

 stress_op.connect(<a id="a8" name="a8"></a>[ansys::dpf::eLocationPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1aa8522e00b69f3a2f2626a088f20823fe), <a id="a9" name="a9"></a>[ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29));

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) eqv_op("eqv\_fc");

 eqv_op.connect(stress_op);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) min_max_op("min\_max\_fc");

 min_max_op.connect(eqv_op);

 

 <a id="_a10" name="_a10"></a>[ansys::dpf::Field](classansys_1_1dpf_1_1Field.xhtml) my_min = min_max_op.getOutputField(0);

 [ansys::dpf::Field](classansys_1_1dpf_1_1Field.xhtml) my_max = min_max_op.getOutputField(1);

}

 

TEST(WorkflowExample, StrainTensorsScopedOnNamedSelection)

{

 // This workflow is an example use case of the mesh scoping in input of a result reader. 

 // Here, the user can extract a mesh scoping (a set of spatial entities: node or elements for example) 

 // from a named selection created in mechanical or mapdl. This mesh scoping is then used as an input 

 // of a strain tensors reader. The output of this workflow is the strain tensors scoped only on the 

 // named selection. Two different versions of this workflow is available: the first one extracts the elements 

 // of the named selection and returns an elemental nodal field, the second extracts the nodes of the named 

 // selection, the strain reader will consequently average the tensors on the node to take into account the 

 // nodal mesh scoping in input.

 

 // set the result file path to the right path

 std::string fileName("../../../testfiles/mapdl\_files/TwoSolids.rst");

 [ansys::dpf::DataSources](classansys_1_1dpf_1_1DataSources.xhtml) my_data_sources;

 my_data_sources.[addResultFile](classansys_1_1dpf_1_1DataSources.xhtml#ad2a5bb6f24ca621ffaaee9e7a47cdc20)(fileName);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) strain_op("EPEL");

 strain_op.connect([ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), my_data_sources);

 strain_op.connect([ansys::dpf::eLocationPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1aa8522e00b69f3a2f2626a088f20823fe), [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29));

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) meshProvider("MeshProvider");

 meshProvider.connect([ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), my_data_sources);

 <a id="_a11" name="_a11"></a>[ansys::dpf::MeshedRegion](classansys_1_1dpf_1_1MeshedRegion.xhtml) mesh = meshProvider.getOutputMeshedRegion(0);

 std::vector&lt;std::string&gt; available_named_sel = mesh.<a id="a12" name="a12"></a>[availableNamedSelections](classansys_1_1dpf_1_1MeshedRegion.xhtml#a3b768ab61193b7b1a6359f4ac619d1c4)();

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) ns_op("scoping\_provider\_by\_ns");

 ns_op.connect([ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), my_data_sources);

 ns_op.connect(0, <a id="a13" name="a13"></a>[ansys::dpf::locations::elemental](structansys_1_1dpf_1_1locations.xhtml#a3f66169a86ab935fb398b3fdde98bb04));

 ns_op.connect(1, available_named_sel[0]);

 

 strain_op.connect(<a id="a14" name="a14"></a>[ansys::dpf::eMeshScopPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a79a70f074b2f79ccaff75ae8e4ec9ec9), ns_op, 0);

 

 [ansys::dpf::FieldsContainer](classansys_1_1dpf_1_1FieldsContainer.xhtml) my_nodal_strains = strain_op.getOutputFieldsContainer(0);

}

 

TEST(WorkflowExample, StressTensorsScopedOnOneElementType)

{

 // This workflow is another example of use of the mesh scoping in input of a result reader. 

 // Here, the user requests a mesh scoping including all the elements of mapdl element type 186. 

 // This mesh scoping is then used as an input of a stress tensors reader. The output of this workflow 

 // is the stress tensors on all the elements of element type 186.

 

 // set the result file path to the right path

 std::string fileName("../../../testfiles/mapdl\_files/TwoSolids.rst");

 [ansys::dpf::DataSources](classansys_1_1dpf_1_1DataSources.xhtml) my_data_sources;

 my_data_sources.[addResultFile](classansys_1_1dpf_1_1DataSources.xhtml#ad2a5bb6f24ca621ffaaee9e7a47cdc20)(fileName);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) stress_op("S");

 stress_op.connect([ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), my_data_sources);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) scop_extract_op("scoping\_provider\_by\_prop");

 scop_extract_op.connect([ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), my_data_sources);

 scop_extract_op.connect(0, [ansys::dpf::locations::elemental](structansys_1_1dpf_1_1locations.xhtml#a3f66169a86ab935fb398b3fdde98bb04));

 scop_extract_op.connect(1, std::string("mapdl\_element\_type"));

 scop_extract_op.connect(2, 186);

 

 stress_op.connect([ansys::dpf::eMeshScopPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a79a70f074b2f79ccaff75ae8e4ec9ec9), scop_extract_op, 0);

 

 [ansys::dpf::FieldsContainer](classansys_1_1dpf_1_1FieldsContainer.xhtml) my_elemental_nodal_stress = stress_op.getOutputFieldsContainer(0);

}

 

TEST(WorkflowExample, HighPassFilteringOnElementalStress)

{

 // This advanced workflow computes the normal ZZ stress averaged on element

 // sand apply a high pass filter keeping all the stress values higher than 

 // 0.5 \* maximum stress.

 // This example requires a license. 

 

 // set the result file path to the right path

 std::string fileName("../../../testfiles/mapdl\_files/TwoSolids.rst");

 [ansys::dpf::DataSources](classansys_1_1dpf_1_1DataSources.xhtml) my_data_sources;

 my_data_sources.[addResultFile](classansys_1_1dpf_1_1DataSources.xhtml#ad2a5bb6f24ca621ffaaee9e7a47cdc20)(fileName);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) s("S");

 s.connect([ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), my_data_sources);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) to_elemental("entity\_average\_fc");

 to_elemental.connect(s);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) comp("component\_selector\_fc");

 comp.connect(to_elemental);

 comp.connect(1, 2); //ZZ comp of stress

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) min_max("min\_max\_over\_label\_fc");

 min_max.connect(comp);

 min_max.connect(1, <a id="a15" name="a15"></a>[ansys::dpf::labels::time](structansys_1_1dpf_1_1labels.xhtml#a22ee1a5e3be8ad98c20c5ca52e247914));

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) scale("scale");

 scale.connect(min_max);

 scale.connect(1, 0.5);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) high_pass("core::field::high\_pass\_fc");

 high_pass.connect(comp);

 high_pass.connect(1, scale, 0);

 

 // uncomment this line to run the workflow.

 // this requires a license.

 //ansys::dpf::FieldsContainer fields = high\_pass.getOutputFieldsContainer(0);

}

 

TEST(WorkflowExample, StressMultiBodySimulation)

{

 // Stress calculation on a multibody simulation without averaging across bodies

 // This workflow shows the computation of stresses in a multibody simulation without 

 // doing averaging across the different bodies.

 

 // set the result file path to the right path

 std::string fileName("../../../testfiles/mapdl\_files/TwoSolids.rst");

 [ansys::dpf::DataSources](classansys_1_1dpf_1_1DataSources.xhtml) my_data_sources;

 my_data_sources.[addResultFile](classansys_1_1dpf_1_1DataSources.xhtml#ad2a5bb6f24ca621ffaaee9e7a47cdc20)(fileName);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) tfreq_op("time\_freq\_support\_provider");

 tfreq_op.connect(4, my_data_sources);

 <a id="_a16" name="_a16"></a>[ansys::dpf::TimeFreqSupport](classansys_1_1dpf_1_1TimeFreqSupport.xhtml) tfreq_support = tfreq_op.getOutput&lt;[ansys::dpf::TimeFreqSupport](classansys_1_1dpf_1_1TimeFreqSupport.xhtml)&gt;(0);

 [ansys::dpf::Field](classansys_1_1dpf_1_1Field.xhtml) tfreq = tfreq_support.<a id="a17" name="a17"></a>[frequencies](classansys_1_1dpf_1_1TimeFreqSupport.xhtml#aa0cf046a80d328f966892abe85308f01)();

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) mesh_op("mesh\_provider");

 mesh_op.connect(4, my_data_sources);

 [ansys::dpf::MeshedRegion](classansys_1_1dpf_1_1MeshedRegion.xhtml) mesh = mesh_op.getOutput&lt;[ansys::dpf::MeshedRegion](classansys_1_1dpf_1_1MeshedRegion.xhtml)&gt;(0);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) spm_op("scoping::by\_property");

 spm_op.connect(7, mesh);

 spm_op.connect(13, std::string("mat"));

 <a id="_a18" name="_a18"></a>[ansys::dpf::ScopingsContainer](classansys_1_1dpf_1_1ScopingsContainer.xhtml) mesh_scoping = spm_op.getOutput&lt;[ansys::dpf::ScopingsContainer](classansys_1_1dpf_1_1ScopingsContainer.xhtml)&gt;(0);

 

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) stress_op("SZ");

 stress_op.connect(0, tfreq);

 stress_op.connect(1, mesh_scoping);

 stress_op.connect(4, my_data_sources);

 stress_op.connect(9, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29));

 

 [ansys::dpf::FieldsContainer](classansys_1_1dpf_1_1FieldsContainer.xhtml) my_stresses = stress_op.getOutputFieldsContainer(0);

}

[ansys::dpf::DataSources](classansys_1_1dpf_1_1DataSources.xhtml)

**Definition:** dpf_api.h:1954



[ansys::dpf::DataSources::addResultFile](classansys_1_1dpf_1_1DataSources.xhtml#ad2a5bb6f24ca621ffaaee9e7a47cdc20)

void addResultFile(std::string const &amp;file_path, std::string const &amp;key)



[ansys::dpf::Field](classansys_1_1dpf_1_1Field.xhtml)

Data for an entity.

**Definition:** dpf_api.h:890



[ansys::dpf::FieldsContainer](classansys_1_1dpf_1_1FieldsContainer.xhtml)

Contains a group of fields.

**Definition:** dpf_api.h:1566



[ansys::dpf::MeshedRegion](classansys_1_1dpf_1_1MeshedRegion.xhtml)

Holds the mesh for a given region (body, faces, skin, ...)

**Definition:** dpf_api.h:3596



[ansys::dpf::MeshedRegion::availableNamedSelections](classansys_1_1dpf_1_1MeshedRegion.xhtml#a3b768ab61193b7b1a6359f4ac619d1c4)

std::vector&lt; std::string &gt; availableNamedSelections() const



[ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml)

Wrap an elementary operation.

**Definition:** dpf_api.h:2216



[ansys::dpf::Operator::getOutputFieldsContainer](classansys_1_1dpf_1_1Operator.xhtml#a9994ffe0f23c4a5de614099abb95286c)

FieldsContainer getOutputFieldsContainer(dp_index pin_index)



[ansys::dpf::ScopingsContainer](classansys_1_1dpf_1_1ScopingsContainer.xhtml)

**Definition:** dpf_api.h:1717



[ansys::dpf::TimeFreqSupport](classansys_1_1dpf_1_1TimeFreqSupport.xhtml)

Define a time/frequency set.

**Definition:** dpf_api.h:3767



[ansys::dpf::TimeFreqSupport::frequencies](classansys_1_1dpf_1_1TimeFreqSupport.xhtml#aa0cf046a80d328f966892abe85308f01)

Field frequencies() const



[ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc)

@ eDataSourcesPin

**Definition:** dpf_api.h:2150



[ansys::dpf::eMeshScopPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a79a70f074b2f79ccaff75ae8e4ec9ec9)

@ eMeshScopPin

**Definition:** dpf_api.h:2144



[ansys::dpf::eLocationPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1aa8522e00b69f3a2f2626a088f20823fe)

@ eLocationPin

**Definition:** dpf_api.h:2160



[ansys::dpf::eTimeScopPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1ac390a52dd8c4f1e8ff81a162cdc04d4f)

@ eTimeScopPin

**Definition:** dpf_api.h:2142



[ansys::dpf::labels::time](structansys_1_1dpf_1_1labels.xhtml#a22ee1a5e3be8ad98c20c5ca52e247914)

static const Label time

**Definition:** dpf_api_base.h:513



[ansys::dpf::locations::elemental](structansys_1_1dpf_1_1locations.xhtml#a3f66169a86ab935fb398b3fdde98bb04)

static const Location elemental

**Definition:** dpf_api_base.h:168



[ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)

static const Location nodal

**Definition:** dpf_api_base.h:166