Refactor: extract fault distance computation

This commit is contained in:
Kristian Bendiksen
2023-04-17 15:41:38 +02:00
parent 5a64e90103
commit be12016128
5 changed files with 161 additions and 59 deletions

View File

@@ -33,6 +33,7 @@
#include "RigEclipseMultiPropertyStatCalc.h"
#include "RigEclipseNativeStatCalc.h"
#include "RigEclipseResultInfo.h"
#include "RigFaultDistanceResultCalculator.h"
#include "RigFormationNames.h"
#include "RigMainGrid.h"
#include "RigSoilResultCalculator.h"
@@ -1906,65 +1907,9 @@ void RigCaseCellResultsData::computeIndexResults()
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::computeFaultDistance()
{
size_t reservoirCellCount = activeCellInfo()->reservoirCellCount();
if ( reservoirCellCount == 0 ) return;
size_t resultIndex = findScalarResultIndexFromAddress(
RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::faultDistanceName() ) );
if ( resultIndex == cvf::UNDEFINED_SIZE_T ) return;
std::vector<std::vector<double>>& result = m_cellScalarResults[resultIndex];
if ( result.empty() ) result.resize( 1 );
bool shouldCompute = false;
if ( result[0].size() < reservoirCellCount )
{
result[0].resize( reservoirCellCount, std::numeric_limits<double>::infinity() );
shouldCompute = true;
}
if ( !shouldCompute ) return;
const std::vector<RigCell>& globalCellArray = m_ownerMainGrid->globalCellArray();
long long numCells = static_cast<long long>( globalCellArray.size() );
std::vector<cvf::StructGridInterface::FaceType> faceTypes = cvf::StructGridInterface::validFaceTypes();
// Preprocessing: create vector of all fault face centers.
std::vector<cvf::Vec3d> faultFaceCenters;
for ( long long cellIdx = 0; cellIdx < numCells; cellIdx++ )
{
if ( activeCellInfo()->isActive( cellIdx ) )
{
const RigCell& cell = globalCellArray[cellIdx];
for ( auto faceType : faceTypes )
{
if ( m_ownerMainGrid->findFaultFromCellIndexAndCellFace( cellIdx, faceType ) )
faultFaceCenters.push_back( cell.faceCenter( faceType ) );
}
}
}
#pragma omp parallel for
for ( long long cellIdx = 0; cellIdx < numCells; cellIdx++ )
{
const RigCell& cell = globalCellArray[cellIdx];
size_t resultIndex = cellIdx;
if ( resultIndex == cvf::UNDEFINED_SIZE_T || !activeCellInfo()->isActive( cellIdx ) ) continue;
// Find closest fault face
double shortestDistance = std::numeric_limits<double>::infinity();
for ( const cvf::Vec3d& faultFaceCenter : faultFaceCenters )
{
shortestDistance = std::min( cell.center().pointDistance( faultFaceCenter ), shortestDistance );
}
result[0][resultIndex] = shortestDistance;
}
RigEclipseResultAddress addr( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::faultDistanceName() );
RigFaultDistanceResultCalculator calculator( *this );
calculator.calculate( addr, 0 );
}
namespace RigTransmissibilityCalcTools