VTK GeoMech: read stress/strain as the rows of a 3x3 tensor

OPM Flow writes each symmetric tensor as three cell arrays
"stress[0]", "stress[1]", "stress[2]", the rows (Si1, Si2, Si3). The
reader took "stress[0]" as (S11, S22, S33) and "stress[1]" as
(S12, S13, S23), so S22, S33 and S13 held the wrong components and
"stress[2]" was ignored. Read the upper triangle from the three rows.

Coordinates are imported with z negated; S13/S23 and E13/E23 now
change sign with it, as U3 already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hnilandClaude Opus 5.5 authored and Kristian Bendiksen committed 2026-10-23 20:27:23 +02:00
1 parent e6dc62a160
commit 03eff53507
3 files changed
+69 -29

No files matched your search

@@ -165,3 +165,36 @@ TEST( RifVtkReaderTest, ReadNodeFieldDisplacement )
EXPECT_NEAR( u3[i], -0.3f, 1e-5f );
}
}
//--------------------------------------------------------------------------------------------------
/// stress[0..2] are the rows of a symmetric tensor; xz and yz change sign with the negated z
//--------------------------------------------------------------------------------------------------
TEST( RifVtkReaderTest, ReadElementFieldStressTensorRows )
{
RifVtkReader reader;
reader.openFile( ( testDataDir() / "model.pvd" ).string(), nullptr );
cvf::ref<RigFemPartCollection> femParts = new RigFemPartCollection();
reader.readFemParts( femParts.p() );
auto elementFields = reader.scalarElementFieldAndComponentNames();
ASSERT_TRUE( elementFields.count( "S_VTK" ) > 0 );
const std::vector<std::string> expectedComponents = { "S11", "S22", "S33", "S12", "S13", "S23" };
EXPECT_EQ( elementFields["S_VTK"], expectedComponents );
std::vector<std::vector<float>> values( 6 );
std::vector<std::vector<float>*> resultValues;
for ( auto& v : values )
resultValues.push_back( &v );
reader.readElementField( "S_VTK", 0, 1, 0, &resultValues );
const std::vector<float> expectedCell0 = { 11, 22, 33, 12, -13, -23 };
const std::vector<float> expectedCell1 = { 111, 122, 133, 112, -113, -123 };
for ( size_t c = 0; c < 6; c++ )
{
ASSERT_EQ( values[c].size(), 2u );
EXPECT_FLOAT_EQ( values[c][0], expectedCell0[c] );
EXPECT_FLOAT_EQ( values[c][1], expectedCell1[c] );
}
}