#3470 Inflow model. New algorithm for calculating averageflow distance

This commit is contained in:
Bjørn Erik Jensen
2018-11-02 09:09:46 +01:00
parent cd61b525a7
commit fa81d0411c
4 changed files with 145 additions and 1 deletions

View File

@@ -21,7 +21,7 @@
#include "cvfAssert.h"
#include <cmath>
#include <limits>
//--------------------------------------------------------------------------------------------------
/// Internal functions
@@ -130,6 +130,36 @@ RiaCellDividingTools::createHexCornerCoords(std::array<cvf::Vec3d, 8> mainCellCo
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------