    

 ## On this page

  

 

 # CompleteRST

 Last update: 16.07.2025 

Example showing how to load an RST file and extract mesh and results.

//

// COPYRIGHT ANSYS. ALL RIGHTS RESERVED.

//

// this must only be included in application once

//#include "dpf\_api\_i.cpp"

\#include &lt;limits&gt;

\#include "Example.h"

 

 

TEST(Complete, BaseTest)

{

 

 std::string fileName("../../../testfiles/Cube.rst");

 

 // Data source

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

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

 

 EXPECT_EQ(dataSources.<a id="a2" name="a2"></a>[numPaths](classansys_1_1dpf_1_1DataSources.xhtml#a74a2a6b4aacae91be09048a58c601d1b)(), 1);

 

 // mesh provider

 <a id="_a3" name="_a3"></a>[ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) meshProvider = [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml)("mapdl::rst::MeshProvider");

 if (meshProvider.<a id="a4" name="a4"></a>[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("MeshProvider failed to load");

 }

 

}

TEST(Complete, RST)

{

 // this is only called a single time in an application

 //ansys::dpf::LibraryHandle lib;

 

 

 std::string fileName("../../../testfiles/Cube.rst");

 

 // Data source

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

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

 

 // mesh provider

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

 if (meshProvider.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("MeshProvider");

 }

 meshProvider.<a id="a5" name="a5"></a>connect(<a id="a6" name="a6"></a>[ansys::dpf::eDataSourcesPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1a5b6613f802062fde4faea4b553db7fbc), dataSources);

 

 // meshed region

 <a id="_a7" name="_a7"></a>[ansys::dpf::MeshedRegion](classansys_1_1dpf_1_1MeshedRegion.xhtml) meshedRegion = meshProvider.<a id="a8" name="a8"></a>[getOutputMeshedRegion](classansys_1_1dpf_1_1Operator.xhtml#ae67b9230160d80fbca07eb423f180f98)(0);

 if (meshedRegion.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("getOutputMeshedRegion");

 }

 // do some checks

 // there are 27 nodes in the entire mesh

 EXPECT_EQ(meshedRegion.<a id="a9" name="a9"></a>[numberOfNodes](classansys_1_1dpf_1_1MeshedRegion.xhtml#af8ad6b50708b2c201a457c5da8e819da)(), 27);

 // there are 8 hex elements in the entire mesh

 EXPECT_EQ(meshedRegion.<a id="a10" name="a10"></a>[numberOfElements](classansys_1_1dpf_1_1MeshedRegion.xhtml#ac3a262bc236fda82374a462d7c9e240c)(), 8);

 // the length unit should be "m"

 <a id="_a11" name="_a11"></a>[ansys::dpf::Unit](classansys_1_1dpf_1_1Unit.xhtml) lengthUnit = meshedRegion.<a id="a12" name="a12"></a>[lengthUnit](classansys_1_1dpf_1_1MeshedRegion.xhtml#aed167b03463f42d94d424797529eccad)();

 EXPECT_STREQ(lengthUnit.<a id="a13" name="a13"></a>[toString](classansys_1_1dpf_1_1Unit.xhtml#aed255d78340372d1dd05461d8bc29d38)(), "m");

 EXPECT_STREQ(lengthUnit.<a id="a14" name="a14"></a>[homogeneity](classansys_1_1dpf_1_1Unit.xhtml#a2ca6139006413a975a4995505ab826fc)(), "Displacement");

 // this file has 3 named selections

 EXPECT_EQ(meshedRegion.<a id="a15" name="a15"></a>[availableNamedSelections](classansys_1_1dpf_1_1MeshedRegion.xhtml#a3b768ab61193b7b1a6359f4ac619d1c4)().size(), 3);

 

 

 // "TOP" is a named selection, so it does not have a mesh associated with it, create one

 <a id="_a16" name="_a16"></a>[ansys::dpf::Scoping](classansys_1_1dpf_1_1Scoping.xhtml) meshedRegionScopingTOP = meshedRegion.<a id="a17" name="a17"></a>[namedSelection](classansys_1_1dpf_1_1MeshedRegion.xhtml#a1f12d06a08e8afe8fe59c0a8d6aee779)("TOP");

 if (meshedRegionScopingTOP.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("namedSelection TOP");

 }

 

 

 // result info provider

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) resultInfoProvider = [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml)("ResultInfoProvider");

 if (resultInfoProvider.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("ResultInfoProvider");

 }

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

 <a id="_a18" name="_a18"></a>[ansys::dpf::ResultInfo](classansys_1_1dpf_1_1ResultInfo.xhtml) resultInfo = resultInfoProvider.<a id="a19" name="a19"></a>[getOutputResultInfo](classansys_1_1dpf_1_1Operator.xhtml#aeb719093c2406e06455423370eed3cd8)(0);

 if (resultInfo.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("getOutputResultInfo");

 }

 // do some checks

 // this file has 12 results

 EXPECT_EQ(resultInfo.<a id="a20" name="a20"></a>[numberOfResults](classansys_1_1dpf_1_1ResultInfo.xhtml#a69427d3a5823aa23acfc59b891fa662a)(), 12);

 

 // one of those results should be Displacement

 EXPECT_TRUE(resultInfo.<a id="a21" name="a21"></a>[operatorNameIsAvailable](classansys_1_1dpf_1_1ResultInfo.xhtml#ad8d61b8875d35dd7812d83b63ae68da9)("U"));

 std::string resultName = resultInfo.<a id="a22" name="a22"></a>[resultNameByOperatorName](classansys_1_1dpf_1_1ResultInfo.xhtml#a640956feeee439f2fa42a2fc145fb05d)("U"); // Displacement

 EXPECT_EQ(resultInfo.<a id="a23" name="a23"></a>[numberOfComponents](classansys_1_1dpf_1_1ResultInfo.xhtml#a33fc997e9f5a93b23afac8ca753d0c25)(resultName), 3);

 EXPECT_STREQ(resultInfo.<a id="a24" name="a24"></a>location(resultName), "Nodal");

 

 // going to want result for last time step/iteration

 // time support provider

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) timeFreqSupportProvider = [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml)("TimeFreqSupportProvider");

 if (timeFreqSupportProvider.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("TimeFreqSupportProvider");

 }

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

 <a id="_a25" name="_a25"></a>[ansys::dpf::TimeFreqSupport](classansys_1_1dpf_1_1TimeFreqSupport.xhtml) timeFreqSupport = timeFreqSupportProvider.<a id="a26" name="a26"></a>[getOutputTimeFreqSupport](classansys_1_1dpf_1_1Operator.xhtml#ad2bfffac019485c51c8d3cc88c94ebd0)(0);

 [ansys::dpf::dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) numTimeSteps = 0;

 if (!timeFreqSupport.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 numTimeSteps = timeFreqSupport.<a id="a27" name="a27"></a>[numberOfSets](classansys_1_1dpf_1_1TimeFreqSupport.xhtml#a87c577de73b5ba2260cf3f940ac43068)();

 }

 

 // results field

 [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml) resultOperator = [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml)("U");

 if (resultOperator.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("GetSharedOperatorByName 'U'");

 }

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

 std::vector&lt;int&gt; timeScoping(1);

 if (numTimeSteps) {

 timeScoping[0] = numTimeSteps;

 resultOperator.connect(<a id="a28" name="a28"></a>[ansys::dpf::eTimeScopPin](namespaceansys_1_1dpf.xhtml#aa4a44a04a0aafb8fe0645f019bbd94d1ac390a52dd8c4f1e8ff81a162cdc04d4f), timeScoping);

 }

 <a id="_a29" name="_a29"></a>[ansys::dpf::FieldsContainer](classansys_1_1dpf_1_1FieldsContainer.xhtml) resultFieldsContainer = resultOperator.<a id="a30" name="a30"></a>[getOutputFieldsContainer](classansys_1_1dpf_1_1Operator.xhtml#a9994ffe0f23c4a5de614099abb95286c)(0);

 if (resultFieldsContainer.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("getOutputFieldsContainer");

 }

 <a id="_a31" name="_a31"></a>[ansys::dpf::Field](classansys_1_1dpf_1_1Field.xhtml) resultsField = resultFieldsContainer.<a id="a32" name="a32"></a>[at](classansys_1_1dpf_1_1FieldsContainer.xhtml#addfee935e69fe9fb9e0e533449f9a5bc)(0); // get the 0th field for timeScoping 1

 if (resultsField.[empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)()) {

 throw std::runtime_error("resultsField");

 }

 

 // For some results, there may not be a value, set a default one

 auto rescope = [ansys::dpf::Operator](classansys_1_1dpf_1_1Operator.xhtml)("Rescope");

 if (rescope.empty()) {

 throw std::runtime_error("Rescope");

 }

}

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

**Definition:** dpf_api.h:2433



[ansys::dpf::DataSources::numPaths](classansys_1_1dpf_1_1DataSources.xhtml#a74a2a6b4aacae91be09048a58c601d1b)

int numPaths() const



[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::DpfTypes::empty](classansys_1_1dpf_1_1DpfTypes.xhtml#a39cd546c42518e2332be8f287db95459)

virtual bool empty() const



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

Data for an entity.

**Definition:** dpf_api.h:1028



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

Contains a group of fields.

**Definition:** dpf_api.h:1945



[ansys::dpf::FieldsContainer::at](classansys_1_1dpf_1_1FieldsContainer.xhtml#addfee935e69fe9fb9e0e533449f9a5bc)

Field at(dp_index index)



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

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

**Definition:** dpf_api.h:4305



[ansys::dpf::MeshedRegion::namedSelection](classansys_1_1dpf_1_1MeshedRegion.xhtml#a1f12d06a08e8afe8fe59c0a8d6aee779)

Scoping namedSelection(std::string const &amp;name) const



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

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



[ansys::dpf::MeshedRegion::numberOfElements](classansys_1_1dpf_1_1MeshedRegion.xhtml#ac3a262bc236fda82374a462d7c9e240c)

dp_int numberOfElements() const



[ansys::dpf::MeshedRegion::lengthUnit](classansys_1_1dpf_1_1MeshedRegion.xhtml#aed167b03463f42d94d424797529eccad)

Unit lengthUnit() const



[ansys::dpf::MeshedRegion::numberOfNodes](classansys_1_1dpf_1_1MeshedRegion.xhtml#af8ad6b50708b2c201a457c5da8e819da)

dp_int numberOfNodes() const



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

Wrap an elementary operation.

**Definition:** dpf_api.h:2724



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

FieldsContainer getOutputFieldsContainer(dp_index pin_index)



[ansys::dpf::Operator::getOutputTimeFreqSupport](classansys_1_1dpf_1_1Operator.xhtml#ad2bfffac019485c51c8d3cc88c94ebd0)

TimeFreqSupport getOutputTimeFreqSupport(dp_index pin_index)



[ansys::dpf::Operator::getOutputMeshedRegion](classansys_1_1dpf_1_1Operator.xhtml#ae67b9230160d80fbca07eb423f180f98)

MeshedRegion getOutputMeshedRegion(dp_index pin_index)



[ansys::dpf::Operator::getOutputResultInfo](classansys_1_1dpf_1_1Operator.xhtml#aeb719093c2406e06455423370eed3cd8)

ResultInfo getOutputResultInfo(dp_index pin_index)



[ansys::dpf::ResultInfo](classansys_1_1dpf_1_1ResultInfo.xhtml)

**Definition:** dpf_api.h:380



[ansys::dpf::ResultInfo::numberOfComponents](classansys_1_1dpf_1_1ResultInfo.xhtml#a33fc997e9f5a93b23afac8ca753d0c25)

dp_int numberOfComponents(std::string const &amp;res_name) const



[ansys::dpf::ResultInfo::resultNameByOperatorName](classansys_1_1dpf_1_1ResultInfo.xhtml#a640956feeee439f2fa42a2fc145fb05d)

std::string resultNameByOperatorName(std::string const &amp;op_name) const



[ansys::dpf::ResultInfo::numberOfResults](classansys_1_1dpf_1_1ResultInfo.xhtml#a69427d3a5823aa23acfc59b891fa662a)

dp_int numberOfResults() const



[ansys::dpf::ResultInfo::operatorNameIsAvailable](classansys_1_1dpf_1_1ResultInfo.xhtml#ad8d61b8875d35dd7812d83b63ae68da9)

bool operatorNameIsAvailable(std::string const &amp;op_name) const



[ansys::dpf::Scoping](classansys_1_1dpf_1_1Scoping.xhtml)

Define a set of entities by ids.

**Definition:** dpf_api.h:874



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

Define a time/frequency set.

**Definition:** dpf_api.h:4480



[ansys::dpf::TimeFreqSupport::numberOfSets](classansys_1_1dpf_1_1TimeFreqSupport.xhtml#a87c577de73b5ba2260cf3f940ac43068)

dp_int numberOfSets() const



[ansys::dpf::Unit](classansys_1_1dpf_1_1Unit.xhtml)

**Definition:** dpf_api.h:329



[ansys::dpf::Unit::homogeneity](classansys_1_1dpf_1_1Unit.xhtml#a2ca6139006413a975a4995505ab826fc)

ansys::dpf::Homogeneity const &amp; homogeneity() const



[ansys::dpf::Unit::toString](classansys_1_1dpf_1_1Unit.xhtml#aed255d78340372d1dd05461d8bc29d38)

std::string const &amp; toString() const



[ansys::dpf::dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0)

int dp_int

**Definition:** dpf_api_base.h:52



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

@ eDataSourcesPin

**Definition:** dpf_api.h:2647



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

@ eTimeScopPin

**Definition:** dpf_api.h:2639