    

 ## On this page

  

 

 # ResultTest

 Last update: 16.07.2025 

Examples showing how to access results data in an RST file.

//

// COPYRIGHT ANSYS. ALL RIGHTS RESERVED.

//

\#ifdef EXAMPLE

\#include "Example.h"

\#else

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

\#endif

 

\#include &lt;math.h&gt;

\#include "helpers/dpf\_result.h"

\#include "helpers/dpf\_model.h"

 

using namespace [ansys::dpf](namespaceansys_1_1dpf.xhtml);

 

TEST(result_info, DimensionalityNature_Homogeneity_AnalysisType_PhysicsType_unitSystem)

{

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

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

 ds.<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) provider("ResultInfoProvider");

 provider.<a id="a3" name="a3"></a>connect(4, ds);

 

 <a id="_a4" name="_a4"></a>[ansys::dpf::ResultInfo](classansys_1_1dpf_1_1ResultInfo.xhtml) res_info = provider.<a id="a5" name="a5"></a>[getOutputResultInfo](classansys_1_1dpf_1_1Operator.xhtml#aeb719093c2406e06455423370eed3cd8)(0); 

 std::string analysis_type_name = res_info.<a id="a6" name="a6"></a>[analysisTypeName](classansys_1_1dpf_1_1ResultInfo.xhtml#ac0f80a2ea905a13dccc274790ef6cbc7)();

 EXPECT_EQ(analysis_type_name, std::string("static"));

 std::string physics_type_name = res_info.<a id="a7" name="a7"></a>[physicsTypeName](classansys_1_1dpf_1_1ResultInfo.xhtml#a4400684a038c4fd6dbae406e828c94f2)();

 EXPECT_EQ(physics_type_name, std::string("mechanical"));

 std::string unit_sys_name = res_info.<a id="a8" name="a8"></a>[unitSystemName](classansys_1_1dpf_1_1ResultInfo.xhtml#ae358df95bebd891adf15148f5b26d21d)();

 EXPECT_EQ(unit_sys_name, std::string("MKS: m, kg, N, s, V, A, degC"));

 

 std::set&lt;std::string&gt; res = res_info.<a id="a9" name="a9"></a>[availableResults](classansys_1_1dpf_1_1ResultInfo.xhtml#a48e23d251d6109166a2a1f681a39c58a)();

 auto iter = res.begin();

 iter++;

 std::string res_name = *iter;

 [ansys::dpf::Dimensionality::ENature](structansys_1_1dpf_1_1Dimensionality.xhtml#af4666dee615e27f2fe603240631b932f) nat = res_info.<a id="a10" name="a10"></a>[nature](classansys_1_1dpf_1_1ResultInfo.xhtml#ab47931a377a99ccb9bc6727bb6187d74)(res_name);

 EXPECT_EQ(nat, ansys::dpf::Dimensionality::eScalar);

 

 <a id="_a11" name="_a11"></a>[ansys::dpf::Unit](classansys_1_1dpf_1_1Unit.xhtml) unit_res = res_info.<a id="a12" name="a12"></a>unit(res_name);

 EXPECT_EQ(std::string(unit_res.<a id="a13" name="a13"></a>[homogeneity](classansys_1_1dpf_1_1Unit.xhtml#a2ca6139006413a975a4995505ab826fc)().<a id="a14" name="a14"></a>[c\_str](classansys_1_1dpf_1_1Homogeneity.xhtml#a74bcfe9b2ed50910f2da21944e3b7437)()), std::string("Energy"));

 

 // disp

 res_name = "Displacement";

 unit_res = res_info.unit(res_name);

 EXPECT_EQ(std::string(unit_res.[homogeneity](classansys_1_1dpf_1_1Unit.xhtml#a2ca6139006413a975a4995505ab826fc)().[c\_str](classansys_1_1dpf_1_1Homogeneity.xhtml#a74bcfe9b2ed50910f2da21944e3b7437)()), std::string("Displacement"));

 

 // Force

 res_name = "Force";

 unit_res = res_info.unit(res_name);

 EXPECT_EQ(std::string(unit_res.[homogeneity](classansys_1_1dpf_1_1Unit.xhtml#a2ca6139006413a975a4995505ab826fc)().[c\_str](classansys_1_1dpf_1_1Homogeneity.xhtml#a74bcfe9b2ed50910f2da21944e3b7437)()), std::string("Force"));

 

 // Strain

 res_name = "Strain";

 unit_res = res_info.unit(res_name);

 EXPECT_EQ(std::string(unit_res.[homogeneity](classansys_1_1dpf_1_1Unit.xhtml#a2ca6139006413a975a4995505ab826fc)().[c\_str](classansys_1_1dpf_1_1Homogeneity.xhtml#a74bcfe9b2ed50910f2da21944e3b7437)()), std::string("DimensionLess"));

}

 

TEST(Results, readSEQV)

{

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

 <a id="_a15" name="_a15"></a>[ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv");

 

 <a id="_a16" name="_a16"></a>[ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTime(0.0, error);

 EXPECT_EQ(fieldsContainer.size(), 1);

 

 Field field = fieldsContainer[0];

 Location location = field.fieldDefinition().location();

 

 EXPECT_EQ(field.dataSize(), 344);

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size; 

 

 Operator minmax = Operator("min\_max");

 minmax.connect(0, field);

 

 Field fieldMin = minmax.getOutputField(0);

 Field fieldMax = minmax.getOutputField(1);

 

 auto dataMax = fieldMax.data(size);

 auto dataMin = fieldMin.data(size);

 

 auto ids_max = fieldMax.scoping().ids(size);

 auto ids_min = fieldMin.scoping().ids(size);

 

 EXPECT_DOUBLE_EQ(dataMax[0], 6314.9823137518824);

 EXPECT_DOUBLE_EQ(dataMin[0], 62.022552581514269);

 

 EXPECT_EQ(ids_max[0], 85);

 EXPECT_EQ(ids_min[0], 141); 

}

 

TEST(Results, readSEQVAtGivenNode)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1 }, <a id="a17" name="a17"></a>[ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTime(0.0, error);

 EXPECT_EQ(fieldsContainer.size(), 1);

 

 Field field = fieldsContainer[0];

 EXPECT_EQ(field.dataSize(), 1);

 EXPECT_STREQ(field.fieldDefinition().location().c_str(), locations::nodal.c_str());

 EXPECT_EQ(field.scoping().size(), 1);

 EXPECT_EQ(field.scoping().at(0), 1);

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 EXPECT_DOUBLE_EQ(field.data(size)[0], 987.40109280968454);

}

 

TEST(Results, readSEQVAtGivenNodes)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1,2 }, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTime(0.0, error);

 EXPECT_EQ(fieldsContainer.size(), 1);

 

 Field field = fieldsContainer[0];

 EXPECT_EQ(field.dataSize(), 2);

 EXPECT_STREQ(field.fieldDefinition().location().c_str(), locations::nodal.c_str());

 EXPECT_EQ(field.scoping().size(), 2);

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 EXPECT_DOUBLE_EQ(field.entityDataById(1, size)[0], 987.40109280968454);

 

 EXPECT_DOUBLE_EQ(field.entityDataById(2, size)[0], 1005.4123172685187);

}

 

TEST(Results, readTemperatures)

{

 std::string fileName("../../../testfiles/mapdl\_files/file.rth");

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 TimeFreqSupport timeFreq = model.getTimeFreqSupport();

 auto numSets = timeFreq.numberOfSets();

 EXPECT_EQ(numSets, 4);

 

 Result res = model.CreateResultEvaluationWorkflow("TEMP");

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTimeIndex(3, error);

 EXPECT_EQ(fieldsContainer.size(), 1);

 

 Field field = fieldsContainer[0];

 EXPECT_EQ(field.dataSize(), 2159);

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 

 Operator minmax = Operator("min\_max");

 minmax.connect(0, field);

 

 Field fieldMin = minmax.getOutputField(0);

 Field fieldMax = minmax.getOutputField(1);

 

 auto dataMax = fieldMax.data(size);

 auto dataMin = fieldMin.data(size);

 

 auto ids_max = fieldMax.scoping().ids(size);

 auto ids_min = fieldMin.scoping().ids(size);

 

 EXPECT_DOUBLE_EQ(dataMax[0], 56.576226358561549);

 EXPECT_DOUBLE_EQ(dataMin[0], 21.999572871657019);

 

 EXPECT_EQ(ids_max[0], 32);

 EXPECT_EQ(ids_min[0], 978);

}

 

TEST(Results, readSXAtGivenNamedSelection)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 Result res = model.CreateResultEvaluationWorkflow("SX", "not\_exist");

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTime(0.0, error);

 EXPECT_FALSE(error.<a id="a18" name="a18"></a>[isOk](classansys_1_1dpf_1_1DpfError.xhtml#aa215db12375801e5addbe0dbf8a97533)()); 

 EXPECT_EQ(fieldsContainer.size(), 0);

 

 res = model.CreateResultEvaluationWorkflow("SX", "\_FIXEDSU");

 fieldsContainer = res.EvaluateAtGivenTime(0.0, error);

 EXPECT_TRUE(error.[isOk](classansys_1_1dpf_1_1DpfError.xhtml#aa215db12375801e5addbe0dbf8a97533)());

 

 Field field = fieldsContainer[0];

 EXPECT_EQ(field.dataSize(), 30);

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 

 Operator minmax = Operator("min\_max");

 minmax.connect(0, field);

 

 Field fieldMin = minmax.getOutputField(0);

 Field fieldMax = minmax.getOutputField(1);

 

 auto dataMax = fieldMax.data(size);

 auto dataMin = fieldMin.data(size);

 

 auto ids_max = fieldMax.scoping().ids(size);

 auto ids_min = fieldMin.scoping().ids(size);

 

 EXPECT_DOUBLE_EQ(dataMax[0], 1292.4295654296875);

 EXPECT_DOUBLE_EQ(dataMin[0], -2806.3163364955358);

 

 EXPECT_EQ(ids_max[0], 100);

 EXPECT_EQ(ids_min[0], 109);

}

 

TEST(Results, readSXAtGivenStepIndexAndSubStep)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 TimeFreqSupport timeFreq = model.getTimeFreqSupport();

 auto numSets = timeFreq.numberOfSets();

 EXPECT_EQ(numSets, 1);

 

 auto numSteps = timeFreq.numberOfSteps();

 EXPECT_EQ(numSteps, 1);

 

 auto numSubSteps = timeFreq.numberOfSubStepsByStepIndex(0);

 EXPECT_EQ(numSubSteps, 1);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1 }, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer fieldsContainer = res.EvaluateAtGivenStepIndexAndSubStep(0, 0, error);

 EXPECT_EQ(fieldsContainer.size(), 1);

 Field field = fieldsContainer.at(0);

 EXPECT_EQ(field.dataSize(), 1);

 EXPECT_DOUBLE_EQ(field.data(size)[0], 987.40109280968454);

}

 

TEST(Results, readSEQVAmplitudeAtGivenTime)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1 }, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer amplitudeFieldsContainer = res.EvaluateAmplitudeAtGivenTime(0.0, error);

 EXPECT_EQ(amplitudeFieldsContainer.size(), 1);

 Field amplitudeField = amplitudeFieldsContainer.at(0);

 EXPECT_EQ(amplitudeField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) amplitudeValue = amplitudeField.data(size)[0];

 EXPECT_DOUBLE_EQ(amplitudeValue, 15953.036468929646);

 

 // now get the real and imaginary separately

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTime(0.0, error);

 EXPECT_EQ(fieldsContainer.size(), 2);

 EXPECT_TRUE(fieldsContainer.hasLabel("complex"));

 EXPECT_TRUE(fieldsContainer.hasLabel("time"));

 

 std::vector&lt;Field&gt; realFields = fieldsContainer.getFieldsForTimeId(1, 0);

 EXPECT_EQ(realFields.size(), 1);

 Field realField = realFields.at(0);

 EXPECT_EQ(realField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) realValue = realField.data(size)[0];

 EXPECT_DOUBLE_EQ(realValue, 15953.030385790376);

 

 std::vector&lt;Field&gt; imaginaryFields = fieldsContainer.getFieldsForTimeId(1, 1);

 EXPECT_EQ(imaginaryFields.size(), 1);

 Field imaginaryField = imaginaryFields[0];

 EXPECT_EQ(imaginaryField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) imaginaryValue = imaginaryField.data(size)[0];

 EXPECT_DOUBLE_EQ(imaginaryValue, 13.931584555079384);

 

 // and compare them

 EXPECT_DOUBLE_EQ(amplitudeValue, sqrt(realValue * realValue + imaginaryValue * imaginaryValue));

}

 

TEST(Results, readSEQVAmplitudeAtGivenTimeIndex)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1 }, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer amplitudeFieldsContainer = res.EvaluateAmplitudeAtGivenTimeIndex(0, error);

 EXPECT_EQ(amplitudeFieldsContainer.size(), 1);

 Field amplitudeField = amplitudeFieldsContainer.at(0);

 EXPECT_EQ(amplitudeField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) amplitudeValue = amplitudeField.data(size)[1];

 EXPECT_DOUBLE_EQ(amplitudeValue, 15953.015373859611);

 

 // now get the real and imaginary separately

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTimeIndex(0, error);

 EXPECT_EQ(fieldsContainer.size(), 2);

 EXPECT_TRUE(fieldsContainer.hasLabel("complex"));

 EXPECT_TRUE(fieldsContainer.hasLabel("time"));

 

 std::vector&lt;Field&gt; realFields = fieldsContainer.getFieldsForTimeId(1, 0);

 EXPECT_EQ(realFields.size(), 1);

 Field realField = realFields.at(0);

 EXPECT_EQ(realField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) realValue = realField.data(size)[1];

 EXPECT_DOUBLE_EQ(realValue, 15953.009290308262);

 

 std::vector&lt;Field&gt; imaginaryFields = fieldsContainer.getFieldsForTimeId(1, 1);

 EXPECT_EQ(imaginaryFields.size(), 1);

 Field imaginaryField = imaginaryFields[0];

 EXPECT_EQ(imaginaryField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) imaginaryValue = imaginaryField.data(size)[1];

 EXPECT_DOUBLE_EQ(imaginaryValue, 13.932047206695039);

 

 // and compare them

 EXPECT_DOUBLE_EQ(amplitudeValue, sqrt(realValue * realValue + imaginaryValue * imaginaryValue));

}

 

TEST(Results, readSEQVAmplitudeAtGivenStepAndSubStep)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 TimeFreqSupport timeFreq = model.getTimeFreqSupport();

 auto numSets = timeFreq.numberOfSets();

 EXPECT_EQ(numSets, 10);

 

 auto numSteps = timeFreq.numberOfSteps();

 EXPECT_EQ(numSteps, 1);

 

 auto numSubSteps = timeFreq.numberOfSubStepsByStepIndex(0);

 EXPECT_EQ(numSubSteps, 10);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1 }, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer amplitudeFieldsContainer = res.EvaluateAmplitudeAtGivenStepIndexAndSubStep(0, 9, error);

 EXPECT_EQ(amplitudeFieldsContainer.size(), 1);

 Field amplitudeField = amplitudeFieldsContainer[0];

 EXPECT_EQ(amplitudeField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) amplitudeValue = amplitudeField.data(size)[0];

 EXPECT_DOUBLE_EQ(amplitudeValue, 4823.449633735253);

 

 // now get the real and imaginary separately idx0,idx9=id10

 FieldsContainer fieldsContainer = res.EvaluateAtGivenStepIndexAndSubStep(0, 9, error);

 EXPECT_EQ(fieldsContainer.size(), 2);

 EXPECT_TRUE(fieldsContainer.hasLabel("complex"));

 EXPECT_TRUE(fieldsContainer.hasLabel("time"));

 

 std::vector&lt;Field&gt; realFields = fieldsContainer.getFieldsForTimeId(10, 0);

 EXPECT_EQ(realFields.size(), 1);

 Field realField = realFields.at(0);

 EXPECT_EQ(realField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) realValue = realField.data(size)[0];

 EXPECT_DOUBLE_EQ(realValue, 4823.4491029746168);

 

 std::vector&lt;Field&gt; imaginaryFields = fieldsContainer.getFieldsForTimeId(10, 1);

 EXPECT_EQ(imaginaryFields.size(), 1);

 Field imaginaryField = imaginaryFields[0];

 EXPECT_EQ(imaginaryField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) imaginaryValue = imaginaryField.data(size)[0];

 EXPECT_DOUBLE_EQ(imaginaryValue, 2.262784593315458);

 

 // and compare them

 EXPECT_DOUBLE_EQ(amplitudeValue, (dp_double)sqrt(realValue * realValue + imaginaryValue * imaginaryValue));

}

 

TEST(Results, readSEQVWithPhaseAtGivenTime)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1 }, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 // theta is in degrees

 const [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) theta = 45.0;

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer amplitudeFieldsContainer = res.EvaluateWithPhaseAtGivenTime(0.0, theta, error);

 EXPECT_EQ(amplitudeFieldsContainer.size(), 1);

 Field amplitudeField = amplitudeFieldsContainer.at(0);

 EXPECT_EQ(amplitudeField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) amplitudeValue = amplitudeField.data(size)[0];

 EXPECT_DOUBLE_EQ(amplitudeValue, 11270.644848355851);

 

 // now get the real and imaginary separately

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTime(0.0, error);

 EXPECT_EQ(fieldsContainer.size(), 2);

 EXPECT_TRUE(fieldsContainer.hasLabel("complex"));

 EXPECT_TRUE(fieldsContainer.hasLabel("time"));

 

 std::vector&lt;Field&gt; realFields = fieldsContainer.getFieldsForTimeId(1, 0);

 EXPECT_EQ(realFields.size(), 1);

 Field realField = realFields.at(0);

 EXPECT_EQ(realField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) realValue = realField.data(size)[0];

 EXPECT_DOUBLE_EQ(realValue, 15953.030385790376);

 

 std::vector&lt;Field&gt; imaginaryFields = fieldsContainer.getFieldsForTimeId(1, 1);

 EXPECT_EQ(imaginaryFields.size(), 1);

 Field imaginaryField = imaginaryFields[0];

 EXPECT_EQ(imaginaryField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) imaginaryValue = imaginaryField.data(size)[0];

 EXPECT_DOUBLE_EQ(imaginaryValue, 13.931584555079384);

 

 double thetaR = theta / 180.0 * 3.14159265358979323846;

 

 // and compare them

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) expectedValue = realValue * cos(thetaR) - imaginaryValue * sin(thetaR);

 EXPECT_DOUBLE_EQ(amplitudeValue, expectedValue);

}

 

TEST(Results, readSEQVWithPhaseAtGivenTimeIndex)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1 }, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 // theta is in degrees

 const [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) theta = 22.5;

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer amplitudeFieldsContainer = res.EvaluateWithPhaseAtGivenTimeIndex(0, theta, error);

 EXPECT_EQ(amplitudeFieldsContainer.size(), 1);

 Field amplitudeField = amplitudeFieldsContainer.at(0);

 EXPECT_EQ(amplitudeField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) amplitudeValue = amplitudeField.data(size)[1];

 EXPECT_DOUBLE_EQ(amplitudeValue, 14733.327201633281);

 

 // now get the real and imaginary separately

 FieldsContainer fieldsContainer = res.EvaluateAtGivenTimeIndex(0, error);

 EXPECT_EQ(fieldsContainer.size(), 2);

 EXPECT_TRUE(fieldsContainer.hasLabel("complex"));

 EXPECT_TRUE(fieldsContainer.hasLabel("time"));

 

 std::vector&lt;Field&gt; realFields = fieldsContainer.getFieldsForTimeId(1, 0);

 EXPECT_EQ(realFields.size(), 1);

 Field realField = realFields.at(0);

 EXPECT_EQ(realField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) realValue = realField.data(size)[1];

 EXPECT_DOUBLE_EQ(realValue, 15953.009290308262);

 

 std::vector&lt;Field&gt; imaginaryFields = fieldsContainer.getFieldsForTimeId(1, 1);

 EXPECT_EQ(imaginaryFields.size(), 1);

 Field imaginaryField = imaginaryFields[0];

 EXPECT_EQ(imaginaryField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) imaginaryValue = imaginaryField.data(size)[1];

 EXPECT_DOUBLE_EQ(imaginaryValue, 13.932047206695039);

 

 double thetaR = theta / 180.0 * 3.14159265358979323846;

 

 // and compare them

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) expectedValue = realValue * cos(thetaR) - imaginaryValue * sin(thetaR);

 EXPECT_DOUBLE_EQ(amplitudeValue, expectedValue);

}

 

TEST(Results, readSEQVWithPhaseAtGivenStepIndexAndSubStep)

{

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

 [ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml) model(fileName);

 

 TimeFreqSupport timeFreq = model.getTimeFreqSupport();

 auto numSets = timeFreq.numberOfSets();

 EXPECT_EQ(numSets, 10);

 

 auto numSteps = timeFreq.numberOfSteps();

 EXPECT_EQ(numSteps, 1);

 

 auto numSubSteps = timeFreq.numberOfSubStepsByStepIndex(0);

 EXPECT_EQ(numSubSteps, 10);

 

 Result res = model.CreateResultEvaluationWorkflow("S\_eqv", Scoping({ 1 }, [ansys::dpf::locations::nodal](structansys_1_1dpf_1_1locations.xhtml#aa4e1967b0838d8597200c606c8564d29)));

 

 [dp\_int](namespaceansys_1_1dpf.xhtml#a60d181a1f9d29cc7cc38b25dac4401f0) size;

 // theta is in degrees

 const [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) theta = 67.5;

 

 [ansys::dpf::DpfError](classansys_1_1dpf_1_1DpfError.xhtml) error;

 FieldsContainer amplitudeFieldsContainer = res.EvaluateWithPhaseAtGivenStepIndexAndSubStep(0, 9, theta, error);

 EXPECT_EQ(amplitudeFieldsContainer.size(), 1);

 Field amplitudeField = amplitudeFieldsContainer[0];

 EXPECT_EQ(amplitudeField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) amplitudeValue = amplitudeField.data(size)[0];

 EXPECT_DOUBLE_EQ(amplitudeValue, 1843.7635181923936);

 

 // now get the real and imaginary separately idx0,idx9=id10

 FieldsContainer fieldsContainer = res.EvaluateAtGivenStepIndexAndSubStep(0, 9, error);

 EXPECT_EQ(fieldsContainer.size(), 2);

 EXPECT_TRUE(fieldsContainer.hasLabel("complex"));

 EXPECT_TRUE(fieldsContainer.hasLabel("time"));

 

 std::vector&lt;Field&gt; realFields = fieldsContainer.getFieldsForTimeId(10, 0);

 EXPECT_EQ(realFields.size(), 1);

 Field realField = realFields.at(0);

 EXPECT_EQ(realField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) realValue = realField.data(size)[0];

 EXPECT_DOUBLE_EQ(realValue, 4823.4491029746168);

 

 std::vector&lt;Field&gt; imaginaryFields = fieldsContainer.getFieldsForTimeId(10, 1);

 EXPECT_EQ(imaginaryFields.size(), 1);

 Field imaginaryField = imaginaryFields[0];

 EXPECT_EQ(imaginaryField.dataSize(), 3);

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) imaginaryValue = imaginaryField.data(size)[0];

 EXPECT_DOUBLE_EQ(imaginaryValue, 2.262784593315458);

 

 double thetaR = theta / 180.0 * 3.14159265358979323846;

 

 // and compare them

 [dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790) expectedValue = realValue * cos(thetaR) - imaginaryValue * sin(thetaR);

 EXPECT_DOUBLE_EQ(amplitudeValue, expectedValue);

}

[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::DpfError](classansys_1_1dpf_1_1DpfError.xhtml)

**Definition:** dpf_api_base.h:1060



[ansys::dpf::DpfError::isOk](classansys_1_1dpf_1_1DpfError.xhtml#aa215db12375801e5addbe0dbf8a97533)

bool isOk() const noexcept



[ansys::dpf::Homogeneity::c\_str](classansys_1_1dpf_1_1Homogeneity.xhtml#a74bcfe9b2ed50910f2da21944e3b7437)

const char * c_str() const



[ansys::dpf::Model](classansys_1_1dpf_1_1Model.xhtml)

**Definition:** dpf_model.h:14



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

Wrap an elementary operation.

**Definition:** dpf_api.h:2216



[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:260



[ansys::dpf::ResultInfo::physicsTypeName](classansys_1_1dpf_1_1ResultInfo.xhtml#a4400684a038c4fd6dbae406e828c94f2)

std::string physicsTypeName() const



[ansys::dpf::ResultInfo::availableResults](classansys_1_1dpf_1_1ResultInfo.xhtml#a48e23d251d6109166a2a1f681a39c58a)

std::set&lt; std::string &gt; availableResults() const



[ansys::dpf::ResultInfo::nature](classansys_1_1dpf_1_1ResultInfo.xhtml#ab47931a377a99ccb9bc6727bb6187d74)

Dimensionality::ENature nature(std::string const &amp;res_name) const



[ansys::dpf::ResultInfo::analysisTypeName](classansys_1_1dpf_1_1ResultInfo.xhtml#ac0f80a2ea905a13dccc274790ef6cbc7)

std::string analysisTypeName() const



[ansys::dpf::ResultInfo::unitSystemName](classansys_1_1dpf_1_1ResultInfo.xhtml#ae358df95bebd891adf15148f5b26d21d)

std::string unitSystemName() const



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

**Definition:** dpf_api.h:226



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

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



[ansys::dpf](namespaceansys_1_1dpf.xhtml)

This is the main namespace of the HGP API.

**Definition:** dpf_model.h:11



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

int dp_int

**Definition:** dpf_api_base.h:48



[ansys::dpf::dp\_double](namespaceansys_1_1dpf.xhtml#acb480013bfed185b5e34a0bdcb0e3790)

double dp_double

**Definition:** dpf_api_base.h:54



[ansys::dpf::Dimensionality::ENature](structansys_1_1dpf_1_1Dimensionality.xhtml#af4666dee615e27f2fe603240631b932f)

ENature

**Definition:** dpf_api_base.h:810



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

static const Location nodal

**Definition:** dpf_api_base.h:166