2023-10-23 16:04:48 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2023 Equinor 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 "RimFaultReactivationDataAccessorTemperature.h"
|
2024-02-14 14:02:05 +01:00
|
|
|
#include "RigFaultReactivationModel.h"
|
2023-10-23 16:04:48 +02:00
|
|
|
#include "RimFaultReactivationEnums.h"
|
|
|
|
|
|
|
|
|
|
#include "RiaDefines.h"
|
|
|
|
|
#include "RiaPorosityModel.h"
|
|
|
|
|
|
|
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
|
#include "RigEclipseResultAddress.h"
|
2024-01-05 14:59:05 +01:00
|
|
|
#include "RigEclipseWellLogExtractor.h"
|
2023-10-23 16:04:48 +02:00
|
|
|
#include "RigMainGrid.h"
|
|
|
|
|
#include "RigResultAccessorFactory.h"
|
2024-01-05 14:59:05 +01:00
|
|
|
#include "RigWellPath.h"
|
2023-10-23 16:04:48 +02:00
|
|
|
|
|
|
|
|
#include "RimEclipseCase.h"
|
2024-01-05 14:59:05 +01:00
|
|
|
#include "RimFaultReactivationDataAccessorWellLogExtraction.h"
|
2023-10-23 16:04:48 +02:00
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-01-05 14:59:05 +01:00
|
|
|
RimFaultReactivationDataAccessorTemperature::RimFaultReactivationDataAccessorTemperature( RimEclipseCase* eclipseCase,
|
|
|
|
|
double seabedTemperature,
|
2024-05-02 09:35:43 +02:00
|
|
|
double seabedDepth,
|
|
|
|
|
size_t firstTimeStep )
|
2023-10-23 16:04:48 +02:00
|
|
|
: m_eclipseCase( eclipseCase )
|
|
|
|
|
, m_caseData( nullptr )
|
|
|
|
|
, m_mainGrid( nullptr )
|
2024-01-05 14:59:05 +01:00
|
|
|
, m_seabedTemperature( seabedTemperature )
|
|
|
|
|
, m_seabedDepth( seabedDepth )
|
2024-05-02 09:35:43 +02:00
|
|
|
, m_firstTimeStep( firstTimeStep )
|
2023-10-23 16:04:48 +02:00
|
|
|
{
|
|
|
|
|
if ( m_eclipseCase )
|
|
|
|
|
{
|
|
|
|
|
m_caseData = m_eclipseCase->eclipseCaseData();
|
|
|
|
|
m_mainGrid = m_eclipseCase->mainGrid();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimFaultReactivationDataAccessorTemperature::~RimFaultReactivationDataAccessorTemperature()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimFaultReactivationDataAccessorTemperature::updateResultAccessor()
|
|
|
|
|
{
|
2024-01-05 14:59:05 +01:00
|
|
|
if ( !m_caseData ) return;
|
|
|
|
|
|
2024-01-10 08:36:26 +01:00
|
|
|
RigEclipseResultAddress resVarAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "TEMP" );
|
2024-01-05 14:59:05 +01:00
|
|
|
m_eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->ensureKnownResultLoaded( resVarAddress );
|
|
|
|
|
m_resultAccessor =
|
|
|
|
|
RigResultAccessorFactory::createFromResultAddress( m_caseData, 0, RiaDefines::PorosityModelType::MATRIX_MODEL, m_timeStep, resVarAddress );
|
|
|
|
|
|
2024-05-02 09:35:43 +02:00
|
|
|
// Only create the first time step accessor once: it is always the same.
|
|
|
|
|
if ( m_resultAccessor0.isNull() )
|
2024-02-15 17:36:38 +01:00
|
|
|
{
|
2024-05-02 09:35:43 +02:00
|
|
|
m_resultAccessor0 = RigResultAccessorFactory::createFromResultAddress( m_caseData,
|
|
|
|
|
0,
|
|
|
|
|
RiaDefines::PorosityModelType::MATRIX_MODEL,
|
|
|
|
|
m_firstTimeStep,
|
|
|
|
|
resVarAddress );
|
|
|
|
|
if ( m_resultAccessor0.notNull() )
|
|
|
|
|
{
|
|
|
|
|
auto [wellPaths, extractors] =
|
|
|
|
|
RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth );
|
|
|
|
|
m_wellPaths = wellPaths;
|
|
|
|
|
m_extractors = extractors;
|
2024-02-14 14:02:05 +01:00
|
|
|
|
2024-05-02 09:35:43 +02:00
|
|
|
m_gradient = computeGradient();
|
|
|
|
|
}
|
2024-02-15 17:36:38 +01:00
|
|
|
}
|
2024-02-14 14:02:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
/// Find the top encounter with reservoir (of the two well paths), and create gradient from that point
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
double RimFaultReactivationDataAccessorTemperature::computeGradient() const
|
|
|
|
|
{
|
|
|
|
|
double gradient = std::numeric_limits<double>::infinity();
|
|
|
|
|
double minDepth = -std::numeric_limits<double>::max();
|
|
|
|
|
for ( auto gridPart : m_model->allGridParts() )
|
|
|
|
|
{
|
|
|
|
|
auto extractor = m_extractors.find( gridPart )->second;
|
|
|
|
|
auto wellPath = m_wellPaths.find( gridPart )->second;
|
|
|
|
|
|
|
|
|
|
auto [values, intersections] =
|
2024-05-02 09:35:43 +02:00
|
|
|
RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor0.p(), *extractor.p(), *wellPath );
|
2024-02-14 14:02:05 +01:00
|
|
|
|
|
|
|
|
int lastOverburdenIndex = RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( values );
|
|
|
|
|
if ( lastOverburdenIndex != -1 )
|
|
|
|
|
{
|
|
|
|
|
double depth = intersections[lastOverburdenIndex].z();
|
|
|
|
|
double value = values[lastOverburdenIndex];
|
|
|
|
|
|
|
|
|
|
if ( !std::isinf( value ) )
|
|
|
|
|
{
|
|
|
|
|
double currentGradient =
|
|
|
|
|
RimFaultReactivationDataAccessorWellLogExtraction::computeGradient( intersections[0].z(),
|
|
|
|
|
m_seabedTemperature,
|
|
|
|
|
intersections[lastOverburdenIndex].z(),
|
|
|
|
|
values[lastOverburdenIndex] );
|
|
|
|
|
if ( !std::isinf( value ) && !std::isnan( currentGradient ) && depth > minDepth )
|
|
|
|
|
{
|
|
|
|
|
gradient = currentGradient;
|
|
|
|
|
minDepth = depth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return gradient;
|
2023-10-23 16:04:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimFaultReactivationDataAccessorTemperature::isMatching( RimFaultReactivation::Property property ) const
|
|
|
|
|
{
|
|
|
|
|
return property == RimFaultReactivation::Property::Temperature;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-12-06 16:00:42 +01:00
|
|
|
double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf::Vec3d& position,
|
|
|
|
|
const RigFaultReactivationModel& model,
|
|
|
|
|
RimFaultReactivation::GridPart gridPart,
|
|
|
|
|
double topDepth,
|
2023-12-08 16:00:20 +01:00
|
|
|
double bottomDepth,
|
|
|
|
|
size_t elementIndex ) const
|
2023-10-23 16:04:48 +02:00
|
|
|
{
|
2024-05-02 09:35:43 +02:00
|
|
|
if ( ( m_mainGrid != nullptr ) && m_resultAccessor.notNull() && m_resultAccessor0.notNull() )
|
2023-10-23 16:04:48 +02:00
|
|
|
{
|
2024-02-14 14:02:05 +01:00
|
|
|
auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position );
|
|
|
|
|
if ( cellIdx != cvf::UNDEFINED_SIZE_T )
|
|
|
|
|
{
|
|
|
|
|
double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx );
|
|
|
|
|
if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 14:59:05 +01:00
|
|
|
CAF_ASSERT( m_extractors.find( gridPart ) != m_extractors.end() );
|
|
|
|
|
auto extractor = m_extractors.find( gridPart )->second;
|
|
|
|
|
|
|
|
|
|
CAF_ASSERT( m_wellPaths.find( gridPart ) != m_wellPaths.end() );
|
|
|
|
|
auto wellPath = m_wellPaths.find( gridPart )->second;
|
|
|
|
|
|
2024-05-02 09:35:43 +02:00
|
|
|
// Use data from first time step when not in reservoir. This ensures that the only difference between the
|
|
|
|
|
// timesteps in the fault-reactivation model is in the reservoir.
|
2024-01-05 14:59:05 +01:00
|
|
|
auto [values, intersections] =
|
2024-05-02 09:35:43 +02:00
|
|
|
RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor0.p(), *extractor.p(), *wellPath );
|
2024-01-05 14:59:05 +01:00
|
|
|
|
|
|
|
|
auto [value, pos] =
|
2024-02-14 14:02:05 +01:00
|
|
|
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, position, m_seabedTemperature, m_gradient );
|
2024-01-05 14:59:05 +01:00
|
|
|
|
|
|
|
|
return value;
|
2023-10-23 16:04:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::numeric_limits<double>::infinity();
|
|
|
|
|
}
|