mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3470 Inflow model. New algorithm for calculating averageflow distance
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Internal functions
|
/// Internal functions
|
||||||
@@ -130,6 +130,36 @@ RiaCellDividingTools::createHexCornerCoords(std::array<cvf::Vec3d, 8> mainCellCo
|
|||||||
return coords;
|
return coords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
double RiaCellDividingTools::computeFlowDistance(const std::array<cvf::Vec3d, 8>& cellVertices,
|
||||||
|
const cvf::Vec3d& areaCenter)
|
||||||
|
{
|
||||||
|
auto subCellCorners = createHexCornerCoords(cellVertices, 2, 2, 2);
|
||||||
|
|
||||||
|
double weightedDistanceTotal = 0.0;
|
||||||
|
double weightTotal = 0.0;
|
||||||
|
|
||||||
|
for (size_t c = 0; c < 8; c++)
|
||||||
|
{
|
||||||
|
double weight = 1.0;
|
||||||
|
weightTotal += weight;
|
||||||
|
|
||||||
|
cvf::Vec3d centerOfSubCell = cvf::Vec3d::ZERO;
|
||||||
|
{
|
||||||
|
cvf::Vec3d vertexSum = cvf::Vec3d::ZERO;
|
||||||
|
for (size_t v = 0; v < 8; v++) vertexSum += subCellCorners[c * 8 + v];
|
||||||
|
centerOfSubCell = vertexSum / 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dist = (centerOfSubCell - areaCenter).length();
|
||||||
|
weightedDistanceTotal += (dist * weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
return weightedDistanceTotal / weightTotal;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -32,4 +32,6 @@ class RiaCellDividingTools
|
|||||||
public:
|
public:
|
||||||
static std::vector<cvf::Vec3d>
|
static std::vector<cvf::Vec3d>
|
||||||
createHexCornerCoords(std::array<cvf::Vec3d, 8> mainCellCorners, size_t nx, size_t ny, size_t nz);
|
createHexCornerCoords(std::array<cvf::Vec3d, 8> mainCellCorners, size_t nx, size_t ny, size_t nz);
|
||||||
|
|
||||||
|
static double computeFlowDistance(const std::array<cvf::Vec3d, 8>& cellVertices, const cvf::Vec3d& areaCenter);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifEclipseDataTableFormatter-Test.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedMean-Test.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedMean-Test.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedGeometricMeanCalculator-Test.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedGeometricMeanCalculator-Test.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedHarmonicMeanCalculator-Test.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedHarmonicMeanCalculator-Test.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools-Test.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
|||||||
111
ApplicationCode/UnitTests/RiaCellDividingTools-Test.cpp
Normal file
111
ApplicationCode/UnitTests/RiaCellDividingTools-Test.cpp
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include "RiaCellDividingTools.h"
|
||||||
|
#include "RigMainGrid.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Helper
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::array<cvf::Vec3d, 8> createRegularCellCoords(cvf::Vec3d refPt, double xLen, double yLen, double zLen)
|
||||||
|
{
|
||||||
|
std::array<cvf::Vec3d, 8> coords = {
|
||||||
|
refPt + cvf::Vec3d(0, 0, 0),
|
||||||
|
refPt + cvf::Vec3d(xLen, 0, 0),
|
||||||
|
refPt + cvf::Vec3d(xLen, yLen, 0),
|
||||||
|
refPt + cvf::Vec3d(0, yLen, 0),
|
||||||
|
refPt + cvf::Vec3d(0, 0, zLen),
|
||||||
|
refPt + cvf::Vec3d(xLen, 0, zLen),
|
||||||
|
refPt + cvf::Vec3d(xLen, yLen, zLen),
|
||||||
|
refPt + cvf::Vec3d(0, yLen, zLen),
|
||||||
|
};
|
||||||
|
return coords;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
TEST(RiaCellDividingTools, flowDistanceCubicMainCell_AreaPointInCenter)
|
||||||
|
{
|
||||||
|
std::array<cvf::Vec3d, 8> mainCellCorners = createRegularCellCoords(cvf::Vec3d(10, 10, 10), 10, 10, 10);
|
||||||
|
cvf::Vec3d point(15, 15, 15);
|
||||||
|
|
||||||
|
double dist = RiaCellDividingTools::computeFlowDistance(mainCellCorners, point);
|
||||||
|
|
||||||
|
double expectedDist =
|
||||||
|
(
|
||||||
|
(cvf::Vec3d(12.5, 12.5, 12.5) - point).length() + (cvf::Vec3d(17.5, 12.5, 12.5) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 17.5, 12.5) - point).length() + (cvf::Vec3d(17.5, 17.5, 12.5) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 12.5, 17.5) - point).length() + (cvf::Vec3d(17.5, 12.5, 17.5) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 17.5, 17.5) - point).length() + (cvf::Vec3d(17.5, 17.5, 17.5) - point).length()
|
||||||
|
) / 8;
|
||||||
|
|
||||||
|
EXPECT_NEAR(expectedDist, dist, 1e-6);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
TEST(RiaCellDividingTools, flowDistanceCubicMainCell_AreaPointNearCorner)
|
||||||
|
{
|
||||||
|
std::array<cvf::Vec3d, 8> mainCellCorners = createRegularCellCoords(cvf::Vec3d(10, 10, 10), 10, 10, 10);
|
||||||
|
cvf::Vec3d point(11, 11, 11);
|
||||||
|
|
||||||
|
double dist = RiaCellDividingTools::computeFlowDistance(mainCellCorners, point);
|
||||||
|
|
||||||
|
double expectedDist = ((cvf::Vec3d(12.5, 12.5, 12.5) - point).length() + (cvf::Vec3d(17.5, 12.5, 12.5) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 17.5, 12.5) - point).length() + (cvf::Vec3d(17.5, 17.5, 12.5) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 12.5, 17.5) - point).length() + (cvf::Vec3d(17.5, 12.5, 17.5) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 17.5, 17.5) - point).length() + (cvf::Vec3d(17.5, 17.5, 17.5) - point).length()) /
|
||||||
|
8;
|
||||||
|
|
||||||
|
EXPECT_NEAR(expectedDist, dist, 1e-6);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
TEST(RiaCellDividingTools, flowDistanceHighMainCell_AreaPointNearLowerCorner)
|
||||||
|
{
|
||||||
|
std::array<cvf::Vec3d, 8> mainCellCorners = createRegularCellCoords(cvf::Vec3d(10, 10, 10), 10, 10, 100);
|
||||||
|
cvf::Vec3d point(11, 11, 11);
|
||||||
|
|
||||||
|
double dist = RiaCellDividingTools::computeFlowDistance(mainCellCorners, point);
|
||||||
|
|
||||||
|
double expectedDist = ((cvf::Vec3d(12.5, 12.5, 35) - point).length() + (cvf::Vec3d(17.5, 12.5, 35) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 17.5, 35) - point).length() + (cvf::Vec3d(17.5, 17.5, 35) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 12.5, 85) - point).length() + (cvf::Vec3d(17.5, 12.5, 85) - point).length() +
|
||||||
|
(cvf::Vec3d(12.5, 17.5, 85) - point).length() + (cvf::Vec3d(17.5, 17.5, 85) - point).length()) /
|
||||||
|
8;
|
||||||
|
|
||||||
|
EXPECT_NEAR(expectedDist, dist, 1e-6);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
TEST(RigCellGeometryTools, lgrNodesTest)
|
||||||
|
{
|
||||||
|
std::array<cvf::Vec3d, 8> mainCellCorners = createRegularCellCoords(cvf::Vec3d(10, 10, 10), 36, 18, 18);
|
||||||
|
auto coords = RiaCellDividingTools::createHexCornerCoords(mainCellCorners, 6, 3, 3);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user