#3644 Write unit test for cell volume calculation and fix negative volumes for "flipped" cells.

This commit is contained in:
Gaute Lindkvist
2018-11-08 13:46:57 +01:00
parent 6ed598e40b
commit 25b45fb8fc
2 changed files with 23 additions and 2 deletions

View File

@@ -21,6 +21,27 @@
#include "RigCellGeometryTools.h"
#include "RigMainGrid.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigCellGeometryTools, calculateCellVolumeTest)
{
cvf::BoundingBox bbox(cvf::Vec3d(1.0, -2.0, 5.0), cvf::Vec3d(200.0, 3.0, 1500.0));
cvf::Vec3d extent = bbox.extent();
double bboxVolume = extent.x() * extent.y() * extent.z();
std::array<cvf::Vec3d, 8> cornerVertices;
bbox.cornerVertices(cornerVertices.data());
EXPECT_DOUBLE_EQ(bboxVolume, RigCellGeometryTools::calculateCellVolume(cornerVertices));
cornerVertices[1].x() += 100.0;
cornerVertices[2].x() += 100.0;
double extraVolume = 0.5 * extent.z() * 100 * extent.y();
EXPECT_DOUBLE_EQ(bboxVolume + extraVolume, RigCellGeometryTools::calculateCellVolume(cornerVertices));
}
//--------------------------------------------------------------------------------------------------
///