#4683 clang-format on all files in ApplicationCode

This commit is contained in:
Magne Sjaastad
2019-09-06 10:40:57 +02:00
parent 3a317504bb
commit fe9e567825
2092 changed files with 117952 additions and 111846 deletions

View File

@@ -29,23 +29,25 @@
//==================================================================================================
///
//==================================================================================================
RigCompletionData::RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex, double orderingValue)
: m_wellName(wellName)
, m_cellIndex(cellIndex)
, m_saturation(std::numeric_limits<double>::infinity())
, m_transmissibility(std::numeric_limits<double>::infinity())
, m_diameter(std::numeric_limits<double>::infinity())
, m_kh(std::numeric_limits<double>::infinity())
, m_skinFactor(std::numeric_limits<double>::infinity())
, m_dFactor(std::numeric_limits<double>::infinity())
, m_direction(DIR_UNDEF)
, m_connectionState(OPEN)
, m_count(1)
, m_wpimult(std::numeric_limits<double>::infinity())
, m_isMainBore(false)
, m_completionType(CT_UNDEFINED)
, m_firstOrderingValue(orderingValue)
, m_secondOrderingValue(std::numeric_limits<double>::infinity())
RigCompletionData::RigCompletionData( const QString wellName,
const RigCompletionDataGridCell& cellIndex,
double orderingValue )
: m_wellName( wellName )
, m_cellIndex( cellIndex )
, m_saturation( std::numeric_limits<double>::infinity() )
, m_transmissibility( std::numeric_limits<double>::infinity() )
, m_diameter( std::numeric_limits<double>::infinity() )
, m_kh( std::numeric_limits<double>::infinity() )
, m_skinFactor( std::numeric_limits<double>::infinity() )
, m_dFactor( std::numeric_limits<double>::infinity() )
, m_direction( DIR_UNDEF )
, m_connectionState( OPEN )
, m_count( 1 )
, m_wpimult( std::numeric_limits<double>::infinity() )
, m_isMainBore( false )
, m_completionType( CT_UNDEFINED )
, m_firstOrderingValue( orderingValue )
, m_secondOrderingValue( std::numeric_limits<double>::infinity() )
{
}
@@ -57,34 +59,34 @@ RigCompletionData::~RigCompletionData() {}
//==================================================================================================
///
//==================================================================================================
RigCompletionData::RigCompletionData(const RigCompletionData& other)
RigCompletionData::RigCompletionData( const RigCompletionData& other )
{
copy(*this, other);
copy( *this, other );
}
//==================================================================================================
///
//==================================================================================================
bool RigCompletionData::operator<(const RigCompletionData& other) const
bool RigCompletionData::operator<( const RigCompletionData& other ) const
{
if (m_wellName != other.m_wellName)
if ( m_wellName != other.m_wellName )
{
return (m_wellName < other.m_wellName);
return ( m_wellName < other.m_wellName );
}
if (m_completionType != other.m_completionType)
if ( m_completionType != other.m_completionType )
{
return (m_completionType < other.m_completionType);
return ( m_completionType < other.m_completionType );
}
if (m_firstOrderingValue != other.m_firstOrderingValue)
if ( m_firstOrderingValue != other.m_firstOrderingValue )
{
return (m_firstOrderingValue < other.m_firstOrderingValue);
return ( m_firstOrderingValue < other.m_firstOrderingValue );
}
if (m_secondOrderingValue != other.m_secondOrderingValue)
if ( m_secondOrderingValue != other.m_secondOrderingValue )
{
return (m_secondOrderingValue < other.m_secondOrderingValue);
return ( m_secondOrderingValue < other.m_secondOrderingValue );
}
return m_cellIndex < other.m_cellIndex;
@@ -93,11 +95,11 @@ bool RigCompletionData::operator<(const RigCompletionData& other) const
//==================================================================================================
///
//==================================================================================================
RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other)
RigCompletionData& RigCompletionData::operator=( const RigCompletionData& other )
{
if (this != &other)
if ( this != &other )
{
copy(*this, other);
copy( *this, other );
}
return *this;
}
@@ -105,7 +107,7 @@ RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCompletionData::isPerforationValve(CompletionType type)
bool RigCompletionData::isPerforationValve( CompletionType type )
{
return type == PERFORATION_AICD || type == PERFORATION_ICD || type == PERFORATION_ICV;
}
@@ -113,15 +115,15 @@ bool RigCompletionData::isPerforationValve(CompletionType type)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCompletionData::isValve(CompletionType type)
bool RigCompletionData::isValve( CompletionType type )
{
return isPerforationValve(type) || type == FISHBONES_ICD;
return isPerforationValve( type ) || type == FISHBONES_ICD;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCompletionData::isWsegValveTypes(CompletionType type)
bool RigCompletionData::isWsegValveTypes( CompletionType type )
{
return type == FISHBONES_ICD || type == PERFORATION_ICD || type == PERFORATION_ICV;
}
@@ -129,7 +131,7 @@ bool RigCompletionData::isWsegValveTypes(CompletionType type)
//==================================================================================================
///
//==================================================================================================
void RigCompletionData::setFromFracture(double transmissibility, double skinFactor, double diameter)
void RigCompletionData::setFromFracture( double transmissibility, double skinFactor, double diameter )
{
m_completionType = FRACTURE;
m_transmissibility = transmissibility;
@@ -140,7 +142,7 @@ void RigCompletionData::setFromFracture(double transmissibility, double skinFact
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCompletionData::setSecondOrderingValue(double orderingValue)
void RigCompletionData::setSecondOrderingValue( double orderingValue )
{
m_secondOrderingValue = orderingValue;
}
@@ -148,7 +150,7 @@ void RigCompletionData::setSecondOrderingValue(double orderingValue)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCompletionData::setDiameter(double diameter)
void RigCompletionData::setDiameter( double diameter )
{
m_diameter = diameter;
}
@@ -156,7 +158,7 @@ void RigCompletionData::setDiameter(double diameter)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCompletionData::setTransmissibility(double transmissibility)
void RigCompletionData::setTransmissibility( double transmissibility )
{
m_transmissibility = transmissibility;
}
@@ -164,11 +166,8 @@ void RigCompletionData::setTransmissibility(double transmissibility)
//==================================================================================================
///
//==================================================================================================
void RigCompletionData::setTransAndWPImultBackgroundDataFromFishbone(double transmissibility,
double skinFactor,
double diameter,
CellDirection direction,
bool isMainBore)
void RigCompletionData::setTransAndWPImultBackgroundDataFromFishbone(
double transmissibility, double skinFactor, double diameter, CellDirection direction, bool isMainBore )
{
m_completionType = FISHBONES;
m_transmissibility = transmissibility;
@@ -181,12 +180,8 @@ void RigCompletionData::setTransAndWPImultBackgroundDataFromFishbone(double
//==================================================================================================
///
//==================================================================================================
void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation(double transmissibility,
double skinFactor,
double diameter,
double dFactor,
double kh,
CellDirection direction)
void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation(
double transmissibility, double skinFactor, double diameter, double dFactor, double kh, CellDirection direction )
{
m_completionType = PERFORATION;
m_transmissibility = transmissibility;
@@ -201,11 +196,11 @@ void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation(double
//==================================================================================================
///
//==================================================================================================
void RigCompletionData::setCombinedValuesExplicitTrans(double transmissibility,
double skinFactor,
double diameter,
CellDirection celldirection,
CompletionType completionType)
void RigCompletionData::setCombinedValuesExplicitTrans( double transmissibility,
double skinFactor,
double diameter,
CellDirection celldirection,
CompletionType completionType )
{
m_transmissibility = transmissibility;
m_skinFactor = skinFactor;
@@ -217,11 +212,8 @@ void RigCompletionData::setCombinedValuesExplicitTrans(double transmissi
//==================================================================================================
///
//==================================================================================================
void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpimult,
double skinFactor,
double diameter,
CellDirection celldirection,
CompletionType completionType)
void RigCompletionData::setCombinedValuesImplicitTransWPImult(
double wpimult, double skinFactor, double diameter, CellDirection celldirection, CompletionType completionType )
{
m_wpimult = wpimult;
m_direction = celldirection;
@@ -235,8 +227,8 @@ void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpi
//--------------------------------------------------------------------------------------------------
bool RigCompletionData::isNonDarcyFlow() const
{
if (!isDefaultValue(m_kh)) return true;
if (!isDefaultValue(m_dFactor)) return true;
if ( !isDefaultValue( m_kh ) ) return true;
if ( !isDefaultValue( m_dFactor ) ) return true;
return false;
}
@@ -244,7 +236,7 @@ bool RigCompletionData::isNonDarcyFlow() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCompletionData::setDFactor(double dFactor)
void RigCompletionData::setDFactor( double dFactor )
{
m_dFactor = dFactor;
}
@@ -252,7 +244,7 @@ void RigCompletionData::setDFactor(double dFactor)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCompletionData::setKh(double kh)
void RigCompletionData::setKh( double kh )
{
m_kh = kh;
}
@@ -260,9 +252,9 @@ void RigCompletionData::setKh(double kh)
//==================================================================================================
///
//==================================================================================================
void RigCompletionData::addMetadata(const QString& name, const QString& comment)
void RigCompletionData::addMetadata( const QString& name, const QString& comment )
{
m_metadata.push_back(RigCompletionMetaData(name, comment));
m_metadata.push_back( RigCompletionMetaData( name, comment ) );
}
//==================================================================================================
@@ -276,7 +268,7 @@ double RigCompletionData::defaultValue()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCompletionData::isDefaultValue(double num)
bool RigCompletionData::isDefaultValue( double num )
{
return num == defaultValue();
}
@@ -420,9 +412,9 @@ double RigCompletionData::secondOrderingValue() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCompletionData::setSourcePdmObject(const caf::PdmObject* object)
void RigCompletionData::setSourcePdmObject( const caf::PdmObject* object )
{
m_sourcePdmObject = const_cast<caf::PdmObject*>(object);
m_sourcePdmObject = const_cast<caf::PdmObject*>( object );
}
//--------------------------------------------------------------------------------------------------
@@ -436,7 +428,7 @@ const caf::PdmObject* RigCompletionData::sourcePdmObject() const
//==================================================================================================
///
//==================================================================================================
void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& from)
void RigCompletionData::copy( RigCompletionData& target, const RigCompletionData& from )
{
target.m_metadata = from.m_metadata;
target.m_wellName = from.m_wellName;

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,24 +22,26 @@
#include <QString>
#include <cafPdmPointer.h>
#include <cafPdmObject.h>
#include <cafPdmPointer.h>
#include <vector>
//==================================================================================================
///
///
//==================================================================================================
enum WellConnectionState {
enum WellConnectionState
{
OPEN,
SHUT,
AUTO,
};
//==================================================================================================
///
///
//==================================================================================================
enum CellDirection {
enum CellDirection
{
DIR_I,
DIR_J,
DIR_K,
@@ -47,22 +49,28 @@ enum CellDirection {
};
//==================================================================================================
///
///
//==================================================================================================
struct RigCompletionMetaData {
RigCompletionMetaData(const QString& name, const QString& comment) : name(name), comment(comment) {}
struct RigCompletionMetaData
{
RigCompletionMetaData( const QString& name, const QString& comment )
: name( name )
, comment( comment )
{
}
QString name;
QString comment;
};
//==================================================================================================
///
///
//==================================================================================================
class RigCompletionData
{
public:
enum CompletionType {
enum CompletionType
{
FISHBONES,
FRACTURE,
PERFORATION,
@@ -73,64 +81,53 @@ public:
CT_UNDEFINED
};
RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex, double orderingValue);
RigCompletionData( const QString wellName, const RigCompletionDataGridCell& cellIndex, double orderingValue );
~RigCompletionData();
RigCompletionData(const RigCompletionData& other);
RigCompletionData( const RigCompletionData& other );
bool operator<(const RigCompletionData& other) const;
RigCompletionData& operator=(const RigCompletionData& other);
bool operator<( const RigCompletionData& other ) const;
RigCompletionData& operator=( const RigCompletionData& other );
static bool isPerforationValve( CompletionType type );
static bool isValve( CompletionType type );
static bool isWsegValveTypes( CompletionType type );
static bool isPerforationValve(CompletionType type);
static bool isValve(CompletionType type);
static bool isWsegValveTypes(CompletionType type);
void setFromFracture( double transmissibility, double skinFactor, double diameter );
void setSecondOrderingValue( double orderingValue );
void setDiameter( double diameter );
void setTransmissibility( double transmissibility );
void setFromFracture(double transmissibility, double skinFactor, double diameter);
void setSecondOrderingValue(double orderingValue);
void setDiameter(double diameter);
void setTransmissibility(double transmissibility);
void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility,
double skinFactor,
double diameter,
CellDirection direction,
bool isMainBore);
void setTransAndWPImultBackgroundDataFromFishbone(
double transmissibility, double skinFactor, double diameter, CellDirection direction, bool isMainBore );
void setTransAndWPImultBackgroundDataFromPerforation(double transmissibility,
double skinFactor,
double diameter,
double dFactor,
double kh,
CellDirection direction);
void setTransAndWPImultBackgroundDataFromPerforation(
double transmissibility, double skinFactor, double diameter, double dFactor, double kh, CellDirection direction );
void setCombinedValuesExplicitTrans(double transmissibility,
double skinFactor,
double diameter,
CellDirection celldirection,
CompletionType completionType);
void setCombinedValuesExplicitTrans( double transmissibility,
double skinFactor,
double diameter,
CellDirection celldirection,
CompletionType completionType );
void setCombinedValuesImplicitTransWPImult(double wpimult,
double skinFactor,
double diameter,
CellDirection celldirection,
CompletionType completionType);
void setCombinedValuesImplicitTransWPImult(
double wpimult, double skinFactor, double diameter, CellDirection celldirection, CompletionType completionType );
bool isNonDarcyFlow() const;
void setDFactor(double dFactor);
void setKh(double kh);
bool isNonDarcyFlow() const;
void setDFactor( double dFactor );
void setKh( double kh );
void addMetadata( const QString& name, const QString& comment );
void addMetadata(const QString& name, const QString& comment);
static double defaultValue();
static bool isDefaultValue(double num);
static bool isDefaultValue( double num );
const std::vector<RigCompletionMetaData>& metadata() const;
const QString& wellName() const;
const RigCompletionDataGridCell& completionDataGridCell() const;
WellConnectionState connectionState() const;
double saturation() const;
double transmissibility() const;
double diameter() const; //TODO: should be ft or m
double diameter() const; // TODO: should be ft or m
double kh() const;
double skinFactor() const;
double dFactor() const;
@@ -140,38 +137,38 @@ public:
CompletionType completionType() const;
bool isMainBore() const;
double firstOrderingValue() const;
double secondOrderingValue() const;
double firstOrderingValue() const;
double secondOrderingValue() const;
void setSourcePdmObject(const caf::PdmObject* object);
const caf::PdmObject* sourcePdmObject() const;
void setSourcePdmObject( const caf::PdmObject* object );
const caf::PdmObject* sourcePdmObject() const;
std::vector<RigCompletionMetaData> m_metadata;
std::vector<RigCompletionMetaData> m_metadata;
private:
QString m_wellName;
RigCompletionDataGridCell m_cellIndex;
WellConnectionState m_connectionState;
double m_saturation; //TODO: remove, always use default in Eclipse?
double m_transmissibility;
double m_diameter;
double m_kh; //TODO: Remove, always use default in Eclipse?
double m_skinFactor;
double m_dFactor; //TODO: Remove, always use default in Eclipse?
CellDirection m_direction;
QString m_wellName;
RigCompletionDataGridCell m_cellIndex;
WellConnectionState m_connectionState;
double m_saturation; // TODO: remove, always use default in Eclipse?
double m_transmissibility;
double m_diameter;
double m_kh; // TODO: Remove, always use default in Eclipse?
double m_skinFactor;
double m_dFactor; // TODO: Remove, always use default in Eclipse?
CellDirection m_direction;
bool m_isMainBore; //to use mainbore for Eclipse calculation
bool m_isMainBore; // to use mainbore for Eclipse calculation
size_t m_count; //TODO: Remove, usage replaced by WPImult
double m_wpimult;
size_t m_count; // TODO: Remove, usage replaced by WPImult
double m_wpimult;
CompletionType m_completionType;
CompletionType m_completionType;
double m_firstOrderingValue;
double m_secondOrderingValue;
double m_firstOrderingValue;
double m_secondOrderingValue;
caf::PdmPointer<caf::PdmObject> m_sourcePdmObject;
caf::PdmPointer<caf::PdmObject> m_sourcePdmObject;
private:
static void copy(RigCompletionData& target, const RigCompletionData& from);
static void copy( RigCompletionData& target, const RigCompletionData& from );
};

View File

@@ -24,40 +24,40 @@
///
//--------------------------------------------------------------------------------------------------
RigCompletionDataGridCell::RigCompletionDataGridCell()
: m_globalCellIndex(0)
, m_lgrName("")
, m_gridIndex(0)
, m_localCellIndexI(0)
, m_localCellIndexJ(0)
, m_localCellIndexK(0)
: m_globalCellIndex( 0 )
, m_lgrName( "" )
, m_gridIndex( 0 )
, m_localCellIndexI( 0 )
, m_localCellIndexJ( 0 )
, m_localCellIndexK( 0 )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCompletionDataGridCell::RigCompletionDataGridCell(size_t globalCellIndex, const RigMainGrid* mainGrid)
: m_globalCellIndex(globalCellIndex)
RigCompletionDataGridCell::RigCompletionDataGridCell( size_t globalCellIndex, const RigMainGrid* mainGrid )
: m_globalCellIndex( globalCellIndex )
{
if (mainGrid)
if ( mainGrid )
{
size_t gridLocalCellIndex;
const RigGridBase* grid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(globalCellIndex, &gridLocalCellIndex);
const RigGridBase* grid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( globalCellIndex, &gridLocalCellIndex );
if (grid)
if ( grid )
{
size_t i = 0;
size_t j = 0;
size_t k = 0;
grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k);
grid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k );
m_localCellIndexI = i;
m_localCellIndexJ = j;
m_localCellIndexK = k;
if (grid != mainGrid)
if ( grid != mainGrid )
{
m_lgrName = QString::fromStdString(grid->gridName());
m_lgrName = QString::fromStdString( grid->gridName() );
}
m_gridIndex = grid->gridIndex();
@@ -68,7 +68,7 @@ RigCompletionDataGridCell::RigCompletionDataGridCell(size_t globalCellIndex, con
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCompletionDataGridCell::operator==(const RigCompletionDataGridCell& other) const
bool RigCompletionDataGridCell::operator==( const RigCompletionDataGridCell& other ) const
{
return m_globalCellIndex == other.m_globalCellIndex;
}
@@ -76,13 +76,13 @@ bool RigCompletionDataGridCell::operator==(const RigCompletionDataGridCell& othe
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCompletionDataGridCell::operator<(const RigCompletionDataGridCell& other) const
bool RigCompletionDataGridCell::operator<( const RigCompletionDataGridCell& other ) const
{
if (m_gridIndex != other.m_gridIndex) return m_gridIndex < other.m_gridIndex;
if ( m_gridIndex != other.m_gridIndex ) return m_gridIndex < other.m_gridIndex;
if (m_localCellIndexI != other.m_localCellIndexI) return m_localCellIndexI < other.m_localCellIndexI;
if (m_localCellIndexJ != other.m_localCellIndexJ) return m_localCellIndexJ < other.m_localCellIndexJ;
if (m_localCellIndexK != other.m_localCellIndexK) return m_localCellIndexK < other.m_localCellIndexK;
if ( m_localCellIndexI != other.m_localCellIndexI ) return m_localCellIndexI < other.m_localCellIndexI;
if ( m_localCellIndexJ != other.m_localCellIndexJ ) return m_localCellIndexJ < other.m_localCellIndexJ;
if ( m_localCellIndexK != other.m_localCellIndexK ) return m_localCellIndexK < other.m_localCellIndexK;
return m_globalCellIndex < other.m_globalCellIndex;
}
@@ -124,7 +124,8 @@ size_t RigCompletionDataGridCell::localCellIndexK() const
//--------------------------------------------------------------------------------------------------
QString RigCompletionDataGridCell::oneBasedLocalCellIndexString() const
{
QString text = QString("[%1, %2, %3]").arg(m_localCellIndexI + 1).arg(m_localCellIndexJ + 1).arg(m_localCellIndexK + 1);
QString text =
QString( "[%1, %2, %3]" ).arg( m_localCellIndexI + 1 ).arg( m_localCellIndexJ + 1 ).arg( m_localCellIndexK + 1 );
return text;
}

View File

@@ -30,11 +30,11 @@ class RigCompletionDataGridCell
public:
RigCompletionDataGridCell();
RigCompletionDataGridCell(size_t globalCellIndex, const RigMainGrid* mainGrid);
RigCompletionDataGridCell( size_t globalCellIndex, const RigMainGrid* mainGrid );
bool operator==(const RigCompletionDataGridCell& other) const;
bool operator==( const RigCompletionDataGridCell& other ) const;
bool operator<(const RigCompletionDataGridCell& other) const;
bool operator<( const RigCompletionDataGridCell& other ) const;
size_t globalCellIndex() const;

View File

@@ -42,18 +42,18 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseToStimPlanCalculator::RigEclipseToStimPlanCalculator(const RimEclipseCase* caseToApply,
cvf::Mat4d fractureTransform,
double skinFactor,
double cDarcy,
const RigFractureGrid& fractureGrid,
const RimFracture* fracture)
: m_case(caseToApply)
, m_fractureTransform(fractureTransform)
, m_fractureSkinFactor(skinFactor)
, m_cDarcy(cDarcy)
, m_fractureGrid(fractureGrid)
, m_fracture(fracture)
RigEclipseToStimPlanCalculator::RigEclipseToStimPlanCalculator( const RimEclipseCase* caseToApply,
cvf::Mat4d fractureTransform,
double skinFactor,
double cDarcy,
const RigFractureGrid& fractureGrid,
const RimFracture* fracture )
: m_case( caseToApply )
, m_fractureTransform( fractureTransform )
, m_fractureSkinFactor( skinFactor )
, m_cDarcy( cDarcy )
, m_fractureGrid( fractureGrid )
, m_fracture( fracture )
{
computeValues();
}
@@ -63,27 +63,28 @@ RigEclipseToStimPlanCalculator::RigEclipseToStimPlanCalculator(const RimEclipseC
//--------------------------------------------------------------------------------------------------
void RigEclipseToStimPlanCalculator::computeValues()
{
auto reservoirCellIndicesOpenForFlow = RimFractureContainmentTools::reservoirCellIndicesOpenForFlow(m_case, m_fracture);
auto reservoirCellIndicesOpenForFlow = RimFractureContainmentTools::reservoirCellIndicesOpenForFlow( m_case,
m_fracture );
for (size_t i = 0; i < m_fractureGrid.fractureCells().size(); i++)
for ( size_t i = 0; i < m_fractureGrid.fractureCells().size(); i++ )
{
const RigFractureCell& fractureCell = m_fractureGrid.fractureCells()[i];
if (!fractureCell.hasNonZeroConductivity()) continue;
if ( !fractureCell.hasNonZeroConductivity() ) continue;
RigEclipseToStimPlanCellTransmissibilityCalculator eclToFractureTransCalc(m_case,
m_fractureTransform,
m_fractureSkinFactor,
m_cDarcy,
fractureCell,
reservoirCellIndicesOpenForFlow,
m_fracture);
RigEclipseToStimPlanCellTransmissibilityCalculator eclToFractureTransCalc( m_case,
m_fractureTransform,
m_fractureSkinFactor,
m_cDarcy,
fractureCell,
reservoirCellIndicesOpenForFlow,
m_fracture );
const std::vector<size_t>& fractureCellContributingEclipseCells =
eclToFractureTransCalc.globalIndiciesToContributingEclipseCells();
const std::vector<size_t>& fractureCellContributingEclipseCells = eclToFractureTransCalc
.globalIndiciesToContributingEclipseCells();
if (!fractureCellContributingEclipseCells.empty())
if ( !fractureCellContributingEclipseCells.empty() )
{
m_singleFractureCellCalculators.emplace(i, eclToFractureTransCalc);
m_singleFractureCellCalculators.emplace( i, eclToFractureTransCalc );
}
}
}
@@ -93,32 +94,36 @@ using CellIdxSpace = RigTransmissibilityCondenser::CellAddress;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseToStimPlanCalculator::appendDataToTransmissibilityCondenser(bool useFiniteConductivityInFracture,
RigTransmissibilityCondenser* condenser) const
void RigEclipseToStimPlanCalculator::appendDataToTransmissibilityCondenser( bool useFiniteConductivityInFracture,
RigTransmissibilityCondenser* condenser ) const
{
for (const auto& eclToFractureTransCalc : m_singleFractureCellCalculators)
for ( const auto& eclToFractureTransCalc : m_singleFractureCellCalculators )
{
const std::vector<size_t>& fractureCellContributingEclipseCells =
eclToFractureTransCalc.second.globalIndiciesToContributingEclipseCells();
const std::vector<size_t>& fractureCellContributingEclipseCells = eclToFractureTransCalc.second
.globalIndiciesToContributingEclipseCells();
const std::vector<double>& fractureCellContributingEclipseCellTransmissibilities =
eclToFractureTransCalc.second.contributingEclipseCellTransmissibilities();
size_t stimPlanCellIndex = eclToFractureTransCalc.first;
for (size_t i = 0; i < fractureCellContributingEclipseCells.size(); i++)
for ( size_t i = 0; i < fractureCellContributingEclipseCells.size(); i++ )
{
if (useFiniteConductivityInFracture)
if ( useFiniteConductivityInFracture )
{
condenser->addNeighborTransmissibility({true, CellIdxSpace::ECLIPSE, fractureCellContributingEclipseCells[i]},
{false, CellIdxSpace::STIMPLAN, stimPlanCellIndex},
fractureCellContributingEclipseCellTransmissibilities[i]);
condenser->addNeighborTransmissibility( {true,
CellIdxSpace::ECLIPSE,
fractureCellContributingEclipseCells[i]},
{false, CellIdxSpace::STIMPLAN, stimPlanCellIndex},
fractureCellContributingEclipseCellTransmissibilities[i] );
}
else
{
condenser->addNeighborTransmissibility({true, CellIdxSpace::ECLIPSE, fractureCellContributingEclipseCells[i]},
{true, CellIdxSpace::WELL, 1},
fractureCellContributingEclipseCellTransmissibilities[i]);
condenser->addNeighborTransmissibility( {true,
CellIdxSpace::ECLIPSE,
fractureCellContributingEclipseCells[i]},
{true, CellIdxSpace::WELL, 1},
fractureCellContributingEclipseCellTransmissibilities[i] );
}
}
}
@@ -131,7 +136,7 @@ double RigEclipseToStimPlanCalculator::totalEclipseAreaOpenForFlow() const
{
double area = 0.0;
for (const auto& singleCellCalc : m_singleFractureCellCalculators)
for ( const auto& singleCellCalc : m_singleFractureCellCalculators )
{
double cellArea = singleCellCalc.second.areaOpenForFlow();
@@ -149,18 +154,18 @@ double RigEclipseToStimPlanCalculator::areaWeightedMatrixPermeability() const
RiaWeightedMeanCalculator<double> calc;
{
for (const auto& singleCellCalc : m_singleFractureCellCalculators)
for ( const auto& singleCellCalc : m_singleFractureCellCalculators )
{
const RigEclipseToStimPlanCellTransmissibilityCalculator& calulator = singleCellCalc.second;
const std::vector<double>& areas = calulator.contributingEclipseCellIntersectionAreas();
const std::vector<double>& permeabilities = calulator.contributingEclipseCellPermeabilities();
if (areas.size() == permeabilities.size())
if ( areas.size() == permeabilities.size() )
{
for (size_t i = 0; i < areas.size(); i++)
for ( size_t i = 0; i < areas.size(); i++ )
{
calc.addValueAndWeight(permeabilities[i], areas[i]);
calc.addValueAndWeight( permeabilities[i], areas[i] );
}
}
}
@@ -176,35 +181,35 @@ double RigEclipseToStimPlanCalculator::areaWeightedWidth() const
{
double width = 0.0;
auto ellipseFractureTemplate = dynamic_cast<const RimEllipseFractureTemplate*>(m_fracture->fractureTemplate());
if (ellipseFractureTemplate)
auto ellipseFractureTemplate = dynamic_cast<const RimEllipseFractureTemplate*>( m_fracture->fractureTemplate() );
if ( ellipseFractureTemplate )
{
width = ellipseFractureTemplate->width();
}
auto stimPlanFractureTemplate = dynamic_cast<const RimStimPlanFractureTemplate*>(m_fracture->fractureTemplate());
if (stimPlanFractureTemplate)
auto stimPlanFractureTemplate = dynamic_cast<const RimStimPlanFractureTemplate*>( m_fracture->fractureTemplate() );
if ( stimPlanFractureTemplate )
{
auto widthValues = stimPlanFractureTemplate->widthResultValues();
if (!widthValues.empty())
if ( !widthValues.empty() )
{
RiaWeightedMeanCalculator<double> calc;
for (const auto& singleCellCalc : m_singleFractureCellCalculators)
for ( const auto& singleCellCalc : m_singleFractureCellCalculators )
{
double cellArea = singleCellCalc.second.areaOpenForFlow();
size_t globalStimPlanCellIndex = singleCellCalc.first;
double widthValue = widthValues[globalStimPlanCellIndex];
calc.addValueAndWeight(widthValue, cellArea);
calc.addValueAndWeight( widthValue, cellArea );
}
width = calc.weightedMean();
}
else
{
width = stimPlanFractureTemplate->computeFractureWidth(m_fracture);
width = stimPlanFractureTemplate->computeFractureWidth( m_fracture );
}
}
@@ -218,11 +223,11 @@ double RigEclipseToStimPlanCalculator::areaWeightedConductivity() const
{
RiaWeightedMeanCalculator<double> calc;
for (const auto& singleCellCalc : m_singleFractureCellCalculators)
for ( const auto& singleCellCalc : m_singleFractureCellCalculators )
{
double cellArea = singleCellCalc.second.areaOpenForFlow();
calc.addValueAndWeight(singleCellCalc.second.fractureCell().getConductivityValue(), cellArea);
calc.addValueAndWeight( singleCellCalc.second.fractureCell().getConductivityValue(), cellArea );
}
return calc.weightedMean();
@@ -238,26 +243,26 @@ double RigEclipseToStimPlanCalculator::longestYSectionOpenForFlow() const
double longestRange = 0.0;
for (size_t i = 0; i < m_fractureGrid.iCellCount(); i++)
for ( size_t i = 0; i < m_fractureGrid.iCellCount(); i++ )
{
double currentAggregatedDistanceY = 0.0;
for (size_t j = 0; j < m_fractureGrid.jCellCount(); j++)
for ( size_t j = 0; j < m_fractureGrid.jCellCount(); j++ )
{
size_t globalStimPlanCellIndex = m_fractureGrid.getGlobalIndexFromIJ(i, j);
size_t globalStimPlanCellIndex = m_fractureGrid.getGlobalIndexFromIJ( i, j );
auto calculatorForCell = m_singleFractureCellCalculators.find(globalStimPlanCellIndex);
if (calculatorForCell != m_singleFractureCellCalculators.end())
auto calculatorForCell = m_singleFractureCellCalculators.find( globalStimPlanCellIndex );
if ( calculatorForCell != m_singleFractureCellCalculators.end() )
{
currentAggregatedDistanceY += calculatorForCell->second.fractureCell().cellSizeZ();
}
else
{
longestRange = std::max(longestRange, currentAggregatedDistanceY);
longestRange = std::max( longestRange, currentAggregatedDistanceY );
currentAggregatedDistanceY = 0.0;
}
}
longestRange = std::max(longestRange, currentAggregatedDistanceY);
longestRange = std::max( longestRange, currentAggregatedDistanceY );
}
return longestRange;

View File

@@ -22,7 +22,6 @@
#include "RigEclipseToStimPlanCellTransmissibilityCalculator.h"
#include "cvfMatrix4.h"
#include <map>
@@ -40,15 +39,15 @@ class RimFracture;
class RigEclipseToStimPlanCalculator
{
public:
explicit RigEclipseToStimPlanCalculator(const RimEclipseCase* caseToApply,
cvf::Mat4d fractureTransform,
double skinFactor,
double cDarcy,
const RigFractureGrid& fractureGrid,
const RimFracture* fracture);
explicit RigEclipseToStimPlanCalculator( const RimEclipseCase* caseToApply,
cvf::Mat4d fractureTransform,
double skinFactor,
double cDarcy,
const RigFractureGrid& fractureGrid,
const RimFracture* fracture );
void appendDataToTransmissibilityCondenser(bool useFiniteConductivityInFracture,
RigTransmissibilityCondenser* condenser) const;
void appendDataToTransmissibilityCondenser( bool useFiniteConductivityInFracture,
RigTransmissibilityCondenser* condenser ) const;
// Returns the area intersecting eclipse cells open for flow, from both active and inactive cells
// Truncated parts of the fracture are not included

View File

@@ -45,15 +45,15 @@ RigEclipseToStimPlanCellTransmissibilityCalculator::RigEclipseToStimPlanCellTran
double cDarcy,
const RigFractureCell& stimPlanCell,
const std::set<size_t>& reservoirCellIndicesOpenForFlow,
const RimFracture* fracture)
: m_case(caseToApply)
, m_fractureTransform(fractureTransform)
, m_fractureSkinFactor(skinFactor)
, m_cDarcy(cDarcy)
, m_stimPlanCell(stimPlanCell)
, m_fracture(fracture)
const RimFracture* fracture )
: m_case( caseToApply )
, m_fractureTransform( fractureTransform )
, m_fractureSkinFactor( skinFactor )
, m_cDarcy( cDarcy )
, m_stimPlanCell( stimPlanCell )
, m_fracture( fracture )
{
calculateStimPlanCellsMatrixTransmissibility(reservoirCellIndicesOpenForFlow);
calculateStimPlanCellsMatrixTransmissibility( reservoirCellIndicesOpenForFlow );
}
//--------------------------------------------------------------------------------------------------
@@ -67,7 +67,8 @@ const std::vector<size_t>& RigEclipseToStimPlanCellTransmissibilityCalculator::g
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RigEclipseToStimPlanCellTransmissibilityCalculator::contributingEclipseCellTransmissibilities() const
const std::vector<double>&
RigEclipseToStimPlanCellTransmissibilityCalculator::contributingEclipseCellTransmissibilities() const
{
return m_contributingEclipseCellTransmissibilities;
}
@@ -95,7 +96,7 @@ double RigEclipseToStimPlanCellTransmissibilityCalculator::areaOpenForFlow() con
{
double area = 0.0;
for (const auto& areaForOneEclipseCell : m_contributingEclipseCellAreas)
for ( const auto& areaForOneEclipseCell : m_contributingEclipseCellAreas )
{
area += areaForOneEclipseCell;
}
@@ -117,13 +118,13 @@ const RigFractureCell& RigEclipseToStimPlanCellTransmissibilityCalculator::fract
std::vector<QString> RigEclipseToStimPlanCellTransmissibilityCalculator::requiredResultNames()
{
std::vector<QString> resultNames;
resultNames.push_back("PERMX");
resultNames.push_back("PERMY");
resultNames.push_back("PERMZ");
resultNames.push_back( "PERMX" );
resultNames.push_back( "PERMY" );
resultNames.push_back( "PERMZ" );
resultNames.push_back("DX");
resultNames.push_back("DY");
resultNames.push_back("DZ");
resultNames.push_back( "DX" );
resultNames.push_back( "DY" );
resultNames.push_back( "DZ" );
return resultNames;
}
@@ -134,7 +135,7 @@ std::vector<QString> RigEclipseToStimPlanCellTransmissibilityCalculator::require
std::vector<QString> RigEclipseToStimPlanCellTransmissibilityCalculator::optionalResultNames()
{
std::vector<QString> resultNames;
resultNames.push_back("NTG");
resultNames.push_back( "NTG" );
return resultNames;
}
@@ -143,73 +144,77 @@ std::vector<QString> RigEclipseToStimPlanCellTransmissibilityCalculator::optiona
///
//--------------------------------------------------------------------------------------------------
void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsMatrixTransmissibility(
const std::set<size_t>& reservoirCellIndicesOpenForFlow)
const std::set<size_t>& reservoirCellIndicesOpenForFlow )
{
// Not calculating flow into fracture if stimPlan cell cond value is 0 (assumed to be outside the fracture):
if (m_stimPlanCell.getConductivityValue() < 1e-7) return;
if ( m_stimPlanCell.getConductivityValue() < 1e-7 ) return;
const RigEclipseCaseData* eclipseCaseData = m_case->eclipseCaseData();
RiaDefines::PorosityModelType porosityModel = RiaDefines::MATRIX_MODEL;
cvf::ref<RigResultAccessor> dataAccessObjectDx = createResultAccessor(m_case, "DX");
cvf::ref<RigResultAccessor> dataAccessObjectDy = createResultAccessor(m_case, "DY");
cvf::ref<RigResultAccessor> dataAccessObjectDz = createResultAccessor(m_case, "DZ");
if (dataAccessObjectDx.isNull() || dataAccessObjectDy.isNull() || dataAccessObjectDz.isNull())
cvf::ref<RigResultAccessor> dataAccessObjectDx = createResultAccessor( m_case, "DX" );
cvf::ref<RigResultAccessor> dataAccessObjectDy = createResultAccessor( m_case, "DY" );
cvf::ref<RigResultAccessor> dataAccessObjectDz = createResultAccessor( m_case, "DZ" );
if ( dataAccessObjectDx.isNull() || dataAccessObjectDy.isNull() || dataAccessObjectDz.isNull() )
{
RiaLogging::error("Data for DX/DY/DZ is not complete, and these values are required for export of COMPDAT. Make sure "
"'Preferences->Compute DEPTH Related Properties' is checked.");
RiaLogging::error(
"Data for DX/DY/DZ is not complete, and these values are required for export of COMPDAT. Make sure "
"'Preferences->Compute DEPTH Related Properties' is checked." );
return;
}
cvf::ref<RigResultAccessor> dataAccessObjectPermX = createResultAccessor(m_case, "PERMX");
cvf::ref<RigResultAccessor> dataAccessObjectPermY = createResultAccessor(m_case, "PERMY");
cvf::ref<RigResultAccessor> dataAccessObjectPermZ = createResultAccessor(m_case, "PERMZ");
if (dataAccessObjectPermX.isNull() || dataAccessObjectPermY.isNull() || dataAccessObjectPermZ.isNull())
cvf::ref<RigResultAccessor> dataAccessObjectPermX = createResultAccessor( m_case, "PERMX" );
cvf::ref<RigResultAccessor> dataAccessObjectPermY = createResultAccessor( m_case, "PERMY" );
cvf::ref<RigResultAccessor> dataAccessObjectPermZ = createResultAccessor( m_case, "PERMZ" );
if ( dataAccessObjectPermX.isNull() || dataAccessObjectPermY.isNull() || dataAccessObjectPermZ.isNull() )
{
RiaLogging::error("Data for PERMX/PERMY/PERMZ is not complete, and these values are required for export of COMPDAT.");
RiaLogging::error(
"Data for PERMX/PERMY/PERMZ is not complete, and these values are required for export of COMPDAT." );
return;
}
cvf::ref<RigResultAccessor> dataAccessObjectNTG = createResultAccessor(m_case, "NTG");
cvf::ref<RigResultAccessor> dataAccessObjectNTG = createResultAccessor( m_case, "NTG" );
const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(porosityModel);
const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( porosityModel );
std::vector<cvf::Vec3d> stimPlanPolygonTransformed;
for (cvf::Vec3d v : m_stimPlanCell.getPolygon())
for ( cvf::Vec3d v : m_stimPlanCell.getPolygon() )
{
v.transformPoint(m_fractureTransform);
stimPlanPolygonTransformed.push_back(v);
v.transformPoint( m_fractureTransform );
stimPlanPolygonTransformed.push_back( v );
}
std::vector<size_t> reservoirCellIndices = getPotentiallyFracturedCellsForPolygon(stimPlanPolygonTransformed);
for (size_t reservoirCellIndex : reservoirCellIndices)
std::vector<size_t> reservoirCellIndices = getPotentiallyFracturedCellsForPolygon( stimPlanPolygonTransformed );
for ( size_t reservoirCellIndex : reservoirCellIndices )
{
const RigMainGrid* mainGrid = m_case->eclipseCaseData()->mainGrid();
if (!m_fracture->isEclipseCellOpenForFlow(mainGrid, reservoirCellIndicesOpenForFlow, reservoirCellIndex)) continue;
if ( !m_fracture->isEclipseCellOpenForFlow( mainGrid, reservoirCellIndicesOpenForFlow, reservoirCellIndex ) )
continue;
std::array<cvf::Vec3d, 8> hexCorners;
mainGrid->cellCornerVertices(reservoirCellIndex, hexCorners.data());
mainGrid->cellCornerVertices( reservoirCellIndex, hexCorners.data() );
std::vector<std::vector<cvf::Vec3d>> planeCellPolygons;
bool isPlanIntersected =
RigHexIntersectionTools::planeHexIntersectionPolygons(hexCorners, m_fractureTransform, planeCellPolygons);
if (!isPlanIntersected || planeCellPolygons.empty()) continue;
bool isPlanIntersected = RigHexIntersectionTools::planeHexIntersectionPolygons( hexCorners,
m_fractureTransform,
planeCellPolygons );
if ( !isPlanIntersected || planeCellPolygons.empty() ) continue;
cvf::Vec3d localX;
cvf::Vec3d localY;
cvf::Vec3d localZ;
RigCellGeometryTools::findCellLocalXYZ(hexCorners, localX, localY, localZ);
RigCellGeometryTools::findCellLocalXYZ( hexCorners, localX, localY, localZ );
// Transform planCell polygon(s) and averageZdirection to x/y coordinate system (where fracturePolygon already is located)
cvf::Mat4d invertedTransMatrix = m_fractureTransform.getInverted();
for (std::vector<cvf::Vec3d>& planeCellPolygon : planeCellPolygons)
for ( std::vector<cvf::Vec3d>& planeCellPolygon : planeCellPolygons )
{
for (cvf::Vec3d& v : planeCellPolygon)
for ( cvf::Vec3d& v : planeCellPolygon )
{
v.transformPoint(invertedTransMatrix);
v.transformPoint( invertedTransMatrix );
}
}
@@ -217,17 +222,17 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
cvf::Vec3d areaVector;
std::vector<cvf::Vec3d> stimPlanPolygon = m_stimPlanCell.getPolygon();
for (const std::vector<cvf::Vec3d>& planeCellPolygon : planeCellPolygons)
for ( const std::vector<cvf::Vec3d>& planeCellPolygon : planeCellPolygons )
{
std::vector<std::vector<cvf::Vec3d>> clippedPolygons =
RigCellGeometryTools::intersectPolygons(planeCellPolygon, stimPlanPolygon);
for (const std::vector<cvf::Vec3d>& clippedPolygon : clippedPolygons)
RigCellGeometryTools::intersectPolygons( planeCellPolygon, stimPlanPolygon );
for ( const std::vector<cvf::Vec3d>& clippedPolygon : clippedPolygons )
{
polygonsForStimPlanCellInEclipseCell.push_back(clippedPolygon);
polygonsForStimPlanCellInEclipseCell.push_back( clippedPolygon );
}
}
if (polygonsForStimPlanCellInEclipseCell.empty()) continue;
if ( polygonsForStimPlanCellInEclipseCell.empty() ) continue;
std::vector<double> areaOfFractureParts;
double length;
@@ -236,30 +241,30 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
double Ay = 0.0;
double Az = 0.0;
for (const std::vector<cvf::Vec3d>& fracturePartPolygon : polygonsForStimPlanCellInEclipseCell)
for ( const std::vector<cvf::Vec3d>& fracturePartPolygon : polygonsForStimPlanCellInEclipseCell )
{
areaVector = cvf::GeometryTools::polygonAreaNormal3D(fracturePartPolygon);
areaVector = cvf::GeometryTools::polygonAreaNormal3D( fracturePartPolygon );
double area = areaVector.length();
areaOfFractureParts.push_back(area);
areaOfFractureParts.push_back( area );
length = RigCellGeometryTools::polygonLengthInLocalXdirWeightedByArea(fracturePartPolygon);
lengthXareaOfFractureParts.push_back(length * area);
length = RigCellGeometryTools::polygonLengthInLocalXdirWeightedByArea( fracturePartPolygon );
lengthXareaOfFractureParts.push_back( length * area );
cvf::Plane fracturePlane;
fracturePlane.setFromPointAndNormal(static_cast<cvf::Vec3d>(m_fractureTransform.translation()),
static_cast<cvf::Vec3d>(m_fractureTransform.col(2)));
fracturePlane.setFromPointAndNormal( static_cast<cvf::Vec3d>( m_fractureTransform.translation() ),
static_cast<cvf::Vec3d>( m_fractureTransform.col( 2 ) ) );
Ax += fabs(area * (fracturePlane.normal().dot(localY)));
Ay += fabs(area * (fracturePlane.normal().dot(localX)));
Az += fabs(area * (fracturePlane.normal().dot(localZ)));
Ax += fabs( area * ( fracturePlane.normal().dot( localY ) ) );
Ay += fabs( area * ( fracturePlane.normal().dot( localX ) ) );
Az += fabs( area * ( fracturePlane.normal().dot( localZ ) ) );
}
double fractureArea = 0.0;
for (double area : areaOfFractureParts)
for ( double area : areaOfFractureParts )
fractureArea += area;
double totalAreaXLength = 0.0;
for (double lengtXarea : lengthXareaOfFractureParts)
for ( double lengtXarea : lengthXareaOfFractureParts )
totalAreaXLength += lengtXarea;
double fractureAreaWeightedlength = totalAreaXLength / fractureArea;
@@ -275,7 +280,7 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
const RigCell& cell = mainGrid->globalCellArray()[reservoirCellIndex];
size_t mainGridReservoirIndex = cell.mainGridCellIndex();
if (!activeCellInfo->isActive(mainGridReservoirIndex))
if ( !activeCellInfo->isActive( mainGridReservoirIndex ) )
{
isActive = false;
}
@@ -283,39 +288,54 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
double matrixPermeability = 0.0;
if (isActive)
if ( isActive )
{
double permX = dataAccessObjectPermX->cellScalarGlobIdx(reservoirCellIndex);
double permY = dataAccessObjectPermY->cellScalarGlobIdx(reservoirCellIndex);
double permZ = dataAccessObjectPermZ->cellScalarGlobIdx(reservoirCellIndex);
double permX = dataAccessObjectPermX->cellScalarGlobIdx( reservoirCellIndex );
double permY = dataAccessObjectPermY->cellScalarGlobIdx( reservoirCellIndex );
double permZ = dataAccessObjectPermZ->cellScalarGlobIdx( reservoirCellIndex );
double dx = dataAccessObjectDx->cellScalarGlobIdx(reservoirCellIndex);
double dy = dataAccessObjectDy->cellScalarGlobIdx(reservoirCellIndex);
double dz = dataAccessObjectDz->cellScalarGlobIdx(reservoirCellIndex);
double dx = dataAccessObjectDx->cellScalarGlobIdx( reservoirCellIndex );
double dy = dataAccessObjectDy->cellScalarGlobIdx( reservoirCellIndex );
double dz = dataAccessObjectDz->cellScalarGlobIdx( reservoirCellIndex );
double NTG = 1.0;
if (dataAccessObjectNTG.notNull())
if ( dataAccessObjectNTG.notNull() )
{
NTG = dataAccessObjectNTG->cellScalarGlobIdx(reservoirCellIndex);
NTG = dataAccessObjectNTG->cellScalarGlobIdx( reservoirCellIndex );
}
double transmissibility_X = RigFractureTransmissibilityEquations::matrixToFractureTrans(
permY, NTG, Ay, dx, m_fractureSkinFactor, fractureAreaWeightedlength, m_cDarcy);
double transmissibility_Y = RigFractureTransmissibilityEquations::matrixToFractureTrans(
permX, NTG, Ax, dy, m_fractureSkinFactor, fractureAreaWeightedlength, m_cDarcy);
double transmissibility_Z = RigFractureTransmissibilityEquations::matrixToFractureTrans(
permZ, 1.0, Az, dz, m_fractureSkinFactor, fractureAreaWeightedlength, m_cDarcy);
double transmissibility_X = RigFractureTransmissibilityEquations::matrixToFractureTrans( permY,
NTG,
Ay,
dx,
m_fractureSkinFactor,
fractureAreaWeightedlength,
m_cDarcy );
double transmissibility_Y = RigFractureTransmissibilityEquations::matrixToFractureTrans( permX,
NTG,
Ax,
dy,
m_fractureSkinFactor,
fractureAreaWeightedlength,
m_cDarcy );
double transmissibility_Z = RigFractureTransmissibilityEquations::matrixToFractureTrans( permZ,
1.0,
Az,
dz,
m_fractureSkinFactor,
fractureAreaWeightedlength,
m_cDarcy );
transmissibility = sqrt(transmissibility_X * transmissibility_X + transmissibility_Y * transmissibility_Y +
transmissibility_Z * transmissibility_Z);
transmissibility = sqrt( transmissibility_X * transmissibility_X + transmissibility_Y * transmissibility_Y +
transmissibility_Z * transmissibility_Z );
matrixPermeability = RigFractureTransmissibilityEquations::matrixPermeability(permX, permY, NTG);
matrixPermeability = RigFractureTransmissibilityEquations::matrixPermeability( permX, permY, NTG );
}
m_globalIndiciesToContributingEclipseCells.push_back(reservoirCellIndex);
m_contributingEclipseCellTransmissibilities.push_back(transmissibility);
m_contributingEclipseCellAreas.push_back(fractureArea);
m_contributingEclipseCellPermeabilities.push_back(matrixPermeability);
m_globalIndiciesToContributingEclipseCells.push_back( reservoirCellIndex );
m_contributingEclipseCellTransmissibilities.push_back( transmissibility );
m_contributingEclipseCellAreas.push_back( fractureArea );
m_contributingEclipseCellPermeabilities.push_back( matrixPermeability );
}
}
@@ -323,28 +343,28 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
///
//--------------------------------------------------------------------------------------------------
std::vector<size_t> RigEclipseToStimPlanCellTransmissibilityCalculator::getPotentiallyFracturedCellsForPolygon(
const std::vector<cvf::Vec3d>& polygon) const
const std::vector<cvf::Vec3d>& polygon ) const
{
std::vector<size_t> cellIndices;
const RigMainGrid* mainGrid = m_case->eclipseCaseData()->mainGrid();
if (!mainGrid) return cellIndices;
if ( !mainGrid ) return cellIndices;
cvf::BoundingBox polygonBBox;
for (const cvf::Vec3d& nodeCoord : polygon)
for ( const cvf::Vec3d& nodeCoord : polygon )
{
polygonBBox.add(nodeCoord);
polygonBBox.add( nodeCoord );
}
mainGrid->findIntersectingCells(polygonBBox, &cellIndices);
mainGrid->findIntersectingCells( polygonBBox, &cellIndices );
std::vector<size_t> cellIndicesToLeafCells;
for (const size_t& index : cellIndices)
for ( const size_t& index : cellIndices )
{
const RigCell& cell = mainGrid->globalCellArray()[index];
if (!cell.subGrid())
if ( !cell.subGrid() )
{
cellIndicesToLeafCells.push_back(index);
cellIndicesToLeafCells.push_back( index );
}
}
@@ -355,13 +375,16 @@ std::vector<size_t> RigEclipseToStimPlanCellTransmissibilityCalculator::getPoten
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigResultAccessor>
RigEclipseToStimPlanCellTransmissibilityCalculator::createResultAccessor(const RimEclipseCase* eclipseCase,
const QString& uiResultName)
RigEclipseToStimPlanCellTransmissibilityCalculator::createResultAccessor( const RimEclipseCase* eclipseCase,
const QString& uiResultName )
{
RiaDefines::PorosityModelType porosityModel = RiaDefines::MATRIX_MODEL;
const RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
// Create result accessor object for main grid at time step zero (static result date is always at first time step
return RigResultAccessorFactory::createFromResultAddress(
eclipseCaseData, 0, porosityModel, 0, RigEclipseResultAddress(uiResultName));
return RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
0,
porosityModel,
0,
RigEclipseResultAddress( uiResultName ) );
}

View File

@@ -20,7 +20,6 @@
#include "RiaPorosityModel.h"
#include "cvfMatrix4.h"
#include "cvfObject.h"
@@ -43,13 +42,13 @@ class RimFracture;
class RigEclipseToStimPlanCellTransmissibilityCalculator
{
public:
explicit RigEclipseToStimPlanCellTransmissibilityCalculator(const RimEclipseCase* caseToApply,
cvf::Mat4d fractureTransform,
double skinFactor,
double cDarcy,
const RigFractureCell& stimPlanCell,
const std::set<size_t>& reservoirCellIndicesOpenForFlow,
const RimFracture* fracture);
explicit RigEclipseToStimPlanCellTransmissibilityCalculator( const RimEclipseCase* caseToApply,
cvf::Mat4d fractureTransform,
double skinFactor,
double cDarcy,
const RigFractureCell& stimPlanCell,
const std::set<size_t>& reservoirCellIndicesOpenForFlow,
const RimFracture* fracture );
// These three vectors have the same size
const std::vector<size_t>& globalIndiciesToContributingEclipseCells() const;
@@ -65,14 +64,15 @@ public:
static std::vector<QString> optionalResultNames();
private:
void calculateStimPlanCellsMatrixTransmissibility(const std::set<size_t>& reservoirCellIndicesOpenForFlow);
std::vector<size_t> getPotentiallyFracturedCellsForPolygon(const std::vector<cvf::Vec3d>& polygon) const;
void calculateStimPlanCellsMatrixTransmissibility( const std::set<size_t>& reservoirCellIndicesOpenForFlow );
std::vector<size_t> getPotentiallyFracturedCellsForPolygon( const std::vector<cvf::Vec3d>& polygon ) const;
static cvf::ref<RigResultAccessor> createResultAccessor(const RimEclipseCase* eclipseCase, const QString& uiResultName);
static cvf::ref<RigResultAccessor> createResultAccessor( const RimEclipseCase* eclipseCase,
const QString& uiResultName );
private:
const RimEclipseCase* m_case;
const RimFracture* m_fracture;
const RimEclipseCase* m_case;
const RimFracture* m_fracture;
double m_cDarcy;
double m_fractureSkinFactor;

View File

@@ -1,24 +1,23 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigFractureTransmissibilityEquations.h"
#include "cvfMath.h"
#include "cvfVector2.h"
@@ -27,20 +26,26 @@
const double RigFractureTransmissibilityEquations::EPSILON = 1.0e-9;
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransmissibilityEquations::centerToCenterFractureCellTrans(double conductivityCell1,
double sideLengthParallellTransCell1,
double sideLengthNormalTransCell1,
double conductivityCell2,
double sideLengthParallellTransCell2,
double sideLengthNormalTransCell2,
double cDarcyForRelevantUnit)
double RigFractureTransmissibilityEquations::centerToCenterFractureCellTrans( double conductivityCell1,
double sideLengthParallellTransCell1,
double sideLengthNormalTransCell1,
double conductivityCell2,
double sideLengthParallellTransCell2,
double sideLengthNormalTransCell2,
double cDarcyForRelevantUnit )
{
double transCell1 = centerToEdgeFractureCellTrans(conductivityCell1, sideLengthParallellTransCell1, sideLengthNormalTransCell1, cDarcyForRelevantUnit);
double transCell2 = centerToEdgeFractureCellTrans(conductivityCell2, sideLengthParallellTransCell2, sideLengthNormalTransCell2, cDarcyForRelevantUnit);
double transCell1 = centerToEdgeFractureCellTrans( conductivityCell1,
sideLengthParallellTransCell1,
sideLengthNormalTransCell1,
cDarcyForRelevantUnit );
double transCell2 = centerToEdgeFractureCellTrans( conductivityCell2,
sideLengthParallellTransCell2,
sideLengthNormalTransCell2,
cDarcyForRelevantUnit );
double totalTrans = 1 / ( (1 / transCell1) + (1 / transCell2));
double totalTrans = 1 / ( ( 1 / transCell1 ) + ( 1 / transCell2 ) );
return totalTrans;
}
@@ -48,58 +53,57 @@ double RigFractureTransmissibilityEquations::centerToCenterFractureCellTrans(dou
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransmissibilityEquations::fractureCellToWellRadialTrans(double fractureCellConductivity,
double fractureCellSizeX,
double fractureCellSizeZ,
double wellRadius,
double skinFactor,
double cDarcyForRelevantUnit)
double RigFractureTransmissibilityEquations::fractureCellToWellRadialTrans( double fractureCellConductivity,
double fractureCellSizeX,
double fractureCellSizeZ,
double wellRadius,
double skinFactor,
double cDarcyForRelevantUnit )
{
double ro = 0.14 * cvf::Math::sqrt(
pow(fractureCellSizeX, 2.0) + pow(fractureCellSizeZ, 2));
double ro = 0.14 * cvf::Math::sqrt( pow( fractureCellSizeX, 2.0 ) + pow( fractureCellSizeZ, 2 ) );
if (ro < (wellRadius * 1.01))
if ( ro < ( wellRadius * 1.01 ) )
{
ro = wellRadius * 1.01;
}
double Tc = 2 * cvf::PI_D * cDarcyForRelevantUnit * fractureCellConductivity /
(log(ro / wellRadius) + skinFactor );
( log( ro / wellRadius ) + skinFactor );
CVF_TIGHT_ASSERT(Tc > 0);
CVF_TIGHT_ASSERT( Tc > 0 );
return Tc;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransmissibilityEquations::fractureCellToWellLinearTrans(double fractureConductivity,
double fractureCellSizeX,
double fractureCellSizeZ,
double perforationLengthVertical,
double perforationLengthHorizontal,
double perforationEfficiency,
double skinfactor,
double cDarcyForRelevantUnit,
double wellRadius)
double RigFractureTransmissibilityEquations::fractureCellToWellLinearTrans( double fractureConductivity,
double fractureCellSizeX,
double fractureCellSizeZ,
double perforationLengthVertical,
double perforationLengthHorizontal,
double perforationEfficiency,
double skinfactor,
double cDarcyForRelevantUnit,
double wellRadius )
{
const double invalidTrans = 1.0e9;
const double epsilon = 1.0e-8;
double TcPrefix = 8 * cDarcyForRelevantUnit * fractureConductivity;
cvf::Vec2d wellOrientation = cvf::Vec2d(perforationLengthHorizontal, perforationLengthVertical).getNormalized();
cvf::Vec2d wellOrientation = cvf::Vec2d( perforationLengthHorizontal, perforationLengthVertical ).getNormalized();
cvf::Vec2d wellRadialVector = wellOrientation.perpendicularVector() * wellRadius;
double DzPerf = perforationLengthVertical * perforationEfficiency;
double DzPerf = perforationLengthVertical * perforationEfficiency;
double DxPerf = perforationLengthHorizontal * perforationEfficiency;
double TcZ = 0.0;
if (DzPerf > epsilon)
if ( DzPerf > epsilon )
{
double effectiveFlowLengthHorizontal = fractureCellSizeX - 4.0 * std::abs(wellRadialVector.x());
double denominatorZ = effectiveFlowLengthHorizontal + skinfactor * DzPerf / cvf::PI_D;
if (denominatorZ < epsilon)
double effectiveFlowLengthHorizontal = fractureCellSizeX - 4.0 * std::abs( wellRadialVector.x() );
double denominatorZ = effectiveFlowLengthHorizontal + skinfactor * DzPerf / cvf::PI_D;
if ( denominatorZ < epsilon )
{
return invalidTrans;
}
@@ -107,57 +111,56 @@ double RigFractureTransmissibilityEquations::fractureCellToWellLinearTrans(doubl
}
double TcX = 0.0;
if (DxPerf > epsilon)
if ( DxPerf > epsilon )
{
double effectiveFlowLengthVertical = fractureCellSizeZ - 4.0 * std::abs(wellRadialVector.y());
double denominatorX = effectiveFlowLengthVertical + skinfactor * DxPerf / cvf::PI_D;
if (denominatorX < epsilon)
double effectiveFlowLengthVertical = fractureCellSizeZ - 4.0 * std::abs( wellRadialVector.y() );
double denominatorX = effectiveFlowLengthVertical + skinfactor * DxPerf / cvf::PI_D;
if ( denominatorX < epsilon )
{
return invalidTrans;
}
TcX = TcPrefix * DxPerf / denominatorX;
}
double Tc = cvf::Math::sqrt(pow(TcX, 2) + pow(TcZ, 2));
double Tc = cvf::Math::sqrt( pow( TcX, 2 ) + pow( TcZ, 2 ) );
return Tc;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransmissibilityEquations::matrixToFractureTrans(double perm,
double NTG,
double A,
double cellSizeLength,
double skinfactor,
double fractureAreaWeightedlength,
double cDarcy)
double RigFractureTransmissibilityEquations::matrixToFractureTrans( double perm,
double NTG,
double A,
double cellSizeLength,
double skinfactor,
double fractureAreaWeightedlength,
double cDarcy )
{
double transmissibility;
double slDivPi = 0.0;
if ( cvf::Math::abs(skinfactor) > EPSILON)
if ( cvf::Math::abs( skinfactor ) > EPSILON )
{
slDivPi = (skinfactor * fractureAreaWeightedlength) / cvf::PI_D;
slDivPi = ( skinfactor * fractureAreaWeightedlength ) / cvf::PI_D;
}
transmissibility = 8 * cDarcy * (perm * NTG) * A / (cellSizeLength + slDivPi);
transmissibility = 8 * cDarcy * ( perm * NTG ) * A / ( cellSizeLength + slDivPi );
CVF_ASSERT(transmissibility == transmissibility);
CVF_ASSERT( transmissibility == transmissibility );
return transmissibility;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransmissibilityEquations::effectiveInternalFractureToWellTransPDDHC(double sumScaledMatrixToFractureTrans,
double scaledMatrixToWellTrans)
double RigFractureTransmissibilityEquations::effectiveInternalFractureToWellTransPDDHC(
double sumScaledMatrixToFractureTrans, double scaledMatrixToWellTrans )
{
double divisor = sumScaledMatrixToFractureTrans - scaledMatrixToWellTrans;
if (cvf::Math::abs(divisor) > EPSILON)
if ( cvf::Math::abs( divisor ) > EPSILON )
{
return (sumScaledMatrixToFractureTrans * scaledMatrixToWellTrans) / divisor;
return ( sumScaledMatrixToFractureTrans * scaledMatrixToWellTrans ) / divisor;
}
return 0.0;
}
@@ -165,37 +168,36 @@ double RigFractureTransmissibilityEquations::effectiveInternalFractureToWellTran
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransmissibilityEquations::effectiveMatrixToWellTransPDDHC(double sumOriginalMatrixToFractureTrans,
double effectiveInternalFractureToWellTrans)
double RigFractureTransmissibilityEquations::effectiveMatrixToWellTransPDDHC( double sumOriginalMatrixToFractureTrans,
double effectiveInternalFractureToWellTrans )
{
double divisor = sumOriginalMatrixToFractureTrans + effectiveInternalFractureToWellTrans;
if (cvf::Math::abs(divisor) > EPSILON)
if ( cvf::Math::abs( divisor ) > EPSILON )
{
return (sumOriginalMatrixToFractureTrans * effectiveInternalFractureToWellTrans) / divisor;
return ( sumOriginalMatrixToFractureTrans * effectiveInternalFractureToWellTrans ) / divisor;
}
return 0.0;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransmissibilityEquations::matrixPermeability(double permx, double permy, double NTG)
double RigFractureTransmissibilityEquations::matrixPermeability( double permx, double permy, double NTG )
{
double permxy = cvf::Math::sqrt(permx * permy);
double permxy = cvf::Math::sqrt( permx * permy );
return permxy * NTG;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransmissibilityEquations::centerToEdgeFractureCellTrans(double conductivity,
double sideLengthParallellTrans,
double sideLengthNormalTrans,
double cDarcyForRelevantUnit)
double RigFractureTransmissibilityEquations::centerToEdgeFractureCellTrans( double conductivity,
double sideLengthParallellTrans,
double sideLengthNormalTrans,
double cDarcyForRelevantUnit )
{
double transmissibility = cDarcyForRelevantUnit * conductivity * sideLengthNormalTrans / (sideLengthParallellTrans / 2);
double transmissibility = cDarcyForRelevantUnit * conductivity * sideLengthNormalTrans /
( sideLengthParallellTrans / 2 );
return transmissibility;
}

View File

@@ -24,52 +24,52 @@
class RigFractureTransmissibilityEquations
{
public:
static double centerToCenterFractureCellTrans(double conductivityCell1,
double sideLengthParallellTransCell1,
double sideLengthNormalTransCell1,
double conductivityCell2,
double sideLengthParallellTransCell2,
double sideLengthNormalTransCell2,
double cDarcyForRelevantUnit);
static double centerToCenterFractureCellTrans( double conductivityCell1,
double sideLengthParallellTransCell1,
double sideLengthNormalTransCell1,
double conductivityCell2,
double sideLengthParallellTransCell2,
double sideLengthNormalTransCell2,
double cDarcyForRelevantUnit );
static double fractureCellToWellRadialTrans(double fractureCellConductivity,
double fractureCellSizeX,
double fractureCellSizeZ,
double wellRadius,
double skinFactor,
double cDarcyForRelevantUnit);
static double fractureCellToWellRadialTrans( double fractureCellConductivity,
double fractureCellSizeX,
double fractureCellSizeZ,
double wellRadius,
double skinFactor,
double cDarcyForRelevantUnit );
static double fractureCellToWellLinearTrans(double fractureConductivity,
double fractureCellSizeX,
double fractureCellSizeZ,
double perforationLengthVertical,
double perforationLengthHorizontal,
double perforationEfficiency,
double skinfactor,
double cDarcyForRelevantUnit,
double wellRadius);
static double fractureCellToWellLinearTrans( double fractureConductivity,
double fractureCellSizeX,
double fractureCellSizeZ,
double perforationLengthVertical,
double perforationLengthHorizontal,
double perforationEfficiency,
double skinfactor,
double cDarcyForRelevantUnit,
double wellRadius );
static double matrixToFractureTrans(double permX,
double NTG,
double Ay,
double dx,
double skinfactor,
double fractureAreaWeightedlength,
double cDarcy);
static double matrixToFractureTrans( double permX,
double NTG,
double Ay,
double dx,
double skinfactor,
double fractureAreaWeightedlength,
double cDarcy );
static double effectiveInternalFractureToWellTransPDDHC(double sumScaledMatrixToFractureTrans,
double scaledMatrixToWellTrans);
static double effectiveInternalFractureToWellTransPDDHC( double sumScaledMatrixToFractureTrans,
double scaledMatrixToWellTrans );
static double effectiveMatrixToWellTransPDDHC(double sumOriginalMatrixToFractureTrans,
double effectiveInternalFractureToWellTrans);
static double effectiveMatrixToWellTransPDDHC( double sumOriginalMatrixToFractureTrans,
double effectiveInternalFractureToWellTrans );
static double matrixPermeability(double permx, double permy, double NTG);
static double matrixPermeability( double permx, double permy, double NTG );
private:
static double centerToEdgeFractureCellTrans(double conductivity,
double sideLengthParallellTrans,
double sideLengthNormalTrans,
double cDarcyForRelevantUnit);
static double centerToEdgeFractureCellTrans( double conductivity,
double sideLengthParallellTrans,
double sideLengthNormalTrans,
double cDarcyForRelevantUnit );
private:
static const double EPSILON;

View File

@@ -18,7 +18,6 @@
#include "RigPerforationTransmissibilityEquations.h"
#include "cvfMath.h"
#include <cmath>
@@ -28,14 +27,14 @@ const double RigPerforationTransmissibilityEquations::EPSILON = 1.0e-9;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigPerforationTransmissibilityEquations::betaFactor(double intertialCoefficient,
double effectivePermeability,
double permeabilityScalingFactor,
double porosity,
double porosityScalingFactor)
double RigPerforationTransmissibilityEquations::betaFactor( double intertialCoefficient,
double effectivePermeability,
double permeabilityScalingFactor,
double porosity,
double porosityScalingFactor )
{
const double scaledEffectivePermeability = std::pow(effectivePermeability, permeabilityScalingFactor);
const double scaledPorosity = std::pow(porosity, porosityScalingFactor);
const double scaledEffectivePermeability = std::pow( effectivePermeability, permeabilityScalingFactor );
const double scaledPorosity = std::pow( porosity, porosityScalingFactor );
return intertialCoefficient * scaledEffectivePermeability * scaledPorosity;
}
@@ -43,13 +42,13 @@ double RigPerforationTransmissibilityEquations::betaFactor(double intertialCoeff
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigPerforationTransmissibilityEquations::dFactor(double unitConstant,
double betaFactor,
double effectivePermeability,
double perforationLengthInCell,
double wellRadius,
double gasDenity,
double gasViscosity)
double RigPerforationTransmissibilityEquations::dFactor( double unitConstant,
double betaFactor,
double effectivePermeability,
double perforationLengthInCell,
double wellRadius,
double gasDenity,
double gasViscosity )
{
// clang-format off
//

View File

@@ -24,19 +24,19 @@
class RigPerforationTransmissibilityEquations
{
public:
static double betaFactor(double intertialCoefficient,
double effectivePermeability,
double permeabilityScalingFactor,
double porosity,
double porosityScalingFactor);
static double betaFactor( double intertialCoefficient,
double effectivePermeability,
double permeabilityScalingFactor,
double porosity,
double porosityScalingFactor );
static double dFactor(double unitConstant,
double betaFactor,
double effectivePermeability,
double perforationLengthInCell,
double wellRadius,
double gasDensity,
double gasViscosity);
static double dFactor( double unitConstant,
double betaFactor,
double effectivePermeability,
double perforationLengthInCell,
double wellRadius,
double gasDensity,
double gasViscosity );
private:
static const double EPSILON;

View File

@@ -1,27 +1,27 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigTransmissibilityCondenser.h"
#include "RigActiveCellInfo.h"
#include "RigFractureTransmissibilityEquations.h"
#include "RiaLogging.h"
#include "RiaWeightedMeanCalculator.h"
#include "RigActiveCellInfo.h"
#include "RigFractureTransmissibilityEquations.h"
#include "cvfAssert.h"
@@ -36,27 +36,24 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigTransmissibilityCondenser::RigTransmissibilityCondenser()
{
}
RigTransmissibilityCondenser::RigTransmissibilityCondenser() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigTransmissibilityCondenser::RigTransmissibilityCondenser(const RigTransmissibilityCondenser& copyFrom)
: m_neighborTransmissibilities(copyFrom.m_neighborTransmissibilities)
, m_condensedTransmissibilities(copyFrom.m_condensedTransmissibilities)
, m_externalCellAddrSet(copyFrom.m_externalCellAddrSet)
, m_TiiInv(copyFrom.m_TiiInv)
, m_Tie(copyFrom.m_Tie)
RigTransmissibilityCondenser::RigTransmissibilityCondenser( const RigTransmissibilityCondenser& copyFrom )
: m_neighborTransmissibilities( copyFrom.m_neighborTransmissibilities )
, m_condensedTransmissibilities( copyFrom.m_condensedTransmissibilities )
, m_externalCellAddrSet( copyFrom.m_externalCellAddrSet )
, m_TiiInv( copyFrom.m_TiiInv )
, m_Tie( copyFrom.m_Tie )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigTransmissibilityCondenser& RigTransmissibilityCondenser::operator=(const RigTransmissibilityCondenser& rhs)
RigTransmissibilityCondenser& RigTransmissibilityCondenser::operator=( const RigTransmissibilityCondenser& rhs )
{
m_neighborTransmissibilities = rhs.m_neighborTransmissibilities;
m_condensedTransmissibilities = rhs.m_condensedTransmissibilities;
@@ -67,11 +64,13 @@ RigTransmissibilityCondenser& RigTransmissibilityCondenser::operator=(const RigT
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigTransmissibilityCondenser::addNeighborTransmissibility(CellAddress cell1, CellAddress cell2, double transmissibility)
void RigTransmissibilityCondenser::addNeighborTransmissibility( CellAddress cell1,
CellAddress cell2,
double transmissibility )
{
if (transmissibility < 1e-9) return;
if ( transmissibility < 1e-9 ) return;
m_condensedTransmissibilities.clear();
m_externalCellAddrSet.clear();
@@ -82,11 +81,11 @@ void RigTransmissibilityCondenser::addNeighborTransmissibility(CellAddress cell1
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::set<RigTransmissibilityCondenser::CellAddress> RigTransmissibilityCondenser::externalCells()
{
if (m_externalCellAddrSet.empty())
if ( m_externalCellAddrSet.empty() )
{
calculateCondensedTransmissibilities();
}
@@ -95,23 +94,23 @@ std::set<RigTransmissibilityCondenser::CellAddress> RigTransmissibilityCondenser
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigTransmissibilityCondenser::condensedTransmissibility(CellAddress externalCell1, CellAddress externalCell2)
double RigTransmissibilityCondenser::condensedTransmissibility( CellAddress externalCell1, CellAddress externalCell2 )
{
CAF_ASSERT(!(externalCell1 == externalCell2));
CAF_ASSERT( !( externalCell1 == externalCell2 ) );
if (m_condensedTransmissibilities.empty())
if ( m_condensedTransmissibilities.empty() )
{
calculateCondensedTransmissibilities();
}
if ( externalCell2 < externalCell1 ) std::swap(externalCell1, externalCell2);
if ( externalCell2 < externalCell1 ) std::swap( externalCell1, externalCell2 );
const auto& adrToAdrTransMapPair = m_condensedTransmissibilities.find(externalCell1);
const auto& adrToAdrTransMapPair = m_condensedTransmissibilities.find( externalCell1 );
if ( adrToAdrTransMapPair != m_condensedTransmissibilities.end() )
{
const auto& adrTransPair = adrToAdrTransMapPair->second.find(externalCell2);
const auto& adrTransPair = adrToAdrTransMapPair->second.find( externalCell2 );
if ( adrTransPair != adrToAdrTransMapPair->second.end() )
{
return adrTransPair->second;
@@ -123,53 +122,58 @@ double RigTransmissibilityCondenser::condensedTransmissibility(CellAddress exter
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<size_t, double> RigTransmissibilityCondenser::scaleMatrixToFracTransByMatrixWellDP(
const RigActiveCellInfo* actCellInfo, double currentWellPressure, const std::vector<double>& currentMatrixPressures,
double* minPressureDrop, double* maxPressureDrop)
std::map<size_t, double>
RigTransmissibilityCondenser::scaleMatrixToFracTransByMatrixWellDP( const RigActiveCellInfo* actCellInfo,
double currentWellPressure,
const std::vector<double>& currentMatrixPressures,
double* minPressureDrop,
double* maxPressureDrop )
{
std::map<size_t, double> originalLumpedMatrixToFractureTrans; // Sum(T_mf)
double epsilonDeltaPressure = 1.0e-6;
double minNonZeroDeltaPressure = std::numeric_limits<double>::infinity();
double minNonZeroDeltaPressure = std::numeric_limits<double>::infinity();
double maxNonZeroDeltaPressure = -std::numeric_limits<double>::infinity();
for (auto it = m_neighborTransmissibilities.begin(); it != m_neighborTransmissibilities.end(); ++it)
for ( auto it = m_neighborTransmissibilities.begin(); it != m_neighborTransmissibilities.end(); ++it )
{
if (it->first.m_cellIndexSpace == CellAddress::STIMPLAN)
if ( it->first.m_cellIndexSpace == CellAddress::STIMPLAN )
{
for (auto jt = it->second.begin(); jt != it->second.end(); ++jt)
for ( auto jt = it->second.begin(); jt != it->second.end(); ++jt )
{
if (jt->first.m_cellIndexSpace == CellAddress::ECLIPSE)
if ( jt->first.m_cellIndexSpace == CellAddress::ECLIPSE )
{
size_t globalMatrixCellIdx = jt->first.m_globalCellIdx;
size_t eclipseResultIndex = actCellInfo->cellResultIndex(globalMatrixCellIdx);
CVF_ASSERT(eclipseResultIndex < currentMatrixPressures.size());
double unsignedDeltaPressure = std::abs(currentMatrixPressures[eclipseResultIndex] - currentWellPressure);
double nonZeroDeltaPressure = std::max(epsilonDeltaPressure, unsignedDeltaPressure);
maxNonZeroDeltaPressure = std::max(maxNonZeroDeltaPressure, nonZeroDeltaPressure);
minNonZeroDeltaPressure = std::min(minNonZeroDeltaPressure, nonZeroDeltaPressure);
size_t eclipseResultIndex = actCellInfo->cellResultIndex( globalMatrixCellIdx );
CVF_ASSERT( eclipseResultIndex < currentMatrixPressures.size() );
double unsignedDeltaPressure = std::abs( currentMatrixPressures[eclipseResultIndex] -
currentWellPressure );
double nonZeroDeltaPressure = std::max( epsilonDeltaPressure, unsignedDeltaPressure );
maxNonZeroDeltaPressure = std::max( maxNonZeroDeltaPressure, nonZeroDeltaPressure );
minNonZeroDeltaPressure = std::min( minNonZeroDeltaPressure, nonZeroDeltaPressure );
}
}
}
}
for (auto it = m_neighborTransmissibilities.begin(); it != m_neighborTransmissibilities.end(); ++it)
for ( auto it = m_neighborTransmissibilities.begin(); it != m_neighborTransmissibilities.end(); ++it )
{
if (it->first.m_cellIndexSpace == CellAddress::STIMPLAN)
if ( it->first.m_cellIndexSpace == CellAddress::STIMPLAN )
{
for (auto jt = it->second.begin(); jt != it->second.end(); ++jt)
for ( auto jt = it->second.begin(); jt != it->second.end(); ++jt )
{
if (jt->first.m_cellIndexSpace == CellAddress::ECLIPSE)
if ( jt->first.m_cellIndexSpace == CellAddress::ECLIPSE )
{
size_t globalMatrixCellIdx = jt->first.m_globalCellIdx;
size_t eclipseResultIndex = actCellInfo->cellResultIndex(globalMatrixCellIdx);
CVF_ASSERT(eclipseResultIndex < currentMatrixPressures.size());
size_t eclipseResultIndex = actCellInfo->cellResultIndex( globalMatrixCellIdx );
CVF_ASSERT( eclipseResultIndex < currentMatrixPressures.size() );
originalLumpedMatrixToFractureTrans[globalMatrixCellIdx] += jt->second;
double unsignedDeltaPressure = std::abs(currentMatrixPressures[eclipseResultIndex] - currentWellPressure);
double nonZeroDeltaPressure = std::max(epsilonDeltaPressure, unsignedDeltaPressure);
double unsignedDeltaPressure = std::abs( currentMatrixPressures[eclipseResultIndex] -
currentWellPressure );
double nonZeroDeltaPressure = std::max( epsilonDeltaPressure, unsignedDeltaPressure );
jt->second *= nonZeroDeltaPressure / maxNonZeroDeltaPressure;
}
@@ -177,11 +181,11 @@ std::map<size_t, double> RigTransmissibilityCondenser::scaleMatrixToFracTransByM
}
}
if (minPressureDrop && minNonZeroDeltaPressure != std::numeric_limits<double>::infinity())
if ( minPressureDrop && minNonZeroDeltaPressure != std::numeric_limits<double>::infinity() )
{
*minPressureDrop = minNonZeroDeltaPressure;
}
if (maxPressureDrop && maxNonZeroDeltaPressure != std::numeric_limits<double>::infinity())
if ( maxPressureDrop && maxNonZeroDeltaPressure != std::numeric_limits<double>::infinity() )
{
*maxPressureDrop = maxNonZeroDeltaPressure;
}
@@ -195,13 +199,13 @@ std::map<size_t, double> RigTransmissibilityCondenser::scaleMatrixToFracTransByM
std::map<size_t, double> RigTransmissibilityCondenser::calculateFicticiousFractureToWellTransmissibilities()
{
std::map<size_t, double> matrixToAllFracturesTrans;
for (auto it = m_neighborTransmissibilities.begin(); it != m_neighborTransmissibilities.end(); ++it)
for ( auto it = m_neighborTransmissibilities.begin(); it != m_neighborTransmissibilities.end(); ++it )
{
if (it->first.m_cellIndexSpace == CellAddress::STIMPLAN)
if ( it->first.m_cellIndexSpace == CellAddress::STIMPLAN )
{
for (auto jt = it->second.begin(); jt != it->second.end(); ++jt)
for ( auto jt = it->second.begin(); jt != it->second.end(); ++jt )
{
if (jt->first.m_cellIndexSpace == CellAddress::ECLIPSE)
if ( jt->first.m_cellIndexSpace == CellAddress::ECLIPSE )
{
size_t globalMatrixCellIdx = jt->first.m_globalCellIdx;
// T'_mf
@@ -214,20 +218,22 @@ std::map<size_t, double> RigTransmissibilityCondenser::calculateFicticiousFractu
}
std::map<size_t, double> fictitiousFractureToWellTrans; // T'_fjw
for (const CellAddress& externalCell : m_externalCellAddrSet)
for ( const CellAddress& externalCell : m_externalCellAddrSet )
{
if (externalCell.m_cellIndexSpace == CellAddress::ECLIPSE)
if ( externalCell.m_cellIndexSpace == CellAddress::ECLIPSE )
{
size_t globalMatrixCellIdx = externalCell.m_globalCellIdx;
// Sum(T'_mf)
double scaledMatrixToFractureTrans = matrixToAllFracturesTrans[globalMatrixCellIdx];
// T'mw
double scaledMatrixToWellTrans =
condensedTransmissibility(externalCell, {true, RigTransmissibilityCondenser::CellAddress::WELL, 1});
double scaledMatrixToWellTrans = condensedTransmissibility( externalCell,
{true,
RigTransmissibilityCondenser::CellAddress::WELL,
1} );
// T'_fjw
fictitiousFractureToWellTrans[globalMatrixCellIdx] =
RigFractureTransmissibilityEquations::effectiveInternalFractureToWellTransPDDHC(scaledMatrixToFractureTrans,
scaledMatrixToWellTrans);
RigFractureTransmissibilityEquations::effectiveInternalFractureToWellTransPDDHC( scaledMatrixToFractureTrans,
scaledMatrixToWellTrans );
}
}
return fictitiousFractureToWellTrans;
@@ -238,66 +244,66 @@ std::map<size_t, double> RigTransmissibilityCondenser::calculateFicticiousFractu
//--------------------------------------------------------------------------------------------------
std::map<size_t, double> RigTransmissibilityCondenser::calculateEffectiveMatrixToWellTransmissibilities(
const std::map<size_t, double>& originalLumpedMatrixToFractureTrans,
const std::map<size_t, double>& ficticuousFractureToWellTransMap)
const std::map<size_t, double>& ficticuousFractureToWellTransMap )
{
std::map<size_t, double> effectiveMatrixToWellTrans;
for (const CellAddress& externalCell : m_externalCellAddrSet)
for ( const CellAddress& externalCell : m_externalCellAddrSet )
{
if (externalCell.m_cellIndexSpace == CellAddress::ECLIPSE)
if ( externalCell.m_cellIndexSpace == CellAddress::ECLIPSE )
{
size_t globalMatrixCellIdx = externalCell.m_globalCellIdx;
auto matrixToFractureIt = originalLumpedMatrixToFractureTrans.find(globalMatrixCellIdx);
CVF_ASSERT(matrixToFractureIt != originalLumpedMatrixToFractureTrans.end());
auto matrixToFractureIt = originalLumpedMatrixToFractureTrans.find( globalMatrixCellIdx );
CVF_ASSERT( matrixToFractureIt != originalLumpedMatrixToFractureTrans.end() );
// Sum(T_mf)
double lumpedOriginalMatrixToFractureT = matrixToFractureIt->second;
// T'_fjw
auto fictitiousFractureToWellIt = ficticuousFractureToWellTransMap.find(globalMatrixCellIdx);
CVF_ASSERT(fictitiousFractureToWellIt != ficticuousFractureToWellTransMap.end());
auto fictitiousFractureToWellIt = ficticuousFractureToWellTransMap.find( globalMatrixCellIdx );
CVF_ASSERT( fictitiousFractureToWellIt != ficticuousFractureToWellTransMap.end() );
double fictitiousFractureToWellTrans = fictitiousFractureToWellIt->second;
// T^dp_mw
effectiveMatrixToWellTrans[globalMatrixCellIdx] =
RigFractureTransmissibilityEquations::effectiveMatrixToWellTransPDDHC(lumpedOriginalMatrixToFractureT, fictitiousFractureToWellTrans);
RigFractureTransmissibilityEquations::effectiveMatrixToWellTransPDDHC( lumpedOriginalMatrixToFractureT,
fictitiousFractureToWellTrans );
}
}
return effectiveMatrixToWellTrans;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigTransmissibilityCondenser::calculateCondensedTransmissibilities()
{
if (m_neighborTransmissibilities.empty()) return;
if ( m_neighborTransmissibilities.empty() ) return;
// Find all equations, and their total ordering
union
{
union {
int idxToFirstExternalEquation;
int internalEquationCount;
};
idxToFirstExternalEquation = -1;
int totalEquationCount = -1;
int totalEquationCount = -1;
std::map<CellAddress, int> cellAddressToEqIdxMap;
std::vector<CellAddress> eqIdxToCellAddressMapping;
{
for ( const auto& adrEqIdxPair : m_neighborTransmissibilities )
{
cellAddressToEqIdxMap.insert({ adrEqIdxPair.first, -1 });
cellAddressToEqIdxMap.insert( {adrEqIdxPair.first, -1} );
for ( const auto& adrTranspair : adrEqIdxPair.second )
{
cellAddressToEqIdxMap.insert({ adrTranspair.first, -1 });
cellAddressToEqIdxMap.insert( {adrTranspair.first, -1} );
}
}
int currentEqIdx = 0;
for ( auto& adrEqIdxPair : cellAddressToEqIdxMap)
for ( auto& adrEqIdxPair : cellAddressToEqIdxMap )
{
adrEqIdxPair.second = currentEqIdx;
eqIdxToCellAddressMapping.push_back(adrEqIdxPair.first);
eqIdxToCellAddressMapping.push_back( adrEqIdxPair.first );
if ( idxToFirstExternalEquation == -1 && adrEqIdxPair.first.m_isExternal )
{
@@ -307,27 +313,27 @@ void RigTransmissibilityCondenser::calculateCondensedTransmissibilities()
}
totalEquationCount = currentEqIdx;
}
CAF_ASSERT(idxToFirstExternalEquation != -1);
CAF_ASSERT( idxToFirstExternalEquation != -1 );
using namespace Eigen;
MatrixXd totalSystem = MatrixXd::Zero(totalEquationCount, totalEquationCount);
for (const auto& adrToAdrTransMapPair : m_neighborTransmissibilities)
MatrixXd totalSystem = MatrixXd::Zero( totalEquationCount, totalEquationCount );
for ( const auto& adrToAdrTransMapPair : m_neighborTransmissibilities )
{
CAF_ASSERT(cellAddressToEqIdxMap.count(adrToAdrTransMapPair.first)); // Remove when stabilized
CAF_ASSERT( cellAddressToEqIdxMap.count( adrToAdrTransMapPair.first ) ); // Remove when stabilized
int c1EquationIdx = cellAddressToEqIdxMap[adrToAdrTransMapPair.first];
for (const auto& adrTranspair : adrToAdrTransMapPair.second)
for ( const auto& adrTranspair : adrToAdrTransMapPair.second )
{
CAF_ASSERT(cellAddressToEqIdxMap.count(adrTranspair.first)); // Remove when stabilized
CAF_ASSERT( cellAddressToEqIdxMap.count( adrTranspair.first ) ); // Remove when stabilized
int c2EquationIdx = cellAddressToEqIdxMap[adrTranspair.first];
totalSystem(c1EquationIdx, c2EquationIdx) += adrTranspair.second;
totalSystem(c2EquationIdx, c1EquationIdx) += adrTranspair.second;
totalSystem(c1EquationIdx, c1EquationIdx) -= adrTranspair.second;
totalSystem(c2EquationIdx, c2EquationIdx) -= adrTranspair.second;
totalSystem( c1EquationIdx, c2EquationIdx ) += adrTranspair.second;
totalSystem( c2EquationIdx, c1EquationIdx ) += adrTranspair.second;
totalSystem( c1EquationIdx, c1EquationIdx ) -= adrTranspair.second;
totalSystem( c2EquationIdx, c2EquationIdx ) -= adrTranspair.second;
}
++c1EquationIdx;
@@ -335,63 +341,64 @@ void RigTransmissibilityCondenser::calculateCondensedTransmissibilities()
// std::cout << "T = " << std::endl << totalSystem << std::endl;
int externalEquationCount = totalEquationCount - internalEquationCount;
int externalEquationCount = totalEquationCount - internalEquationCount;
MatrixXd condensedSystem;
MatrixXd Tee = totalSystem.bottomRightCorner(externalEquationCount, externalEquationCount);
MatrixXd Tee = totalSystem.bottomRightCorner( externalEquationCount, externalEquationCount );
if (internalEquationCount == 0)
if ( internalEquationCount == 0 )
{
condensedSystem = Tee;
}
else
{
MatrixXd Tei = totalSystem.bottomLeftCorner(externalEquationCount, internalEquationCount);
m_TiiInv = totalSystem.topLeftCorner(internalEquationCount, internalEquationCount).inverse();
m_Tie = totalSystem.topRightCorner(internalEquationCount, externalEquationCount);
MatrixXd Tei = totalSystem.bottomLeftCorner( externalEquationCount, internalEquationCount );
m_TiiInv = totalSystem.topLeftCorner( internalEquationCount, internalEquationCount ).inverse();
m_Tie = totalSystem.topRightCorner( internalEquationCount, externalEquationCount );
condensedSystem = Tee - Tei * m_TiiInv * m_Tie;
}
// std::cout << "Te = " << std::endl << condensedSystem << std::endl << std::endl;
for (int exEqIdx = 0; exEqIdx < externalEquationCount; ++exEqIdx)
for ( int exEqIdx = 0; exEqIdx < externalEquationCount; ++exEqIdx )
{
for (int exColIdx = exEqIdx +1; exColIdx < externalEquationCount; ++exColIdx)
for ( int exColIdx = exEqIdx + 1; exColIdx < externalEquationCount; ++exColIdx )
{
double T = condensedSystem(exEqIdx, exColIdx);
//if (T != 0.0)
double T = condensedSystem( exEqIdx, exColIdx );
// if (T != 0.0)
{
CellAddress cell1 = eqIdxToCellAddressMapping[exEqIdx + internalEquationCount];
CellAddress cell2 = eqIdxToCellAddressMapping[exColIdx + internalEquationCount];
if (cell1 < cell2) m_condensedTransmissibilities[cell1][cell2] = T;
else m_condensedTransmissibilities[cell2][cell1] = T;
m_externalCellAddrSet.insert(cell1);
m_externalCellAddrSet.insert(cell2);
if ( cell1 < cell2 )
m_condensedTransmissibilities[cell1][cell2] = T;
else
m_condensedTransmissibilities[cell2][cell1] = T;
m_externalCellAddrSet.insert( cell1 );
m_externalCellAddrSet.insert( cell2 );
}
}
}
}
}
#include "RimStimPlanFractureTemplate.h"
#include "RigMainGrid.h"
#include "RigFractureCell.h"
#include "RigMainGrid.h"
#include "RimStimPlanFractureTemplate.h"
void printCellAddress(std::stringstream& str,
const RigMainGrid* mainGrid,
const RigFractureGrid* fractureGrid,
RigTransmissibilityCondenser::CellAddress cellAddr)
void printCellAddress( std::stringstream& str,
const RigMainGrid* mainGrid,
const RigFractureGrid* fractureGrid,
RigTransmissibilityCondenser::CellAddress cellAddr )
{
using CellAddress = RigTransmissibilityCondenser::CellAddress;
using CellAddress = RigTransmissibilityCondenser::CellAddress;
str << (cellAddr.m_isExternal ? "E " : "I ");
str << ( cellAddr.m_isExternal ? "E " : "I " );
switch (cellAddr.m_cellIndexSpace) {
case CellAddress::ECLIPSE:
switch ( cellAddr.m_cellIndexSpace )
{
case CellAddress::ECLIPSE:
{
if (cellAddr.m_globalCellIdx > mainGrid->cellCount())
if ( cellAddr.m_globalCellIdx > mainGrid->cellCount() )
{
str << "ECL - LGR CELL ";
}
@@ -399,23 +406,23 @@ void printCellAddress(std::stringstream& str,
{
str << "ECL ";
size_t i, j, k;
mainGrid->ijkFromCellIndex(cellAddr.m_globalCellIdx, &i, &j, &k);
str << std::setw(5) << i+1 << std::setw(5) << j+1 << std::setw(5) << k+1;
mainGrid->ijkFromCellIndex( cellAddr.m_globalCellIdx, &i, &j, &k );
str << std::setw( 5 ) << i + 1 << std::setw( 5 ) << j + 1 << std::setw( 5 ) << k + 1;
}
}
break;
case CellAddress::STIMPLAN:
case CellAddress::STIMPLAN:
{
str << "STP ";
const RigFractureCell& stpCell = fractureGrid->cellFromIndex(cellAddr.m_globalCellIdx);
str << std::setw(5) << stpCell.getI()+1 << std::setw(5) << stpCell.getJ()+1 << std::setw(5) << " ";
const RigFractureCell& stpCell = fractureGrid->cellFromIndex( cellAddr.m_globalCellIdx );
str << std::setw( 5 ) << stpCell.getI() + 1 << std::setw( 5 ) << stpCell.getJ() + 1 << std::setw( 5 ) << " ";
}
break;
case CellAddress::WELL:
case CellAddress::WELL:
{
str << "WEL ";
str << std::setw(5) << cellAddr.m_globalCellIdx << std::setw(5) << " " << std::setw(5) << " ";
str << std::setw( 5 ) << cellAddr.m_globalCellIdx << std::setw( 5 ) << " " << std::setw( 5 ) << " ";
}
break;
}
@@ -423,22 +430,22 @@ void printCellAddress(std::stringstream& str,
str << " ";
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::string RigTransmissibilityCondenser::neighborTransDebugOutput(const RigMainGrid* mainGrid, const RigFractureGrid* fractureGrid)
std::string RigTransmissibilityCondenser::neighborTransDebugOutput( const RigMainGrid* mainGrid,
const RigFractureGrid* fractureGrid )
{
std::stringstream debugText;
for ( const auto& adrEqIdxPair : m_neighborTransmissibilities )
{
for (const auto& adrTransPair :adrEqIdxPair.second)
{
for ( const auto& adrTransPair : adrEqIdxPair.second )
{
debugText << "-- ";
printCellAddress(debugText, mainGrid, fractureGrid, adrEqIdxPair.first);
printCellAddress(debugText, mainGrid, fractureGrid, adrTransPair.first);
printCellAddress( debugText, mainGrid, fractureGrid, adrEqIdxPair.first );
printCellAddress( debugText, mainGrid, fractureGrid, adrTransPair.first );
debugText << " Trans: " << std::setprecision(10) << std::fixed << adrTransPair.second;
debugText << " Trans: " << std::setprecision( 10 ) << std::fixed << adrTransPair.second;
debugText << std::endl;
}
}
@@ -446,22 +453,22 @@ std::string RigTransmissibilityCondenser::neighborTransDebugOutput(const RigMain
return debugText.str();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::string RigTransmissibilityCondenser::condensedTransDebugOutput(const RigMainGrid* mainGrid, const RigFractureGrid* fractureGrid)
std::string RigTransmissibilityCondenser::condensedTransDebugOutput( const RigMainGrid* mainGrid,
const RigFractureGrid* fractureGrid )
{
std::stringstream debugText;
for ( const auto& adrEqIdxPair : m_condensedTransmissibilities )
{
for (const auto& adrTransPair :adrEqIdxPair.second)
for ( const auto& adrTransPair : adrEqIdxPair.second )
{
debugText << "-- ";
printCellAddress(debugText, mainGrid, fractureGrid, adrEqIdxPair.first);
printCellAddress(debugText, mainGrid, fractureGrid, adrTransPair.first);
printCellAddress( debugText, mainGrid, fractureGrid, adrEqIdxPair.first );
printCellAddress( debugText, mainGrid, fractureGrid, adrTransPair.first );
debugText << " Trans: " << std::setprecision(10) << std::fixed << adrTransPair.second;
debugText << " Trans: " << std::setprecision( 10 ) << std::fixed << adrTransPair.second;
debugText << std::endl;
}
}

View File

@@ -38,8 +38,8 @@ class RigTransmissibilityCondenser
{
public:
RigTransmissibilityCondenser();
RigTransmissibilityCondenser(const RigTransmissibilityCondenser& copyFrom);
RigTransmissibilityCondenser& operator=(const RigTransmissibilityCondenser& rhs);
RigTransmissibilityCondenser( const RigTransmissibilityCondenser& copyFrom );
RigTransmissibilityCondenser& operator=( const RigTransmissibilityCondenser& rhs );
class CellAddress
{
@@ -52,15 +52,15 @@ public:
};
CellAddress()
: m_isExternal(false)
, m_cellIndexSpace(STIMPLAN)
, m_globalCellIdx(-1)
: m_isExternal( false )
, m_cellIndexSpace( STIMPLAN )
, m_globalCellIdx( -1 )
{
}
CellAddress(bool isExternal, CellIndexSpace cellType, size_t globalCellIdx)
: m_isExternal(isExternal)
, m_cellIndexSpace(cellType)
, m_globalCellIdx(globalCellIdx)
CellAddress( bool isExternal, CellIndexSpace cellType, size_t globalCellIdx )
: m_isExternal( isExternal )
, m_cellIndexSpace( cellType )
, m_globalCellIdx( globalCellIdx )
{
}
@@ -68,39 +68,43 @@ public:
CellIndexSpace m_cellIndexSpace;
size_t m_globalCellIdx;
bool operator==(const CellAddress& o)
bool operator==( const CellAddress& o )
{
return (m_isExternal == o.m_isExternal) && (m_cellIndexSpace == o.m_cellIndexSpace) &&
(m_globalCellIdx == o.m_globalCellIdx);
return ( m_isExternal == o.m_isExternal ) && ( m_cellIndexSpace == o.m_cellIndexSpace ) &&
( m_globalCellIdx == o.m_globalCellIdx );
}
// Ordering external after internal is important for the matrix order internally
bool operator<(const CellAddress& other) const
bool operator<( const CellAddress& other ) const
{
if (m_isExternal != other.m_isExternal) return !m_isExternal; // Internal cells < External cells
if (m_cellIndexSpace != other.m_cellIndexSpace)
if ( m_isExternal != other.m_isExternal ) return !m_isExternal; // Internal cells < External cells
if ( m_cellIndexSpace != other.m_cellIndexSpace )
return m_cellIndexSpace < other.m_cellIndexSpace; // Eclipse < StimPlan
if (m_globalCellIdx != other.m_globalCellIdx) return m_globalCellIdx < other.m_globalCellIdx;
if ( m_globalCellIdx != other.m_globalCellIdx ) return m_globalCellIdx < other.m_globalCellIdx;
return false;
}
};
void addNeighborTransmissibility(CellAddress cell1, CellAddress cell2, double transmissibility);
void addNeighborTransmissibility( CellAddress cell1, CellAddress cell2, double transmissibility );
std::set<CellAddress> externalCells();
double condensedTransmissibility(CellAddress externalCell1, CellAddress externalCell2);
double condensedTransmissibility( CellAddress externalCell1, CellAddress externalCell2 );
std::string neighborTransDebugOutput(const RigMainGrid* mainGrid, const RigFractureGrid* fractureGrid);
std::string condensedTransDebugOutput(const RigMainGrid* mainGrid, const RigFractureGrid* fractureGrid);
std::string neighborTransDebugOutput( const RigMainGrid* mainGrid, const RigFractureGrid* fractureGrid );
std::string condensedTransDebugOutput( const RigMainGrid* mainGrid, const RigFractureGrid* fractureGrid );
std::map<size_t, double> scaleMatrixToFracTransByMatrixWellDP(const RigActiveCellInfo* actCellInfo, double currentWellPressure, const std::vector<double>& currentMatrixPressures, double* minPressureDrop, double* maxPressureDrop);
std::map<size_t, double> scaleMatrixToFracTransByMatrixWellDP( const RigActiveCellInfo* actCellInfo,
double currentWellPressure,
const std::vector<double>& currentMatrixPressures,
double* minPressureDrop,
double* maxPressureDrop );
std::map<size_t, double> calculateFicticiousFractureToWellTransmissibilities();
std::map<size_t, double>
calculateEffectiveMatrixToWellTransmissibilities(const std::map<size_t, double>& originalLumpedMatrixToFractureTrans,
const std::map<size_t, double>& ficticuousFractureToWellTransMap);
std::map<size_t, double> calculateEffectiveMatrixToWellTransmissibilities(
const std::map<size_t, double>& originalLumpedMatrixToFractureTrans,
const std::map<size_t, double>& ficticuousFractureToWellTransMap );
void calculateCondensedTransmissibilities();

View File

@@ -28,19 +28,20 @@ CompletionDataFrame::CompletionDataFrame() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CompletionDataFrame::setCompletionData(const std::vector<RigCompletionData>& completions)
void CompletionDataFrame::setCompletionData( const std::vector<RigCompletionData>& completions )
{
for (auto& completion : completions)
for ( auto& completion : completions )
{
auto it = m_multipleCompletionsPerEclipseCell.find(completion.completionDataGridCell().globalCellIndex());
if (it != m_multipleCompletionsPerEclipseCell.end())
auto it = m_multipleCompletionsPerEclipseCell.find( completion.completionDataGridCell().globalCellIndex() );
if ( it != m_multipleCompletionsPerEclipseCell.end() )
{
it->second.push_back(completion);
it->second.push_back( completion );
}
else
{
m_multipleCompletionsPerEclipseCell.insert(std::pair<size_t, std::vector<RigCompletionData>>(
completion.completionDataGridCell().globalCellIndex(), std::vector<RigCompletionData>{completion}));
m_multipleCompletionsPerEclipseCell.insert(
std::pair<size_t, std::vector<RigCompletionData>>( completion.completionDataGridCell().globalCellIndex(),
std::vector<RigCompletionData>{completion} ) );
}
}
}
@@ -67,26 +68,25 @@ RigVirtualPerforationTransmissibilities::~RigVirtualPerforationTransmissibilitie
///
//--------------------------------------------------------------------------------------------------
void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath(
const RimWellPath* wellPath,
const std::vector<std::vector<RigCompletionData>>& completionsPerTimeStep)
const RimWellPath* wellPath, const std::vector<std::vector<RigCompletionData>>& completionsPerTimeStep )
{
auto item = m_mapFromWellToCompletionData.find(wellPath);
auto item = m_mapFromWellToCompletionData.find( wellPath );
CVF_ASSERT(item == m_mapFromWellToCompletionData.end());
CVF_ASSERT( item == m_mapFromWellToCompletionData.end() );
{
std::vector<CompletionDataFrame> values;
for (const auto& c : completionsPerTimeStep)
for ( const auto& c : completionsPerTimeStep )
{
CompletionDataFrame oneTimeStep;
oneTimeStep.setCompletionData(c);
values.push_back(oneTimeStep);
oneTimeStep.setCompletionData( c );
values.push_back( oneTimeStep );
}
auto pair = std::pair<const RimWellPath*, std::vector<CompletionDataFrame>>(wellPath, values);
auto pair = std::pair<const RimWellPath*, std::vector<CompletionDataFrame>>( wellPath, values );
m_mapFromWellToCompletionData.insert(pair);
m_mapFromWellToCompletionData.insert( pair );
}
}
@@ -94,16 +94,16 @@ void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath(
///
//--------------------------------------------------------------------------------------------------
const std::map<size_t, std::vector<RigCompletionData>>&
RigVirtualPerforationTransmissibilities::multipleCompletionsPerEclipseCell(const RimWellPath* wellPath,
size_t timeStepIndex) const
RigVirtualPerforationTransmissibilities::multipleCompletionsPerEclipseCell( const RimWellPath* wellPath,
size_t timeStepIndex ) const
{
static std::map<size_t, std::vector<RigCompletionData>> dummy;
auto item = m_mapFromWellToCompletionData.find(wellPath);
if (item != m_mapFromWellToCompletionData.end())
auto item = m_mapFromWellToCompletionData.find( wellPath );
if ( item != m_mapFromWellToCompletionData.end() )
{
size_t indexToUse = timeStepIndex;
if (item->second.size() == 1)
if ( item->second.size() == 1 )
{
indexToUse = 0;
}
@@ -118,8 +118,7 @@ const std::map<size_t, std::vector<RigCompletionData>>&
///
//--------------------------------------------------------------------------------------------------
void RigVirtualPerforationTransmissibilities::setCompletionDataForSimWell(
const RigSimWellData* simWellData,
const std::vector<std::vector<RigCompletionData>>& completionsPerTimeStep)
const RigSimWellData* simWellData, const std::vector<std::vector<RigCompletionData>>& completionsPerTimeStep )
{
m_mapFromSimWellToCompletionData[simWellData] = completionsPerTimeStep;
}
@@ -128,12 +127,13 @@ void RigVirtualPerforationTransmissibilities::setCompletionDataForSimWell(
///
//--------------------------------------------------------------------------------------------------
const std::vector<RigCompletionData>&
RigVirtualPerforationTransmissibilities::completionsForSimWell(const RigSimWellData* simWellData, size_t timeStepIndex) const
RigVirtualPerforationTransmissibilities::completionsForSimWell( const RigSimWellData* simWellData,
size_t timeStepIndex ) const
{
static std::vector<RigCompletionData> dummayVector;
auto item = m_mapFromSimWellToCompletionData.find(simWellData);
if (item != m_mapFromSimWellToCompletionData.end())
auto item = m_mapFromSimWellToCompletionData.find( simWellData );
if ( item != m_mapFromSimWellToCompletionData.end() )
{
return item->second[timeStepIndex];
}
@@ -144,51 +144,51 @@ const std::vector<RigCompletionData>&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigVirtualPerforationTransmissibilities::computeMinMax(double* minValue,
double* maxValue,
double* posClosestToZero,
double* negClosestToZero) const
void RigVirtualPerforationTransmissibilities::computeMinMax( double* minValue,
double* maxValue,
double* posClosestToZero,
double* negClosestToZero ) const
{
MinMaxAccumulator minMaxAccumulator;
PosNegAccumulator posNegAccumulator;
for (const auto& item : m_mapFromWellToCompletionData)
for ( const auto& item : m_mapFromWellToCompletionData )
{
auto dataForWellPath = item.second;
for (const auto& timeStepFrame : dataForWellPath)
for ( const auto& timeStepFrame : dataForWellPath )
{
for (const auto& allCompletionsForWell : timeStepFrame.multipleCompletionsPerEclipseCell())
for ( const auto& allCompletionsForWell : timeStepFrame.multipleCompletionsPerEclipseCell() )
{
for (const auto& completionData : allCompletionsForWell.second)
for ( const auto& completionData : allCompletionsForWell.second )
{
double transmissibility = completionData.transmissibility();
minMaxAccumulator.addValue(transmissibility);
posNegAccumulator.addValue(transmissibility);
minMaxAccumulator.addValue( transmissibility );
posNegAccumulator.addValue( transmissibility );
}
}
}
}
for (const auto& item : m_mapFromSimWellToCompletionData)
for ( const auto& item : m_mapFromSimWellToCompletionData )
{
auto dataForSimWell = item.second;
for (const auto& timeStepFrame : dataForSimWell)
for ( const auto& timeStepFrame : dataForSimWell )
{
for (const auto& completionData : timeStepFrame)
for ( const auto& completionData : timeStepFrame )
{
double transmissibility = completionData.transmissibility();
minMaxAccumulator.addValue(transmissibility);
posNegAccumulator.addValue(transmissibility);
minMaxAccumulator.addValue( transmissibility );
posNegAccumulator.addValue( transmissibility );
}
}
}
if (*minValue) *minValue = minMaxAccumulator.min;
if (*maxValue) *maxValue = minMaxAccumulator.max;
if (*posClosestToZero) *posClosestToZero = posNegAccumulator.pos;
if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg;
if ( *minValue ) *minValue = minMaxAccumulator.min;
if ( *maxValue ) *maxValue = minMaxAccumulator.max;
if ( *posClosestToZero ) *posClosestToZero = posNegAccumulator.pos;
if ( *negClosestToZero ) *negClosestToZero = posNegAccumulator.neg;
}

View File

@@ -20,7 +20,6 @@
#include "RigCompletionData.h"
#include "cvfObject.h"
#include <map>
@@ -39,7 +38,7 @@ class CompletionDataFrame
public:
CompletionDataFrame();
void setCompletionData(const std::vector<RigCompletionData>& completions);
void setCompletionData( const std::vector<RigCompletionData>& completions );
const std::map<size_t, std::vector<RigCompletionData>>& multipleCompletionsPerEclipseCell() const;
@@ -56,18 +55,19 @@ public:
RigVirtualPerforationTransmissibilities();
~RigVirtualPerforationTransmissibilities() override;
void setCompletionDataForWellPath(const RimWellPath* wellPath,
const std::vector<std::vector<RigCompletionData>>& completionsPerTimeStep);
void setCompletionDataForWellPath( const RimWellPath* wellPath,
const std::vector<std::vector<RigCompletionData>>& completionsPerTimeStep );
const std::map<size_t, std::vector<RigCompletionData>>& multipleCompletionsPerEclipseCell(const RimWellPath* wellPath,
size_t timeStepIndex) const;
const std::map<size_t, std::vector<RigCompletionData>>&
multipleCompletionsPerEclipseCell( const RimWellPath* wellPath, size_t timeStepIndex ) const;
void setCompletionDataForSimWell(const RigSimWellData* simWellData,
const std::vector<std::vector<RigCompletionData>>& completionsPerTimeStep);
void setCompletionDataForSimWell( const RigSimWellData* simWellData,
const std::vector<std::vector<RigCompletionData>>& completionsPerTimeStep );
const std::vector<RigCompletionData>& completionsForSimWell(const RigSimWellData* simWellData, size_t timeStepIndex) const;
const std::vector<RigCompletionData>& completionsForSimWell( const RigSimWellData* simWellData,
size_t timeStepIndex ) const;
void computeMinMax(double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const;
void computeMinMax( double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero ) const;
private:
std::map<const RimWellPath*, std::vector<CompletionDataFrame>> m_mapFromWellToCompletionData;

View File

@@ -28,7 +28,6 @@
#include "RimSimWellFracture.h"
#include "RimStimPlanFractureTemplate.h"
#include "cvfMath.h"
#include "cvfMatrix4.h"
@@ -37,10 +36,11 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath* wellPathGeom, const RimFracture* rimFracture)
RigWellPathStimplanIntersector::RigWellPathStimplanIntersector( const RigWellPath* wellPathGeom,
const RimFracture* rimFracture )
{
std::vector<cvf::Vec3d> wellPathPoints =
wellPathGeom->wellPathPointsIncludingInterpolatedIntersectionPoint(rimFracture->fractureMD());
std::vector<cvf::Vec3d> wellPathPoints = wellPathGeom->wellPathPointsIncludingInterpolatedIntersectionPoint(
rimFracture->fractureMD() );
cvf::Mat4d fractureXf = rimFracture->transformMatrix();
double wellRadius = rimFracture->wellRadius();
@@ -48,23 +48,23 @@ RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath
{
RimFractureTemplate* fractureTemplate = rimFracture->fractureTemplate();
if (fractureTemplate && fractureTemplate->fractureGrid())
if ( fractureTemplate && fractureTemplate->fractureGrid() )
{
const std::vector<RigFractureCell>& stpCells = fractureTemplate->fractureGrid()->fractureCells();
for (const auto& stpCell : stpCells)
for ( const auto& stpCell : stpCells )
{
fractureGridCellPolygons.push_back(stpCell.getPolygon());
fractureGridCellPolygons.push_back( stpCell.getPolygon() );
}
}
}
double perforationLength = rimFracture->perforationLength();
calculate(fractureXf,
wellPathPoints,
wellRadius,
perforationLength,
fractureGridCellPolygons,
m_stimPlanCellIdxToIntersectionInfoMap);
calculate( fractureXf,
wellPathPoints,
wellRadius,
perforationLength,
fractureGridCellPolygons,
m_stimPlanCellIdxToIntersectionInfoMap );
}
//--------------------------------------------------------------------------------------------------
@@ -79,12 +79,12 @@ const std::map<size_t, RigWellPathStimplanIntersector::RigWellPathStimplanInters
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d& fractureXf,
const std::vector<cvf::Vec3d>& wellPathPointsDomainCoords,
double wellRadius,
double perforationLength,
const std::vector<std::vector<cvf::Vec3d>>& fractureGridCellPolygons,
std::map<size_t, WellCellIntersection>& m_stimPlanCellIdxToIntersectionInfoMap)
void RigWellPathStimplanIntersector::calculate( const cvf::Mat4d& fractureXf,
const std::vector<cvf::Vec3d>& wellPathPointsDomainCoords,
double wellRadius,
double perforationLength,
const std::vector<std::vector<cvf::Vec3d>>& fractureGridCellPolygons,
std::map<size_t, WellCellIntersection>& m_stimPlanCellIdxToIntersectionInfoMap )
{
cvf::Mat4d toFractureXf = fractureXf.getInverted();
@@ -93,44 +93,46 @@ void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d&
double cicleRadius = perforationLength / 2;
int pointsInCirclePolygon = 20;
for (int i = 0; i < pointsInCirclePolygon; i++)
for ( int i = 0; i < pointsInCirclePolygon; i++ )
{
double x = cicleRadius * cvf::Math::cos(i * (2 * cvf::PI_D / pointsInCirclePolygon));
double y = cicleRadius * cvf::Math::sin(i * (2 * cvf::PI_D / pointsInCirclePolygon));
perforationLengthBoundingBoxPolygon.push_back(cvf::Vec3d(x, y, 0));
double x = cicleRadius * cvf::Math::cos( i * ( 2 * cvf::PI_D / pointsInCirclePolygon ) );
double y = cicleRadius * cvf::Math::sin( i * ( 2 * cvf::PI_D / pointsInCirclePolygon ) );
perforationLengthBoundingBoxPolygon.push_back( cvf::Vec3d( x, y, 0 ) );
}
}
// Convert well path to fracture template system
std::vector<cvf::Vec3d> fractureRelativeWellPathPoints;
for (const auto& wellPPoint : wellPathPointsDomainCoords)
for ( const auto& wellPPoint : wellPathPointsDomainCoords )
{
fractureRelativeWellPathPoints.push_back(wellPPoint.getTransformedPoint(toFractureXf));
fractureRelativeWellPathPoints.push_back( wellPPoint.getTransformedPoint( toFractureXf ) );
}
// Clip well path to fracture domain
std::vector<std::vector<cvf::Vec3d>> wellPathPartsWithinFracture = RigCellGeometryTools::clipPolylineByPolygon(
fractureRelativeWellPathPoints, perforationLengthBoundingBoxPolygon, RigCellGeometryTools::INTERPOLATE_LINE_Z);
std::vector<std::vector<cvf::Vec3d>> wellPathPartsWithinFracture =
RigCellGeometryTools::clipPolylineByPolygon( fractureRelativeWellPathPoints,
perforationLengthBoundingBoxPolygon,
RigCellGeometryTools::INTERPOLATE_LINE_Z );
// Remove the part of the well path that is more than well radius away from the fracture plane
std::vector<std::vector<cvf::Vec3d>> intersectingWellPathParts;
for (const auto& part : wellPathPartsWithinFracture)
for ( const auto& part : wellPathPartsWithinFracture )
{
std::vector<cvf::Vec3d> currentIntersectingWpPart;
for (size_t vxIdx = 0; vxIdx < part.size() - 1; ++vxIdx)
for ( size_t vxIdx = 0; vxIdx < part.size() - 1; ++vxIdx )
{
double thisAbsZ = fabs(part[vxIdx].z());
double nextAbsZ = fabs(part[vxIdx + 1].z());
double thisAbsZ = fabs( part[vxIdx].z() );
double nextAbsZ = fabs( part[vxIdx + 1].z() );
double thisZ = part[vxIdx].z();
double nextZ = part[vxIdx + 1].z();
if (thisAbsZ >= wellRadius && nextAbsZ >= wellRadius)
if ( thisAbsZ >= wellRadius && nextAbsZ >= wellRadius )
{
if ((thisZ >= 0 && nextZ >= 0) || (thisZ <= 0 && nextZ <= 0))
if ( ( thisZ >= 0 && nextZ >= 0 ) || ( thisZ <= 0 && nextZ <= 0 ) )
{
continue; // Outside
}
@@ -139,92 +141,92 @@ void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d&
{
double wellRadiusDistFromPlane = thisZ > 0 ? wellRadius : -wellRadius;
double fraction = (wellRadiusDistFromPlane - thisZ) / (nextZ - thisZ);
double fraction = ( wellRadiusDistFromPlane - thisZ ) / ( nextZ - thisZ );
cvf::Vec3d intersectPoint = part[vxIdx] + fraction * (part[vxIdx + 1] - part[vxIdx]);
currentIntersectingWpPart.push_back(intersectPoint);
cvf::Vec3d intersectPoint = part[vxIdx] + fraction * ( part[vxIdx + 1] - part[vxIdx] );
currentIntersectingWpPart.push_back( intersectPoint );
}
{
double wellRadiusDistFromPlane = nextZ > 0 ? wellRadius : -wellRadius;
double fraction = (wellRadiusDistFromPlane - thisZ) / (nextZ - thisZ);
double fraction = ( wellRadiusDistFromPlane - thisZ ) / ( nextZ - thisZ );
cvf::Vec3d intersectPoint = part[vxIdx] + fraction * (part[vxIdx + 1] - part[vxIdx]);
currentIntersectingWpPart.push_back(intersectPoint);
cvf::Vec3d intersectPoint = part[vxIdx] + fraction * ( part[vxIdx + 1] - part[vxIdx] );
currentIntersectingWpPart.push_back( intersectPoint );
intersectingWellPathParts.push_back(currentIntersectingWpPart);
intersectingWellPathParts.push_back( currentIntersectingWpPart );
currentIntersectingWpPart.clear();
}
continue;
}
}
if (thisAbsZ < wellRadius && nextAbsZ < wellRadius) // Inside
if ( thisAbsZ < wellRadius && nextAbsZ < wellRadius ) // Inside
{
currentIntersectingWpPart.push_back(part[vxIdx]);
currentIntersectingWpPart.push_back( part[vxIdx] );
continue;
}
if (thisAbsZ < wellRadius && nextAbsZ >= wellRadius) // Going out
if ( thisAbsZ < wellRadius && nextAbsZ >= wellRadius ) // Going out
{
currentIntersectingWpPart.push_back(part[vxIdx]);
currentIntersectingWpPart.push_back( part[vxIdx] );
double wellRadiusDistFromPlane = nextZ > 0 ? wellRadius : -wellRadius;
double fraction = (wellRadiusDistFromPlane - thisZ) / (nextZ - thisZ);
double fraction = ( wellRadiusDistFromPlane - thisZ ) / ( nextZ - thisZ );
cvf::Vec3d intersectPoint = part[vxIdx] + fraction * (part[vxIdx + 1] - part[vxIdx]);
currentIntersectingWpPart.push_back(intersectPoint);
cvf::Vec3d intersectPoint = part[vxIdx] + fraction * ( part[vxIdx + 1] - part[vxIdx] );
currentIntersectingWpPart.push_back( intersectPoint );
intersectingWellPathParts.push_back(currentIntersectingWpPart);
intersectingWellPathParts.push_back( currentIntersectingWpPart );
currentIntersectingWpPart.clear();
continue;
}
if (thisAbsZ >= wellRadius && nextAbsZ < wellRadius) // Going in
if ( thisAbsZ >= wellRadius && nextAbsZ < wellRadius ) // Going in
{
double wellRadiusDistFromPlane = thisZ > 0 ? wellRadius : -wellRadius;
double fraction = (wellRadiusDistFromPlane - thisZ) / (nextZ - thisZ);
double fraction = ( wellRadiusDistFromPlane - thisZ ) / ( nextZ - thisZ );
cvf::Vec3d intersectPoint = part[vxIdx] + fraction * (part[vxIdx + 1] - part[vxIdx]);
currentIntersectingWpPart.push_back(intersectPoint);
cvf::Vec3d intersectPoint = part[vxIdx] + fraction * ( part[vxIdx + 1] - part[vxIdx] );
currentIntersectingWpPart.push_back( intersectPoint );
continue;
}
}
// Add last point if it is within the radius
if (part.size() > 1 && fabs(part.back().z()) < wellRadius)
if ( part.size() > 1 && fabs( part.back().z() ) < wellRadius )
{
currentIntersectingWpPart.push_back(part.back());
currentIntersectingWpPart.push_back( part.back() );
}
if (!currentIntersectingWpPart.empty())
if ( !currentIntersectingWpPart.empty() )
{
intersectingWellPathParts.push_back(currentIntersectingWpPart);
intersectingWellPathParts.push_back( currentIntersectingWpPart );
}
}
// Find the StimPlan cells touched by the intersecting well path parts
for (size_t cIdx = 0; cIdx < fractureGridCellPolygons.size(); ++cIdx)
for ( size_t cIdx = 0; cIdx < fractureGridCellPolygons.size(); ++cIdx )
{
const std::vector<cvf::Vec3d>& cellPolygon = fractureGridCellPolygons[cIdx];
for (const auto& wellpathPart : intersectingWellPathParts)
for ( const auto& wellpathPart : intersectingWellPathParts )
{
std::vector<std::vector<cvf::Vec3d>> wellPathPartsInPolygon =
RigCellGeometryTools::clipPolylineByPolygon(wellpathPart, cellPolygon, RigCellGeometryTools::USE_HUGEVAL);
for (const auto& wellPathPartInCell : wellPathPartsInPolygon)
RigCellGeometryTools::clipPolylineByPolygon( wellpathPart, cellPolygon, RigCellGeometryTools::USE_HUGEVAL );
for ( const auto& wellPathPartInCell : wellPathPartsInPolygon )
{
if (!wellPathPartInCell.empty())
if ( !wellPathPartInCell.empty() )
{
int endpointCount = 0;
if (wellPathPartInCell.front().z() != HUGE_VAL) ++endpointCount;
if (wellPathPartInCell.back().z() != HUGE_VAL) ++endpointCount;
if ( wellPathPartInCell.front().z() != HUGE_VAL ) ++endpointCount;
if ( wellPathPartInCell.back().z() != HUGE_VAL ) ++endpointCount;
cvf::Vec3d intersectionLength = (wellPathPartInCell.back() - wellPathPartInCell.front());
double xLengthInCell = fabs(intersectionLength.x());
double yLengthInCell = fabs(intersectionLength.y());
cvf::Vec3d intersectionLength = ( wellPathPartInCell.back() - wellPathPartInCell.front() );
double xLengthInCell = fabs( intersectionLength.x() );
double yLengthInCell = fabs( intersectionLength.y() );
m_stimPlanCellIdxToIntersectionInfoMap[cIdx].endpointCount += endpointCount;
m_stimPlanCellIdxToIntersectionInfoMap[cIdx].hlength += xLengthInCell;

View File

@@ -18,7 +18,6 @@
#pragma once
#include "cvfMatrix4.h"
#include <map>
@@ -37,9 +36,9 @@ public:
struct WellCellIntersection
{
WellCellIntersection()
: hlength(0.0)
, vlength(0.0)
, endpointCount(0)
: hlength( 0.0 )
, vlength( 0.0 )
, endpointCount( 0 )
{
}
double hlength;
@@ -48,22 +47,22 @@ public:
double computeLength() const
{
return cvf::Math::sqrt(hlength * hlength + vlength * vlength);
return cvf::Math::sqrt( hlength * hlength + vlength * vlength );
}
};
RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, const RimFracture* rimFracture);
RigWellPathStimplanIntersector( const RigWellPath* wellpathGeom, const RimFracture* rimFracture );
const std::map<size_t, WellCellIntersection>& intersections() const;
private:
friend class RigWellPathStimplanIntersectorTester;
static void calculate(const cvf::Mat4d& fractureXf,
const std::vector<cvf::Vec3d>& wellPathPoints,
double wellRadius,
double perforationLength,
const std::vector<std::vector<cvf::Vec3d>>& stpCellPolygons,
std::map<size_t, WellCellIntersection>& stimPlanCellIdxToIntersectionInfoMap);
static void calculate( const cvf::Mat4d& fractureXf,
const std::vector<cvf::Vec3d>& wellPathPoints,
double wellRadius,
double perforationLength,
const std::vector<std::vector<cvf::Vec3d>>& stpCellPolygons,
std::map<size_t, WellCellIntersection>& stimPlanCellIdxToIntersectionInfoMap );
std::map<size_t, WellCellIntersection> m_stimPlanCellIdxToIntersectionInfoMap;
};
@@ -80,9 +79,13 @@ public:
double wellRadius,
double perforationLength,
const std::vector<std::vector<cvf::Vec3d>>& stpCellPolygons,
std::map<size_t, RigWellPathStimplanIntersector::WellCellIntersection>& stimPlanCellIdxToIntersectionInfoMap)
std::map<size_t, RigWellPathStimplanIntersector::WellCellIntersection>& stimPlanCellIdxToIntersectionInfoMap )
{
RigWellPathStimplanIntersector::calculate(
fractureXf, wellPathPoints, wellRadius, perforationLength, stpCellPolygons, stimPlanCellIdxToIntersectionInfoMap);
RigWellPathStimplanIntersector::calculate( fractureXf,
wellPathPoints,
wellRadius,
perforationLength,
stpCellPolygons,
stimPlanCellIdxToIntersectionInfoMap );
}
};

View File

@@ -1,27 +1,27 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <vector>
#include <map>
#include <vector>
//==================================================================================================
///
///
///
///
//==================================================================================================
class RigMainGrid;
@@ -30,11 +30,13 @@ class RigActiveCellInfo;
class RigEclCellIndexCalculator
{
public:
RigEclCellIndexCalculator(const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo)
: m_mainGrid(mainGrid), m_activeCellInfo(activeCellInfo)
{}
RigEclCellIndexCalculator( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo )
: m_mainGrid( mainGrid )
, m_activeCellInfo( activeCellInfo )
{
}
size_t resultCellIndex(size_t gridIndex, size_t gridCellIndex) const;
size_t resultCellIndex( size_t gridIndex, size_t gridCellIndex ) const;
private:
const RigMainGrid* m_mainGrid;
@@ -42,8 +44,8 @@ private:
};
//==================================================================================================
///
///
///
///
//==================================================================================================
#include <QString>
@@ -54,102 +56,98 @@ struct RigWellResultPoint;
class RigAccWellFlowCalculator
{
public:
RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds,
const std::map<QString, const std::vector<double>* >& tracerCellFractionValues,
const RigEclCellIndexCalculator& cellIndexCalculator,
double smallContribThreshold,
bool isProducer);
RigAccWellFlowCalculator( const std::vector<std::vector<cvf::Vec3d>>& pipeBranchesCLCoords,
const std::vector<std::vector<RigWellResultPoint>>& pipeBranchesCellIds,
const std::map<QString, const std::vector<double>*>& tracerCellFractionValues,
const RigEclCellIndexCalculator& cellIndexCalculator,
double smallContribThreshold,
bool isProducer );
RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds,
double smallContribThreshold);
RigAccWellFlowCalculator( const std::vector<std::vector<cvf::Vec3d>>& pipeBranchesCLCoords,
const std::vector<std::vector<RigWellResultPoint>>& pipeBranchesCellIds,
double smallContribThreshold );
RigAccWellFlowCalculator(const std::vector <cvf::Vec3d> & pipeBranchCLCoords,
const std::vector <RigWellResultPoint> & pipeBranchCellIds,
const std::vector <double> & pipeBranchMeasuredDepths,
bool totalFlowOnly);
RigAccWellFlowCalculator( const std::vector<cvf::Vec3d>& pipeBranchCLCoords,
const std::vector<RigWellResultPoint>& pipeBranchCellIds,
const std::vector<double>& pipeBranchMeasuredDepths,
bool totalFlowOnly );
const std::vector<double>& connectionNumbersFromTop(size_t branchIdx) const;
const std::vector<double>& accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx) const;
const std::vector<double>& tracerFlowPrConnection(const QString& tracerName, size_t branchIdx) const;
const std::vector<double>& connectionNumbersFromTop( size_t branchIdx ) const;
const std::vector<double>& accumulatedTracerFlowPrConnection( const QString& tracerName, size_t branchIdx ) const;
const std::vector<double>& tracerFlowPrConnection( const QString& tracerName, size_t branchIdx ) const;
const std::vector<double>& pseudoLengthFromTop(size_t branchIdx) const;
const std::vector<double>& trueVerticalDepth(size_t branchIdx) const;
const std::vector<double>& accumulatedTracerFlowPrPseudoLength(const QString& tracerName, size_t branchIdx) const;
const std::vector<double>& tracerFlowPrPseudoLength(const QString& tracerName, size_t branchIdx) const;
const std::vector<double>& pseudoLengthFromTop( size_t branchIdx ) const;
const std::vector<double>& trueVerticalDepth( size_t branchIdx ) const;
const std::vector<double>& accumulatedTracerFlowPrPseudoLength( const QString& tracerName, size_t branchIdx ) const;
const std::vector<double>& tracerFlowPrPseudoLength( const QString& tracerName, size_t branchIdx ) const;
const std::vector<QString>& tracerNames() const
{
return m_tracerNames;
}
const std::vector<QString>& tracerNames() const { return m_tracerNames;}
std::vector<std::pair<QString, double> > totalTracerFractions() const;
std::vector<std::pair<QString, double>> totalTracerFractions() const;
private:
void initializePipeBranchesMeasuredDepths();
void initializePipeBranchesMeasuredDepths();
bool isConnectionFlowConsistent(const RigWellResultPoint &wellCell) const;
bool isFlowRateConsistent(double flowRate) const;
bool isConnectionFlowConsistent( const RigWellResultPoint& wellCell ) const;
bool isFlowRateConsistent( double flowRate ) const;
void calculateAccumulatedFlowPrConnection(size_t branchIdx,
size_t startConnectionNumberFromTop);
void calculateFlowPrPseudoLength(size_t branchIdx,
double startPseudoLengthFromTop);
void calculateAccumulatedFlowPrConnection( size_t branchIdx, size_t startConnectionNumberFromTop );
void calculateFlowPrPseudoLength( size_t branchIdx, double startPseudoLengthFromTop );
std::vector<double> calculateWellCellFlowPrTracer(const RigWellResultPoint& wellCell,
const std::vector<double>& currentAccumulatedFlowPrTracer ) const;
void sortTracers();
void groupSmallContributions();
std::vector<double> calculateWellCellFlowPrTracer( const RigWellResultPoint& wellCell,
const std::vector<double>& currentAccumulatedFlowPrTracer ) const;
void sortTracers();
void groupSmallContributions();
void groupSmallTracers(std::map<QString, std::vector<double> >* branchFlowSet,
const std::vector<QString>& tracersToGroup);
void groupSmallTracers( std::map<QString, std::vector<double>>* branchFlowSet,
const std::vector<QString>& tracersToGroup );
bool isWellFlowConsistent() const;
std::vector<double> calculateAccumulatedFractions(const std::vector<double>& accumulatedFlowPrTracer) const;
std::vector<size_t> wrpToUniqueWrpIndexFromBottom(const std::vector<RigWellResultPoint> &branchCells) const;
static size_t connectionIndexFromTop( const std::vector<size_t>& resPointToConnectionIndexFromBottom, size_t clSegIdx) ;
std::vector<size_t> findDownStreamBranchIdxs( const RigWellResultPoint& connectionPoint) const;
bool isWellFlowConsistent() const;
std::vector<double> calculateAccumulatedFractions( const std::vector<double>& accumulatedFlowPrTracer ) const;
std::vector<size_t> wrpToUniqueWrpIndexFromBottom( const std::vector<RigWellResultPoint>& branchCells ) const;
static size_t connectionIndexFromTop( const std::vector<size_t>& resPointToConnectionIndexFromBottom,
size_t clSegIdx );
std::vector<size_t> findDownStreamBranchIdxs( const RigWellResultPoint& connectionPoint ) const;
std::vector<std::pair<QString, double> > totalWellFlowPrTracer() const;
std::vector<std::pair<QString, double>> totalWellFlowPrTracer() const;
std::vector<std::vector<cvf::Vec3d>> m_pipeBranchesCLCoords;
std::vector<std::vector<RigWellResultPoint>> m_pipeBranchesWellResultPoints;
std::vector<std::vector<double>> m_pipeBranchesMeasuredDepths;
std::vector< std::vector <cvf::Vec3d> > m_pipeBranchesCLCoords;
std::vector< std::vector <RigWellResultPoint> > m_pipeBranchesWellResultPoints;
std::vector< std::vector <double> > m_pipeBranchesMeasuredDepths;
const std::map<QString, const std::vector<double>* >* m_tracerCellFractionValues;
RigEclCellIndexCalculator m_cellIndexCalculator;
std::vector<QString> m_tracerNames;
double m_smallContributionsThreshold;
bool m_isProducer;
bool m_useTotalWellPhaseRateOnly;
const std::map<QString, const std::vector<double>*>* m_tracerCellFractionValues;
RigEclCellIndexCalculator m_cellIndexCalculator;
std::vector<QString> m_tracerNames;
double m_smallContributionsThreshold;
bool m_isProducer;
bool m_useTotalWellPhaseRateOnly;
struct BranchFlow
{
std::vector<double> depthValuesFromTop;
std::vector<double> trueVerticalDepth;
std::map<QString, std::vector<double> > accFlowPrTracer;
std::map<QString, std::vector<double> > flowPrTracer;
};
std::vector<double> depthValuesFromTop;
std::vector<double> trueVerticalDepth;
std::map<QString, std::vector<double>> accFlowPrTracer;
std::map<QString, std::vector<double>> flowPrTracer;
};
void storeFlowOnDepth(BranchFlow *branchFlow,
double depthValue,
const std::vector<double>& accFlowPrTracer,
const std::vector<double>& flowPrTracer);
void storeFlowOnDepthWTvd(BranchFlow *branchFlow,
double depthValue,
double trueVerticalDepth,
const std::vector<double>& accFlowPrTracer,
const std::vector<double>& flowPrTracer);
void storeFlowOnDepth( BranchFlow* branchFlow,
double depthValue,
const std::vector<double>& accFlowPrTracer,
const std::vector<double>& flowPrTracer );
void storeFlowOnDepthWTvd( BranchFlow* branchFlow,
double depthValue,
double trueVerticalDepth,
const std::vector<double>& accFlowPrTracer,
const std::vector<double>& flowPrTracer );
std::vector<double> accumulatedDsBranchFlowPrTracer(const BranchFlow &downStreamBranchFlow) const;
void addDownStreamBranchFlow(std::vector<double> *accFlowPrTracer,
const std::vector<double>& accBranchFlowPrTracer) const;
std::vector< BranchFlow > m_connectionFlowPrBranch;
std::vector< BranchFlow > m_pseudoLengthFlowPrBranch;
std::vector<double> accumulatedDsBranchFlowPrTracer( const BranchFlow& downStreamBranchFlow ) const;
void addDownStreamBranchFlow( std::vector<double>* accFlowPrTracer,
const std::vector<double>& accBranchFlowPrTracer ) const;
std::vector<BranchFlow> m_connectionFlowPrBranch;
std::vector<BranchFlow> m_pseudoLengthFlowPrBranch;
};

View File

@@ -24,19 +24,19 @@
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo::RigActiveCellInfo()
: m_reservoirActiveCellCount(0)
, m_reservoirCellResultCount(0)
, m_activeCellPositionMin(cvf::Vec3d::ZERO)
, m_activeCellPositionMax(cvf::Vec3d::ZERO)
: m_reservoirActiveCellCount( 0 )
, m_reservoirCellResultCount( 0 )
, m_activeCellPositionMin( cvf::Vec3d::ZERO )
, m_activeCellPositionMax( cvf::Vec3d::ZERO )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setReservoirCellCount(size_t reservoirCellCount)
void RigActiveCellInfo::setReservoirCellCount( size_t reservoirCellCount )
{
m_cellIndexToResultIndex.resize(reservoirCellCount, cvf::UNDEFINED_SIZE_T);
m_cellIndexToResultIndex.resize( reservoirCellCount, cvf::UNDEFINED_SIZE_T );
}
//--------------------------------------------------------------------------------------------------
@@ -58,14 +58,14 @@ size_t RigActiveCellInfo::reservoirCellResultCount() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigActiveCellInfo::isActive(size_t reservoirCellIndex) const
bool RigActiveCellInfo::isActive( size_t reservoirCellIndex ) const
{
if (m_cellIndexToResultIndex.size() == 0)
if ( m_cellIndexToResultIndex.size() == 0 )
{
return true;
}
CVF_TIGHT_ASSERT(reservoirCellIndex < m_cellIndexToResultIndex.size());
CVF_TIGHT_ASSERT( reservoirCellIndex < m_cellIndexToResultIndex.size() );
return m_cellIndexToResultIndex[reservoirCellIndex] != cvf::UNDEFINED_SIZE_T;
}
@@ -73,14 +73,14 @@ bool RigActiveCellInfo::isActive(size_t reservoirCellIndex) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigActiveCellInfo::cellResultIndex(size_t reservoirCellIndex) const
size_t RigActiveCellInfo::cellResultIndex( size_t reservoirCellIndex ) const
{
if (m_cellIndexToResultIndex.size() == 0)
if ( m_cellIndexToResultIndex.size() == 0 )
{
return reservoirCellIndex;
}
CVF_TIGHT_ASSERT(reservoirCellIndex < m_cellIndexToResultIndex.size());
CVF_TIGHT_ASSERT( reservoirCellIndex < m_cellIndexToResultIndex.size() );
return m_cellIndexToResultIndex[reservoirCellIndex];
}
@@ -88,13 +88,13 @@ size_t RigActiveCellInfo::cellResultIndex(size_t reservoirCellIndex) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setCellResultIndex(size_t reservoirCellIndex, size_t reservoirCellResultIndex)
void RigActiveCellInfo::setCellResultIndex( size_t reservoirCellIndex, size_t reservoirCellResultIndex )
{
CVF_TIGHT_ASSERT(reservoirCellResultIndex < m_cellIndexToResultIndex.size());
CVF_TIGHT_ASSERT( reservoirCellResultIndex < m_cellIndexToResultIndex.size() );
m_cellIndexToResultIndex[reservoirCellIndex] = reservoirCellResultIndex;
#pragma omp critical
#pragma omp critical
{
if ( reservoirCellResultIndex >= m_reservoirCellResultCount )
{
@@ -106,19 +106,19 @@ void RigActiveCellInfo::setCellResultIndex(size_t reservoirCellIndex, size_t res
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGridCount(size_t gridCount)
void RigActiveCellInfo::setGridCount( size_t gridCount )
{
m_perGridActiveCellInfo.resize(gridCount);
m_perGridActiveCellInfo.resize( gridCount );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t activeCellCount)
void RigActiveCellInfo::setGridActiveCellCounts( size_t gridIndex, size_t activeCellCount )
{
CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size());
CVF_ASSERT( gridIndex < m_perGridActiveCellInfo.size() );
m_perGridActiveCellInfo[gridIndex].setActiveCellCount(activeCellCount);
m_perGridActiveCellInfo[gridIndex].setActiveCellCount( activeCellCount );
}
//--------------------------------------------------------------------------------------------------
@@ -128,7 +128,7 @@ void RigActiveCellInfo::computeDerivedData()
{
m_reservoirActiveCellCount = 0;
for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++)
for ( size_t i = 0; i < m_perGridActiveCellInfo.size(); i++ )
{
m_reservoirActiveCellCount += m_perGridActiveCellInfo[i].activeCellCount();
}
@@ -145,7 +145,7 @@ size_t RigActiveCellInfo::reservoirActiveCellCount() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setIJKBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max)
void RigActiveCellInfo::setIJKBoundingBox( const cvf::Vec3st& min, const cvf::Vec3st& max )
{
m_activeCellPositionMin = min;
m_activeCellPositionMax = max;
@@ -154,7 +154,7 @@ void RigActiveCellInfo::setIJKBoundingBox(const cvf::Vec3st& min, const cvf::Vec
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::IJKBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const
void RigActiveCellInfo::IJKBoundingBox( cvf::Vec3st& min, cvf::Vec3st& max ) const
{
min = m_activeCellPositionMin;
max = m_activeCellPositionMax;
@@ -163,7 +163,7 @@ void RigActiveCellInfo::IJKBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& activeCellCount) const
void RigActiveCellInfo::gridActiveCellCounts( size_t gridIndex, size_t& activeCellCount ) const
{
activeCellCount = m_perGridActiveCellInfo[gridIndex].activeCellCount();
}
@@ -178,7 +178,7 @@ cvf::BoundingBox RigActiveCellInfo::geometryBoundingBox() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGeometryBoundingBox(cvf::BoundingBox bb)
void RigActiveCellInfo::setGeometryBoundingBox( cvf::BoundingBox bb )
{
m_activeCellsBoundingBox = bb;
}
@@ -191,29 +191,29 @@ void RigActiveCellInfo::clear()
m_perGridActiveCellInfo.clear();
m_cellIndexToResultIndex.clear();
m_reservoirActiveCellCount = 0;
m_activeCellPositionMin = cvf::Vec3st(0, 0, 0);
m_activeCellPositionMax = cvf::Vec3st(0, 0, 0);
m_activeCellPositionMin = cvf::Vec3st( 0, 0, 0 );
m_activeCellPositionMax = cvf::Vec3st( 0, 0, 0 );
m_activeCellsBoundingBox.reset();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::addLgr(size_t cellCount)
void RigActiveCellInfo::addLgr( size_t cellCount )
{
size_t currentGridCount = m_perGridActiveCellInfo.size();
size_t currentActiveCellCount = reservoirActiveCellCount();
size_t currentReservoirCellCount = reservoirCellCount();
setGridCount(currentGridCount + 1);
setGridActiveCellCounts(currentGridCount, cellCount);
setReservoirCellCount(currentReservoirCellCount + cellCount);
setGridCount( currentGridCount + 1 );
setGridActiveCellCounts( currentGridCount, cellCount );
setReservoirCellCount( currentReservoirCellCount + cellCount );
computeDerivedData();
for (size_t i = 0; i < cellCount; i++)
for ( size_t i = 0; i < cellCount; i++ )
{
setCellResultIndex(currentReservoirCellCount + i, currentActiveCellCount + i);
setCellResultIndex( currentReservoirCellCount + i, currentActiveCellCount + i );
}
}
@@ -229,7 +229,7 @@ bool RigActiveCellInfo::isCoarseningActive() const
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo::GridActiveCellCounts::GridActiveCellCounts()
: m_activeCellCount(0)
: m_activeCellCount( 0 )
{
}
@@ -244,7 +244,7 @@ size_t RigActiveCellInfo::GridActiveCellCounts::activeCellCount() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::GridActiveCellCounts::setActiveCellCount(size_t activeCellCount)
void RigActiveCellInfo::GridActiveCellCounts::setActiveCellCount( size_t activeCellCount )
{
m_activeCellCount = activeCellCount;
}

View File

@@ -3,60 +3,58 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBoundingBox.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfBoundingBox.h"
#include <vector>
class RigActiveCellInfo : public cvf::Object
{
public:
RigActiveCellInfo();
void setReservoirCellCount(size_t reservoirCellCount);
size_t reservoirCellCount() const;
size_t reservoirActiveCellCount() const;
size_t reservoirCellResultCount() const;
bool isCoarseningActive() const;
void setReservoirCellCount( size_t reservoirCellCount );
size_t reservoirCellCount() const;
size_t reservoirActiveCellCount() const;
size_t reservoirCellResultCount() const;
bool isCoarseningActive() const;
bool isActive(size_t reservoirCellIndex) const;
size_t cellResultIndex(size_t reservoirCellIndex) const;
void setCellResultIndex(size_t reservoirCellIndex, size_t globalResultCellIndex);
bool isActive( size_t reservoirCellIndex ) const;
size_t cellResultIndex( size_t reservoirCellIndex ) const;
void setCellResultIndex( size_t reservoirCellIndex, size_t globalResultCellIndex );
void setGridCount(size_t gridCount);
void setGridActiveCellCounts(size_t gridIndex, size_t activeCellCount);
void gridActiveCellCounts(size_t gridIndex, size_t& activeCellCount) const;
void computeDerivedData();
void setGridCount( size_t gridCount );
void setGridActiveCellCounts( size_t gridIndex, size_t activeCellCount );
void gridActiveCellCounts( size_t gridIndex, size_t& activeCellCount ) const;
void computeDerivedData();
void setIJKBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max);
void IJKBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const;
void setIJKBoundingBox( const cvf::Vec3st& min, const cvf::Vec3st& max );
void IJKBoundingBox( cvf::Vec3st& min, cvf::Vec3st& max ) const;
cvf::BoundingBox geometryBoundingBox() const;
void setGeometryBoundingBox(cvf::BoundingBox bb);
cvf::BoundingBox geometryBoundingBox() const;
void setGeometryBoundingBox( cvf::BoundingBox bb );
void clear();
void clear();
void addLgr(size_t cellCount);
void addLgr( size_t cellCount );
private:
class GridActiveCellCounts
@@ -64,24 +62,23 @@ private:
public:
GridActiveCellCounts();
size_t activeCellCount() const;
void setActiveCellCount(size_t activeCellCount);
size_t activeCellCount() const;
void setActiveCellCount( size_t activeCellCount );
private:
size_t m_activeCellCount;
size_t m_activeCellCount;
};
private:
std::vector<GridActiveCellCounts> m_perGridActiveCellInfo;
std::vector<GridActiveCellCounts> m_perGridActiveCellInfo;
std::vector<size_t> m_cellIndexToResultIndex;
std::vector<size_t> m_cellIndexToResultIndex;
size_t m_reservoirActiveCellCount;
size_t m_reservoirCellResultCount;
size_t m_reservoirActiveCellCount;
size_t m_reservoirCellResultCount;
cvf::Vec3st m_activeCellPositionMin;
cvf::Vec3st m_activeCellPositionMax;
cvf::Vec3st m_activeCellPositionMin;
cvf::Vec3st m_activeCellPositionMax;
cvf::BoundingBox m_activeCellsBoundingBox;
cvf::BoundingBox m_activeCellsBoundingBox;
};

View File

@@ -2,87 +2,88 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigActiveCellsResultAccessor.h"
#include "RigGridBase.h"
#include "RigActiveCellInfo.h"
#include "RigGridBase.h"
#include <cmath>
RigActiveCellsResultAccessor::RigActiveCellsResultAccessor(const RigGridBase* grid, const std::vector<double>* reservoirResultValues, const RigActiveCellInfo* activeCellInfo)
: m_activeCellInfo(activeCellInfo),
m_grid(grid),
m_reservoirResultValues(reservoirResultValues)
RigActiveCellsResultAccessor::RigActiveCellsResultAccessor( const RigGridBase* grid,
const std::vector<double>* reservoirResultValues,
const RigActiveCellInfo* activeCellInfo )
: m_activeCellInfo( activeCellInfo )
, m_grid( grid )
, m_reservoirResultValues( reservoirResultValues )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigActiveCellsResultAccessor::cellScalar(size_t gridLocalCellIndex) const
double RigActiveCellsResultAccessor::cellScalar( size_t gridLocalCellIndex ) const
{
if (m_reservoirResultValues == nullptr || m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
if ( m_reservoirResultValues == nullptr || m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
size_t reservoirCellIndex = m_grid->reservoirCellIndex(gridLocalCellIndex);
size_t resultValueIndex = m_activeCellInfo->cellResultIndex(reservoirCellIndex);
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
size_t reservoirCellIndex = m_grid->reservoirCellIndex( gridLocalCellIndex );
size_t resultValueIndex = m_activeCellInfo->cellResultIndex( reservoirCellIndex );
if ( resultValueIndex == cvf::UNDEFINED_SIZE_T ) return HUGE_VAL;
if (resultValueIndex < m_reservoirResultValues->size())
return m_reservoirResultValues->at(resultValueIndex);
if ( resultValueIndex < m_reservoirResultValues->size() ) return m_reservoirResultValues->at( resultValueIndex );
CVF_TIGHT_ASSERT(resultValueIndex < m_activeCellInfo->reservoirActiveCellCount()); // Because some static results might lack LGR data
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigActiveCellsResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const
{
return cellScalar(gridLocalCellIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigActiveCellsResultAccessor::cellScalarGlobIdx(size_t reservoirCellIndex) const
{
if (m_reservoirResultValues == nullptr || m_reservoirResultValues->size() == 0) return HUGE_VAL;
size_t resultValueIndex = m_activeCellInfo->cellResultIndex(reservoirCellIndex);
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
if(resultValueIndex < m_reservoirResultValues->size())
return m_reservoirResultValues->at(resultValueIndex);
CVF_TIGHT_ASSERT(resultValueIndex < m_activeCellInfo->reservoirActiveCellCount()); // Because some static results might lack LGR data
CVF_TIGHT_ASSERT( resultValueIndex <
m_activeCellInfo->reservoirActiveCellCount() ); // Because some static results might lack LGR data
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigActiveCellsResultAccessor::cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigActiveCellsResultAccessor::cellFaceScalar( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
return cellScalarGlobIdx(globCellIndex);
return cellScalar( gridLocalCellIndex );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigActiveCellsResultAccessor::cellScalarGlobIdx( size_t reservoirCellIndex ) const
{
if ( m_reservoirResultValues == nullptr || m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
size_t resultValueIndex = m_activeCellInfo->cellResultIndex( reservoirCellIndex );
if ( resultValueIndex == cvf::UNDEFINED_SIZE_T ) return HUGE_VAL;
if ( resultValueIndex < m_reservoirResultValues->size() ) return m_reservoirResultValues->at( resultValueIndex );
CVF_TIGHT_ASSERT( resultValueIndex <
m_activeCellInfo->reservoirActiveCellCount() ); // Because some static results might lack LGR data
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigActiveCellsResultAccessor::cellFaceScalarGlobIdx( size_t globCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
return cellScalarGlobIdx( globCellIndex );
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -24,24 +24,24 @@
class RigGridBase;
class RigActiveCellInfo;
//==================================================================================================
///
///
//==================================================================================================
class RigActiveCellsResultAccessor : public RigResultAccessor
{
public:
RigActiveCellsResultAccessor(const RigGridBase* grid, const std::vector<double>* reservoirResultValues, const RigActiveCellInfo* activeCellInfo);
RigActiveCellsResultAccessor( const RigGridBase* grid,
const std::vector<double>* reservoirResultValues,
const RigActiveCellInfo* activeCellInfo );
double cellScalar(size_t gridLocalCellIndex) const override;
double cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalar( size_t gridLocalCellIndex ) const override;
double cellFaceScalar( size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
double cellScalarGlobIdx(size_t globCellIndex) const override;
double cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalarGlobIdx( size_t globCellIndex ) const override;
double cellFaceScalarGlobIdx( size_t globCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
private:
const RigActiveCellInfo* m_activeCellInfo;
const RigGridBase* m_grid;
const std::vector<double>* m_reservoirResultValues;
const RigActiveCellInfo* m_activeCellInfo;
const RigGridBase* m_grid;
const std::vector<double>* m_reservoirResultValues;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,55 +23,55 @@
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigAllGridCellsResultAccessor::RigAllGridCellsResultAccessor(const RigGridBase* grid, const std::vector<double>* reservoirResultValues)
: m_grid(grid),
m_reservoirResultValues(reservoirResultValues)
RigAllGridCellsResultAccessor::RigAllGridCellsResultAccessor( const RigGridBase* grid,
const std::vector<double>* reservoirResultValues )
: m_grid( grid )
, m_reservoirResultValues( reservoirResultValues )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigAllGridCellsResultAccessor::cellScalar(size_t gridLocalCellIndex) const
double RigAllGridCellsResultAccessor::cellScalar( size_t gridLocalCellIndex ) const
{
if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
if ( m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
size_t reservoirCellIndex = m_grid->reservoirCellIndex(gridLocalCellIndex);
CVF_TIGHT_ASSERT(reservoirCellIndex < m_reservoirResultValues->size());
size_t reservoirCellIndex = m_grid->reservoirCellIndex( gridLocalCellIndex );
CVF_TIGHT_ASSERT( reservoirCellIndex < m_reservoirResultValues->size() );
return m_reservoirResultValues->at(reservoirCellIndex);
return m_reservoirResultValues->at( reservoirCellIndex );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigAllGridCellsResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigAllGridCellsResultAccessor::cellFaceScalar( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
return cellScalar(gridLocalCellIndex);
return cellScalar( gridLocalCellIndex );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigAllGridCellsResultAccessor::cellScalarGlobIdx(size_t globCellIndex) const
double RigAllGridCellsResultAccessor::cellScalarGlobIdx( size_t globCellIndex ) const
{
if (m_reservoirResultValues->size() == 0) return HUGE_VAL;
if ( m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
CVF_TIGHT_ASSERT(globCellIndex < m_reservoirResultValues->size());
return m_reservoirResultValues->at(globCellIndex);
CVF_TIGHT_ASSERT( globCellIndex < m_reservoirResultValues->size() );
return m_reservoirResultValues->at( globCellIndex );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigAllGridCellsResultAccessor::cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigAllGridCellsResultAccessor::cellFaceScalarGlobIdx( size_t globCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
return cellScalarGlobIdx(globCellIndex);
return cellScalarGlobIdx( globCellIndex );
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,23 +23,20 @@
class RigGridBase;
//==================================================================================================
///
///
//==================================================================================================
class RigAllGridCellsResultAccessor : public RigResultAccessor
{
public:
RigAllGridCellsResultAccessor(const RigGridBase* grid, const std::vector<double>* reservoirResultValues);
RigAllGridCellsResultAccessor( const RigGridBase* grid, const std::vector<double>* reservoirResultValues );
double cellScalar(size_t gridLocalCellIndex) const override;
double cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalarGlobIdx(size_t globCellIndex) const override;
double cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalar( size_t gridLocalCellIndex ) const override;
double cellFaceScalar( size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
double cellScalarGlobIdx( size_t globCellIndex ) const override;
double cellFaceScalarGlobIdx( size_t globCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
private:
const RigGridBase* m_grid;
const std::vector<double>* m_reservoirResultValues;
const RigGridBase* m_grid;
const std::vector<double>* m_reservoirResultValues;
};

View File

@@ -39,25 +39,25 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCaseCellResultCalculator::computeDifference(RigEclipseCaseData* sourceCase,
RiaDefines::PorosityModelType porosityModel,
const RigEclipseResultAddress& address)
bool RigCaseCellResultCalculator::computeDifference( RigEclipseCaseData* sourceCase,
RiaDefines::PorosityModelType porosityModel,
const RigEclipseResultAddress& address )
{
CVF_ASSERT(address.isValid());
CVF_ASSERT(address.hasDifferenceCase() || address.isTimeLapse());
CVF_ASSERT( address.isValid() );
CVF_ASSERT( address.hasDifferenceCase() || address.isTimeLapse() );
// Assume at this stage that data for the case is available
// It is up to the caller to make sure the case is read from file
RigEclipseCaseData* baseCase = sourceCase;
if (address.hasDifferenceCase())
if ( address.hasDifferenceCase() )
{
{
auto eclipseCases = RiaApplication::instance()->project()->eclipseCases();
for (RimEclipseCase* c : eclipseCases)
for ( RimEclipseCase* c : eclipseCases )
{
if (c && c->caseId() == address.m_differenceCaseId && c->eclipseCaseData())
if ( c && c->caseId() == address.m_differenceCaseId && c->eclipseCaseData() )
{
baseCase = c->eclipseCaseData();
}
@@ -65,9 +65,9 @@ bool RigCaseCellResultCalculator::computeDifference(RigEclipseCaseData*
}
}
if (!baseCase || !sourceCase)
if ( !baseCase || !sourceCase )
{
RiaLogging::error("Missing input case for difference calculator");
RiaLogging::error( "Missing input case for difference calculator" );
return false;
}
@@ -75,92 +75,100 @@ bool RigCaseCellResultCalculator::computeDifference(RigEclipseCaseData*
RigMainGrid* sourceMainGrid = sourceCase->mainGrid();
RigMainGrid* baseMainGrid = baseCase->mainGrid();
if (!RigGridManager::isMainGridDimensionsEqual(sourceMainGrid, baseMainGrid))
if ( !RigGridManager::isMainGridDimensionsEqual( sourceMainGrid, baseMainGrid ) )
{
RiaLogging::error("Case difference : Grid cases do not match");
RiaLogging::error( "Case difference : Grid cases do not match" );
return false;
}
RigCaseCellResultsData* baseCaseResults = baseCase->results(porosityModel);
RigCaseCellResultsData* sourceCaseResults = sourceCase->results(porosityModel);
RigCaseCellResultsData* baseCaseResults = baseCase->results( porosityModel );
RigCaseCellResultsData* sourceCaseResults = sourceCase->results( porosityModel );
if (!baseCaseResults || !sourceCaseResults)
if ( !baseCaseResults || !sourceCaseResults )
{
RiaLogging::error("Missing result data for difference calculator");
RiaLogging::error( "Missing result data for difference calculator" );
return false;
}
RigEclipseResultAddress nativeAddress(address);
RigEclipseResultAddress nativeAddress( address );
nativeAddress.m_differenceCaseId = RigEclipseResultAddress::noCaseDiffValue();
nativeAddress.m_timeLapseBaseFrameIdx = RigEclipseResultAddress::noTimeLapseValue();
if (!sourceCaseResults->ensureKnownResultLoaded(nativeAddress))
if ( !sourceCaseResults->ensureKnownResultLoaded( nativeAddress ) )
{
RiaLogging::error("Failed to load destination diff result");
RiaLogging::error( "Failed to load destination diff result" );
return false;
}
if (!baseCaseResults->ensureKnownResultLoaded(nativeAddress))
if ( !baseCaseResults->ensureKnownResultLoaded( nativeAddress ) )
{
RiaLogging::error("Failed to load difference result");
RiaLogging::error( "Failed to load difference result" );
return false;
}
// Initialize difference result with infinity for correct number of time steps and values per time step
{
const std::vector<std::vector<double>>& srcFrames = sourceCaseResults->cellScalarResults(nativeAddress);
std::vector<std::vector<double>>& diffResultFrames = sourceCaseResults->modifiableCellScalarResultTimesteps(address);
diffResultFrames.resize(srcFrames.size());
for (size_t fIdx = 0; fIdx < srcFrames.size(); ++fIdx)
const std::vector<std::vector<double>>& srcFrames = sourceCaseResults->cellScalarResults( nativeAddress );
std::vector<std::vector<double>>& diffResultFrames = sourceCaseResults->modifiableCellScalarResultTimesteps(
address );
diffResultFrames.resize( srcFrames.size() );
for ( size_t fIdx = 0; fIdx < srcFrames.size(); ++fIdx )
{
const std::vector<double>& srcVals = srcFrames[fIdx];
std::vector<double>& dstVals = diffResultFrames[fIdx];
dstVals.resize(srcVals.size(), std::numeric_limits<double>::infinity());
dstVals.resize( srcVals.size(), std::numeric_limits<double>::infinity() );
}
}
size_t baseFrameCount = baseCaseResults->cellScalarResults(nativeAddress).size();
size_t sourceFrameCount = sourceCaseResults->cellScalarResults(nativeAddress).size();
size_t maxFrameCount = std::min(baseFrameCount, sourceFrameCount);
size_t maxGridCount = std::min(baseMainGrid->gridCount(), sourceMainGrid->gridCount());
size_t baseFrameCount = baseCaseResults->cellScalarResults( nativeAddress ).size();
size_t sourceFrameCount = sourceCaseResults->cellScalarResults( nativeAddress ).size();
size_t maxFrameCount = std::min( baseFrameCount, sourceFrameCount );
size_t maxGridCount = std::min( baseMainGrid->gridCount(), sourceMainGrid->gridCount() );
for (size_t gridIdx = 0; gridIdx < maxGridCount; ++gridIdx)
for ( size_t gridIdx = 0; gridIdx < maxGridCount; ++gridIdx )
{
auto grid = sourceMainGrid->gridByIndex(gridIdx);
auto grid = sourceMainGrid->gridByIndex( gridIdx );
const RigActiveCellInfo* activeCellInfo = sourceCaseResults->activeCellInfo();
for (size_t fIdx = 0; fIdx < maxFrameCount; ++fIdx)
for ( size_t fIdx = 0; fIdx < maxFrameCount; ++fIdx )
{
cvf::ref<RigResultAccessor> sourceResultAccessor =
RigResultAccessorFactory::createFromResultAddress(sourceCase, gridIdx, porosityModel, fIdx, nativeAddress);
RigResultAccessorFactory::createFromResultAddress( sourceCase, gridIdx, porosityModel, fIdx, nativeAddress );
cvf::ref<RigResultModifier> resultModifier =
RigResultModifierFactory::createResultModifier(sourceCase, gridIdx, porosityModel, fIdx, address);
cvf::ref<RigResultModifier> resultModifier = RigResultModifierFactory::createResultModifier( sourceCase,
gridIdx,
porosityModel,
fIdx,
address );
size_t baseFrameIdx = fIdx;
if (address.isTimeLapse())
if ( address.isTimeLapse() )
{
baseFrameIdx = address.m_timeLapseBaseFrameIdx;
}
cvf::ref<RigResultAccessor> baseResultAccessor =
RigResultAccessorFactory::createFromResultAddress(baseCase, gridIdx, porosityModel, baseFrameIdx, nativeAddress);
RigResultAccessorFactory::createFromResultAddress( baseCase,
gridIdx,
porosityModel,
baseFrameIdx,
nativeAddress );
for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++)
for ( size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++ )
{
size_t reservoirCellIndex = grid->reservoirCellIndex(localGridCellIdx);
if (activeCellInfo->isActive(reservoirCellIndex))
size_t reservoirCellIndex = grid->reservoirCellIndex( localGridCellIdx );
if ( activeCellInfo->isActive( reservoirCellIndex ) )
{
double sourceVal = sourceResultAccessor->cellScalar(localGridCellIdx);
double baseVal = baseResultAccessor->cellScalar(localGridCellIdx);
double sourceVal = sourceResultAccessor->cellScalar( localGridCellIdx );
double baseVal = baseResultAccessor->cellScalar( localGridCellIdx );
double difference = sourceVal - baseVal;
resultModifier->setCellScalar(localGridCellIdx, difference);
resultModifier->setCellScalar( localGridCellIdx, difference );
}
}
}

View File

@@ -29,7 +29,7 @@ class RigEclipseResultAddress;
class RigCaseCellResultCalculator
{
public:
static bool computeDifference(RigEclipseCaseData* destination,
RiaDefines::PorosityModelType porosityModel,
const RigEclipseResultAddress& address);
static bool computeDifference( RigEclipseCaseData* destination,
RiaDefines::PorosityModelType porosityModel,
const RigEclipseResultAddress& address );
};

File diff suppressed because it is too large Load Diff

View File

@@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -29,9 +29,8 @@
#include <QDateTime>
#include <vector>
#include <cmath>
#include <vector>
class RifReaderInterface;
class RigActiveCellInfo;
@@ -44,155 +43,157 @@ class RigFormationNames;
class RimEclipseCase;
//==================================================================================================
/// Class containing the results for the complete number of active cells. Both main grid and LGR's
//==================================================================================================
class RigCaseCellResultsData : public cvf::Object
{
public:
explicit RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData, RiaDefines::PorosityModelType porosityModel);
explicit RigCaseCellResultsData( RigEclipseCaseData* ownerCaseData, RiaDefines::PorosityModelType porosityModel );
// Initialization
void setReaderInterface(RifReaderInterface* readerInterface);
const RifReaderInterface* readerInterface() const;
void setHdf5Filename(const QString& hdf5SourSimFilename );
void setActiveFormationNames(RigFormationNames* activeFormationNames);
RigFormationNames* activeFormationNames();
void setReaderInterface( RifReaderInterface* readerInterface );
const RifReaderInterface* readerInterface() const;
void setHdf5Filename( const QString& hdf5SourSimFilename );
void setActiveFormationNames( RigFormationNames* activeFormationNames );
RigFormationNames* activeFormationNames();
void setMainGrid(RigMainGrid* ownerGrid);
void setActiveCellInfo(RigActiveCellInfo* activeCellInfo);
RigActiveCellInfo* activeCellInfo();
const RigActiveCellInfo* activeCellInfo() const;
void setMainGrid( RigMainGrid* ownerGrid );
void setActiveCellInfo( RigActiveCellInfo* activeCellInfo );
RigActiveCellInfo* activeCellInfo();
const RigActiveCellInfo* activeCellInfo() const;
// Access the results data
const std::vector< std::vector<double> > & cellScalarResults(const RigEclipseResultAddress& resVarAddr) const;
const std::vector<double>& cellScalarResults(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex) const;
std::vector< std::vector<double> > & modifiableCellScalarResultTimesteps(const RigEclipseResultAddress& resVarAddr);
std::vector<double>& modifiableCellScalarResult(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex);
const std::vector<std::vector<double>>& cellScalarResults( const RigEclipseResultAddress& resVarAddr ) const;
const std::vector<double>& cellScalarResults( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) const;
std::vector<std::vector<double>>& modifiableCellScalarResultTimesteps( const RigEclipseResultAddress& resVarAddr );
std::vector<double>& modifiableCellScalarResult( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex );
bool isUsingGlobalActiveIndex(const RigEclipseResultAddress& resVarAddr) const;
bool isUsingGlobalActiveIndex( const RigEclipseResultAddress& resVarAddr ) const;
static const std::vector<double>* getResultIndexableStaticResult(RigActiveCellInfo* actCellInfo,
RigCaseCellResultsData* gridCellResults,
QString porvResultName,
std::vector<double> &activeCellsResultsTempContainer);
static const std::vector<double>*
getResultIndexableStaticResult( RigActiveCellInfo* actCellInfo,
RigCaseCellResultsData* gridCellResults,
QString porvResultName,
std::vector<double>& activeCellsResultsTempContainer );
// Statistic values of the results
void recalculateStatistics(const RigEclipseResultAddress& resVarAddr);
void minMaxCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& min, double& max);
void minMaxCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& min, double& max);
void posNegClosestToZero(const RigEclipseResultAddress& resVarAddr, double& pos, double& neg);
void posNegClosestToZero(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& pos, double& neg);
const std::vector<size_t>& cellScalarValuesHistogram(const RigEclipseResultAddress& resVarAddr);
const std::vector<size_t>& cellScalarValuesHistogram(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex);
void p10p90CellScalarValues(const RigEclipseResultAddress& resVarAddr, double& p10, double& p90);
void p10p90CellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& p10, double& p90);
void meanCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& meanValue);
void meanCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue);
const std::vector<int>& uniqueCellScalarValues(const RigEclipseResultAddress& resVarAddr);
void sumCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& sumValue);
void sumCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& sumValue);
void mobileVolumeWeightedMean(const RigEclipseResultAddress& resVarAddr, double& meanValue);
void mobileVolumeWeightedMean(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue);
void recalculateStatistics( const RigEclipseResultAddress& resVarAddr );
void minMaxCellScalarValues( const RigEclipseResultAddress& resVarAddr, double& min, double& max );
void minMaxCellScalarValues( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& min, double& max );
void posNegClosestToZero( const RigEclipseResultAddress& resVarAddr, double& pos, double& neg );
void posNegClosestToZero( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& pos, double& neg );
const std::vector<size_t>& cellScalarValuesHistogram( const RigEclipseResultAddress& resVarAddr );
const std::vector<size_t>& cellScalarValuesHistogram( const RigEclipseResultAddress& resVarAddr,
size_t timeStepIndex );
void p10p90CellScalarValues( const RigEclipseResultAddress& resVarAddr, double& p10, double& p90 );
void p10p90CellScalarValues( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& p10, double& p90 );
void meanCellScalarValues( const RigEclipseResultAddress& resVarAddr, double& meanValue );
void meanCellScalarValues( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue );
const std::vector<int>& uniqueCellScalarValues( const RigEclipseResultAddress& resVarAddr );
void sumCellScalarValues( const RigEclipseResultAddress& resVarAddr, double& sumValue );
void sumCellScalarValues( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& sumValue );
void mobileVolumeWeightedMean( const RigEclipseResultAddress& resVarAddr, double& meanValue );
void mobileVolumeWeightedMean( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue );
// Access meta-information about the results
size_t timeStepCount(const RigEclipseResultAddress& resVarAddr) const;
size_t maxTimeStepCount(RigEclipseResultAddress* resultAddressWithMostTimeSteps = nullptr) const;
size_t timeStepCount( const RigEclipseResultAddress& resVarAddr ) const;
size_t maxTimeStepCount( RigEclipseResultAddress* resultAddressWithMostTimeSteps = nullptr ) const;
std::vector<QDateTime> allTimeStepDatesFromEclipseReader() const;
std::vector<QDateTime> timeStepDates() const;
std::vector<QDateTime> timeStepDates(const RigEclipseResultAddress& resVarAddr) const;
std::vector<double> daysSinceSimulationStart() const;
std::vector<double> daysSinceSimulationStart(const RigEclipseResultAddress& resVarAddr) const;
int reportStepNumber(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex) const;
std::vector<RigEclipseTimeStepInfo> timeStepInfos(const RigEclipseResultAddress& resVarAddr) const;
void setTimeStepInfos(const RigEclipseResultAddress& resVarAddr, const std::vector<RigEclipseTimeStepInfo>& timeStepInfos);
std::vector<QDateTime> allTimeStepDatesFromEclipseReader() const;
std::vector<QDateTime> timeStepDates() const;
std::vector<QDateTime> timeStepDates( const RigEclipseResultAddress& resVarAddr ) const;
std::vector<double> daysSinceSimulationStart() const;
std::vector<double> daysSinceSimulationStart( const RigEclipseResultAddress& resVarAddr ) const;
int reportStepNumber( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) const;
void clearScalarResult(RiaDefines::ResultCatType type, const QString & resultName);
void clearScalarResult(const RigEclipseResultAddress& resultAddress);
void clearAllResults();
void freeAllocatedResultsData();
void eraseAllSourSimData();
std::vector<RigEclipseTimeStepInfo> timeStepInfos( const RigEclipseResultAddress& resVarAddr ) const;
void setTimeStepInfos( const RigEclipseResultAddress& resVarAddr,
const std::vector<RigEclipseTimeStepInfo>& timeStepInfos );
QStringList resultNames(RiaDefines::ResultCatType type) const;
std::vector<RigEclipseResultAddress> existingResults() const;
const RigEclipseResultInfo* resultInfo(const RigEclipseResultAddress& resVarAddr) const;
bool updateResultName(RiaDefines::ResultCatType resultType, QString& oldName, const QString& newName);
QString makeResultNameUnique(const QString& resultNameProposal) const;
void clearScalarResult( RiaDefines::ResultCatType type, const QString& resultName );
void clearScalarResult( const RigEclipseResultAddress& resultAddress );
void clearAllResults();
void freeAllocatedResultsData();
void eraseAllSourSimData();
void ensureKnownResultLoadedForTimeStep(const RigEclipseResultAddress& resultAddress, size_t timeStepIndex);
bool ensureKnownResultLoaded(const RigEclipseResultAddress& resultAddress);
bool hasResultEntry(const RigEclipseResultAddress& resultAddress) const;
bool isResultLoaded(const RigEclipseResultAddress& resultAddress) const;
void createResultEntry(const RigEclipseResultAddress& resultAddress, bool needsToBeStored);
void createPlaceholderResultEntries();
void computeDepthRelatedResults();
void computeCellVolumes();
bool hasFlowDiagUsableFluxes() const;
QStringList resultNames( RiaDefines::ResultCatType type ) const;
std::vector<RigEclipseResultAddress> existingResults() const;
const RigEclipseResultInfo* resultInfo( const RigEclipseResultAddress& resVarAddr ) const;
bool updateResultName( RiaDefines::ResultCatType resultType, QString& oldName, const QString& newName );
QString makeResultNameUnique( const QString& resultNameProposal ) const;
static void copyResultsMetaDataFromMainCase(RigEclipseCaseData* mainCaseResultsData,
RiaDefines::PorosityModelType poroModel,
std::vector<RimEclipseCase*> destinationCases);
private:
size_t findOrLoadKnownScalarResult(const RigEclipseResultAddress& resVarAddr);
size_t findOrLoadKnownScalarResultForTimeStep(const RigEclipseResultAddress& resVarAddr,
size_t timeStepIndex);
size_t findOrCreateScalarResultIndex(const RigEclipseResultAddress& resVarAddr, bool needsToBeStored);
void ensureKnownResultLoadedForTimeStep( const RigEclipseResultAddress& resultAddress, size_t timeStepIndex );
bool ensureKnownResultLoaded( const RigEclipseResultAddress& resultAddress );
bool hasResultEntry( const RigEclipseResultAddress& resultAddress ) const;
bool isResultLoaded( const RigEclipseResultAddress& resultAddress ) const;
void createResultEntry( const RigEclipseResultAddress& resultAddress, bool needsToBeStored );
void createPlaceholderResultEntries();
void computeDepthRelatedResults();
void computeCellVolumes();
bool hasFlowDiagUsableFluxes() const;
size_t findScalarResultIndexFromAddress(const RigEclipseResultAddress& resVarAddr ) const;
size_t addStaticScalarResult(RiaDefines::ResultCatType type,
const QString& resultName,
bool needsToBeStored,
size_t resultValueCount);
const std::vector<RigEclipseResultInfo>& infoForEachResultIndex();
size_t resultCount() const;
bool mustBeCalculated(size_t scalarResultIndex) const;
void setMustBeCalculated(size_t scalarResultIndex);
void computeSOILForTimeStep(size_t timeStepIndex);
void testAndComputeSgasForTimeStep(size_t timeStepIndex);
bool hasCompleteTransmissibilityResults() const;
void computeRiTransComponent(const QString& riTransComponentResultName);
void computeNncCombRiTrans();
void computeRiMULTComponent(const QString& riMultCompName);
void computeNncCombRiMULT();
void computeRiTRANSbyAreaComponent(const QString& riTransByAreaCompResultName);
void computeNncCombRiTRANSbyArea();
void computeCompletionTypeForTimeStep(size_t timeStep);
double darchysValue();
void computeOilVolumes();
void computeMobilePV();
bool isDataPresent(size_t scalarResultIndex) const;
void assignValuesToTemporaryLgrs(const QString& resultName, std::vector<double>& values);
RigStatisticsDataCache* statistics(const RigEclipseResultAddress& resVarAddr);
static void copyResultsMetaDataFromMainCase( RigEclipseCaseData* mainCaseResultsData,
RiaDefines::PorosityModelType poroModel,
std::vector<RimEclipseCase*> destinationCases );
private:
cvf::ref<RifReaderInterface> m_readerInterface;
cvf::ref<RigFormationNames> m_activeFormationNamesData;
size_t findOrLoadKnownScalarResult( const RigEclipseResultAddress& resVarAddr );
size_t findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex );
size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored );
std::vector< std::vector< std::vector<double> > > m_cellScalarResults; ///< Scalar results on the complete reservoir for each Result index (ResultVariable) and timestep
cvf::Collection<RigStatisticsDataCache> m_statisticsDataCache;
std::vector<RigEclipseResultInfo> m_resultInfos;
size_t findScalarResultIndexFromAddress( const RigEclipseResultAddress& resVarAddr ) const;
RigMainGrid* m_ownerMainGrid;
RigEclipseCaseData* m_ownerCaseData;
RigActiveCellInfo* m_activeCellInfo;
RiaDefines::PorosityModelType m_porosityModel;
size_t addStaticScalarResult( RiaDefines::ResultCatType type,
const QString& resultName,
bool needsToBeStored,
size_t resultValueCount );
const std::vector<RigEclipseResultInfo>& infoForEachResultIndex();
size_t resultCount() const;
bool mustBeCalculated( size_t scalarResultIndex ) const;
void setMustBeCalculated( size_t scalarResultIndex );
void computeSOILForTimeStep( size_t timeStepIndex );
void testAndComputeSgasForTimeStep( size_t timeStepIndex );
bool hasCompleteTransmissibilityResults() const;
void computeRiTransComponent( const QString& riTransComponentResultName );
void computeNncCombRiTrans();
void computeRiMULTComponent( const QString& riMultCompName );
void computeNncCombRiMULT();
void computeRiTRANSbyAreaComponent( const QString& riTransByAreaCompResultName );
void computeNncCombRiTRANSbyArea();
void computeCompletionTypeForTimeStep( size_t timeStep );
double darchysValue();
void computeOilVolumes();
void computeMobilePV();
bool isDataPresent( size_t scalarResultIndex ) const;
void assignValuesToTemporaryLgrs( const QString& resultName, std::vector<double>& values );
RigStatisticsDataCache* statistics( const RigEclipseResultAddress& resVarAddr );
private:
cvf::ref<RifReaderInterface> m_readerInterface;
cvf::ref<RigFormationNames> m_activeFormationNamesData;
std::vector<std::vector<std::vector<double>>>
m_cellScalarResults; ///< Scalar results on the complete reservoir for each Result index (ResultVariable) and timestep
cvf::Collection<RigStatisticsDataCache> m_statisticsDataCache;
std::vector<RigEclipseResultInfo> m_resultInfos;
RigMainGrid* m_ownerMainGrid;
RigEclipseCaseData* m_ownerCaseData;
RigActiveCellInfo* m_activeCellInfo;
RiaDefines::PorosityModelType m_porosityModel;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,53 +21,56 @@
#include <QString>
#include <QStringList>
#include <limits>
#include <functional>
#include <limits>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCaseRealizationParameters::Value::Value() : m_valueType(TYPE_NONE), m_numericValue(std::numeric_limits<double>::infinity())
RigCaseRealizationParameters::Value::Value()
: m_valueType( TYPE_NONE )
, m_numericValue( std::numeric_limits<double>::infinity() )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCaseRealizationParameters::Value::Value(double value) : Value()
RigCaseRealizationParameters::Value::Value( double value )
: Value()
{
setValue(value);
setValue( value );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCaseRealizationParameters::Value::Value(const QString& value) : Value()
RigCaseRealizationParameters::Value::Value( const QString& value )
: Value()
{
setValue(value);
setValue( value );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseRealizationParameters::Value::setValue(double value)
void RigCaseRealizationParameters::Value::setValue( double value )
{
m_valueType = TYPE_NUMERIC;
m_valueType = TYPE_NUMERIC;
m_numericValue = value;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseRealizationParameters::Value::setValue(const QString& value)
void RigCaseRealizationParameters::Value::setValue( const QString& value )
{
m_valueType = TYPE_TEXT;
m_textValue = value;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCaseRealizationParameters::Value::numericValue() const
{
@@ -75,7 +78,7 @@ double RigCaseRealizationParameters::Value::numericValue() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
const QString& RigCaseRealizationParameters::Value::textValue() const
{
@@ -83,32 +86,32 @@ const QString& RigCaseRealizationParameters::Value::textValue() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseRealizationParameters::addParameter(const QString& name, double value)
void RigCaseRealizationParameters::addParameter( const QString& name, double value )
{
m_parameters[name].setValue(value);
m_parameters[name].setValue( value );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseRealizationParameters::addParameter(const QString& name, const QString& value)
void RigCaseRealizationParameters::addParameter( const QString& name, const QString& value )
{
m_parameters[name].setValue(value);
m_parameters[name].setValue( value );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCaseRealizationParameters::Value RigCaseRealizationParameters::parameterValue(const QString& name)
RigCaseRealizationParameters::Value RigCaseRealizationParameters::parameterValue( const QString& name )
{
if (m_parameters.count(name) == 0) return Value();
if ( m_parameters.count( name ) == 0 ) return Value();
return m_parameters[name];
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::map<QString, RigCaseRealizationParameters::Value> RigCaseRealizationParameters::parameters() const
{
@@ -116,55 +119,56 @@ std::map<QString, RigCaseRealizationParameters::Value> RigCaseRealizationParamet
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::set<QString> RigCaseRealizationParameters::parameterNames() const
{
std::set<QString> names;
for (auto& par : parameters()) names.insert(par.first);
for ( auto& par : parameters() )
names.insert( par.first );
return names;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigCaseRealizationParameters::parameterHash(const QString& name) const
size_t RigCaseRealizationParameters::parameterHash( const QString& name ) const
{
auto itr = m_parameters.find(name);
if (itr == m_parameters.end() || !itr->second.isValid()) return 0;
auto itr = m_parameters.find( name );
if ( itr == m_parameters.end() || !itr->second.isValid() ) return 0;
std::hash<std::string> stringHasher;
std::hash<double> doubleHasher;
size_t nameHash;
size_t valueHash = 0;
std::hash<std::string> stringHasher;
std::hash<double> doubleHasher;
size_t nameHash;
size_t valueHash = 0;
nameHash = stringHasher(name.toStdString());
nameHash = stringHasher( name.toStdString() );
auto value = itr->second;
if (value.isNumeric())
if ( value.isNumeric() )
{
valueHash = doubleHasher(value.numericValue());
valueHash = doubleHasher( value.numericValue() );
}
else if (value.isText())
else if ( value.isText() )
{
valueHash = stringHasher(value.textValue().toStdString());
valueHash = stringHasher( value.textValue().toStdString() );
}
QString s = QString::number(nameHash) + QString::number(valueHash);
return stringHasher((QString::number(nameHash) + QString::number(valueHash)).toStdString());
QString s = QString::number( nameHash ) + QString::number( valueHash );
return stringHasher( ( QString::number( nameHash ) + QString::number( valueHash ) ).toStdString() );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigCaseRealizationParameters::parametersHash()
{
if (m_parametersHash == 0) calculateParametersHash();
if ( m_parametersHash == 0 ) calculateParametersHash();
return m_parametersHash;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseRealizationParameters::clearParametersHash()
{
@@ -172,28 +176,28 @@ void RigCaseRealizationParameters::clearParametersHash()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseRealizationParameters::calculateParametersHash(const std::set<QString>& paramNames /*= std::set<QString>()*/)
void RigCaseRealizationParameters::calculateParametersHash( const std::set<QString>& paramNames /*= std::set<QString>()*/ )
{
QStringList hashes;
if (paramNames.empty())
if ( paramNames.empty() )
{
for (auto param : m_parameters)
for ( auto param : m_parameters )
{
hashes.push_back(QString::number(parameterHash(param.first)));
hashes.push_back( QString::number( parameterHash( param.first ) ) );
}
}
else
{
for (auto paramName : paramNames)
for ( auto paramName : paramNames )
{
if (m_parameters.find(paramName) == m_parameters.end()) return;
hashes.push_back(QString::number(parameterHash(paramName)));
if ( m_parameters.find( paramName ) == m_parameters.end() ) return;
hashes.push_back( QString::number( parameterHash( paramName ) ) );
}
}
std::hash<std::string> stringHasher;
m_parametersHash = stringHasher(hashes.join("").toStdString());
std::hash<std::string> stringHasher;
m_parametersHash = stringHasher( hashes.join( "" ).toStdString() );
}

View File

@@ -1,31 +1,30 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfObject.h"
#include <QString>
#include <map>
#include <set>
#include <memory>
#include <set>
//==================================================================================================
//
@@ -37,45 +36,62 @@ public:
// Internal class
class Value
{
enum ValueType { TYPE_NONE, TYPE_NUMERIC, TYPE_TEXT };
enum ValueType
{
TYPE_NONE,
TYPE_NUMERIC,
TYPE_TEXT
};
public:
Value();
Value(double value);
Value(const QString& value);
Value( double value );
Value( const QString& value );
void setValue(double value);
void setValue(const QString& value);
void setValue( double value );
void setValue( const QString& value );
bool isValid() const { return m_valueType != TYPE_NONE; }
bool isNumeric() const { return m_valueType == TYPE_NUMERIC; }
bool isText() const { return m_valueType == TYPE_TEXT; }
bool isValid() const
{
return m_valueType != TYPE_NONE;
}
bool isNumeric() const
{
return m_valueType == TYPE_NUMERIC;
}
bool isText() const
{
return m_valueType == TYPE_TEXT;
}
double numericValue() const;
const QString& textValue() const;
double numericValue() const;
const QString& textValue() const;
private:
ValueType m_valueType;
double m_numericValue;
QString m_textValue;
ValueType m_valueType;
double m_numericValue;
QString m_textValue;
};
RigCaseRealizationParameters() : m_parametersHash(0) { }
RigCaseRealizationParameters()
: m_parametersHash( 0 )
{
}
void addParameter(const QString& name, double value);
void addParameter(const QString& name, const QString& value);
Value parameterValue(const QString& name);
void addParameter( const QString& name, double value );
void addParameter( const QString& name, const QString& value );
Value parameterValue( const QString& name );
std::map<QString, Value> parameters() const;
std::set<QString> parameterNames() const;
std::map<QString, Value> parameters() const;
std::set<QString> parameterNames() const;
size_t parameterHash(const QString& name) const;
size_t parametersHash();
size_t parameterHash( const QString& name ) const;
size_t parametersHash();
void clearParametersHash();
void calculateParametersHash(const std::set<QString>& paramNames = std::set<QString>());
void clearParametersHash();
void calculateParametersHash( const std::set<QString>& paramNames = std::set<QString>() );
private:
std::map<QString, Value> m_parameters;
size_t m_parametersHash;
std::map<QString, Value> m_parameters;
size_t m_parametersHash;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,167 +21,171 @@
#include "RigCaseToCaseCellMapperTools.h"
#include "RigFemPart.h"
#include "RigMainGrid.h"
#include "RigFemPartGrid.h"
#include "RigMainGrid.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, RigMainGrid* dependentEclGrid)
: m_masterGrid(masterEclGrid),
m_dependentGrid(dependentEclGrid),
m_masterFemPart(nullptr),
m_dependentFemPart(nullptr)
RigCaseToCaseCellMapper::RigCaseToCaseCellMapper( RigMainGrid* masterEclGrid, RigMainGrid* dependentEclGrid )
: m_masterGrid( masterEclGrid )
, m_dependentGrid( dependentEclGrid )
, m_masterFemPart( nullptr )
, m_dependentFemPart( nullptr )
{
m_masterCellOrIntervalIndex.resize(dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT);
m_masterCellOrIntervalIndex.resize( dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigMainGrid* dependentEclGrid)
: m_masterGrid(nullptr),
m_dependentGrid(dependentEclGrid),
m_masterFemPart(masterFemPart),
m_dependentFemPart(nullptr)
RigCaseToCaseCellMapper::RigCaseToCaseCellMapper( RigFemPart* masterFemPart, RigMainGrid* dependentEclGrid )
: m_masterGrid( nullptr )
, m_dependentGrid( dependentEclGrid )
, m_masterFemPart( masterFemPart )
, m_dependentFemPart( nullptr )
{
m_masterCellOrIntervalIndex.resize(dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT);
this->calculateEclToGeomCellMapping(dependentEclGrid, masterFemPart, false);
m_masterCellOrIntervalIndex.resize( dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT );
this->calculateEclToGeomCellMapping( dependentEclGrid, masterFemPart, false );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigFemPart* dependentFemPart)
: m_masterGrid(nullptr),
m_dependentGrid(nullptr),
m_masterFemPart(masterFemPart),
m_dependentFemPart(dependentFemPart)
RigCaseToCaseCellMapper::RigCaseToCaseCellMapper( RigFemPart* masterFemPart, RigFemPart* dependentFemPart )
: m_masterGrid( nullptr )
, m_dependentGrid( nullptr )
, m_masterFemPart( masterFemPart )
, m_dependentFemPart( dependentFemPart )
{
m_masterCellOrIntervalIndex.resize(dependentFemPart->elementCount(), cvf::UNDEFINED_INT);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart)
: m_masterGrid(masterEclGrid),
m_dependentGrid(nullptr),
m_masterFemPart(dependentFemPart),
m_dependentFemPart(nullptr)
{
m_masterCellOrIntervalIndex.resize(dependentFemPart->elementCount(), cvf::UNDEFINED_INT);
this->calculateEclToGeomCellMapping(masterEclGrid, dependentFemPart, true);
m_masterCellOrIntervalIndex.resize( dependentFemPart->elementCount(), cvf::UNDEFINED_INT );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
const int * RigCaseToCaseCellMapper::masterCaseCellIndices(int dependentCaseReservoirCellIndex, int* masterCaseCellIndexCount) const
RigCaseToCaseCellMapper::RigCaseToCaseCellMapper( RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart )
: m_masterGrid( masterEclGrid )
, m_dependentGrid( nullptr )
, m_masterFemPart( dependentFemPart )
, m_dependentFemPart( nullptr )
{
m_masterCellOrIntervalIndex.resize( dependentFemPart->elementCount(), cvf::UNDEFINED_INT );
this->calculateEclToGeomCellMapping( masterEclGrid, dependentFemPart, true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const int* RigCaseToCaseCellMapper::masterCaseCellIndices( int dependentCaseReservoirCellIndex,
int* masterCaseCellIndexCount ) const
{
int seriesIndex = m_masterCellOrIntervalIndex[dependentCaseReservoirCellIndex];
if (seriesIndex == cvf::UNDEFINED_INT)
if ( seriesIndex == cvf::UNDEFINED_INT )
{
(*masterCaseCellIndexCount) = 0;
( *masterCaseCellIndexCount ) = 0;
return nullptr;
}
if (seriesIndex < 0)
if ( seriesIndex < 0 )
{
(*masterCaseCellIndexCount) = static_cast<int>(m_masterCellIndexSeries[-seriesIndex].size());
return &(m_masterCellIndexSeries[-seriesIndex][0]);
( *masterCaseCellIndexCount ) = static_cast<int>( m_masterCellIndexSeries[-seriesIndex].size() );
return &( m_masterCellIndexSeries[-seriesIndex][0] );
}
else
{
(*masterCaseCellIndexCount) = 1;
return &(m_masterCellOrIntervalIndex[dependentCaseReservoirCellIndex]);
( *masterCaseCellIndexCount ) = 1;
return &( m_masterCellOrIntervalIndex[dependentCaseReservoirCellIndex] );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseCellMapper::addMapping(int depCaseCellIdx, int masterCaseMatchingCell)
void RigCaseToCaseCellMapper::addMapping( int depCaseCellIdx, int masterCaseMatchingCell )
{
int mcOrSeriesIdx = m_masterCellOrIntervalIndex[depCaseCellIdx];
if (mcOrSeriesIdx == cvf::UNDEFINED_INT)
if ( mcOrSeriesIdx == cvf::UNDEFINED_INT )
{
m_masterCellOrIntervalIndex[depCaseCellIdx] = masterCaseMatchingCell;
}
else if (mcOrSeriesIdx >= 0)
else if ( mcOrSeriesIdx >= 0 )
{
int newSeriesIdx = static_cast<int>(m_masterCellIndexSeries.size());
m_masterCellIndexSeries.push_back(std::vector<int>());
m_masterCellIndexSeries.back().push_back(mcOrSeriesIdx);
m_masterCellIndexSeries.back().push_back(masterCaseMatchingCell);
int newSeriesIdx = static_cast<int>( m_masterCellIndexSeries.size() );
m_masterCellIndexSeries.push_back( std::vector<int>() );
m_masterCellIndexSeries.back().push_back( mcOrSeriesIdx );
m_masterCellIndexSeries.back().push_back( masterCaseMatchingCell );
m_masterCellOrIntervalIndex[depCaseCellIdx] = -newSeriesIdx;
}
else
{
m_masterCellIndexSeries[-mcOrSeriesIdx].push_back(masterCaseMatchingCell);
m_masterCellIndexSeries[-mcOrSeriesIdx].push_back( masterCaseMatchingCell );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseCellMapper::calculateEclToGeomCellMapping(RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart, bool eclipseIsMaster)
void RigCaseToCaseCellMapper::calculateEclToGeomCellMapping( RigMainGrid* masterEclGrid,
RigFemPart* dependentFemPart,
bool eclipseIsMaster )
{
// Find tolerance
double cellSizeI, cellSizeJ, cellSizeK;
masterEclGrid->characteristicCellSizes(&cellSizeI, &cellSizeJ, &cellSizeK);
double xyTolerance = cellSizeI* 0.4;
double zTolerance = cellSizeK* 0.4;
masterEclGrid->characteristicCellSizes( &cellSizeI, &cellSizeJ, &cellSizeK );
double xyTolerance = cellSizeI * 0.4;
double zTolerance = cellSizeK * 0.4;
bool isEclFaceNormalsOutwards = masterEclGrid->isFaceNormalsOutwards();
cvf::Vec3d elmCorners[8];
size_t cellCount = masterEclGrid->cellCount();
size_t cellCount = masterEclGrid->cellCount();
for (size_t cellIdx = 0; cellIdx < cellCount; ++cellIdx)
for ( size_t cellIdx = 0; cellIdx < cellCount; ++cellIdx )
{
#ifdef _DEBUG
{
// For debugging
#ifdef _DEBUG
{
// For debugging
size_t i, j, k;
masterEclGrid->ijkFromCellIndex(cellIdx, &i, &j, &k); // Will not work when LGR present
masterEclGrid->ijkFromCellIndex( cellIdx, &i, &j, &k ); // Will not work when LGR present
}
#endif
#endif
cvf::Vec3d geoMechConvertedEclCell[8];
RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell(masterEclGrid, cellIdx, geoMechConvertedEclCell);
RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell( masterEclGrid, cellIdx, geoMechConvertedEclCell );
cvf::BoundingBox elmBBox;
for (int i = 0; i < 8 ; ++i) elmBBox.add(geoMechConvertedEclCell[i]);
for ( int i = 0; i < 8; ++i )
elmBBox.add( geoMechConvertedEclCell[i] );
std::vector<size_t> closeElements;
dependentFemPart->findIntersectingCells(elmBBox, &closeElements);
dependentFemPart->findIntersectingCells( elmBBox, &closeElements );
for (size_t ccIdx = 0; ccIdx < closeElements.size(); ++ccIdx)
for ( size_t ccIdx = 0; ccIdx < closeElements.size(); ++ccIdx )
{
int elmIdx = static_cast<int>(closeElements[ccIdx]);
int elmIdx = static_cast<int>( closeElements[ccIdx] );
RigCaseToCaseCellMapperTools::elementCorners(dependentFemPart, elmIdx, elmCorners);
RigCaseToCaseCellMapperTools::elementCorners( dependentFemPart, elmIdx, elmCorners );
RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell(geoMechConvertedEclCell, isEclFaceNormalsOutwards , elmCorners);
RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell( geoMechConvertedEclCell,
isEclFaceNormalsOutwards,
elmCorners );
bool isMatching = RigCaseToCaseCellMapperTools::isEclFemCellsMatching(geoMechConvertedEclCell, elmCorners,
xyTolerance, zTolerance);
bool isMatching = RigCaseToCaseCellMapperTools::isEclFemCellsMatching( geoMechConvertedEclCell,
elmCorners,
xyTolerance,
zTolerance );
if (isMatching)
if ( isMatching )
{
if (eclipseIsMaster)
addMapping(elmIdx, static_cast<int>(cellIdx));
if ( eclipseIsMaster )
addMapping( elmIdx, static_cast<int>( cellIdx ) );
else
addMapping(static_cast<int>(cellIdx), elmIdx);
addMapping( static_cast<int>( cellIdx ), elmIdx );
break;
}

View File

@@ -2,26 +2,25 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfObject.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <vector>
@@ -29,36 +28,45 @@
class RigMainGrid;
class RigFemPart;
//==================================================================================================
///
///
//==================================================================================================
class RigCaseToCaseCellMapper : public cvf::Object
{
public:
RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart);
RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, RigMainGrid* dependentEclGrid);
RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigMainGrid* dependentEclGrid);
RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigFemPart* dependentFemPart);
RigCaseToCaseCellMapper( RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart );
RigCaseToCaseCellMapper( RigMainGrid* masterEclGrid, RigMainGrid* dependentEclGrid );
RigCaseToCaseCellMapper( RigFemPart* masterFemPart, RigMainGrid* dependentEclGrid );
RigCaseToCaseCellMapper( RigFemPart* masterFemPart, RigFemPart* dependentFemPart );
const int * masterCaseCellIndices(int dependentCaseReservoirCellIndex, int* masterCaseCellIndexCount) const;
const int* masterCaseCellIndices( int dependentCaseReservoirCellIndex, int* masterCaseCellIndexCount ) const;
const RigMainGrid* masterGrid() const { return m_masterGrid;}
const RigMainGrid* dependentGrid() const { return m_dependentGrid;}
const RigFemPart* masterFemPart() const { return m_masterFemPart;}
const RigFemPart* dependentFemPart() const { return m_dependentFemPart;}
const RigMainGrid* masterGrid() const
{
return m_masterGrid;
}
const RigMainGrid* dependentGrid() const
{
return m_dependentGrid;
}
const RigFemPart* masterFemPart() const
{
return m_masterFemPart;
}
const RigFemPart* dependentFemPart() const
{
return m_dependentFemPart;
}
private:
void addMapping( int depCaseCellIdx, int masterCaseMatchingCell );
void calculateEclToGeomCellMapping( RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart, bool eclipseIsMaster );
void addMapping(int depCaseCellIdx, int masterCaseMatchingCell);
void calculateEclToGeomCellMapping(RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart, bool eclipseIsMaster);
std::vector<int> m_masterCellOrIntervalIndex;
std::vector<std::vector<int> > m_masterCellIndexSeries;
std::vector<int> m_masterCellOrIntervalIndex;
std::vector<std::vector<int>> m_masterCellIndexSeries;
RigMainGrid* m_masterGrid;
RigMainGrid* m_dependentGrid;
RigFemPart* m_masterFemPart;
RigFemPart* m_dependentFemPart;
};

View File

@@ -2,85 +2,88 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigCaseToCaseCellMapper.h"
#include "RigCaseToCaseCellMapperTools.h"
#include "RigCaseToCaseCellMapper.h"
#include "RigFemPart.h"
#include "RigMainGrid.h"
#include "RigFemPartGrid.h"
#include "RigMainGrid.h"
//==================================================================================================
///
///
//==================================================================================================
class RigNeighborCornerFinder
{
public:
RigNeighborCornerFinder(const RigMainGrid* mainGrid, size_t baseI, size_t baseJ, size_t baseK)
: m_mainGrid(mainGrid),
m_baseI(baseI),
m_baseJ(baseJ),
m_baseK(baseK)
{}
const std::array<size_t, 8>* neighborIndices(int offsetI, int offsetJ, int offsetK)
RigNeighborCornerFinder( const RigMainGrid* mainGrid, size_t baseI, size_t baseJ, size_t baseK )
: m_mainGrid( mainGrid )
, m_baseI( baseI )
, m_baseJ( baseJ )
, m_baseK( baseK )
{
if (offsetI < 0 && m_baseI == 0) return nullptr;
if (offsetJ < 0 && m_baseJ == 0) return nullptr;
if (offsetK < 0 && m_baseK == 0) return nullptr;
if (offsetI > 0 && m_baseI == m_mainGrid->cellCountI()-1) return nullptr;
if (offsetJ > 0 && m_baseJ == m_mainGrid->cellCountJ()-1) return nullptr;
if (offsetK > 0 && m_baseK == m_mainGrid->cellCountK()-1) return nullptr;
}
size_t gridLocalCellIndex = m_mainGrid->cellIndexFromIJK(m_baseI + offsetI, m_baseJ + offsetJ, m_baseK + offsetK);
const RigCell& cell = m_mainGrid->globalCellArray()[gridLocalCellIndex];
return &(cell.cornerIndices());
const std::array<size_t, 8>* neighborIndices( int offsetI, int offsetJ, int offsetK )
{
if ( offsetI < 0 && m_baseI == 0 ) return nullptr;
if ( offsetJ < 0 && m_baseJ == 0 ) return nullptr;
if ( offsetK < 0 && m_baseK == 0 ) return nullptr;
if ( offsetI > 0 && m_baseI == m_mainGrid->cellCountI() - 1 ) return nullptr;
if ( offsetJ > 0 && m_baseJ == m_mainGrid->cellCountJ() - 1 ) return nullptr;
if ( offsetK > 0 && m_baseK == m_mainGrid->cellCountK() - 1 ) return nullptr;
size_t gridLocalCellIndex = m_mainGrid->cellIndexFromIJK( m_baseI + offsetI, m_baseJ + offsetJ, m_baseK + offsetK );
const RigCell& cell = m_mainGrid->globalCellArray()[gridLocalCellIndex];
return &( cell.cornerIndices() );
}
private:
const RigMainGrid* m_mainGrid;
size_t m_baseI;
size_t m_baseJ;
size_t m_baseK;
size_t m_baseI;
size_t m_baseJ;
size_t m_baseK;
};
//==================================================================================================
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Average of neighbor corresponding nodes
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell(const RigMainGrid* eclGrid, size_t reservoirCellIndex, cvf::Vec3d estimatedElmCorners[8])
void RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell( const RigMainGrid* eclGrid,
size_t reservoirCellIndex,
cvf::Vec3d estimatedElmCorners[8] )
{
CVF_TIGHT_ASSERT(reservoirCellIndex < eclGrid->cellCount()); // Assume reservoirCellIdx == localGridCellIdx for maingrid
CVF_TIGHT_ASSERT( reservoirCellIndex <
eclGrid->cellCount() ); // Assume reservoirCellIdx == localGridCellIdx for maingrid
const std::vector<cvf::Vec3d>& eclNodes = eclGrid->nodes();
size_t I,J,K;
eclGrid->ijkFromCellIndex(reservoirCellIndex, &I, &J, &K);
RigNeighborCornerFinder nbFinder(eclGrid, I,J,K);
size_t I, J, K;
eclGrid->ijkFromCellIndex( reservoirCellIndex, &I, &J, &K );
RigNeighborCornerFinder nbFinder( eclGrid, I, J, K );
// Cell corner Averaging mapping: Local cell index in neighbor matching specific corner of this cell
// N - Negative P - positive
// 0 <- NI[1] NINJ[2] NJ[3] NK[4] NINK[5] NINJNK[6] NJNK[7]
// 1 <- NJ[2] PINJ[3] PI[0] NK[5] NJNK[6] PINJNK[7] PINK[4]
// 0 <- NI[1] NINJ[2] NJ[3] NK[4] NINK[5] NINJNK[6] NJNK[7]
// 1 <- NJ[2] PINJ[3] PI[0] NK[5] NJNK[6] PINJNK[7] PINK[4]
// 2 <- PI[3] PIPJ[0] PJ[1] NK[6] PINK[7] PIPJNK[4] PJNK[5]
// 3 <- PJ[0] NIPJ[1] NI[2] NK[7] PJNK[4] NIPJNK[5] NINK[6]
// 4 <- NI[5] NINJ[6] NJ[7] PK[0] NIPK[1] NINJPK[2] NJPK[3]
@@ -88,120 +91,120 @@ void RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell(const RigMainGrid
// 6 <- PI[7] PIPJ[4] PJ[5] PK[2] PIPK[3] PIPJPK[0] PJPK[1]
// 7 <- PJ[4] NIPJ[5] NI[6] PK[3] PJPK[0] NIPJPK[1] NIPK[2]
const std::array<size_t, 8>* IJK = nbFinder.neighborIndices( 0, 0, 0);
const std::array<size_t, 8>* NI = nbFinder.neighborIndices(-1, 0, 0);
const std::array<size_t, 8>* NJ = nbFinder.neighborIndices( 0,-1, 0);
const std::array<size_t, 8>* PI = nbFinder.neighborIndices( 1, 0, 0);
const std::array<size_t, 8>* PJ = nbFinder.neighborIndices( 0, 1, 0);
const std::array<size_t, 8>* NK = nbFinder.neighborIndices( 0, 0,-1);
const std::array<size_t, 8>* PK = nbFinder.neighborIndices( 0, 0, 1);
const std::array<size_t, 8>* NINJ = nbFinder.neighborIndices(-1,-1, 0);
const std::array<size_t, 8>* PINJ = nbFinder.neighborIndices( 1,-1, 0);
const std::array<size_t, 8>* IJK = nbFinder.neighborIndices( 0, 0, 0 );
const std::array<size_t, 8>* NI = nbFinder.neighborIndices( -1, 0, 0 );
const std::array<size_t, 8>* NJ = nbFinder.neighborIndices( 0, -1, 0 );
const std::array<size_t, 8>* PI = nbFinder.neighborIndices( 1, 0, 0 );
const std::array<size_t, 8>* PJ = nbFinder.neighborIndices( 0, 1, 0 );
const std::array<size_t, 8>* NK = nbFinder.neighborIndices( 0, 0, -1 );
const std::array<size_t, 8>* PK = nbFinder.neighborIndices( 0, 0, 1 );
const std::array<size_t, 8>* NINJ = nbFinder.neighborIndices( -1, -1, 0 );
const std::array<size_t, 8>* PINJ = nbFinder.neighborIndices( 1, -1, 0 );
const std::array<size_t, 8>* PIPJ = nbFinder.neighborIndices( 1, 1, 0);
const std::array<size_t, 8>* NIPJ = nbFinder.neighborIndices(-1, 1, 0);
const std::array<size_t, 8>* NINK = nbFinder.neighborIndices(-1, 0,-1);
const std::array<size_t, 8>* NJNK = nbFinder.neighborIndices( 0,-1,-1);
const std::array<size_t, 8>* PINK = nbFinder.neighborIndices( 1, 0,-1);
const std::array<size_t, 8>* PJNK = nbFinder.neighborIndices( 0, 1,-1);
const std::array<size_t, 8>* NIPK = nbFinder.neighborIndices(-1, 0, 1);
const std::array<size_t, 8>* NJPK = nbFinder.neighborIndices( 0,-1, 1);
const std::array<size_t, 8>* PIPK = nbFinder.neighborIndices( 1, 0, 1);
const std::array<size_t, 8>* PIPJ = nbFinder.neighborIndices( 1, 1, 0 );
const std::array<size_t, 8>* NIPJ = nbFinder.neighborIndices( -1, 1, 0 );
const std::array<size_t, 8>* NINK = nbFinder.neighborIndices( -1, 0, -1 );
const std::array<size_t, 8>* NJNK = nbFinder.neighborIndices( 0, -1, -1 );
const std::array<size_t, 8>* PINK = nbFinder.neighborIndices( 1, 0, -1 );
const std::array<size_t, 8>* PJNK = nbFinder.neighborIndices( 0, 1, -1 );
const std::array<size_t, 8>* NIPK = nbFinder.neighborIndices( -1, 0, 1 );
const std::array<size_t, 8>* NJPK = nbFinder.neighborIndices( 0, -1, 1 );
const std::array<size_t, 8>* PIPK = nbFinder.neighborIndices( 1, 0, 1 );
const std::array<size_t, 8>* PJPK = nbFinder.neighborIndices( 0, 1, 1);
const std::array<size_t, 8>* NINJNK = nbFinder.neighborIndices(-1,-1,-1);
const std::array<size_t, 8>* PINJNK = nbFinder.neighborIndices( 1,-1,-1);
const std::array<size_t, 8>* PIPJNK = nbFinder.neighborIndices( 1, 1,-1);
const std::array<size_t, 8>* NIPJNK = nbFinder.neighborIndices(-1, 1,-1);
const std::array<size_t, 8>* NINJPK = nbFinder.neighborIndices(-1,-1, 1);
const std::array<size_t, 8>* PINJPK = nbFinder.neighborIndices( 1,-1, 1);
const std::array<size_t, 8>* PIPJPK = nbFinder.neighborIndices( 1, 1, 1);
const std::array<size_t, 8>* NIPJPK = nbFinder.neighborIndices(-1, 1, 1);
const std::array<size_t, 8>* PJPK = nbFinder.neighborIndices( 0, 1, 1 );
const std::array<size_t, 8>* NINJNK = nbFinder.neighborIndices( -1, -1, -1 );
const std::array<size_t, 8>* PINJNK = nbFinder.neighborIndices( 1, -1, -1 );
const std::array<size_t, 8>* PIPJNK = nbFinder.neighborIndices( 1, 1, -1 );
const std::array<size_t, 8>* NIPJNK = nbFinder.neighborIndices( -1, 1, -1 );
const std::array<size_t, 8>* NINJPK = nbFinder.neighborIndices( -1, -1, 1 );
const std::array<size_t, 8>* PINJPK = nbFinder.neighborIndices( 1, -1, 1 );
const std::array<size_t, 8>* PIPJPK = nbFinder.neighborIndices( 1, 1, 1 );
const std::array<size_t, 8>* NIPJPK = nbFinder.neighborIndices( -1, 1, 1 );
std::vector<size_t> contributingNodeIndicesPrCellCorner[8];
if (IJK ) contributingNodeIndicesPrCellCorner[0].push_back((*IJK )[0]);
if (NI ) contributingNodeIndicesPrCellCorner[0].push_back((*NI )[1]);
if (NINJ ) contributingNodeIndicesPrCellCorner[0].push_back((*NINJ )[2]);
if (NJ ) contributingNodeIndicesPrCellCorner[0].push_back((*NJ )[3]);
if (NK ) contributingNodeIndicesPrCellCorner[0].push_back((*NK )[4]);
if (NINK ) contributingNodeIndicesPrCellCorner[0].push_back((*NINK )[5]);
if (NINJNK) contributingNodeIndicesPrCellCorner[0].push_back((*NINJNK)[6]);
if (NJNK ) contributingNodeIndicesPrCellCorner[0].push_back((*NJNK )[7]);
if ( IJK ) contributingNodeIndicesPrCellCorner[0].push_back( ( *IJK )[0] );
if ( NI ) contributingNodeIndicesPrCellCorner[0].push_back( ( *NI )[1] );
if ( NINJ ) contributingNodeIndicesPrCellCorner[0].push_back( ( *NINJ )[2] );
if ( NJ ) contributingNodeIndicesPrCellCorner[0].push_back( ( *NJ )[3] );
if ( NK ) contributingNodeIndicesPrCellCorner[0].push_back( ( *NK )[4] );
if ( NINK ) contributingNodeIndicesPrCellCorner[0].push_back( ( *NINK )[5] );
if ( NINJNK ) contributingNodeIndicesPrCellCorner[0].push_back( ( *NINJNK )[6] );
if ( NJNK ) contributingNodeIndicesPrCellCorner[0].push_back( ( *NJNK )[7] );
if (IJK ) contributingNodeIndicesPrCellCorner[1].push_back((*IJK )[1]);
if (NJ ) contributingNodeIndicesPrCellCorner[1].push_back((*NJ )[2]);
if (PINJ ) contributingNodeIndicesPrCellCorner[1].push_back((*PINJ )[3]);
if (PI ) contributingNodeIndicesPrCellCorner[1].push_back((*PI )[0]);
if (NK ) contributingNodeIndicesPrCellCorner[1].push_back((*NK )[5]);
if (NJNK ) contributingNodeIndicesPrCellCorner[1].push_back((*NJNK )[6]);
if (PINJNK) contributingNodeIndicesPrCellCorner[1].push_back((*PINJNK)[7]);
if (PINK ) contributingNodeIndicesPrCellCorner[1].push_back((*PINK )[4]);
if ( IJK ) contributingNodeIndicesPrCellCorner[1].push_back( ( *IJK )[1] );
if ( NJ ) contributingNodeIndicesPrCellCorner[1].push_back( ( *NJ )[2] );
if ( PINJ ) contributingNodeIndicesPrCellCorner[1].push_back( ( *PINJ )[3] );
if ( PI ) contributingNodeIndicesPrCellCorner[1].push_back( ( *PI )[0] );
if ( NK ) contributingNodeIndicesPrCellCorner[1].push_back( ( *NK )[5] );
if ( NJNK ) contributingNodeIndicesPrCellCorner[1].push_back( ( *NJNK )[6] );
if ( PINJNK ) contributingNodeIndicesPrCellCorner[1].push_back( ( *PINJNK )[7] );
if ( PINK ) contributingNodeIndicesPrCellCorner[1].push_back( ( *PINK )[4] );
if (IJK ) contributingNodeIndicesPrCellCorner[2].push_back((*IJK )[2]);
if (PI ) contributingNodeIndicesPrCellCorner[2].push_back((*PI )[3]);
if (PIPJ ) contributingNodeIndicesPrCellCorner[2].push_back((*PIPJ )[0]);
if (PJ ) contributingNodeIndicesPrCellCorner[2].push_back((*PJ )[1]);
if (NK ) contributingNodeIndicesPrCellCorner[2].push_back((*NK )[6]);
if (PINK ) contributingNodeIndicesPrCellCorner[2].push_back((*PINK )[7]);
if (PIPJNK) contributingNodeIndicesPrCellCorner[2].push_back((*PIPJNK)[4]);
if (PJNK ) contributingNodeIndicesPrCellCorner[2].push_back((*PJNK )[5]);
if ( IJK ) contributingNodeIndicesPrCellCorner[2].push_back( ( *IJK )[2] );
if ( PI ) contributingNodeIndicesPrCellCorner[2].push_back( ( *PI )[3] );
if ( PIPJ ) contributingNodeIndicesPrCellCorner[2].push_back( ( *PIPJ )[0] );
if ( PJ ) contributingNodeIndicesPrCellCorner[2].push_back( ( *PJ )[1] );
if ( NK ) contributingNodeIndicesPrCellCorner[2].push_back( ( *NK )[6] );
if ( PINK ) contributingNodeIndicesPrCellCorner[2].push_back( ( *PINK )[7] );
if ( PIPJNK ) contributingNodeIndicesPrCellCorner[2].push_back( ( *PIPJNK )[4] );
if ( PJNK ) contributingNodeIndicesPrCellCorner[2].push_back( ( *PJNK )[5] );
if (IJK ) contributingNodeIndicesPrCellCorner[3].push_back((*IJK )[3]);
if (PJ ) contributingNodeIndicesPrCellCorner[3].push_back((*PJ )[0]);
if (NIPJ ) contributingNodeIndicesPrCellCorner[3].push_back((*NIPJ )[1]);
if (NI ) contributingNodeIndicesPrCellCorner[3].push_back((*NI )[2]);
if (NK ) contributingNodeIndicesPrCellCorner[3].push_back((*NK )[7]);
if (PJNK ) contributingNodeIndicesPrCellCorner[3].push_back((*PJNK )[4]);
if (NIPJNK) contributingNodeIndicesPrCellCorner[3].push_back((*NIPJNK)[5]);
if (NINK ) contributingNodeIndicesPrCellCorner[3].push_back((*NINK )[6]);
if ( IJK ) contributingNodeIndicesPrCellCorner[3].push_back( ( *IJK )[3] );
if ( PJ ) contributingNodeIndicesPrCellCorner[3].push_back( ( *PJ )[0] );
if ( NIPJ ) contributingNodeIndicesPrCellCorner[3].push_back( ( *NIPJ )[1] );
if ( NI ) contributingNodeIndicesPrCellCorner[3].push_back( ( *NI )[2] );
if ( NK ) contributingNodeIndicesPrCellCorner[3].push_back( ( *NK )[7] );
if ( PJNK ) contributingNodeIndicesPrCellCorner[3].push_back( ( *PJNK )[4] );
if ( NIPJNK ) contributingNodeIndicesPrCellCorner[3].push_back( ( *NIPJNK )[5] );
if ( NINK ) contributingNodeIndicesPrCellCorner[3].push_back( ( *NINK )[6] );
// 4 <- NI[5] NINJ[6] NJ[7] PK[0] NIPK[1] NINJPK[2] NJPK[3]
// 4 <- NI[5] NINJ[6] NJ[7] PK[0] NIPK[1] NINJPK[2] NJPK[3]
if (IJK ) contributingNodeIndicesPrCellCorner[4].push_back((*IJK )[4]);
if (NI ) contributingNodeIndicesPrCellCorner[4].push_back((*NI )[5]);
if (NINJ ) contributingNodeIndicesPrCellCorner[4].push_back((*NINJ )[6]);
if (NJ ) contributingNodeIndicesPrCellCorner[4].push_back((*NJ )[7]);
if (PK ) contributingNodeIndicesPrCellCorner[4].push_back((*PK )[0]);
if (NIPK ) contributingNodeIndicesPrCellCorner[4].push_back((*NIPK )[1]);
if (NINJPK) contributingNodeIndicesPrCellCorner[4].push_back((*NINJPK)[2]);
if (NJPK ) contributingNodeIndicesPrCellCorner[4].push_back((*NJPK )[3]);
if ( IJK ) contributingNodeIndicesPrCellCorner[4].push_back( ( *IJK )[4] );
if ( NI ) contributingNodeIndicesPrCellCorner[4].push_back( ( *NI )[5] );
if ( NINJ ) contributingNodeIndicesPrCellCorner[4].push_back( ( *NINJ )[6] );
if ( NJ ) contributingNodeIndicesPrCellCorner[4].push_back( ( *NJ )[7] );
if ( PK ) contributingNodeIndicesPrCellCorner[4].push_back( ( *PK )[0] );
if ( NIPK ) contributingNodeIndicesPrCellCorner[4].push_back( ( *NIPK )[1] );
if ( NINJPK ) contributingNodeIndicesPrCellCorner[4].push_back( ( *NINJPK )[2] );
if ( NJPK ) contributingNodeIndicesPrCellCorner[4].push_back( ( *NJPK )[3] );
if ( IJK ) contributingNodeIndicesPrCellCorner[5].push_back( ( *IJK )[5] );
if ( NJ ) contributingNodeIndicesPrCellCorner[5].push_back( ( *NJ )[6] );
if ( PINJ ) contributingNodeIndicesPrCellCorner[5].push_back( ( *PINJ )[7] );
if ( PI ) contributingNodeIndicesPrCellCorner[5].push_back( ( *PI )[4] );
if ( PK ) contributingNodeIndicesPrCellCorner[5].push_back( ( *PK )[1] );
if ( NJPK ) contributingNodeIndicesPrCellCorner[5].push_back( ( *NJPK )[2] );
if ( PINJPK ) contributingNodeIndicesPrCellCorner[5].push_back( ( *PINJPK )[3] );
if ( PIPK ) contributingNodeIndicesPrCellCorner[5].push_back( ( *PIPK )[0] );
if (IJK ) contributingNodeIndicesPrCellCorner[5].push_back((*IJK )[5]);
if (NJ ) contributingNodeIndicesPrCellCorner[5].push_back((*NJ )[6]);
if (PINJ ) contributingNodeIndicesPrCellCorner[5].push_back((*PINJ )[7]);
if (PI ) contributingNodeIndicesPrCellCorner[5].push_back((*PI )[4]);
if (PK ) contributingNodeIndicesPrCellCorner[5].push_back((*PK )[1]);
if (NJPK ) contributingNodeIndicesPrCellCorner[5].push_back((*NJPK )[2]);
if (PINJPK) contributingNodeIndicesPrCellCorner[5].push_back((*PINJPK)[3]);
if (PIPK ) contributingNodeIndicesPrCellCorner[5].push_back((*PIPK )[0]);
// 6 <- PI[7] PIPJ[4] PJ[5] PK[2] PIPK[3] PIPJPK[0] PJPK[1]
if (IJK ) contributingNodeIndicesPrCellCorner[6].push_back((*IJK )[6]);
if (PI ) contributingNodeIndicesPrCellCorner[6].push_back((*PI )[7]);
if (PIPJ ) contributingNodeIndicesPrCellCorner[6].push_back((*PIPJ )[4]);
if (PJ ) contributingNodeIndicesPrCellCorner[6].push_back((*PJ )[5]);
if (PK ) contributingNodeIndicesPrCellCorner[6].push_back((*PK )[2]);
if (PIPK ) contributingNodeIndicesPrCellCorner[6].push_back((*PIPK )[3]);
if (PIPJPK) contributingNodeIndicesPrCellCorner[6].push_back((*PIPJPK)[0]);
if (PJPK ) contributingNodeIndicesPrCellCorner[6].push_back((*PJPK )[1]);
if ( IJK ) contributingNodeIndicesPrCellCorner[6].push_back( ( *IJK )[6] );
if ( PI ) contributingNodeIndicesPrCellCorner[6].push_back( ( *PI )[7] );
if ( PIPJ ) contributingNodeIndicesPrCellCorner[6].push_back( ( *PIPJ )[4] );
if ( PJ ) contributingNodeIndicesPrCellCorner[6].push_back( ( *PJ )[5] );
if ( PK ) contributingNodeIndicesPrCellCorner[6].push_back( ( *PK )[2] );
if ( PIPK ) contributingNodeIndicesPrCellCorner[6].push_back( ( *PIPK )[3] );
if ( PIPJPK ) contributingNodeIndicesPrCellCorner[6].push_back( ( *PIPJPK )[0] );
if ( PJPK ) contributingNodeIndicesPrCellCorner[6].push_back( ( *PJPK )[1] );
if (IJK ) contributingNodeIndicesPrCellCorner[7].push_back((*IJK )[7]);
if (PJ ) contributingNodeIndicesPrCellCorner[7].push_back((*PJ )[4]);
if (NIPJ ) contributingNodeIndicesPrCellCorner[7].push_back((*NIPJ )[5]);
if (NI ) contributingNodeIndicesPrCellCorner[7].push_back((*NI )[6]);
if (PK ) contributingNodeIndicesPrCellCorner[7].push_back((*PK )[3]);
if (PJPK ) contributingNodeIndicesPrCellCorner[7].push_back((*PJPK )[0]);
if (NIPJPK) contributingNodeIndicesPrCellCorner[7].push_back((*NIPJPK)[1]);
if (NIPK ) contributingNodeIndicesPrCellCorner[7].push_back((*NIPK )[2]);
if ( IJK ) contributingNodeIndicesPrCellCorner[7].push_back( ( *IJK )[7] );
if ( PJ ) contributingNodeIndicesPrCellCorner[7].push_back( ( *PJ )[4] );
if ( NIPJ ) contributingNodeIndicesPrCellCorner[7].push_back( ( *NIPJ )[5] );
if ( NI ) contributingNodeIndicesPrCellCorner[7].push_back( ( *NI )[6] );
if ( PK ) contributingNodeIndicesPrCellCorner[7].push_back( ( *PK )[3] );
if ( PJPK ) contributingNodeIndicesPrCellCorner[7].push_back( ( *PJPK )[0] );
if ( NIPJPK ) contributingNodeIndicesPrCellCorner[7].push_back( ( *NIPJPK )[1] );
if ( NIPK ) contributingNodeIndicesPrCellCorner[7].push_back( ( *NIPK )[2] );
// Average the nodes
for (size_t cornIdx = 0; cornIdx < 8; ++cornIdx)
for ( size_t cornIdx = 0; cornIdx < 8; ++cornIdx )
{
estimatedElmCorners[cornIdx] = cvf::Vec3d::ZERO;
size_t contribCount = contributingNodeIndicesPrCellCorner[cornIdx].size();
for (size_t ctnIdx = 0; ctnIdx < contribCount; ++ctnIdx)
size_t contribCount = contributingNodeIndicesPrCellCorner[cornIdx].size();
for ( size_t ctnIdx = 0; ctnIdx < contribCount; ++ctnIdx )
{
estimatedElmCorners[cornIdx] += eclNodes[contributingNodeIndicesPrCellCorner[cornIdx][ctnIdx]];
}
@@ -210,11 +213,11 @@ void RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell(const RigMainGrid
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseCellMapperTools::rotateQuad(cvf::Vec3d quad[4], int idxToNewStart)
void RigCaseToCaseCellMapperTools::rotateQuad( cvf::Vec3d quad[4], int idxToNewStart )
{
if (idxToNewStart == 0) return;
if ( idxToNewStart == 0 ) return;
cvf::Vec3d tmpQuad[4];
tmpQuad[0] = quad[0];
tmpQuad[1] = quad[1];
@@ -222,96 +225,104 @@ void RigCaseToCaseCellMapperTools::rotateQuad(cvf::Vec3d quad[4], int idxToNewSt
tmpQuad[3] = quad[3];
quad[0] = tmpQuad[idxToNewStart];
++idxToNewStart; if (idxToNewStart > 3) idxToNewStart = 0;
++idxToNewStart;
if ( idxToNewStart > 3 ) idxToNewStart = 0;
quad[1] = tmpQuad[idxToNewStart];
++idxToNewStart; if (idxToNewStart > 3) idxToNewStart = 0;
++idxToNewStart;
if ( idxToNewStart > 3 ) idxToNewStart = 0;
quad[2] = tmpQuad[idxToNewStart];
++idxToNewStart; if (idxToNewStart > 3) idxToNewStart = 0;
++idxToNewStart;
if ( idxToNewStart > 3 ) idxToNewStart = 0;
quad[3] = tmpQuad[idxToNewStart];
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseCellMapperTools::flipQuadWinding(cvf::Vec3d quad[4])
void RigCaseToCaseCellMapperTools::flipQuadWinding( cvf::Vec3d quad[4] )
{
cvf::Vec3d temp = quad[1];
quad[1] = quad[3];
quad[3] = temp;
quad[1] = quad[3];
quad[3] = temp;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
int RigCaseToCaseCellMapperTools::quadVxClosestToXYOfPoint( const cvf::Vec3d point, const cvf::Vec3d quad[4])
int RigCaseToCaseCellMapperTools::quadVxClosestToXYOfPoint( const cvf::Vec3d point, const cvf::Vec3d quad[4] )
{
double minSqDist = HUGE_VAL;
int quadVxIdxClosestToPoint = cvf::UNDEFINED_INT;
double minSqDist = HUGE_VAL;
int quadVxIdxClosestToPoint = cvf::UNDEFINED_INT;
for (int i = 0; i < 4; ++i)
for ( int i = 0; i < 4; ++i )
{
cvf::Vec3d diff = quad[i]- point;
diff[2] = 0.0;
cvf::Vec3d diff = quad[i] - point;
diff[2] = 0.0;
double sqDist = diff.lengthSquared();
if (sqDist < minSqDist)
if ( sqDist < minSqDist )
{
minSqDist = sqDist;
minSqDist = sqDist;
quadVxIdxClosestToPoint = i;
}
}
return quadVxIdxClosestToPoint;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigCaseToCaseCellMapperTools::elementCorners(const RigFemPart* femPart, int elmIdx, cvf::Vec3d elmCorners[8])
bool RigCaseToCaseCellMapperTools::elementCorners( const RigFemPart* femPart, int elmIdx, cvf::Vec3d elmCorners[8] )
{
RigElementType elmType = femPart->elementType(elmIdx);
if (!(elmType == HEX8 || elmType == HEX8P)) return false;
RigElementType elmType = femPart->elementType( elmIdx );
if ( !( elmType == HEX8 || elmType == HEX8P ) ) return false;
const std::vector<cvf::Vec3f>& nodeCoords = femPart->nodes().coordinates;
const int* cornerIndices = femPart->connectivities(elmIdx);
const std::vector<cvf::Vec3f>& nodeCoords = femPart->nodes().coordinates;
const int* cornerIndices = femPart->connectivities( elmIdx );
elmCorners[0] = cvf::Vec3d(nodeCoords[cornerIndices[0]]);
elmCorners[1] = cvf::Vec3d(nodeCoords[cornerIndices[1]]);
elmCorners[2] = cvf::Vec3d(nodeCoords[cornerIndices[2]]);
elmCorners[3] = cvf::Vec3d(nodeCoords[cornerIndices[3]]);
elmCorners[4] = cvf::Vec3d(nodeCoords[cornerIndices[4]]);
elmCorners[5] = cvf::Vec3d(nodeCoords[cornerIndices[5]]);
elmCorners[6] = cvf::Vec3d(nodeCoords[cornerIndices[6]]);
elmCorners[7] = cvf::Vec3d(nodeCoords[cornerIndices[7]]);
elmCorners[0] = cvf::Vec3d( nodeCoords[cornerIndices[0]] );
elmCorners[1] = cvf::Vec3d( nodeCoords[cornerIndices[1]] );
elmCorners[2] = cvf::Vec3d( nodeCoords[cornerIndices[2]] );
elmCorners[3] = cvf::Vec3d( nodeCoords[cornerIndices[3]] );
elmCorners[4] = cvf::Vec3d( nodeCoords[cornerIndices[4]] );
elmCorners[5] = cvf::Vec3d( nodeCoords[cornerIndices[5]] );
elmCorners[6] = cvf::Vec3d( nodeCoords[cornerIndices[6]] );
elmCorners[7] = cvf::Vec3d( nodeCoords[cornerIndices[7]] );
return true;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
int RigCaseToCaseCellMapperTools::findMatchingPOSKFaceIdx(const cvf::Vec3d baseCell[8],bool isBaseCellNormalsOutwards, const cvf::Vec3d c2[8])
int RigCaseToCaseCellMapperTools::findMatchingPOSKFaceIdx( const cvf::Vec3d baseCell[8],
bool isBaseCellNormalsOutwards,
const cvf::Vec3d c2[8] )
{
int faceNodeCount;
const int* posKFace = RigFemTypes::localElmNodeIndicesForFace(HEX8, (int)(cvf::StructGridInterface::POS_K), &faceNodeCount);
int faceNodeCount;
const int* posKFace = RigFemTypes::localElmNodeIndicesForFace( HEX8,
(int)( cvf::StructGridInterface::POS_K ),
&faceNodeCount );
double sign = isBaseCellNormalsOutwards ? 1.0 : -1.0;
cvf::Vec3d posKnormal = sign*(baseCell[posKFace[2]] - baseCell[posKFace[0]]) ^ (baseCell[posKFace[3]] - baseCell[posKFace[1]]);
cvf::Vec3d posKnormal = sign * ( baseCell[posKFace[2]] - baseCell[posKFace[0]] ) ^
( baseCell[posKFace[3]] - baseCell[posKFace[1]] );
posKnormal.normalize();
double minDiff = HUGE_VAL;
int bestFace = -1;
for (int faceIdx = 5; faceIdx >= 0; --faceIdx) // Backwards. might hit earlier more often
double minDiff = HUGE_VAL;
int bestFace = -1;
for ( int faceIdx = 5; faceIdx >= 0; --faceIdx ) // Backwards. might hit earlier more often
{
const int* face = RigFemTypes::localElmNodeIndicesForFace(HEX8, faceIdx, &faceNodeCount);
cvf::Vec3d normal = (c2[face[2]] - c2[face[0]]) ^ (c2[face[3]] - c2[face[1]]);
const int* face = RigFemTypes::localElmNodeIndicesForFace( HEX8, faceIdx, &faceNodeCount );
cvf::Vec3d normal = ( c2[face[2]] - c2[face[0]] ) ^ ( c2[face[3]] - c2[face[1]] );
normal.normalize();
double sqDiff = (posKnormal-normal).lengthSquared();
if (sqDiff < minDiff)
double sqDiff = ( posKnormal - normal ).lengthSquared();
if ( sqDiff < minDiff )
{
minDiff = sqDiff;
bestFace = faceIdx;
if (minDiff < 0.1*0.1) break; // This must be the one. Do not search further
if ( minDiff < 0.1 * 0.1 ) break; // This must be the one. Do not search further
}
}
@@ -319,20 +330,20 @@ int RigCaseToCaseCellMapperTools::findMatchingPOSKFaceIdx(const cvf::Vec3d baseC
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigCaseToCaseCellMapperTools::isEclFemCellsMatching(const cvf::Vec3d baseCell[8],
cvf::Vec3d cell[8],
double xyTolerance, double zTolerance)
bool RigCaseToCaseCellMapperTools::isEclFemCellsMatching( const cvf::Vec3d baseCell[8],
cvf::Vec3d cell[8],
double xyTolerance,
double zTolerance )
{
bool isMatching = true;
for (int i = 0; i < 4 ; ++i)
for ( int i = 0; i < 4; ++i )
{
cvf::Vec3d diff = cell[i] - baseCell[i];
if (!(fabs(diff.x()) < xyTolerance && fabs(diff.y()) < xyTolerance && fabs(diff.z()) < zTolerance))
if ( !( fabs( diff.x() ) < xyTolerance && fabs( diff.y() ) < xyTolerance && fabs( diff.z() ) < zTolerance ) )
{
isMatching = false;
break;
@@ -343,11 +354,13 @@ bool RigCaseToCaseCellMapperTools::isEclFemCellsMatching(const cvf::Vec3d baseCe
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell(const cvf::Vec3d * baseCell, bool baseCellFaceNormalsIsOutwards, cvf::Vec3d * cell)
void RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell( const cvf::Vec3d* baseCell,
bool baseCellFaceNormalsIsOutwards,
cvf::Vec3d* cell )
{
int femDeepZFaceIdx = findMatchingPOSKFaceIdx(baseCell, baseCellFaceNormalsIsOutwards, cell);
int femDeepZFaceIdx = findMatchingPOSKFaceIdx( baseCell, baseCellFaceNormalsIsOutwards, cell );
{
cvf::Vec3d tmpFemCorners[8];
@@ -360,11 +373,15 @@ void RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell(const
tmpFemCorners[6] = cell[6];
tmpFemCorners[7] = cell[7];
int femShallowZFaceIdx = RigFemTypes::oppositeFace(HEX8, femDeepZFaceIdx);
int femShallowZFaceIdx = RigFemTypes::oppositeFace( HEX8, femDeepZFaceIdx );
int faceNodeCount;
const int* localElmNodeIndicesForPOSKFace = RigFemTypes::localElmNodeIndicesForFace(HEX8, femDeepZFaceIdx, &faceNodeCount);
const int* localElmNodeIndicesForNEGKFace = RigFemTypes::localElmNodeIndicesForFace(HEX8, femShallowZFaceIdx, &faceNodeCount);
int faceNodeCount;
const int* localElmNodeIndicesForPOSKFace = RigFemTypes::localElmNodeIndicesForFace( HEX8,
femDeepZFaceIdx,
&faceNodeCount );
const int* localElmNodeIndicesForNEGKFace = RigFemTypes::localElmNodeIndicesForFace( HEX8,
femShallowZFaceIdx,
&faceNodeCount );
cell[0] = tmpFemCorners[localElmNodeIndicesForNEGKFace[0]];
cell[1] = tmpFemCorners[localElmNodeIndicesForNEGKFace[1]];
@@ -376,32 +393,30 @@ void RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell(const
cell[7] = tmpFemCorners[localElmNodeIndicesForPOSKFace[3]];
}
cvf::Vec3d* femDeepestQuad = &(cell[4]);
cvf::Vec3d* femShallowQuad = &(cell[0]);
cvf::Vec3d* femDeepestQuad = &( cell[4] );
cvf::Vec3d* femShallowQuad = &( cell[0] );
// Now the top/bottom have opposite winding. To make the comparisons and index rotations simpler
// flip the winding of the top or bottom face depending on whether the eclipse grid is inside-out
if (baseCellFaceNormalsIsOutwards)
if ( baseCellFaceNormalsIsOutwards )
{
flipQuadWinding(femShallowQuad);
flipQuadWinding( femShallowQuad );
}
else
{
flipQuadWinding(femDeepestQuad);
flipQuadWinding( femDeepestQuad );
}
// We now need to rotate the fem quads to be alligned with the ecl quads
// Since the start point of the quad always is aligned with the opposite face-quad start
// we can find the rotation for the top, and apply it to both top and bottom
int femQuadStartIdx = quadVxClosestToXYOfPoint(baseCell[0], femShallowQuad);
rotateQuad(femDeepestQuad, femQuadStartIdx);
rotateQuad(femShallowQuad, femQuadStartIdx);
int femQuadStartIdx = quadVxClosestToXYOfPoint( baseCell[0], femShallowQuad );
rotateQuad( femDeepestQuad, femQuadStartIdx );
rotateQuad( femShallowQuad, femQuadStartIdx );
}
#if 0 // Inside Bounding box test
cvf::BoundingBox cellBBox;
for (int i = 0; i < 8 ; ++i) cellBBox.add(cellCorners[i]);
@@ -472,14 +487,14 @@ for (size_t ij = 0; ij < minIJCount; ++ij )
#endif
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigCaseToCaseCellMapperTools::calculateCellCenter(cvf::Vec3d elmCorners[8])
cvf::Vec3d RigCaseToCaseCellMapperTools::calculateCellCenter( cvf::Vec3d elmCorners[8] )
{
cvf::Vec3d avg(cvf::Vec3d::ZERO);
cvf::Vec3d avg( cvf::Vec3d::ZERO );
size_t i;
for (i = 0; i < 8; i++)
for ( i = 0; i < 8; i++ )
{
avg += elmCorners[i];
}
@@ -488,5 +503,3 @@ cvf::Vec3d RigCaseToCaseCellMapperTools::calculateCellCenter(cvf::Vec3d elmCorne
return avg;
}

View File

@@ -2,26 +2,25 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfObject.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <vector>
@@ -29,26 +28,28 @@
class RigMainGrid;
class RigFemPart;
//==================================================================================================
///
///
//==================================================================================================
class RigCaseToCaseCellMapperTools
{
public:
static void estimatedFemCellFromEclCell(const RigMainGrid* eclGrid, size_t reservoirCellIndex, cvf::Vec3d estimatedElmCorners[8]);
static void rotateCellTopologicallyToMatchBaseCell(const cvf::Vec3d * baseCell, bool baseCellFaceNormalsIsOutwards, cvf::Vec3d * cell);
static cvf::Vec3d calculateCellCenter(cvf::Vec3d elmCorners[8]);
static bool elementCorners(const RigFemPart* femPart, int elmIdx, cvf::Vec3d elmCorners[8]);
static bool isEclFemCellsMatching(const cvf::Vec3d baseCell[8], cvf::Vec3d cell[8], double xyTolerance, double zTolerance);
static void estimatedFemCellFromEclCell( const RigMainGrid* eclGrid,
size_t reservoirCellIndex,
cvf::Vec3d estimatedElmCorners[8] );
static void rotateCellTopologicallyToMatchBaseCell( const cvf::Vec3d* baseCell,
bool baseCellFaceNormalsIsOutwards,
cvf::Vec3d* cell );
static cvf::Vec3d calculateCellCenter( cvf::Vec3d elmCorners[8] );
static bool elementCorners( const RigFemPart* femPart, int elmIdx, cvf::Vec3d elmCorners[8] );
static bool
isEclFemCellsMatching( const cvf::Vec3d baseCell[8], cvf::Vec3d cell[8], double xyTolerance, double zTolerance );
private:
static void rotateQuad(cvf::Vec3d quad[4], int idxToNewStart);
static void flipQuadWinding(cvf::Vec3d quad[4]);
static int quadVxClosestToXYOfPoint(const cvf::Vec3d point, const cvf::Vec3d quad[4]);
static int findMatchingPOSKFaceIdx(const cvf::Vec3d baseCell[8], bool isBaseCellNormalsOutwards, const cvf::Vec3d c2[8]);
static void rotateQuad( cvf::Vec3d quad[4], int idxToNewStart );
static void flipQuadWinding( cvf::Vec3d quad[4] );
static int quadVxClosestToXYOfPoint( const cvf::Vec3d point, const cvf::Vec3d quad[4] );
static int
findMatchingPOSKFaceIdx( const cvf::Vec3d baseCell[8], bool isBaseCellNormalsOutwards, const cvf::Vec3d c2[8] );
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,71 +22,74 @@
#include "RigCaseToCaseCellMapperTools.h"
#include "RigFemPart.h"
#include "RigMainGrid.h"
#include "RigFemPartGrid.h"
#include "RigMainGrid.h"
#include "RimCellRangeFilter.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseRangeFilterMapper::convertRangeFilterEclToFem(RimCellRangeFilter* srcFilter, const RigMainGrid* srcEclGrid,
RimCellRangeFilter* dstFilter, const RigFemPart* dstFemPart)
void RigCaseToCaseRangeFilterMapper::convertRangeFilterEclToFem( RimCellRangeFilter* srcFilter,
const RigMainGrid* srcEclGrid,
RimCellRangeFilter* dstFilter,
const RigFemPart* dstFemPart )
{
convertRangeFilter(srcFilter, dstFilter, srcEclGrid, dstFemPart, true);
convertRangeFilter( srcFilter, dstFilter, srcEclGrid, dstFemPart, true );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseRangeFilterMapper::convertRangeFilterFemToEcl(RimCellRangeFilter* srcFilter, const RigFemPart* srcFemPart,
RimCellRangeFilter* dstFilter, const RigMainGrid* dstEclGrid)
void RigCaseToCaseRangeFilterMapper::convertRangeFilterFemToEcl( RimCellRangeFilter* srcFilter,
const RigFemPart* srcFemPart,
RimCellRangeFilter* dstFilter,
const RigMainGrid* dstEclGrid )
{
convertRangeFilter(srcFilter, dstFilter, dstEclGrid, srcFemPart, false);
convertRangeFilter( srcFilter, dstFilter, dstEclGrid, srcFemPart, false );
}
struct RigRangeEndPoints
{
RigRangeEndPoints()
: StartI(cvf::UNDEFINED_SIZE_T),
StartJ(cvf::UNDEFINED_SIZE_T),
StartK(cvf::UNDEFINED_SIZE_T),
EndI(cvf::UNDEFINED_SIZE_T),
EndJ(cvf::UNDEFINED_SIZE_T),
EndK(cvf::UNDEFINED_SIZE_T)
{}
: StartI( cvf::UNDEFINED_SIZE_T )
, StartJ( cvf::UNDEFINED_SIZE_T )
, StartK( cvf::UNDEFINED_SIZE_T )
, EndI( cvf::UNDEFINED_SIZE_T )
, EndJ( cvf::UNDEFINED_SIZE_T )
, EndK( cvf::UNDEFINED_SIZE_T )
{
}
size_t StartI;
size_t StartJ;
size_t StartK;
size_t EndI ;
size_t EndJ ;
size_t EndK ;
size_t EndI;
size_t EndJ;
size_t EndK;
};
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseRangeFilterMapper::convertRangeFilter(const RimCellRangeFilter* srcFilter,
RimCellRangeFilter* dstFilter,
const RigMainGrid* eclGrid,
const RigFemPart* femPart,
bool femIsDestination)
void RigCaseToCaseRangeFilterMapper::convertRangeFilter( const RimCellRangeFilter* srcFilter,
RimCellRangeFilter* dstFilter,
const RigMainGrid* eclGrid,
const RigFemPart* femPart,
bool femIsDestination )
{
CVF_ASSERT(srcFilter && eclGrid && dstFilter && femPart);
CVF_ASSERT(srcFilter->gridIndex() == 0); // LGR not supported yet
CVF_ASSERT( srcFilter && eclGrid && dstFilter && femPart );
CVF_ASSERT( srcFilter->gridIndex() == 0 ); // LGR not supported yet
RigRangeEndPoints src;
// Convert the (start, count) range filter vars to end point cell ijk
// Convert the (start, count) range filter vars to end point cell ijk
{
src.StartI = srcFilter->startIndexI() - 1;
src.StartJ = srcFilter->startIndexJ() - 1;
src.StartK = srcFilter->startIndexK() - 1;
// Needs to subtract one more to have the end idx beeing
// Needs to subtract one more to have the end idx beeing
// the last cell in the selection, not the first outside
src.EndI = src.StartI + srcFilter->cellCountI() - 1;
src.EndJ = src.StartJ + srcFilter->cellCountJ() - 1;
@@ -99,70 +102,66 @@ void RigCaseToCaseRangeFilterMapper::convertRangeFilter(const RimCellRangeFilter
size_t maxJIndex;
size_t maxKIndex;
// Clamp end
if (femIsDestination)
// Clamp end
if ( femIsDestination )
{
maxIIndex = eclGrid->cellCountI()- 1;
maxJIndex = eclGrid->cellCountJ()- 1;
maxKIndex = eclGrid->cellCountK()- 1;
maxIIndex = eclGrid->cellCountI() - 1;
maxJIndex = eclGrid->cellCountJ() - 1;
maxKIndex = eclGrid->cellCountK() - 1;
}
else
{
maxIIndex = femPart->getOrCreateStructGrid()->cellCountI()- 1;
maxJIndex = femPart->getOrCreateStructGrid()->cellCountJ()- 1;
maxKIndex = femPart->getOrCreateStructGrid()->cellCountK()- 1;
maxIIndex = femPart->getOrCreateStructGrid()->cellCountI() - 1;
maxJIndex = femPart->getOrCreateStructGrid()->cellCountJ() - 1;
maxKIndex = femPart->getOrCreateStructGrid()->cellCountK() - 1;
}
src.EndI = CVF_MIN(src.EndI, maxIIndex);
src.EndJ = CVF_MIN(src.EndJ, maxJIndex);
src.EndK = CVF_MIN(src.EndK, maxKIndex);
src.EndI = CVF_MIN( src.EndI, maxIIndex );
src.EndJ = CVF_MIN( src.EndJ, maxJIndex );
src.EndK = CVF_MIN( src.EndK, maxKIndex );
}
// When using femPart as source we need to clamp the fem srcRange filter
// to the extents of the ecl grid within the fem part before
// doing the mapping. If not, the range filter corners will most likely be outside
// to the extents of the ecl grid within the fem part before
// doing the mapping. If not, the range filter corners will most likely be outside
// the ecl grid, resulting in an undefined conversion.
if (!femIsDestination)
if ( !femIsDestination )
{
RigRangeEndPoints eclMaxMin;
eclMaxMin.StartI = 0;
eclMaxMin.StartJ = 0;
eclMaxMin.StartK = 0;
eclMaxMin.EndI = eclGrid->cellCountI() - 1;
eclMaxMin.EndJ = eclGrid->cellCountJ() - 1;
eclMaxMin.EndK = eclGrid->cellCountK() - 1;
RigRangeEndPoints eclExtInFem;
RigRangeEndPoints eclMaxMin;
eclMaxMin.StartI = 0;
eclMaxMin.StartJ = 0;
eclMaxMin.StartK = 0;
eclMaxMin.EndI = eclGrid->cellCountI() - 1;
eclMaxMin.EndJ = eclGrid->cellCountJ() - 1;
eclMaxMin.EndK = eclGrid->cellCountK() - 1;
RigRangeEndPoints eclExtInFem;
convertRangeFilterEndPoints(eclMaxMin, eclExtInFem, eclGrid, femPart, true);
convertRangeFilterEndPoints( eclMaxMin, eclExtInFem, eclGrid, femPart, true );
src.StartI = CVF_MAX(src.StartI, eclExtInFem.StartI);
src.StartJ = CVF_MAX(src.StartJ, eclExtInFem.StartJ);
src.StartK = CVF_MAX(src.StartK, eclExtInFem.StartK);
src.EndI = CVF_MIN(src.EndI , eclExtInFem.EndI);
src.EndJ = CVF_MIN(src.EndJ , eclExtInFem.EndJ);
src.EndK = CVF_MIN(src.EndK , eclExtInFem.EndK);
src.StartI = CVF_MAX( src.StartI, eclExtInFem.StartI );
src.StartJ = CVF_MAX( src.StartJ, eclExtInFem.StartJ );
src.StartK = CVF_MAX( src.StartK, eclExtInFem.StartK );
src.EndI = CVF_MIN( src.EndI, eclExtInFem.EndI );
src.EndJ = CVF_MIN( src.EndJ, eclExtInFem.EndJ );
src.EndK = CVF_MIN( src.EndK, eclExtInFem.EndK );
}
RigRangeEndPoints dst;
convertRangeFilterEndPoints(src, dst, eclGrid, femPart, femIsDestination);
convertRangeFilterEndPoints( src, dst, eclGrid, femPart, femIsDestination );
// Populate the dst range filter with new data
if ( dst.StartI != cvf::UNDEFINED_SIZE_T
&& dst.StartJ != cvf::UNDEFINED_SIZE_T
&& dst.StartK != cvf::UNDEFINED_SIZE_T
&& dst.EndI != cvf::UNDEFINED_SIZE_T
&& dst.EndJ != cvf::UNDEFINED_SIZE_T
&& dst.EndK != cvf::UNDEFINED_SIZE_T)
if ( dst.StartI != cvf::UNDEFINED_SIZE_T && dst.StartJ != cvf::UNDEFINED_SIZE_T &&
dst.StartK != cvf::UNDEFINED_SIZE_T && dst.EndI != cvf::UNDEFINED_SIZE_T &&
dst.EndJ != cvf::UNDEFINED_SIZE_T && dst.EndK != cvf::UNDEFINED_SIZE_T )
{
dstFilter->startIndexI = static_cast<int>(dst.StartI + 1);
dstFilter->startIndexJ = static_cast<int>(dst.StartJ + 1);
dstFilter->startIndexK = static_cast<int>(dst.StartK + 1);
dstFilter->startIndexI = static_cast<int>( dst.StartI + 1 );
dstFilter->startIndexJ = static_cast<int>( dst.StartJ + 1 );
dstFilter->startIndexK = static_cast<int>( dst.StartK + 1 );
dstFilter->cellCountI = static_cast<int>(dst.EndI - (dst.StartI-1));
dstFilter->cellCountJ = static_cast<int>(dst.EndJ - (dst.StartJ-1));
dstFilter->cellCountK = static_cast<int>(dst.EndK - (dst.StartK-1));
dstFilter->cellCountI = static_cast<int>( dst.EndI - ( dst.StartI - 1 ) );
dstFilter->cellCountJ = static_cast<int>( dst.EndJ - ( dst.StartJ - 1 ) );
dstFilter->cellCountK = static_cast<int>( dst.EndK - ( dst.StartK - 1 ) );
}
else
{
@@ -177,79 +176,92 @@ void RigCaseToCaseRangeFilterMapper::convertRangeFilter(const RimCellRangeFilter
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseRangeFilterMapper::convertRangeFilterEndPoints(const RigRangeEndPoints &src,
RigRangeEndPoints &dst,
const RigMainGrid* eclGrid,
const RigFemPart* femPart,
bool femIsDestination)
void RigCaseToCaseRangeFilterMapper::convertRangeFilterEndPoints( const RigRangeEndPoints& src,
RigRangeEndPoints& dst,
const RigMainGrid* eclGrid,
const RigFemPart* femPart,
bool femIsDestination )
{
{
struct RangeFilterCorner { RangeFilterCorner() : cellMatchType(APPROX_ON_COLLAPSED){} cvf::Vec3st ijk; CellMatchType cellMatchType; };
struct RangeFilterCorner
{
RangeFilterCorner()
: cellMatchType( APPROX_ON_COLLAPSED )
{
}
cvf::Vec3st ijk;
CellMatchType cellMatchType;
};
RangeFilterCorner rangeFilterMatches[8];
cvf::Vec3st srcRangeCube[8];
srcRangeCube[0] = cvf::Vec3st(src.StartI, src.StartJ, src.StartK);
srcRangeCube[1] = cvf::Vec3st(src.EndI , src.StartJ, src.StartK);
srcRangeCube[2] = cvf::Vec3st(src.EndI , src.EndJ , src.StartK);
srcRangeCube[3] = cvf::Vec3st(src.StartI, src.EndJ , src.StartK);
srcRangeCube[4] = cvf::Vec3st(src.StartI, src.StartJ, src.EndK);
srcRangeCube[5] = cvf::Vec3st(src.EndI , src.StartJ, src.EndK);
srcRangeCube[6] = cvf::Vec3st(src.EndI , src.EndJ , src.EndK);
srcRangeCube[7] = cvf::Vec3st(src.StartI, src.EndJ , src.EndK);
srcRangeCube[0] = cvf::Vec3st( src.StartI, src.StartJ, src.StartK );
srcRangeCube[1] = cvf::Vec3st( src.EndI, src.StartJ, src.StartK );
srcRangeCube[2] = cvf::Vec3st( src.EndI, src.EndJ, src.StartK );
srcRangeCube[3] = cvf::Vec3st( src.StartI, src.EndJ, src.StartK );
srcRangeCube[4] = cvf::Vec3st( src.StartI, src.StartJ, src.EndK );
srcRangeCube[5] = cvf::Vec3st( src.EndI, src.StartJ, src.EndK );
srcRangeCube[6] = cvf::Vec3st( src.EndI, src.EndJ, src.EndK );
srcRangeCube[7] = cvf::Vec3st( src.StartI, src.EndJ, src.EndK );
bool foundExactMatch = false;
int cornerIdx = 0;
int diagIdx = 6;// Index to diagonal corner
int cornerIdx = 0;
int diagIdx = 6; // Index to diagonal corner
for (cornerIdx = 0; cornerIdx < 4; ++cornerIdx)
for ( cornerIdx = 0; cornerIdx < 4; ++cornerIdx )
{
diagIdx = (cornerIdx < 2) ? cornerIdx + 6 : cornerIdx + 2;
diagIdx = ( cornerIdx < 2 ) ? cornerIdx + 6 : cornerIdx + 2;
if (femIsDestination)
if ( femIsDestination )
{
rangeFilterMatches[cornerIdx].cellMatchType = findBestFemCellFromEclCell(eclGrid,
srcRangeCube[cornerIdx][0],
srcRangeCube[cornerIdx][1],
srcRangeCube[cornerIdx][2],
femPart,
&(rangeFilterMatches[cornerIdx].ijk[0]),
&(rangeFilterMatches[cornerIdx].ijk[1]),
&(rangeFilterMatches[cornerIdx].ijk[2]));
rangeFilterMatches[cornerIdx]
.cellMatchType = findBestFemCellFromEclCell( eclGrid,
srcRangeCube[cornerIdx][0],
srcRangeCube[cornerIdx][1],
srcRangeCube[cornerIdx][2],
femPart,
&( rangeFilterMatches[cornerIdx].ijk[0] ),
&( rangeFilterMatches[cornerIdx].ijk[1] ),
&( rangeFilterMatches[cornerIdx].ijk[2] ) );
rangeFilterMatches[diagIdx].cellMatchType = findBestFemCellFromEclCell(eclGrid,
srcRangeCube[diagIdx][0],
srcRangeCube[diagIdx][1],
srcRangeCube[diagIdx][2],
femPart,
&(rangeFilterMatches[diagIdx].ijk[0]),
&(rangeFilterMatches[diagIdx].ijk[1]),
&(rangeFilterMatches[diagIdx].ijk[2]));
rangeFilterMatches[diagIdx]
.cellMatchType = findBestFemCellFromEclCell( eclGrid,
srcRangeCube[diagIdx][0],
srcRangeCube[diagIdx][1],
srcRangeCube[diagIdx][2],
femPart,
&( rangeFilterMatches[diagIdx].ijk[0] ),
&( rangeFilterMatches[diagIdx].ijk[1] ),
&( rangeFilterMatches[diagIdx].ijk[2] ) );
}
else
{
rangeFilterMatches[cornerIdx].cellMatchType = findBestEclCellFromFemCell(femPart,
srcRangeCube[cornerIdx][0],
srcRangeCube[cornerIdx][1],
srcRangeCube[cornerIdx][2],
eclGrid,
&(rangeFilterMatches[cornerIdx].ijk[0]),
&(rangeFilterMatches[cornerIdx].ijk[1]),
&(rangeFilterMatches[cornerIdx].ijk[2]));
rangeFilterMatches[cornerIdx]
.cellMatchType = findBestEclCellFromFemCell( femPart,
srcRangeCube[cornerIdx][0],
srcRangeCube[cornerIdx][1],
srcRangeCube[cornerIdx][2],
eclGrid,
&( rangeFilterMatches[cornerIdx].ijk[0] ),
&( rangeFilterMatches[cornerIdx].ijk[1] ),
&( rangeFilterMatches[cornerIdx].ijk[2] ) );
rangeFilterMatches[diagIdx].cellMatchType = findBestEclCellFromFemCell(femPart,
srcRangeCube[diagIdx][0],
srcRangeCube[diagIdx][1],
srcRangeCube[diagIdx][2],
eclGrid,
&(rangeFilterMatches[diagIdx].ijk[0]),
&(rangeFilterMatches[diagIdx].ijk[1]),
&(rangeFilterMatches[diagIdx].ijk[2]));
rangeFilterMatches[diagIdx]
.cellMatchType = findBestEclCellFromFemCell( femPart,
srcRangeCube[diagIdx][0],
srcRangeCube[diagIdx][1],
srcRangeCube[diagIdx][2],
eclGrid,
&( rangeFilterMatches[diagIdx].ijk[0] ),
&( rangeFilterMatches[diagIdx].ijk[1] ),
&( rangeFilterMatches[diagIdx].ijk[2] ) );
}
if (rangeFilterMatches[cornerIdx].cellMatchType == EXACT && rangeFilterMatches[diagIdx].cellMatchType == EXACT)
if ( rangeFilterMatches[cornerIdx].cellMatchType == EXACT &&
rangeFilterMatches[diagIdx].cellMatchType == EXACT )
{
foundExactMatch = true;
break;
@@ -257,34 +269,43 @@ void RigCaseToCaseRangeFilterMapper::convertRangeFilterEndPoints(const RigRangeE
}
// Get the start and end IJK from the matched corners
if (foundExactMatch)
if ( foundExactMatch )
{
// Populate dst range filter from the diagonal that matches exact
dst.StartI = CVF_MIN(rangeFilterMatches[cornerIdx].ijk[0], rangeFilterMatches[diagIdx].ijk[0]);
dst.StartJ = CVF_MIN(rangeFilterMatches[cornerIdx].ijk[1], rangeFilterMatches[diagIdx].ijk[1]);
dst.StartK = CVF_MIN(rangeFilterMatches[cornerIdx].ijk[2], rangeFilterMatches[diagIdx].ijk[2]);
dst.EndI = CVF_MAX(rangeFilterMatches[cornerIdx].ijk[0], rangeFilterMatches[diagIdx].ijk[0]);
dst.EndJ = CVF_MAX(rangeFilterMatches[cornerIdx].ijk[1], rangeFilterMatches[diagIdx].ijk[1]);
dst.EndK = CVF_MAX(rangeFilterMatches[cornerIdx].ijk[2], rangeFilterMatches[diagIdx].ijk[2]);
dst.StartI = CVF_MIN( rangeFilterMatches[cornerIdx].ijk[0], rangeFilterMatches[diagIdx].ijk[0] );
dst.StartJ = CVF_MIN( rangeFilterMatches[cornerIdx].ijk[1], rangeFilterMatches[diagIdx].ijk[1] );
dst.StartK = CVF_MIN( rangeFilterMatches[cornerIdx].ijk[2], rangeFilterMatches[diagIdx].ijk[2] );
dst.EndI = CVF_MAX( rangeFilterMatches[cornerIdx].ijk[0], rangeFilterMatches[diagIdx].ijk[0] );
dst.EndJ = CVF_MAX( rangeFilterMatches[cornerIdx].ijk[1], rangeFilterMatches[diagIdx].ijk[1] );
dst.EndK = CVF_MAX( rangeFilterMatches[cornerIdx].ijk[2], rangeFilterMatches[diagIdx].ijk[2] );
}
else
{
// Look at the matches for each "face" of the range filter cube,
// Look at the matches for each "face" of the range filter cube,
// and use first exact match to determine the position of that "face"
size_t faceIJKs[6] = {cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T,cvf::UNDEFINED_SIZE_T,cvf::UNDEFINED_SIZE_T,cvf::UNDEFINED_SIZE_T,cvf::UNDEFINED_SIZE_T};
for (int faceIdx = 0; faceIdx < 6; ++faceIdx)
size_t faceIJKs[6] = {cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T};
for ( int faceIdx = 0; faceIdx < 6; ++faceIdx )
{
int ijOrk = 0;
if (faceIdx == cvf::StructGridInterface::POS_I || faceIdx == cvf::StructGridInterface::NEG_I) ijOrk = 0;
if (faceIdx == cvf::StructGridInterface::POS_J || faceIdx == cvf::StructGridInterface::NEG_J) ijOrk = 1;
if (faceIdx == cvf::StructGridInterface::POS_K || faceIdx == cvf::StructGridInterface::NEG_K) ijOrk = 2;
if ( faceIdx == cvf::StructGridInterface::POS_I || faceIdx == cvf::StructGridInterface::NEG_I )
ijOrk = 0;
if ( faceIdx == cvf::StructGridInterface::POS_J || faceIdx == cvf::StructGridInterface::NEG_J )
ijOrk = 1;
if ( faceIdx == cvf::StructGridInterface::POS_K || faceIdx == cvf::StructGridInterface::NEG_K )
ijOrk = 2;
cvf::ubyte surfCorners[4];
cvf::StructGridInterface::cellFaceVertexIndices((cvf::StructGridInterface::FaceType) faceIdx , surfCorners);
cvf::StructGridInterface::cellFaceVertexIndices( (cvf::StructGridInterface::FaceType)faceIdx,
surfCorners );
bool foundAcceptedMatch = false;
for (int cIdx = 0; cIdx < 4; ++cIdx)
for ( int cIdx = 0; cIdx < 4; ++cIdx )
{
if (rangeFilterMatches[surfCorners[cIdx]].cellMatchType == EXACT)
if ( rangeFilterMatches[surfCorners[cIdx]].cellMatchType == EXACT )
{
foundAcceptedMatch = true;
@@ -293,12 +314,12 @@ void RigCaseToCaseRangeFilterMapper::convertRangeFilterEndPoints(const RigRangeE
}
}
if (!foundAcceptedMatch)
if ( !foundAcceptedMatch )
{
// Take first match that is not related to a collapsed eclipse cell
for (int cIdx = 0; cIdx < 4; ++cIdx)
for ( int cIdx = 0; cIdx < 4; ++cIdx )
{
if (rangeFilterMatches[surfCorners[cIdx]].cellMatchType == APPROX)
if ( rangeFilterMatches[surfCorners[cIdx]].cellMatchType == APPROX )
{
foundAcceptedMatch = true;
@@ -307,8 +328,7 @@ void RigCaseToCaseRangeFilterMapper::convertRangeFilterEndPoints(const RigRangeE
}
}
if (!foundAcceptedMatch)
if ( !foundAcceptedMatch )
{
// Only collapsed cell hits in this "face"
// Todo: then use opposite face - range filter thickness
@@ -318,9 +338,12 @@ void RigCaseToCaseRangeFilterMapper::convertRangeFilterEndPoints(const RigRangeE
}
}
#ifdef DEBUG
for (int faceIdx = 0; faceIdx <6; ++faceIdx) {CVF_TIGHT_ASSERT(faceIJKs[faceIdx] != cvf::UNDEFINED_SIZE_T);}
#endif
#ifdef DEBUG
for ( int faceIdx = 0; faceIdx < 6; ++faceIdx )
{
CVF_TIGHT_ASSERT( faceIJKs[faceIdx] != cvf::UNDEFINED_SIZE_T );
}
#endif
dst.EndI = faceIJKs[cvf::StructGridInterface::POS_I];
dst.StartI = faceIJKs[cvf::StructGridInterface::NEG_I];
@@ -328,139 +351,158 @@ void RigCaseToCaseRangeFilterMapper::convertRangeFilterEndPoints(const RigRangeE
dst.StartJ = faceIJKs[cvf::StructGridInterface::NEG_J];
dst.EndK = faceIJKs[cvf::StructGridInterface::POS_K];
dst.StartK = faceIJKs[cvf::StructGridInterface::NEG_K];
}
}
}
//--------------------------------------------------------------------------------------------------
/// Return 0 for collapsed cell 1 for
/// Return 0 for collapsed cell 1 for
//--------------------------------------------------------------------------------------------------
RigCaseToCaseRangeFilterMapper::CellMatchType
RigCaseToCaseRangeFilterMapper::findBestFemCellFromEclCell(const RigMainGrid* masterEclGrid, size_t ei, size_t ej, size_t ek, const RigFemPart* dependentFemPart, size_t* fi, size_t * fj, size_t* fk)
RigCaseToCaseRangeFilterMapper::CellMatchType
RigCaseToCaseRangeFilterMapper::findBestFemCellFromEclCell( const RigMainGrid* masterEclGrid,
size_t ei,
size_t ej,
size_t ek,
const RigFemPart* dependentFemPart,
size_t* fi,
size_t* fj,
size_t* fk )
{
// Find tolerance
double cellSizeI, cellSizeJ, cellSizeK;
masterEclGrid->characteristicCellSizes(&cellSizeI, &cellSizeJ, &cellSizeK);
masterEclGrid->characteristicCellSizes( &cellSizeI, &cellSizeJ, &cellSizeK );
double xyTolerance = cellSizeI* 0.01;
double zTolerance = cellSizeK* 0.01;
double xyTolerance = cellSizeI * 0.01;
double zTolerance = cellSizeK * 0.01;
bool isEclFaceNormalsOutwards = masterEclGrid->isFaceNormalsOutwards();
size_t cellIdx = masterEclGrid->cellIndexFromIJK(ei, ej, ek);
size_t cellIdx = masterEclGrid->cellIndexFromIJK( ei, ej, ek );
bool isCollapsedCell = masterEclGrid->globalCellArray()[cellIdx].isCollapsedCell();
bool isCollapsedCell = masterEclGrid->globalCellArray()[cellIdx].isCollapsedCell();
cvf::Vec3d geoMechConvertedEclCell[8];
RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell(masterEclGrid, cellIdx, geoMechConvertedEclCell);
RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell( masterEclGrid, cellIdx, geoMechConvertedEclCell );
cvf::BoundingBox elmBBox;
for (int i = 0; i < 8 ; ++i) elmBBox.add(geoMechConvertedEclCell[i]);
for ( int i = 0; i < 8; ++i )
elmBBox.add( geoMechConvertedEclCell[i] );
std::vector<size_t> closeElements;
dependentFemPart->findIntersectingCells(elmBBox, &closeElements);
dependentFemPart->findIntersectingCells( elmBBox, &closeElements );
cvf::Vec3d elmCorners[8];
int elmIdxToBestMatch = -1;
double sqDistToClosestElmCenter = HUGE_VAL;
cvf::Vec3d convEclCellCenter = RigCaseToCaseCellMapperTools::calculateCellCenter(geoMechConvertedEclCell);
int elmIdxToBestMatch = -1;
double sqDistToClosestElmCenter = HUGE_VAL;
cvf::Vec3d convEclCellCenter = RigCaseToCaseCellMapperTools::calculateCellCenter( geoMechConvertedEclCell );
bool foundExactMatch = false;
for (size_t ccIdx = 0; ccIdx < closeElements.size(); ++ccIdx)
for ( size_t ccIdx = 0; ccIdx < closeElements.size(); ++ccIdx )
{
int elmIdx = static_cast<int>(closeElements[ccIdx]);
int elmIdx = static_cast<int>( closeElements[ccIdx] );
RigCaseToCaseCellMapperTools::elementCorners(dependentFemPart, elmIdx, elmCorners);
RigCaseToCaseCellMapperTools::elementCorners( dependentFemPart, elmIdx, elmCorners );
cvf::Vec3d cellCenter = RigCaseToCaseCellMapperTools::calculateCellCenter(elmCorners);
double sqDist = (cellCenter - convEclCellCenter).lengthSquared();
if (sqDist < sqDistToClosestElmCenter)
cvf::Vec3d cellCenter = RigCaseToCaseCellMapperTools::calculateCellCenter( elmCorners );
double sqDist = ( cellCenter - convEclCellCenter ).lengthSquared();
if ( sqDist < sqDistToClosestElmCenter )
{
elmIdxToBestMatch = elmIdx;
elmIdxToBestMatch = elmIdx;
sqDistToClosestElmCenter = sqDist;
}
RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell(geoMechConvertedEclCell, isEclFaceNormalsOutwards, elmCorners);
RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell( geoMechConvertedEclCell,
isEclFaceNormalsOutwards,
elmCorners );
foundExactMatch = RigCaseToCaseCellMapperTools::isEclFemCellsMatching(geoMechConvertedEclCell, elmCorners,
xyTolerance, zTolerance);
foundExactMatch = RigCaseToCaseCellMapperTools::isEclFemCellsMatching( geoMechConvertedEclCell,
elmCorners,
xyTolerance,
zTolerance );
if (foundExactMatch)
if ( foundExactMatch )
{
elmIdxToBestMatch = elmIdx;
break;
}
}
if (elmIdxToBestMatch != -1)
if ( elmIdxToBestMatch != -1 )
{
bool validIndex = dependentFemPart->getOrCreateStructGrid()->ijkFromCellIndex(elmIdxToBestMatch, fi, fj, fk);
CVF_ASSERT(validIndex);
bool validIndex = dependentFemPart->getOrCreateStructGrid()->ijkFromCellIndex( elmIdxToBestMatch, fi, fj, fk );
CVF_ASSERT( validIndex );
}
else
{
(*fi) = cvf::UNDEFINED_SIZE_T;
(*fj) = cvf::UNDEFINED_SIZE_T;
(*fk) = cvf::UNDEFINED_SIZE_T;
( *fi ) = cvf::UNDEFINED_SIZE_T;
( *fj ) = cvf::UNDEFINED_SIZE_T;
( *fk ) = cvf::UNDEFINED_SIZE_T;
}
if (foundExactMatch) return EXACT;
if (isCollapsedCell) return APPROX_ON_COLLAPSED;
if ( foundExactMatch ) return EXACT;
if ( isCollapsedCell ) return APPROX_ON_COLLAPSED;
return APPROX;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCaseToCaseRangeFilterMapper::CellMatchType
RigCaseToCaseRangeFilterMapper::findBestEclCellFromFemCell(const RigFemPart* dependentFemPart, size_t fi, size_t fj, size_t fk, const RigMainGrid* masterEclGrid, size_t* ei, size_t* ej, size_t* ek)
RigCaseToCaseRangeFilterMapper::CellMatchType
RigCaseToCaseRangeFilterMapper::findBestEclCellFromFemCell( const RigFemPart* dependentFemPart,
size_t fi,
size_t fj,
size_t fk,
const RigMainGrid* masterEclGrid,
size_t* ei,
size_t* ej,
size_t* ek )
{
// Find tolerance
double cellSizeI, cellSizeJ, cellSizeK;
masterEclGrid->characteristicCellSizes(&cellSizeI, &cellSizeJ, &cellSizeK);
masterEclGrid->characteristicCellSizes( &cellSizeI, &cellSizeJ, &cellSizeK );
double xyTolerance = cellSizeI* 0.4;
double zTolerance = cellSizeK* 0.4;
double xyTolerance = cellSizeI * 0.4;
double zTolerance = cellSizeK * 0.4;
bool isEclFaceNormalsOutwards = masterEclGrid->isFaceNormalsOutwards();
int elementIdx = static_cast<int>(dependentFemPart->getOrCreateStructGrid()->cellIndexFromIJK(fi, fj, fk));
int elementIdx = static_cast<int>( dependentFemPart->getOrCreateStructGrid()->cellIndexFromIJK( fi, fj, fk ) );
cvf::Vec3d elmCorners[8];
RigCaseToCaseCellMapperTools::elementCorners(dependentFemPart, elementIdx, elmCorners);
RigCaseToCaseCellMapperTools::elementCorners( dependentFemPart, elementIdx, elmCorners );
cvf::BoundingBox elmBBox;
for (int i = 0; i < 8 ; ++i) elmBBox.add(elmCorners[i]);
for ( int i = 0; i < 8; ++i )
elmBBox.add( elmCorners[i] );
std::vector<size_t> closeCells;
masterEclGrid->findIntersectingCells(elmBBox, &closeCells); // This might actually miss the exact one, but we have no other alternative yet.
masterEclGrid->findIntersectingCells( elmBBox,
&closeCells ); // This might actually miss the exact one, but we have no other alternative yet.
size_t globCellIdxToBestMatch = cvf::UNDEFINED_SIZE_T;
double sqDistToClosestCellCenter = HUGE_VAL;
cvf::Vec3d elmCenter = RigCaseToCaseCellMapperTools::calculateCellCenter(elmCorners);
size_t globCellIdxToBestMatch = cvf::UNDEFINED_SIZE_T;
double sqDistToClosestCellCenter = HUGE_VAL;
cvf::Vec3d elmCenter = RigCaseToCaseCellMapperTools::calculateCellCenter( elmCorners );
bool foundExactMatch = false;
cvf::Vec3d rotatedElm[8];
bool foundExactMatch = false;
cvf::Vec3d rotatedElm[8];
for (size_t ccIdx = 0; ccIdx < closeCells.size(); ++ccIdx)
for ( size_t ccIdx = 0; ccIdx < closeCells.size(); ++ccIdx )
{
size_t cellIdx = closeCells[ccIdx];
size_t cellIdx = closeCells[ccIdx];
cvf::Vec3d geoMechConvertedEclCell[8];
RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell(masterEclGrid, cellIdx, geoMechConvertedEclCell);
RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell( masterEclGrid, cellIdx, geoMechConvertedEclCell );
cvf::Vec3d cellCenter = RigCaseToCaseCellMapperTools::calculateCellCenter(geoMechConvertedEclCell);
double sqDist = (cellCenter - elmCenter).lengthSquared();
if (sqDist < sqDistToClosestCellCenter)
cvf::Vec3d cellCenter = RigCaseToCaseCellMapperTools::calculateCellCenter( geoMechConvertedEclCell );
double sqDist = ( cellCenter - elmCenter ).lengthSquared();
if ( sqDist < sqDistToClosestCellCenter )
{
globCellIdxToBestMatch = cellIdx;
globCellIdxToBestMatch = cellIdx;
sqDistToClosestCellCenter = sqDist;
}
rotatedElm[0] = elmCorners[0];
rotatedElm[1] = elmCorners[1];
rotatedElm[2] = elmCorners[2];
@@ -470,12 +512,16 @@ RigCaseToCaseRangeFilterMapper::findBestEclCellFromFemCell(const RigFemPart* dep
rotatedElm[6] = elmCorners[6];
rotatedElm[7] = elmCorners[7];
RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell(geoMechConvertedEclCell, isEclFaceNormalsOutwards, rotatedElm);
RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell( geoMechConvertedEclCell,
isEclFaceNormalsOutwards,
rotatedElm );
foundExactMatch = RigCaseToCaseCellMapperTools::isEclFemCellsMatching(geoMechConvertedEclCell, rotatedElm,
xyTolerance, zTolerance);
foundExactMatch = RigCaseToCaseCellMapperTools::isEclFemCellsMatching( geoMechConvertedEclCell,
rotatedElm,
xyTolerance,
zTolerance );
if (foundExactMatch)
if ( foundExactMatch )
{
globCellIdxToBestMatch = cellIdx;
break;
@@ -483,19 +529,19 @@ RigCaseToCaseRangeFilterMapper::findBestEclCellFromFemCell(const RigFemPart* dep
}
bool isCollapsedCell = false;
if (globCellIdxToBestMatch != cvf::UNDEFINED_SIZE_T)
if ( globCellIdxToBestMatch != cvf::UNDEFINED_SIZE_T )
{
masterEclGrid->ijkFromCellIndex(globCellIdxToBestMatch, ei, ej, ek);
isCollapsedCell = masterEclGrid->globalCellArray()[globCellIdxToBestMatch].isCollapsedCell();
masterEclGrid->ijkFromCellIndex( globCellIdxToBestMatch, ei, ej, ek );
isCollapsedCell = masterEclGrid->globalCellArray()[globCellIdxToBestMatch].isCollapsedCell();
}
else
{
(*ei) = cvf::UNDEFINED_SIZE_T;
(*ej) = cvf::UNDEFINED_SIZE_T;
(*ek) = cvf::UNDEFINED_SIZE_T;
( *ei ) = cvf::UNDEFINED_SIZE_T;
( *ej ) = cvf::UNDEFINED_SIZE_T;
( *ek ) = cvf::UNDEFINED_SIZE_T;
}
if (foundExactMatch) return EXACT;
if (isCollapsedCell) return APPROX_ON_COLLAPSED;
if ( foundExactMatch ) return EXACT;
if ( isCollapsedCell ) return APPROX_ON_COLLAPSED;
return APPROX;
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -28,29 +28,49 @@ struct RigRangeEndPoints;
class RigCaseToCaseRangeFilterMapper
{
public:
static void convertRangeFilterEclToFem(RimCellRangeFilter* srcFilter, const RigMainGrid* srcEclGrid,
RimCellRangeFilter* dstFilter, const RigFemPart* dstFemPart);
static void convertRangeFilterFemToEcl(RimCellRangeFilter* srcFilter, const RigFemPart* srcFemPart,
RimCellRangeFilter* dstFilter, const RigMainGrid* dstEclGrid);
static void convertRangeFilterEclToFem( RimCellRangeFilter* srcFilter,
const RigMainGrid* srcEclGrid,
RimCellRangeFilter* dstFilter,
const RigFemPart* dstFemPart );
static void convertRangeFilterFemToEcl( RimCellRangeFilter* srcFilter,
const RigFemPart* srcFemPart,
RimCellRangeFilter* dstFilter,
const RigMainGrid* dstEclGrid );
private:
static void convertRangeFilter( const RimCellRangeFilter* srcFilter,
RimCellRangeFilter* dstFilter,
const RigMainGrid* eclGrid,
const RigFemPart* femPart,
bool femIsDestination );
static void convertRangeFilter(const RimCellRangeFilter* srcFilter, RimCellRangeFilter* dstFilter,
const RigMainGrid* eclGrid, const RigFemPart* femPart,
bool femIsDestination);
static void convertRangeFilterEndPoints( const RigRangeEndPoints& src,
RigRangeEndPoints& dst,
const RigMainGrid* eclGrid,
const RigFemPart* femPart,
bool femIsDestination );
static void convertRangeFilterEndPoints(const RigRangeEndPoints &src,
RigRangeEndPoints &dst,
const RigMainGrid* eclGrid,
const RigFemPart* femPart,
bool femIsDestination);
enum CellMatchType
{
APPROX_ON_COLLAPSED,
APPROX,
EXACT
};
static CellMatchType findBestFemCellFromEclCell( const RigMainGrid* masterEclGrid,
size_t ei,
size_t ej,
size_t ek,
const RigFemPart* dependentFemPart,
size_t* fi,
size_t* fj,
size_t* fk );
enum CellMatchType {APPROX_ON_COLLAPSED, APPROX, EXACT };
static CellMatchType findBestFemCellFromEclCell(const RigMainGrid* masterEclGrid, size_t ei, size_t ej, size_t ek,
const RigFemPart* dependentFemPart, size_t* fi, size_t * fj, size_t* fk);
static CellMatchType findBestEclCellFromFemCell(const RigFemPart* dependentFemPart, size_t fi, size_t fj, size_t fk,
const RigMainGrid* masterEclGrid, size_t* ei, size_t* ej, size_t* ek);
static CellMatchType findBestEclCellFromFemCell( const RigFemPart* dependentFemPart,
size_t fi,
size_t fj,
size_t fk,
const RigMainGrid* masterEclGrid,
size_t* ei,
size_t* ej,
size_t* ek );
};

View File

@@ -3,22 +3,21 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigCell.h"
#include "RigCellGeometryTools.h"
#include "RigMainGrid.h"
@@ -34,20 +33,20 @@ static size_t undefinedCornersArray[8] = {cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T,
cvf::UNDEFINED_SIZE_T };
cvf::UNDEFINED_SIZE_T};
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCell::RigCell() :
m_gridLocalCellIndex(cvf::UNDEFINED_SIZE_T),
m_hostGrid(nullptr),
m_subGrid(nullptr),
m_parentCellIndex(cvf::UNDEFINED_SIZE_T),
m_mainGridCellIndex(cvf::UNDEFINED_SIZE_T),
m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T),
m_isInvalid(false)
RigCell::RigCell()
: m_gridLocalCellIndex( cvf::UNDEFINED_SIZE_T )
, m_hostGrid( nullptr )
, m_subGrid( nullptr )
, m_parentCellIndex( cvf::UNDEFINED_SIZE_T )
, m_mainGridCellIndex( cvf::UNDEFINED_SIZE_T )
, m_coarseningBoxIndex( cvf::UNDEFINED_SIZE_T )
, m_isInvalid( false )
{
memcpy(m_cornerIndices.data(), undefinedCornersArray, 8*sizeof(size_t));
memcpy( m_cornerIndices.data(), undefinedCornersArray, 8 * sizeof( size_t ) );
m_cellFaceFaults[0] = false;
m_cellFaceFaults[1] = false;
@@ -58,22 +57,19 @@ RigCell::RigCell() :
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCell::~RigCell()
{
}
RigCell::~RigCell() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigCell::center() const
{
cvf::Vec3d avg(cvf::Vec3d::ZERO);
cvf::Vec3d avg( cvf::Vec3d::ZERO );
size_t i;
for (i = 0; i < 8; i++)
for ( i = 0; i < 8; i++ )
{
avg += m_hostGrid->mainGrid()->nodes()[m_cornerIndices[i]];
}
@@ -83,11 +79,10 @@ cvf::Vec3d RigCell::center() const
return avg;
}
bool isNear(const cvf::Vec3d& p1, const cvf::Vec3d& p2, double tolerance)
bool isNear( const cvf::Vec3d& p1, const cvf::Vec3d& p2, double tolerance )
{
if ( cvf::Math::abs(p1[0] - p2[0]) < tolerance
&& cvf::Math::abs(p1[1] - p2[1]) < tolerance
&& cvf::Math::abs(p1[2] - p2[2]) < tolerance )
if ( cvf::Math::abs( p1[0] - p2[0] ) < tolerance && cvf::Math::abs( p1[1] - p2[1] ) < tolerance &&
cvf::Math::abs( p1[2] - p2[2] ) < tolerance )
{
return true;
}
@@ -98,35 +93,45 @@ bool isNear(const cvf::Vec3d& p1, const cvf::Vec3d& p2, double tolerance)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigCell::isLongPyramidCell(double maxHeightFactor, double nodeNearTolerance ) const
bool RigCell::isLongPyramidCell( double maxHeightFactor, double nodeNearTolerance ) const
{
cvf::ubyte faceVertexIndices[4];
double squaredMaxHeightFactor = maxHeightFactor*maxHeightFactor;
double squaredMaxHeightFactor = maxHeightFactor * maxHeightFactor;
const std::vector<cvf::Vec3d>& nodes = m_hostGrid->mainGrid()->nodes();
int face;
for ( face = 0; face < 6 ; ++face)
for ( face = 0; face < 6; ++face )
{
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( static_cast<cvf::StructGridInterface::FaceType>( face ),
faceVertexIndices );
int zeroLengthEdgeCount = 0;
const cvf::Vec3d& c0 = nodes[m_cornerIndices[faceVertexIndices[0]]];
const cvf::Vec3d& c1 = nodes[m_cornerIndices[faceVertexIndices[1]]];
const cvf::Vec3d& c2 = nodes[m_cornerIndices[faceVertexIndices[2]]];
const cvf::Vec3d& c3 = nodes[m_cornerIndices[faceVertexIndices[3]]];
const cvf::Vec3d& c0 = nodes[m_cornerIndices[faceVertexIndices[0]]];
const cvf::Vec3d& c1 = nodes[m_cornerIndices[faceVertexIndices[1]]];
const cvf::Vec3d& c2 = nodes[m_cornerIndices[faceVertexIndices[2]]];
const cvf::Vec3d& c3 = nodes[m_cornerIndices[faceVertexIndices[3]]];
if (isNear(c0, c1, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if (isNear(c1, c2, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if (isNear(c2, c3, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if ( isNear( c0, c1, nodeNearTolerance ) )
{
++zeroLengthEdgeCount;
}
if ( isNear( c1, c2, nodeNearTolerance ) )
{
++zeroLengthEdgeCount;
}
if ( isNear( c2, c3, nodeNearTolerance ) )
{
++zeroLengthEdgeCount;
}
if (zeroLengthEdgeCount == 3)
if ( zeroLengthEdgeCount == 3 )
{
return true;
#if 0 // More advanced checks turned off since the start. Why did I do that ?
#if 0 // More advanced checks turned off since the start. Why did I do that ?
// Collapse of a complete face is detected. This is possibly the top of a pyramid
// "face" has the index to the collapsed face. We need the size of the opposite face
@@ -195,24 +200,24 @@ bool RigCell::isLongPyramidCell(double maxHeightFactor, double nodeNearTolerance
return true;
}
}
#endif
#endif
}
// Check the ratio of the length of opposite edges.
// both ratios have to be above threshold to detect a pyramid-ish cell
// Only test this if we have all nonzero edge lenghts.
else if (zeroLengthEdgeCount == 0) // If the four first faces are ok, the two last must be as well
else if ( zeroLengthEdgeCount == 0 ) // If the four first faces are ok, the two last must be as well
{
double e0SquareLenght = (c1 - c0).lengthSquared();
double e2SquareLenght = (c3 - c2).lengthSquared();
if ( e0SquareLenght / e2SquareLenght > squaredMaxHeightFactor
|| e2SquareLenght / e0SquareLenght > squaredMaxHeightFactor )
double e0SquareLenght = ( c1 - c0 ).lengthSquared();
double e2SquareLenght = ( c3 - c2 ).lengthSquared();
if ( e0SquareLenght / e2SquareLenght > squaredMaxHeightFactor ||
e2SquareLenght / e0SquareLenght > squaredMaxHeightFactor )
{
double e1SquareLenght = (c2 - c1).lengthSquared();
double e3SquareLenght = (c0 - c3).lengthSquared();
double e1SquareLenght = ( c2 - c1 ).lengthSquared();
double e3SquareLenght = ( c0 - c3 ).lengthSquared();
if ( e1SquareLenght / e3SquareLenght > squaredMaxHeightFactor
|| e3SquareLenght / e1SquareLenght > squaredMaxHeightFactor )
if ( e1SquareLenght / e3SquareLenght > squaredMaxHeightFactor ||
e3SquareLenght / e1SquareLenght > squaredMaxHeightFactor )
{
return true;
}
@@ -224,9 +229,9 @@ bool RigCell::isLongPyramidCell(double maxHeightFactor, double nodeNearTolerance
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigCell::isCollapsedCell(double nodeNearTolerance) const
bool RigCell::isCollapsedCell( double nodeNearTolerance ) const
{
const std::vector<cvf::Vec3d>& nodes = m_hostGrid->mainGrid()->nodes();
@@ -234,28 +239,43 @@ bool RigCell::isCollapsedCell(double nodeNearTolerance) const
cvf::ubyte oppFaceVertexIndices[4];
int face;
for ( face = 0; face < 6 ; face += 2)
for ( face = 0; face < 6; face += 2 )
{
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices(cvf::StructGridInterface::oppositeFace(static_cast<cvf::StructGridInterface::FaceType>(face)), oppFaceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( static_cast<cvf::StructGridInterface::FaceType>( face ),
faceVertexIndices );
cvf::StructGridInterface::cellFaceVertexIndices( cvf::StructGridInterface::oppositeFace(
static_cast<cvf::StructGridInterface::FaceType>( face ) ),
oppFaceVertexIndices );
cvf::Vec3d c0 = nodes[m_cornerIndices[faceVertexIndices[0]]];
cvf::Vec3d c1 = nodes[m_cornerIndices[faceVertexIndices[1]]];
cvf::Vec3d c2 = nodes[m_cornerIndices[faceVertexIndices[2]]];
cvf::Vec3d c3 = nodes[m_cornerIndices[faceVertexIndices[3]]];
cvf::Vec3d c0 = nodes[m_cornerIndices[faceVertexIndices[0]]];
cvf::Vec3d c1 = nodes[m_cornerIndices[faceVertexIndices[1]]];
cvf::Vec3d c2 = nodes[m_cornerIndices[faceVertexIndices[2]]];
cvf::Vec3d c3 = nodes[m_cornerIndices[faceVertexIndices[3]]];
cvf::Vec3d oc0 = nodes[m_cornerIndices[oppFaceVertexIndices[0]]];
cvf::Vec3d oc1 = nodes[m_cornerIndices[oppFaceVertexIndices[1]]];
cvf::Vec3d oc2 = nodes[m_cornerIndices[oppFaceVertexIndices[2]]];
cvf::Vec3d oc3 = nodes[m_cornerIndices[oppFaceVertexIndices[3]]];
cvf::Vec3d oc0 = nodes[m_cornerIndices[oppFaceVertexIndices[0]]];
cvf::Vec3d oc1 = nodes[m_cornerIndices[oppFaceVertexIndices[1]]];
cvf::Vec3d oc2 = nodes[m_cornerIndices[oppFaceVertexIndices[2]]];
cvf::Vec3d oc3 = nodes[m_cornerIndices[oppFaceVertexIndices[3]]];
int zeroLengthEdgeCount = 0;
if (isNear(c0, oc0, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if (isNear(c1, oc3, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if (isNear(c2, oc2, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if (isNear(c3, oc1, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if ( isNear( c0, oc0, nodeNearTolerance ) )
{
++zeroLengthEdgeCount;
}
if ( isNear( c1, oc3, nodeNearTolerance ) )
{
++zeroLengthEdgeCount;
}
if ( isNear( c2, oc2, nodeNearTolerance ) )
{
++zeroLengthEdgeCount;
}
if ( isNear( c3, oc1, nodeNearTolerance ) )
{
++zeroLengthEdgeCount;
}
if (zeroLengthEdgeCount >= 4)
if ( zeroLengthEdgeCount >= 4 )
{
return true;
}
@@ -264,21 +284,20 @@ bool RigCell::isCollapsedCell(double nodeNearTolerance) const
return false;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigCell::faceCenter(cvf::StructGridInterface::FaceType face) const
cvf::Vec3d RigCell::faceCenter( cvf::StructGridInterface::FaceType face ) const
{
cvf::Vec3d avg(cvf::Vec3d::ZERO);
cvf::Vec3d avg( cvf::Vec3d::ZERO );
cvf::ubyte faceVertexIndices[4];
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( face, faceVertexIndices );
const std::vector<cvf::Vec3d>& nodeCoords = m_hostGrid->mainGrid()->nodes();
size_t i;
for (i = 0; i < 4; i++)
for ( i = 0; i < 4; i++ )
{
avg += nodeCoords[m_cornerIndices[faceVertexIndices[i]]];
}
@@ -289,20 +308,20 @@ cvf::Vec3d RigCell::faceCenter(cvf::StructGridInterface::FaceType face) const
}
//--------------------------------------------------------------------------------------------------
/// Returns an area vector for the cell face. The direction is the face normal, and the length is
/// Returns an area vector for the cell face. The direction is the face normal, and the length is
/// equal to the face area (projected to the plane represented by the diagonal in case of warp)
/// The components of this area vector are equal to the area of the face projection onto
/// The components of this area vector are equal to the area of the face projection onto
/// the corresponding plane.
/// See http://geomalgorithms.com/a01-_area.html
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigCell::faceNormalWithAreaLenght(cvf::StructGridInterface::FaceType face) const
cvf::Vec3d RigCell::faceNormalWithAreaLenght( cvf::StructGridInterface::FaceType face ) const
{
cvf::ubyte faceVertexIndices[4];
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( face, faceVertexIndices );
const std::vector<cvf::Vec3d>& nodeCoords = m_hostGrid->mainGrid()->nodes();
return 0.5*( nodeCoords[m_cornerIndices[faceVertexIndices[2]]] - nodeCoords[m_cornerIndices[faceVertexIndices[0]]]) ^
( nodeCoords[m_cornerIndices[faceVertexIndices[3]]] - nodeCoords[m_cornerIndices[faceVertexIndices[1]]]);
return 0.5 * ( nodeCoords[m_cornerIndices[faceVertexIndices[2]]] - nodeCoords[m_cornerIndices[faceVertexIndices[0]]] ) ^
( nodeCoords[m_cornerIndices[faceVertexIndices[3]]] - nodeCoords[m_cornerIndices[faceVertexIndices[1]]] );
}
//--------------------------------------------------------------------------------------------------
@@ -313,11 +332,11 @@ double RigCell::volume() const
const std::vector<cvf::Vec3d>& nodeCoords = m_hostGrid->mainGrid()->nodes();
std::array<cvf::Vec3d, 8> hexCorners;
for (size_t i = 0; i < 8; ++i)
for ( size_t i = 0; i < 8; ++i )
{
hexCorners[i] = nodeCoords.at(m_cornerIndices[i]);
hexCorners[i] = nodeCoords.at( m_cornerIndices[i] );
}
return RigCellGeometryTools::calculateCellVolume(hexCorners);
return RigCellGeometryTools::calculateCellVolume( hexCorners );
}
//--------------------------------------------------------------------------------------------------
@@ -326,44 +345,45 @@ double RigCell::volume() const
/// the cell is interpreted as.
/// If no intersection is found, the intersection point is untouched.
//--------------------------------------------------------------------------------------------------
int RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const
int RigCell::firstIntersectionPoint( const cvf::Ray& ray, cvf::Vec3d* intersectionPoint ) const
{
CVF_ASSERT(intersectionPoint != nullptr);
CVF_ASSERT( intersectionPoint != nullptr );
cvf::ubyte faceVertexIndices[4];
int face;
cvf::ubyte faceVertexIndices[4];
int face;
const std::vector<cvf::Vec3d>& nodes = m_hostGrid->mainGrid()->nodes();
cvf::Vec3d firstIntersection(cvf::Vec3d::ZERO);
double minLsq = HUGE_VAL;
int intersectionCount = 0;
cvf::Vec3d firstIntersection( cvf::Vec3d::ZERO );
double minLsq = HUGE_VAL;
int intersectionCount = 0;
for (face = 0; face < 6 ; ++face)
for ( face = 0; face < 6; ++face )
{
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( static_cast<cvf::StructGridInterface::FaceType>( face ),
faceVertexIndices );
cvf::Vec3d intersection;
cvf::Vec3d faceCenter = this->faceCenter(static_cast<cvf::StructGridInterface::FaceType>(face));
cvf::Vec3d faceCenter = this->faceCenter( static_cast<cvf::StructGridInterface::FaceType>( face ) );
for (size_t i = 0; i < 4; ++i)
for ( size_t i = 0; i < 4; ++i )
{
size_t next = i < 3 ? i+1 : 0;
if ( ray.triangleIntersect( nodes[m_cornerIndices[faceVertexIndices[i]]],
nodes[m_cornerIndices[faceVertexIndices[next]]],
faceCenter,
&intersection))
size_t next = i < 3 ? i + 1 : 0;
if ( ray.triangleIntersect( nodes[m_cornerIndices[faceVertexIndices[i]]],
nodes[m_cornerIndices[faceVertexIndices[next]]],
faceCenter,
&intersection ) )
{
intersectionCount++;
double lsq = (intersection - ray.origin() ).lengthSquared();
if (lsq < minLsq)
double lsq = ( intersection - ray.origin() ).lengthSquared();
if ( lsq < minLsq )
{
firstIntersection = intersection;
minLsq = lsq;
minLsq = lsq;
}
}
}
}
if (intersectionCount > 0)
if ( intersectionCount > 0 )
{
*intersectionPoint = firstIntersection;
}
@@ -372,16 +392,15 @@ int RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectio
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCell::faceIndices(cvf::StructGridInterface::FaceType face, std::array<size_t, 4>* indices) const
void RigCell::faceIndices( cvf::StructGridInterface::FaceType face, std::array<size_t, 4>* indices ) const
{
cvf::ubyte faceVertexIndices[4];
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( face, faceVertexIndices );
(*indices)[0] = m_cornerIndices[faceVertexIndices[0]];
(*indices)[1] = m_cornerIndices[faceVertexIndices[1]];
(*indices)[2] = m_cornerIndices[faceVertexIndices[2]];
(*indices)[3] = m_cornerIndices[faceVertexIndices[3]];
( *indices )[0] = m_cornerIndices[faceVertexIndices[0]];
( *indices )[1] = m_cornerIndices[faceVertexIndices[1]];
( *indices )[2] = m_cornerIndices[faceVertexIndices[2]];
( *indices )[3] = m_cornerIndices[faceVertexIndices[3]];
}

View File

@@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -27,68 +27,123 @@
namespace cvf
{
class Ray;
class Ray;
}
class RigCell
{
public:
RigCell();
~RigCell(); // Not virtual, to save space. Do not inherit from this class
std::array<size_t, 8>& cornerIndices() { return m_cornerIndices;}
const std::array<size_t, 8>& cornerIndices() const { return m_cornerIndices;}
std::array<size_t, 8>& cornerIndices()
{
return m_cornerIndices;
}
const std::array<size_t, 8>& cornerIndices() const
{
return m_cornerIndices;
}
void faceIndices(cvf::StructGridInterface::FaceType face, std::array<size_t, 4>* faceIndices) const ;
void faceIndices( cvf::StructGridInterface::FaceType face, std::array<size_t, 4>* faceIndices ) const;
bool isInvalid() const { return m_isInvalid; }
void setInvalid( bool val ) { m_isInvalid = val; }
bool isInvalid() const
{
return m_isInvalid;
}
void setInvalid( bool val )
{
m_isInvalid = val;
}
size_t gridLocalCellIndex() const { return m_gridLocalCellIndex; }
void setGridLocalCellIndex(size_t val) { m_gridLocalCellIndex = val; }
size_t gridLocalCellIndex() const
{
return m_gridLocalCellIndex;
}
void setGridLocalCellIndex( size_t val )
{
m_gridLocalCellIndex = val;
}
RigLocalGrid* subGrid() const { return m_subGrid; }
void setSubGrid(RigLocalGrid* subGrid) { m_subGrid = subGrid; }
void removeSubGrid(RigLocalGrid* subGrid) { m_subGrid = nullptr; }
RigLocalGrid* subGrid() const
{
return m_subGrid;
}
void setSubGrid( RigLocalGrid* subGrid )
{
m_subGrid = subGrid;
}
void removeSubGrid( RigLocalGrid* subGrid )
{
m_subGrid = nullptr;
}
RigGridBase* hostGrid() const { return m_hostGrid; }
void setHostGrid(RigGridBase* hostGrid) { m_hostGrid = hostGrid; }
RigGridBase* hostGrid() const
{
return m_hostGrid;
}
void setHostGrid( RigGridBase* hostGrid )
{
m_hostGrid = hostGrid;
}
size_t parentCellIndex() const { return m_parentCellIndex; }
void setParentCellIndex(size_t parentCellIndex) { m_parentCellIndex = parentCellIndex; }
size_t mainGridCellIndex() const { return m_mainGridCellIndex; }
void setMainGridCellIndex(size_t mainGridCellContainingThisCell) { m_mainGridCellIndex = mainGridCellContainingThisCell; }
size_t parentCellIndex() const
{
return m_parentCellIndex;
}
void setParentCellIndex( size_t parentCellIndex )
{
m_parentCellIndex = parentCellIndex;
}
size_t mainGridCellIndex() const
{
return m_mainGridCellIndex;
}
void setMainGridCellIndex( size_t mainGridCellContainingThisCell )
{
m_mainGridCellIndex = mainGridCellContainingThisCell;
}
size_t coarseningBoxIndex() const { return m_coarseningBoxIndex; }
void setCoarseningBoxIndex(size_t coarseningBoxIndex) { m_coarseningBoxIndex = coarseningBoxIndex; }
size_t coarseningBoxIndex() const
{
return m_coarseningBoxIndex;
}
void setCoarseningBoxIndex( size_t coarseningBoxIndex )
{
m_coarseningBoxIndex = coarseningBoxIndex;
}
void setCellFaceFault(cvf::StructGridInterface::FaceType face) { m_cellFaceFaults[face] = true; }
bool isCellFaceFault(cvf::StructGridInterface::FaceType face) const { return m_cellFaceFaults[face]; }
void setCellFaceFault( cvf::StructGridInterface::FaceType face )
{
m_cellFaceFaults[face] = true;
}
bool isCellFaceFault( cvf::StructGridInterface::FaceType face ) const
{
return m_cellFaceFaults[face];
}
cvf::Vec3d center() const;
cvf::Vec3d faceCenter(cvf::StructGridInterface::FaceType face) const;
cvf::Vec3d faceNormalWithAreaLenght(cvf::StructGridInterface::FaceType face) const;
double volume() const;
cvf::Vec3d center() const;
cvf::Vec3d faceCenter( cvf::StructGridInterface::FaceType face ) const;
cvf::Vec3d faceNormalWithAreaLenght( cvf::StructGridInterface::FaceType face ) const;
double volume() const;
int firstIntersectionPoint( const cvf::Ray& ray, cvf::Vec3d* intersectionPoint ) const;
bool isLongPyramidCell( double maxHeightFactor = 5, double nodeNearTolerance = 1e-3 ) const;
bool isCollapsedCell( double nodeNearTolerance = 1e-3 ) const;
int firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const;
bool isLongPyramidCell(double maxHeightFactor = 5, double nodeNearTolerance = 1e-3 ) const;
bool isCollapsedCell( double nodeNearTolerance = 1e-3) const;
private:
std::array<size_t, 8> m_cornerIndices;
std::array<size_t, 8> m_cornerIndices;
size_t m_gridLocalCellIndex; ///< This cells index in the grid it belongs to.
RigGridBase* m_hostGrid;
RigLocalGrid* m_subGrid;
size_t m_gridLocalCellIndex; ///< This cells index in the grid it belongs to.
RigGridBase* m_hostGrid;
RigLocalGrid* m_subGrid;
size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell
size_t m_mainGridCellIndex;
size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell
size_t m_mainGridCellIndex;
size_t m_coarseningBoxIndex; ///< If defined, index into list of coarsening boxes in RigGridBase
size_t m_coarseningBoxIndex; ///< If defined, index into list of coarsening boxes in RigGridBase
bool m_cellFaceFaults[6];
bool m_cellFaceFaults[6];
bool m_isInvalid;
bool m_isInvalid;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,72 +21,68 @@
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCellEdgeResultAccessor::RigCellEdgeResultAccessor() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCellEdgeResultAccessor::RigCellEdgeResultAccessor()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCellEdgeResultAccessor::setDataAccessObjectForFace(cvf::StructGridInterface::FaceType faceId, RigResultAccessor* resultAccessObject)
void RigCellEdgeResultAccessor::setDataAccessObjectForFace( cvf::StructGridInterface::FaceType faceId,
RigResultAccessor* resultAccessObject )
{
m_resultAccessObjects[faceId] = resultAccessObject;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCellEdgeResultAccessor::cellScalar(size_t gridLocalCellIndex) const
double RigCellEdgeResultAccessor::cellScalar( size_t gridLocalCellIndex ) const
{
// TODO: How to handle when we get here?
CVF_ASSERT(false);
CVF_ASSERT( false );
return cvf::UNDEFINED_DOUBLE;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCellEdgeResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigCellEdgeResultAccessor::cellFaceScalar( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
const RigResultAccessor* resultAccessObj = m_resultAccessObjects[faceId].p();
if (resultAccessObj != nullptr)
if ( resultAccessObj != nullptr )
{
return resultAccessObj->cellFaceScalar(gridLocalCellIndex, faceId);
return resultAccessObj->cellFaceScalar( gridLocalCellIndex, faceId );
}
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCellEdgeResultAccessor::cellScalarGlobIdx(size_t globCellIndex) const
double RigCellEdgeResultAccessor::cellScalarGlobIdx( size_t globCellIndex ) const
{
// TODO: How to handle when we get here?
CVF_ASSERT(false);
CVF_ASSERT( false );
return cvf::UNDEFINED_DOUBLE;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCellEdgeResultAccessor::cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigCellEdgeResultAccessor::cellFaceScalarGlobIdx( size_t globCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
const RigResultAccessor* resultAccessObj = m_resultAccessObjects[faceId].p();
if (resultAccessObj != nullptr)
if ( resultAccessObj != nullptr )
{
return resultAccessObj->cellFaceScalarGlobIdx(globCellIndex, faceId);
return resultAccessObj->cellFaceScalarGlobIdx( globCellIndex, faceId );
}
return HUGE_VAL;
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,22 +23,21 @@
#include <array>
//==================================================================================================
///
///
//==================================================================================================
class RigCellEdgeResultAccessor : public RigResultAccessor
{
public:
RigCellEdgeResultAccessor();
void setDataAccessObjectForFace(cvf::StructGridInterface::FaceType faceId, RigResultAccessor* resultAccessObject);
void setDataAccessObjectForFace( cvf::StructGridInterface::FaceType faceId, RigResultAccessor* resultAccessObject );
double cellScalar(size_t gridLocalCellIndex) const override;
double cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalar( size_t gridLocalCellIndex ) const override;
double cellFaceScalar( size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
double cellScalarGlobIdx(size_t globCellIndex) const override;
double cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalarGlobIdx( size_t globCellIndex ) const override;
double cellFaceScalarGlobIdx( size_t globCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
private:
std::array<cvf::ref<RigResultAccessor>, 6> m_resultAccessObjects;

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,6 @@
#pragma once
#include "cvfVector3.h"
#include "cvfBoundingBox.h"
@@ -31,29 +30,30 @@
class RigCellGeometryTools
{
public:
static double calculateCellVolume(const std::array<cvf::Vec3d, 8>& hexCorners);
static bool estimateHexOverlapWithBoundingBox(const std::array<cvf::Vec3d, 8>& hexCorners,
const cvf::BoundingBox& boundingBox2dExtrusion,
std::array<cvf::Vec3d, 8>* overlapCorners,
cvf::BoundingBox* overlapBoundingBox);
static double calculateCellVolume( const std::array<cvf::Vec3d, 8>& hexCorners );
static bool estimateHexOverlapWithBoundingBox( const std::array<cvf::Vec3d, 8>& hexCorners,
const cvf::BoundingBox& boundingBox2dExtrusion,
std::array<cvf::Vec3d, 8>* overlapCorners,
cvf::BoundingBox* overlapBoundingBox );
static void createPolygonFromLineSegments(std::list<std::pair<cvf::Vec3d, cvf::Vec3d>>& intersectionLineSegments,
std::vector<std::vector<cvf::Vec3d>>& polygons,
double tolerance = 1.0e-4);
static void simplifyPolygon(std::vector<cvf::Vec3d>* vertices, double epsilon);
static void createPolygonFromLineSegments( std::list<std::pair<cvf::Vec3d, cvf::Vec3d>>& intersectionLineSegments,
std::vector<std::vector<cvf::Vec3d>>& polygons,
double tolerance = 1.0e-4 );
static void simplifyPolygon( std::vector<cvf::Vec3d>* vertices, double epsilon );
static void findCellLocalXYZ(const std::array<cvf::Vec3d, 8>& hexCorners,
cvf::Vec3d& localXdirection,
cvf::Vec3d& localYdirection,
cvf::Vec3d& localZdirection);
static void findCellLocalXYZ( const std::array<cvf::Vec3d, 8>& hexCorners,
cvf::Vec3d& localXdirection,
cvf::Vec3d& localYdirection,
cvf::Vec3d& localZdirection );
static double polygonLengthInLocalXdirWeightedByArea(const std::vector<cvf::Vec3d>& polygon2d);
static double polygonLengthInLocalXdirWeightedByArea( const std::vector<cvf::Vec3d>& polygon2d );
static std::vector<std::vector<cvf::Vec3d>> intersectPolygons(const std::vector<cvf::Vec3d>& polygon1,
const std::vector<cvf::Vec3d>& polygon2);
static std::vector<std::vector<cvf::Vec3d>> intersectPolygons( const std::vector<cvf::Vec3d>& polygon1,
const std::vector<cvf::Vec3d>& polygon2 );
static std::vector<std::vector<cvf::Vec3d>> subtractPolygons(const std::vector<cvf::Vec3d>& sourcePolygon,
const std::vector<std::vector<cvf::Vec3d>>& polygonToSubtract);
static std::vector<std::vector<cvf::Vec3d>>
subtractPolygons( const std::vector<cvf::Vec3d>& sourcePolygon,
const std::vector<std::vector<cvf::Vec3d>>& polygonToSubtract );
enum ZInterpolationType
{
@@ -61,20 +61,20 @@ public:
USE_HUGEVAL,
USE_ZERO
};
static std::vector<std::vector<cvf::Vec3d>> clipPolylineByPolygon(const std::vector<cvf::Vec3d>& polyLine,
const std::vector<cvf::Vec3d>& polygon,
ZInterpolationType interpolType = USE_ZERO);
static std::vector<std::vector<cvf::Vec3d>> clipPolylineByPolygon( const std::vector<cvf::Vec3d>& polyLine,
const std::vector<cvf::Vec3d>& polygon,
ZInterpolationType interpolType = USE_ZERO );
static std::pair<cvf::Vec3d, cvf::Vec3d> getLineThroughBoundingBox(const cvf::Vec3d& lineDirection,
const cvf::BoundingBox& polygonBBox,
const cvf::Vec3d& pointOnLine);
static std::pair<cvf::Vec3d, cvf::Vec3d> getLineThroughBoundingBox( const cvf::Vec3d& lineDirection,
const cvf::BoundingBox& polygonBBox,
const cvf::Vec3d& pointOnLine );
static double getLengthOfPolygonAlongLine(const std::pair<cvf::Vec3d, cvf::Vec3d>& line,
const std::vector<cvf::Vec3d>& polygon);
static double getLengthOfPolygonAlongLine( const std::pair<cvf::Vec3d, cvf::Vec3d>& line,
const std::vector<cvf::Vec3d>& polygon );
static std::vector<cvf::Vec3d> unionOfPolygons(const std::vector<std::vector<cvf::Vec3d>>& polygons);
static std::vector<cvf::Vec3d> unionOfPolygons( const std::vector<std::vector<cvf::Vec3d>>& polygons );
private:
static std::vector<cvf::Vec3d> ajustPolygonToAvoidIntersectionsAtVertex(const std::vector<cvf::Vec3d>& polyLine,
const std::vector<cvf::Vec3d>& polygon);
static std::vector<cvf::Vec3d> ajustPolygonToAvoidIntersectionsAtVertex( const std::vector<cvf::Vec3d>& polyLine,
const std::vector<cvf::Vec3d>& polygon );
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,26 +21,27 @@
#include "RigGridBase.h"
#include <cmath>
#include "RigCell.h"
#include "RigMainGrid.h"
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCombMultResultAccessor::RigCombMultResultAccessor(const RigGridBase* grid)
: m_grid(grid)
RigCombMultResultAccessor::RigCombMultResultAccessor( const RigGridBase* grid )
: m_grid( grid )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigCombMultResultAccessor::setMultResultAccessors(
RigResultAccessor* multXPosAccessor, RigResultAccessor* multXNegAccessor,
RigResultAccessor* multYPosAccessor, RigResultAccessor* multYNegAccessor,
RigResultAccessor* multZPosAccessor, RigResultAccessor* multZNegAccessor)
void RigCombMultResultAccessor::setMultResultAccessors( RigResultAccessor* multXPosAccessor,
RigResultAccessor* multXNegAccessor,
RigResultAccessor* multYPosAccessor,
RigResultAccessor* multYNegAccessor,
RigResultAccessor* multZPosAccessor,
RigResultAccessor* multZNegAccessor )
{
m_multXPosAccessor = multXPosAccessor;
m_multXNegAccessor = multXNegAccessor;
@@ -51,99 +52,101 @@ void RigCombMultResultAccessor::setMultResultAccessors(
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombMultResultAccessor::cellScalar(size_t gridLocalCellIndex) const
double RigCombMultResultAccessor::cellScalar( size_t gridLocalCellIndex ) const
{
CVF_TIGHT_ASSERT(false);
CVF_TIGHT_ASSERT( false );
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombMultResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigCombMultResultAccessor::cellFaceScalar( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
size_t i, j, k, neighborGridCellIdx;
m_grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k);
m_grid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k );
double faceScalarThisCell = nativeMultScalar(gridLocalCellIndex, faceId);
double faceScalarThisCell = nativeMultScalar( gridLocalCellIndex, faceId );
double faceScalarNeighborCell = 1.0;
if (m_grid->cellIJKNeighbor(i, j, k, faceId, &neighborGridCellIdx))
if ( m_grid->cellIJKNeighbor( i, j, k, faceId, &neighborGridCellIdx ) )
{
faceScalarNeighborCell = nativeMultScalar(neighborGridCellIdx, cvf::StructGridInterface::oppositeFace(faceId));
faceScalarNeighborCell = nativeMultScalar( neighborGridCellIdx, cvf::StructGridInterface::oppositeFace( faceId ) );
}
return faceScalarThisCell * faceScalarNeighborCell;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombMultResultAccessor::nativeMultScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigCombMultResultAccessor::nativeMultScalar( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
double faceScalar = 1.0;
switch (faceId)
switch ( faceId )
{
case cvf::StructGridInterface::POS_I:
{
if (m_multXPosAccessor.notNull())
if ( m_multXPosAccessor.notNull() )
{
faceScalar = m_multXPosAccessor->cellScalar(gridLocalCellIndex);
faceScalar = m_multXPosAccessor->cellScalar( gridLocalCellIndex );
}
break;
}
case cvf::StructGridInterface::NEG_I:
{
if (m_multXNegAccessor.notNull())
if ( m_multXNegAccessor.notNull() )
{
faceScalar = m_multXNegAccessor->cellScalar(gridLocalCellIndex);
faceScalar = m_multXNegAccessor->cellScalar( gridLocalCellIndex );
}
break;
}
case cvf::StructGridInterface::POS_J:
{
if (m_multYPosAccessor.notNull())
if ( m_multYPosAccessor.notNull() )
{
faceScalar = m_multYPosAccessor->cellScalar(gridLocalCellIndex);
faceScalar = m_multYPosAccessor->cellScalar( gridLocalCellIndex );
}
break;
}
case cvf::StructGridInterface::NEG_J:
{
if (m_multYNegAccessor.notNull())
if ( m_multYNegAccessor.notNull() )
{
faceScalar = m_multYNegAccessor->cellScalar(gridLocalCellIndex);
faceScalar = m_multYNegAccessor->cellScalar( gridLocalCellIndex );
}
break;
}
case cvf::StructGridInterface::POS_K:
{
if (m_multZPosAccessor.notNull())
if ( m_multZPosAccessor.notNull() )
{
faceScalar = m_multZPosAccessor->cellScalar(gridLocalCellIndex);
faceScalar = m_multZPosAccessor->cellScalar( gridLocalCellIndex );
}
break;
}
case cvf::StructGridInterface::NEG_K:
{
if (m_multZNegAccessor.notNull())
if ( m_multZNegAccessor.notNull() )
{
faceScalar = m_multZNegAccessor->cellScalar(gridLocalCellIndex);
faceScalar = m_multZNegAccessor->cellScalar( gridLocalCellIndex );
}
break;
}
default:
break;
default:
break;
}
// FaceScalar with value HUGE_VAL means value outside valid IJK-range. Clamp to 1.0 as this means no change in MULT factor.
if (faceScalar == HUGE_VAL)
if ( faceScalar == HUGE_VAL )
{
faceScalar = 1.0;
}
@@ -152,21 +155,21 @@ double RigCombMultResultAccessor::nativeMultScalar(size_t gridLocalCellIndex, cv
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombMultResultAccessor::cellScalarGlobIdx(size_t globCellIndex) const
double RigCombMultResultAccessor::cellScalarGlobIdx( size_t globCellIndex ) const
{
CVF_TIGHT_ASSERT(false);
CVF_TIGHT_ASSERT( false );
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombMultResultAccessor::cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigCombMultResultAccessor::cellFaceScalarGlobIdx( size_t globCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
size_t gridLocalCellIndex = m_grid->mainGrid()->cell(globCellIndex).gridLocalCellIndex();
return this->cellFaceScalar(gridLocalCellIndex, faceId);
size_t gridLocalCellIndex = m_grid->mainGrid()->cell( globCellIndex ).gridLocalCellIndex();
return this->cellFaceScalar( gridLocalCellIndex, faceId );
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,30 +25,28 @@
class RigGridBase;
//==================================================================================================
///
///
//==================================================================================================
class RigCombMultResultAccessor : public RigResultAccessor
{
public:
explicit RigCombMultResultAccessor(const RigGridBase* grid);
explicit RigCombMultResultAccessor( const RigGridBase* grid );
void setMultResultAccessors(
RigResultAccessor* multXPosAccessor,
RigResultAccessor* multXNegAccessor,
RigResultAccessor* multYPosAccessor,
RigResultAccessor* multYNegAccessor,
RigResultAccessor* multZPosAccessor,
RigResultAccessor* multZNegAccessor);
void setMultResultAccessors( RigResultAccessor* multXPosAccessor,
RigResultAccessor* multXNegAccessor,
RigResultAccessor* multYPosAccessor,
RigResultAccessor* multYNegAccessor,
RigResultAccessor* multZPosAccessor,
RigResultAccessor* multZNegAccessor );
double cellScalar(size_t gridLocalCellIndex) const override;
double cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalarGlobIdx(size_t globCellIndex) const override;
double cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalar( size_t gridLocalCellIndex ) const override;
double cellFaceScalar( size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
double cellScalarGlobIdx( size_t globCellIndex ) const override;
double cellFaceScalarGlobIdx( size_t globCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
private:
double nativeMultScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const;
double nativeMultScalar( size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId ) const;
private:
cvf::ref<RigResultAccessor> m_multXPosAccessor;
@@ -58,5 +56,5 @@ private:
cvf::ref<RigResultAccessor> m_multZPosAccessor;
cvf::ref<RigResultAccessor> m_multZNegAccessor;
const RigGridBase* m_grid;
const RigGridBase* m_grid;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,27 +21,25 @@
#include "RigGridBase.h"
#include <cmath>
#include "RigCell.h"
#include "RigMainGrid.h"
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigCombTransResultAccessor::RigCombTransResultAccessor(const RigGridBase* grid)
: m_grid(grid)
RigCombTransResultAccessor::RigCombTransResultAccessor( const RigGridBase* grid )
: m_grid( grid )
{
}
//--------------------------------------------------------------------------------------------------
/// Only sensible to provide the positive values, as the negative ones will never be used.
/// The negative faces gets their value from the neighbor cell in that direction
//--------------------------------------------------------------------------------------------------
void RigCombTransResultAccessor::setTransResultAccessors(RigResultAccessor* xTransAccessor,
RigResultAccessor* yTransAccessor,
RigResultAccessor* zTransAccessor)
void RigCombTransResultAccessor::setTransResultAccessors( RigResultAccessor* xTransAccessor,
RigResultAccessor* yTransAccessor,
RigResultAccessor* zTransAccessor )
{
m_xTransAccessor = xTransAccessor;
@@ -50,28 +48,30 @@ void RigCombTransResultAccessor::setTransResultAccessors(RigResultAccessor* xTra
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombTransResultAccessor::cellScalar(size_t gridLocalCellIndex) const
double RigCombTransResultAccessor::cellScalar( size_t gridLocalCellIndex ) const
{
CVF_TIGHT_ASSERT(false);
CVF_TIGHT_ASSERT( false );
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
/// Get tran value from neighbor cell. Return 0.0 on active/inactive cell borders and end of grid
//--------------------------------------------------------------------------------------------------
double RigCombTransResultAccessor::neighborCellTran(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId, const RigResultAccessor* transAccessor) const
double RigCombTransResultAccessor::neighborCellTran( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId,
const RigResultAccessor* transAccessor ) const
{
if (transAccessor != nullptr)
if ( transAccessor != nullptr )
{
size_t i, j, k, neighborGridCellIdx;
m_grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k);
m_grid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k );
if (m_grid->cellIJKNeighbor(i, j, k, faceId, &neighborGridCellIdx))
if ( m_grid->cellIJKNeighbor( i, j, k, faceId, &neighborGridCellIdx ) )
{
double neighborCellValue = transAccessor->cellScalar(neighborGridCellIdx);
if (neighborCellValue == HUGE_VAL && transAccessor->cellScalar(gridLocalCellIndex) != HUGE_VAL)
double neighborCellValue = transAccessor->cellScalar( neighborGridCellIdx );
if ( neighborCellValue == HUGE_VAL && transAccessor->cellScalar( gridLocalCellIndex ) != HUGE_VAL )
{
return 0.0;
}
@@ -89,74 +89,75 @@ double RigCombTransResultAccessor::neighborCellTran(size_t gridLocalCellIndex, c
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombTransResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigCombTransResultAccessor::cellFaceScalar( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
switch (faceId)
switch ( faceId )
{
case cvf::StructGridInterface::POS_I:
case cvf::StructGridInterface::POS_I:
{
if (m_xTransAccessor.notNull())
if ( m_xTransAccessor.notNull() )
{
return m_xTransAccessor->cellScalar(gridLocalCellIndex);
return m_xTransAccessor->cellScalar( gridLocalCellIndex );
}
}
break;
case cvf::StructGridInterface::NEG_I:
case cvf::StructGridInterface::NEG_I:
{
return this->neighborCellTran(gridLocalCellIndex, cvf::StructGridInterface::NEG_I, m_xTransAccessor.p());
return this->neighborCellTran( gridLocalCellIndex, cvf::StructGridInterface::NEG_I, m_xTransAccessor.p() );
}
break;
case cvf::StructGridInterface::POS_J:
case cvf::StructGridInterface::POS_J:
{
if (m_yTransAccessor.notNull())
if ( m_yTransAccessor.notNull() )
{
return m_yTransAccessor->cellScalar(gridLocalCellIndex);
return m_yTransAccessor->cellScalar( gridLocalCellIndex );
}
}
break;
case cvf::StructGridInterface::NEG_J:
case cvf::StructGridInterface::NEG_J:
{
return this->neighborCellTran(gridLocalCellIndex, cvf::StructGridInterface::NEG_J, m_yTransAccessor.p());
return this->neighborCellTran( gridLocalCellIndex, cvf::StructGridInterface::NEG_J, m_yTransAccessor.p() );
}
break;
case cvf::StructGridInterface::POS_K:
case cvf::StructGridInterface::POS_K:
{
if (m_zTransAccessor.notNull())
if ( m_zTransAccessor.notNull() )
{
return m_zTransAccessor->cellScalar(gridLocalCellIndex);
return m_zTransAccessor->cellScalar( gridLocalCellIndex );
}
}
break;
case cvf::StructGridInterface::NEG_K:
case cvf::StructGridInterface::NEG_K:
{
return this->neighborCellTran(gridLocalCellIndex, cvf::StructGridInterface::NEG_K, m_zTransAccessor.p());
return this->neighborCellTran( gridLocalCellIndex, cvf::StructGridInterface::NEG_K, m_zTransAccessor.p() );
}
break;
default:
break;
default:
break;
}
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombTransResultAccessor::cellScalarGlobIdx(size_t globCellIndex) const
double RigCombTransResultAccessor::cellScalarGlobIdx( size_t globCellIndex ) const
{
CVF_TIGHT_ASSERT(false);
CVF_TIGHT_ASSERT( false );
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigCombTransResultAccessor::cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const
double RigCombTransResultAccessor::cellFaceScalarGlobIdx( size_t globCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
{
size_t gridLocalCellIndex = m_grid->mainGrid()->cell(globCellIndex).gridLocalCellIndex();
return this->cellFaceScalar(gridLocalCellIndex, faceId);
size_t gridLocalCellIndex = m_grid->mainGrid()->cell( globCellIndex ).gridLocalCellIndex();
return this->cellFaceScalar( gridLocalCellIndex, faceId );
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,27 +25,27 @@
class RigGridBase;
//==================================================================================================
///
///
//==================================================================================================
class RigCombTransResultAccessor : public RigResultAccessor
{
public:
explicit RigCombTransResultAccessor(const RigGridBase* grid);
explicit RigCombTransResultAccessor( const RigGridBase* grid );
void setTransResultAccessors(RigResultAccessor* xTransAccessor,
RigResultAccessor* yTransAccessor,
RigResultAccessor* zTransAccessor);
void setTransResultAccessors( RigResultAccessor* xTransAccessor,
RigResultAccessor* yTransAccessor,
RigResultAccessor* zTransAccessor );
double cellScalar(size_t gridLocalCellIndex) const override;
double cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalarGlobIdx(size_t globCellIndex) const override;
double cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const override;
double cellScalar( size_t gridLocalCellIndex ) const override;
double cellFaceScalar( size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
double cellScalarGlobIdx( size_t globCellIndex ) const override;
double cellFaceScalarGlobIdx( size_t globCellIndex, cvf::StructGridInterface::FaceType faceId ) const override;
private:
double neighborCellTran(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId, const RigResultAccessor* transAccessor) const;
double neighborCellTran( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId,
const RigResultAccessor* transAccessor ) const;
cvf::ref<RigResultAccessor> m_xTransAccessor;
cvf::ref<RigResultAccessor> m_yTransAccessor;

View File

@@ -45,20 +45,20 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseCaseData::RigEclipseCaseData(RimEclipseCase* ownerCase)
: m_hasParsedDeckForEquilData(false)
RigEclipseCaseData::RigEclipseCaseData( RimEclipseCase* ownerCase )
: m_hasParsedDeckForEquilData( false )
{
m_mainGrid = new RigMainGrid();
m_ownerCase = ownerCase;
m_matrixModelResults = new RigCaseCellResultsData(this, RiaDefines::MATRIX_MODEL);
m_fractureModelResults = new RigCaseCellResultsData(this, RiaDefines::FRACTURE_MODEL);
m_matrixModelResults = new RigCaseCellResultsData( this, RiaDefines::MATRIX_MODEL );
m_fractureModelResults = new RigCaseCellResultsData( this, RiaDefines::FRACTURE_MODEL );
m_activeCellInfo = new RigActiveCellInfo;
m_fractureActiveCellInfo = new RigActiveCellInfo;
m_matrixModelResults->setActiveCellInfo(m_activeCellInfo.p());
m_fractureModelResults->setActiveCellInfo(m_fractureActiveCellInfo.p());
m_matrixModelResults->setActiveCellInfo( m_activeCellInfo.p() );
m_fractureModelResults->setActiveCellInfo( m_fractureActiveCellInfo.p() );
m_unitsType = RiaEclipseUnitTools::UNITS_METRIC;
}
@@ -87,90 +87,90 @@ const RigMainGrid* RigEclipseCaseData::mainGrid() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::setMainGrid(RigMainGrid* mainGrid)
void RigEclipseCaseData::setMainGrid( RigMainGrid* mainGrid )
{
m_mainGrid = mainGrid;
m_matrixModelResults->setMainGrid(m_mainGrid.p());
m_fractureModelResults->setMainGrid(m_mainGrid.p());
m_matrixModelResults->setMainGrid( m_mainGrid.p() );
m_fractureModelResults->setMainGrid( m_mainGrid.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::allGrids(std::vector<RigGridBase*>* grids)
void RigEclipseCaseData::allGrids( std::vector<RigGridBase*>* grids )
{
CVF_ASSERT(grids);
CVF_ASSERT( grids );
if (m_mainGrid.isNull())
if ( m_mainGrid.isNull() )
{
return;
}
size_t i;
for (i = 0; i < m_mainGrid->gridCount(); i++)
for ( i = 0; i < m_mainGrid->gridCount(); i++ )
{
grids->push_back(m_mainGrid->gridByIndex(i));
grids->push_back( m_mainGrid->gridByIndex( i ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::allGrids(std::vector<const RigGridBase*>* grids) const
void RigEclipseCaseData::allGrids( std::vector<const RigGridBase*>* grids ) const
{
CVF_ASSERT(grids);
CVF_ASSERT( grids );
if (m_mainGrid.isNull())
if ( m_mainGrid.isNull() )
{
return;
}
size_t i;
for (i = 0; i < m_mainGrid->gridCount(); i++)
for ( i = 0; i < m_mainGrid->gridCount(); i++ )
{
grids->push_back(m_mainGrid->gridByIndex(i));
grids->push_back( m_mainGrid->gridByIndex( i ) );
}
}
//--------------------------------------------------------------------------------------------------
/// Get grid by index. The main grid has index 0, so the first lgr has index 1
//--------------------------------------------------------------------------------------------------
const RigGridBase* RigEclipseCaseData::grid(size_t index) const
const RigGridBase* RigEclipseCaseData::grid( size_t index ) const
{
CVF_ASSERT(m_mainGrid.notNull());
return m_mainGrid->gridByIndex(index);
CVF_ASSERT( m_mainGrid.notNull() );
return m_mainGrid->gridByIndex( index );
}
//--------------------------------------------------------------------------------------------------
/// Get grid by index. The main grid has index 0, so the first lgr has index 1
//--------------------------------------------------------------------------------------------------
RigGridBase* RigEclipseCaseData::grid(size_t index)
RigGridBase* RigEclipseCaseData::grid( size_t index )
{
CVF_ASSERT(m_mainGrid.notNull());
return m_mainGrid->gridByIndex(index);
CVF_ASSERT( m_mainGrid.notNull() );
return m_mainGrid->gridByIndex( index );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigGridBase* RigEclipseCaseData::grid(const QString& gridName) const
const RigGridBase* RigEclipseCaseData::grid( const QString& gridName ) const
{
if (m_mainGrid.isNull())
if ( m_mainGrid.isNull() )
{
return nullptr;
}
if (gridName.isEmpty())
if ( gridName.isEmpty() )
{
return m_mainGrid.p();
}
size_t i;
for (i = 0; i < m_mainGrid->gridCount(); i++)
for ( i = 0; i < m_mainGrid->gridCount(); i++ )
{
const RigGridBase* grid = m_mainGrid->gridByIndex(i);
if (QString::fromStdString(grid->gridName()) == gridName) return grid;
const RigGridBase* grid = m_mainGrid->gridByIndex( i );
if ( QString::fromStdString( grid->gridName() ) == gridName ) return grid;
}
return nullptr;
}
@@ -180,7 +180,7 @@ const RigGridBase* RigEclipseCaseData::grid(const QString& gridName) const
//--------------------------------------------------------------------------------------------------
size_t RigEclipseCaseData::gridCount() const
{
CVF_ASSERT(m_mainGrid.notNull());
CVF_ASSERT( m_mainGrid.notNull() );
return m_mainGrid->gridCount();
}
@@ -190,10 +190,10 @@ size_t RigEclipseCaseData::gridCount() const
void RigEclipseCaseData::computeWellCellsPrGrid()
{
// If we have computed this already, return
if (m_wellCellsInGrid.size()) return;
if ( m_wellCellsInGrid.size() ) return;
std::vector<RigGridBase*> grids;
this->allGrids(&grids);
this->allGrids( &grids );
// Debug code used to display grid names and grid sizes
/*
@@ -217,50 +217,50 @@ void RigEclipseCaseData::computeWellCellsPrGrid()
// Allocate and initialize the arrays
m_wellCellsInGrid.resize(grids.size());
m_gridCellToResultWellIndex.resize(grids.size());
m_wellCellsInGrid.resize( grids.size() );
m_gridCellToResultWellIndex.resize( grids.size() );
for (gIdx = 0; gIdx < grids.size(); ++gIdx)
for ( gIdx = 0; gIdx < grids.size(); ++gIdx )
{
if (m_wellCellsInGrid[gIdx].isNull() || m_wellCellsInGrid[gIdx]->size() != grids[gIdx]->cellCount())
if ( m_wellCellsInGrid[gIdx].isNull() || m_wellCellsInGrid[gIdx]->size() != grids[gIdx]->cellCount() )
{
m_wellCellsInGrid[gIdx] = new cvf::UByteArray;
m_wellCellsInGrid[gIdx]->resize(grids[gIdx]->cellCount());
m_wellCellsInGrid[gIdx]->resize( grids[gIdx]->cellCount() );
m_gridCellToResultWellIndex[gIdx] = new cvf::UIntArray;
m_gridCellToResultWellIndex[gIdx]->resize(grids[gIdx]->cellCount());
m_gridCellToResultWellIndex[gIdx]->resize( grids[gIdx]->cellCount() );
}
m_wellCellsInGrid[gIdx]->setAll(false);
m_gridCellToResultWellIndex[gIdx]->setAll(cvf::UNDEFINED_UINT);
m_wellCellsInGrid[gIdx]->setAll( false );
m_gridCellToResultWellIndex[gIdx]->setAll( cvf::UNDEFINED_UINT );
}
// Fill arrays with data
size_t wIdx;
for (wIdx = 0; wIdx < m_simWellData.size(); ++wIdx)
for ( wIdx = 0; wIdx < m_simWellData.size(); ++wIdx )
{
size_t tIdx;
for (tIdx = 0; tIdx < m_simWellData[wIdx]->m_wellCellsTimeSteps.size(); ++tIdx)
for ( tIdx = 0; tIdx < m_simWellData[wIdx]->m_wellCellsTimeSteps.size(); ++tIdx )
{
RigWellResultFrame& wellCells = m_simWellData[wIdx]->m_wellCellsTimeSteps[tIdx];
// Well result branches
for (size_t sIdx = 0; sIdx < wellCells.m_wellResultBranches.size(); ++sIdx)
for ( size_t sIdx = 0; sIdx < wellCells.m_wellResultBranches.size(); ++sIdx )
{
RigWellResultBranch& wellSegment = wellCells.m_wellResultBranches[sIdx];
size_t cdIdx;
for (cdIdx = 0; cdIdx < wellSegment.m_branchResultPoints.size(); ++cdIdx)
for ( cdIdx = 0; cdIdx < wellSegment.m_branchResultPoints.size(); ++cdIdx )
{
size_t gridIndex = wellSegment.m_branchResultPoints[cdIdx].m_gridIndex;
size_t gridCellIndex = wellSegment.m_branchResultPoints[cdIdx].m_gridCellIndex;
if (gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size())
if ( gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size() )
{
// NOTE : We do not check if the grid cell is active as we do for well head.
// If we add test for active cell, thorough testing and verification of the new behaviour must be adressed
m_wellCellsInGrid[gridIndex]->set(gridCellIndex, true);
m_gridCellToResultWellIndex[gridIndex]->set(gridCellIndex, static_cast<cvf::uint>(wIdx));
m_wellCellsInGrid[gridIndex]->set( gridCellIndex, true );
m_gridCellToResultWellIndex[gridIndex]->set( gridCellIndex, static_cast<cvf::uint>( wIdx ) );
}
}
}
@@ -271,7 +271,7 @@ void RigEclipseCaseData::computeWellCellsPrGrid()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::setSimWellData(const cvf::Collection<RigSimWellData>& data)
void RigEclipseCaseData::setSimWellData( const cvf::Collection<RigSimWellData>& data )
{
m_simWellData = data;
m_wellCellsInGrid.clear();
@@ -289,9 +289,9 @@ std::set<QString> RigEclipseCaseData::findSortedWellNames() const
const cvf::Collection<RigSimWellData>& simWellData = wellResults();
for (size_t wIdx = 0; wIdx < simWellData.size(); ++wIdx)
for ( size_t wIdx = 0; wIdx < simWellData.size(); ++wIdx )
{
sortedWellNames.insert(simWellData[wIdx]->m_wellName);
sortedWellNames.insert( simWellData[wIdx]->m_wellName );
}
return sortedWellNames;
@@ -300,11 +300,11 @@ std::set<QString> RigEclipseCaseData::findSortedWellNames() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigSimWellData* RigEclipseCaseData::findSimWellData(QString wellName) const
const RigSimWellData* RigEclipseCaseData::findSimWellData( QString wellName ) const
{
for (size_t wIdx = 0; wIdx < m_simWellData.size(); ++wIdx)
for ( size_t wIdx = 0; wIdx < m_simWellData.size(); ++wIdx )
{
if (m_simWellData[wIdx]->m_wellName == wellName)
if ( m_simWellData[wIdx]->m_wellName == wellName )
{
return m_simWellData[wIdx].p();
}
@@ -316,10 +316,10 @@ const RigSimWellData* RigEclipseCaseData::findSimWellData(QString wellName) cons
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::UByteArray* RigEclipseCaseData::wellCellsInGrid(size_t gridIndex)
const cvf::UByteArray* RigEclipseCaseData::wellCellsInGrid( size_t gridIndex )
{
computeWellCellsPrGrid();
CVF_ASSERT(gridIndex < m_wellCellsInGrid.size());
CVF_ASSERT( gridIndex < m_wellCellsInGrid.size() );
return m_wellCellsInGrid[gridIndex].p();
}
@@ -327,10 +327,10 @@ const cvf::UByteArray* RigEclipseCaseData::wellCellsInGrid(size_t gridIndex)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::UIntArray* RigEclipseCaseData::gridCellToResultWellIndex(size_t gridIndex)
const cvf::UIntArray* RigEclipseCaseData::gridCellToResultWellIndex( size_t gridIndex )
{
computeWellCellsPrGrid();
CVF_ASSERT(gridIndex < m_gridCellToResultWellIndex.size());
CVF_ASSERT( gridIndex < m_gridCellToResultWellIndex.size() );
return m_gridCellToResultWellIndex[gridIndex].p();
}
@@ -338,25 +338,25 @@ const cvf::UIntArray* RigEclipseCaseData::gridCellToResultWellIndex(size_t gridI
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigCell& RigEclipseCaseData::cellFromWellResultCell(const RigWellResultPoint& wellResultCell) const
const RigCell& RigEclipseCaseData::cellFromWellResultCell( const RigWellResultPoint& wellResultCell ) const
{
CVF_ASSERT(wellResultCell.isCell());
CVF_ASSERT( wellResultCell.isCell() );
size_t gridIndex = wellResultCell.m_gridIndex;
size_t gridCellIndex = wellResultCell.m_gridCellIndex;
std::vector<const RigGridBase*> grids;
allGrids(&grids);
allGrids( &grids );
return grids[gridIndex]->cell(gridCellIndex);
return grids[gridIndex]->cell( gridCellIndex );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigEclipseCaseData::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,
const RigWellResultPoint& sourceWellCellResult,
const RigWellResultPoint& otherWellCellResult) const
bool RigEclipseCaseData::findSharedSourceFace( cvf::StructGridInterface::FaceType& sharedSourceFace,
const RigWellResultPoint& sourceWellCellResult,
const RigWellResultPoint& otherWellCellResult ) const
{
size_t gridIndex = sourceWellCellResult.m_gridIndex;
size_t gridCellIndex = sourceWellCellResult.m_gridCellIndex;
@@ -364,28 +364,28 @@ bool RigEclipseCaseData::findSharedSourceFace(cvf::StructGridInterface::FaceType
size_t otherGridIndex = otherWellCellResult.m_gridIndex;
size_t otherGridCellIndex = otherWellCellResult.m_gridCellIndex;
if (gridIndex != otherGridIndex) return false;
if ( gridIndex != otherGridIndex ) return false;
std::vector<const RigGridBase*> grids;
allGrids(&grids);
allGrids( &grids );
const RigGridBase* grid = grids[gridIndex];
size_t i, j, k;
grid->ijkFromCellIndex(gridCellIndex, &i, &j, &k);
grid->ijkFromCellIndex( gridCellIndex, &i, &j, &k );
size_t faceIdx;
for (faceIdx = 0; faceIdx < 6; faceIdx++)
for ( faceIdx = 0; faceIdx < 6; faceIdx++ )
{
cvf::StructGridInterface::FaceType sourceFace = static_cast<cvf::StructGridInterface::FaceType>(faceIdx);
cvf::StructGridInterface::FaceType sourceFace = static_cast<cvf::StructGridInterface::FaceType>( faceIdx );
size_t ni, nj, nk;
grid->neighborIJKAtCellFace(i, j, k, sourceFace, &ni, &nj, &nk);
grid->neighborIJKAtCellFace( i, j, k, sourceFace, &ni, &nj, &nk );
if (grid->isCellValid(ni, nj, nk))
if ( grid->isCellValid( ni, nj, nk ) )
{
size_t neighborCellIndex = grid->cellIndexFromIJK(ni, nj, nk);
size_t neighborCellIndex = grid->cellIndexFromIJK( ni, nj, nk );
if (neighborCellIndex == otherGridCellIndex)
if ( neighborCellIndex == otherGridCellIndex )
{
sharedSourceFace = sourceFace;
return true;
@@ -403,20 +403,20 @@ class CellRangeBB
{
public:
CellRangeBB()
: m_min(cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T)
, m_max(cvf::Vec3st::ZERO)
: m_min( cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T )
, m_max( cvf::Vec3st::ZERO )
{
}
void add(size_t i, size_t j, size_t k)
void add( size_t i, size_t j, size_t k )
{
if (i < m_min.x()) m_min.x() = i;
if (j < m_min.y()) m_min.y() = j;
if (k < m_min.z()) m_min.z() = k;
if ( i < m_min.x() ) m_min.x() = i;
if ( j < m_min.y() ) m_min.y() = j;
if ( k < m_min.z() ) m_min.z() = k;
if (i > m_max.x()) m_max.x() = i;
if (j > m_max.y()) m_max.y() = j;
if (k > m_max.z()) m_max.z() = k;
if ( i > m_max.x() ) m_max.x() = i;
if ( j > m_max.y() ) m_max.y() = j;
if ( k > m_max.z() ) m_max.z() = k;
}
public:
@@ -429,29 +429,29 @@ public:
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::computeActiveCellIJKBBox()
{
if (m_mainGrid.notNull() && m_activeCellInfo.notNull() && m_fractureActiveCellInfo.notNull())
if ( m_mainGrid.notNull() && m_activeCellInfo.notNull() && m_fractureActiveCellInfo.notNull() )
{
CellRangeBB matrixModelActiveBB;
CellRangeBB fractureModelActiveBB;
size_t idx;
for (idx = 0; idx < m_mainGrid->cellCount(); idx++)
for ( idx = 0; idx < m_mainGrid->cellCount(); idx++ )
{
size_t i, j, k;
m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k);
m_mainGrid->ijkFromCellIndex( idx, &i, &j, &k );
if (m_activeCellInfo->isActive(idx))
if ( m_activeCellInfo->isActive( idx ) )
{
matrixModelActiveBB.add(i, j, k);
matrixModelActiveBB.add( i, j, k );
}
if (m_fractureActiveCellInfo->isActive(idx))
if ( m_fractureActiveCellInfo->isActive( idx ) )
{
fractureModelActiveBB.add(i, j, k);
fractureModelActiveBB.add( i, j, k );
}
}
m_activeCellInfo->setIJKBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max);
m_fractureActiveCellInfo->setIJKBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max);
m_activeCellInfo->setIJKBoundingBox( matrixModelActiveBB.m_min, matrixModelActiveBB.m_max );
m_fractureActiveCellInfo->setIJKBoundingBox( fractureModelActiveBB.m_min, fractureModelActiveBB.m_max );
}
}
@@ -470,9 +470,9 @@ void RigEclipseCaseData::computeActiveCellBoundingBoxes()
std::vector<QString> RigEclipseCaseData::simulationWellNames() const
{
std::vector<QString> wellNames;
for (const auto& wellResult : wellResults())
for ( const auto& wellResult : wellResults() )
{
wellNames.push_back(wellResult->m_wellName);
wellNames.push_back( wellResult->m_wellName );
}
return wellNames;
}
@@ -480,57 +480,63 @@ std::vector<QString> RigEclipseCaseData::simulationWellNames() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigEclipseCaseData::hasSimulationWell(const QString& simWellName) const
bool RigEclipseCaseData::hasSimulationWell( const QString& simWellName ) const
{
const auto wellNames = simulationWellNames();
return std::find(wellNames.begin(), wellNames.end(), simWellName) != wellNames.end();
return std::find( wellNames.begin(), wellNames.end(), simWellName ) != wellNames.end();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<const RigWellPath*> RigEclipseCaseData::simulationWellBranches(const QString& simWellName,
bool includeAllCellCenters,
bool useAutoDetectionOfBranches) const
std::vector<const RigWellPath*> RigEclipseCaseData::simulationWellBranches( const QString& simWellName,
bool includeAllCellCenters,
bool useAutoDetectionOfBranches ) const
{
std::vector<const RigWellPath*> branches;
if (simWellName.isEmpty() || simWellName.toUpper() == "NONE")
if ( simWellName.isEmpty() || simWellName.toUpper() == "NONE" )
{
return branches;
}
const RigSimWellData* simWellData = findSimWellData(simWellName);
if (!simWellData) return branches;
const RigSimWellData* simWellData = findSimWellData( simWellName );
if ( !simWellData ) return branches;
std::tuple<QString, bool, bool> simWellSeachItem =
std::make_tuple(simWellName, includeAllCellCenters, useAutoDetectionOfBranches);
std::tuple<QString, bool, bool> simWellSeachItem = std::make_tuple( simWellName,
includeAllCellCenters,
useAutoDetectionOfBranches );
if (m_simWellBranchCache.find(simWellSeachItem) == m_simWellBranchCache.end())
if ( m_simWellBranchCache.find( simWellSeachItem ) == m_simWellBranchCache.end() )
{
std::vector<std::vector<cvf::Vec3d>> pipeBranchesCLCoords;
std::vector<std::vector<RigWellResultPoint>> pipeBranchesCellIds;
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(
this, simWellData, -1, useAutoDetectionOfBranches, includeAllCellCenters, pipeBranchesCLCoords, pipeBranchesCellIds);
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame( this,
simWellData,
-1,
useAutoDetectionOfBranches,
includeAllCellCenters,
pipeBranchesCLCoords,
pipeBranchesCellIds );
m_simWellBranchCache.insert(std::make_pair(simWellSeachItem, cvf::Collection<RigWellPath>()));
m_simWellBranchCache.insert( std::make_pair( simWellSeachItem, cvf::Collection<RigWellPath>() ) );
for (size_t brIdx = 0; brIdx < pipeBranchesCLCoords.size(); ++brIdx)
for ( size_t brIdx = 0; brIdx < pipeBranchesCLCoords.size(); ++brIdx )
{
auto wellMdCalculator = RigSimulationWellCoordsAndMD(pipeBranchesCLCoords[brIdx]);
auto wellMdCalculator = RigSimulationWellCoordsAndMD( pipeBranchesCLCoords[brIdx] );
cvf::ref<RigWellPath> newWellPath = new RigWellPath();
newWellPath->m_measuredDepths = wellMdCalculator.measuredDepths();
newWellPath->m_wellPathPoints = wellMdCalculator.wellPathPoints();
m_simWellBranchCache[simWellSeachItem].push_back(newWellPath.p());
m_simWellBranchCache[simWellSeachItem].push_back( newWellPath.p() );
}
}
for (const auto& branch : m_simWellBranchCache[simWellSeachItem])
for ( const auto& branch : m_simWellBranchCache[simWellSeachItem] )
{
branches.push_back(branch.p());
branches.push_back( branch.p() );
}
return branches;
@@ -540,7 +546,7 @@ std::vector<const RigWellPath*> RigEclipseCaseData::simulationWellBranches(const
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::setVirtualPerforationTransmissibilities(
RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities)
RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities )
{
m_virtualPerforationTransmissibilities = virtualPerforationTransmissibilities;
}
@@ -556,11 +562,12 @@ const RigVirtualPerforationTransmissibilities* RigEclipseCaseData::virtualPerfor
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::ensureDeckIsParsedForEquilData(const QString& dataDeckFile, const QString& includeFileAbsolutePathPrefix)
void RigEclipseCaseData::ensureDeckIsParsedForEquilData( const QString& dataDeckFile,
const QString& includeFileAbsolutePathPrefix )
{
if (!m_hasParsedDeckForEquilData)
if ( !m_hasParsedDeckForEquilData )
{
RifReaderEclipseOutput::importEquilData(dataDeckFile, includeFileAbsolutePathPrefix, this);
RifReaderEclipseOutput::importEquilData( dataDeckFile, includeFileAbsolutePathPrefix, this );
m_hasParsedDeckForEquilData = true;
}
@@ -577,7 +584,7 @@ std::vector<RigEquil> RigEclipseCaseData::equilData() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::setEquilData(const std::vector<RigEquil>& equilObjects)
void RigEclipseCaseData::setEquilData( const std::vector<RigEquil>& equilObjects )
{
m_equil = equilObjects;
}
@@ -585,9 +592,9 @@ void RigEclipseCaseData::setEquilData(const std::vector<RigEquil>& equilObjects)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RigEclipseCaseData::activeCellInfo(RiaDefines::PorosityModelType porosityModel)
RigActiveCellInfo* RigEclipseCaseData::activeCellInfo( RiaDefines::PorosityModelType porosityModel )
{
if (porosityModel == RiaDefines::MATRIX_MODEL)
if ( porosityModel == RiaDefines::MATRIX_MODEL )
{
return m_activeCellInfo.p();
}
@@ -598,9 +605,9 @@ RigActiveCellInfo* RigEclipseCaseData::activeCellInfo(RiaDefines::PorosityModelT
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigActiveCellInfo* RigEclipseCaseData::activeCellInfo(RiaDefines::PorosityModelType porosityModel) const
const RigActiveCellInfo* RigEclipseCaseData::activeCellInfo( RiaDefines::PorosityModelType porosityModel ) const
{
if (porosityModel == RiaDefines::MATRIX_MODEL)
if ( porosityModel == RiaDefines::MATRIX_MODEL )
{
return m_activeCellInfo.p();
}
@@ -611,17 +618,18 @@ const RigActiveCellInfo* RigEclipseCaseData::activeCellInfo(RiaDefines::Porosity
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::setActiveCellInfo(RiaDefines::PorosityModelType porosityModel, RigActiveCellInfo* activeCellInfo)
void RigEclipseCaseData::setActiveCellInfo( RiaDefines::PorosityModelType porosityModel,
RigActiveCellInfo* activeCellInfo )
{
if (porosityModel == RiaDefines::MATRIX_MODEL)
if ( porosityModel == RiaDefines::MATRIX_MODEL )
{
m_activeCellInfo = activeCellInfo;
m_matrixModelResults->setActiveCellInfo(m_activeCellInfo.p());
m_matrixModelResults->setActiveCellInfo( m_activeCellInfo.p() );
}
else
{
m_fractureActiveCellInfo = activeCellInfo;
m_fractureModelResults->setActiveCellInfo(m_fractureActiveCellInfo.p());
m_fractureModelResults->setActiveCellInfo( m_fractureActiveCellInfo.p() );
}
}
@@ -630,7 +638,8 @@ void RigEclipseCaseData::setActiveCellInfo(RiaDefines::PorosityModelType porosit
//--------------------------------------------------------------------------------------------------
bool RigEclipseCaseData::hasFractureResults() const
{
if (activeCellInfo(RiaDefines::FRACTURE_MODEL) && activeCellInfo(RiaDefines::FRACTURE_MODEL)->reservoirActiveCellCount() > 0)
if ( activeCellInfo( RiaDefines::FRACTURE_MODEL ) &&
activeCellInfo( RiaDefines::FRACTURE_MODEL )->reservoirActiveCellCount() > 0 )
{
return true;
}
@@ -643,16 +652,16 @@ bool RigEclipseCaseData::hasFractureResults() const
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
{
if (m_activeCellInfo.isNull() || m_fractureActiveCellInfo.isNull())
if ( m_activeCellInfo.isNull() || m_fractureActiveCellInfo.isNull() )
{
return;
}
if (m_mainGrid.isNull())
if ( m_mainGrid.isNull() )
{
cvf::BoundingBox bb;
m_activeCellInfo->setGeometryBoundingBox(bb);
m_fractureActiveCellInfo->setGeometryBoundingBox(bb);
m_activeCellInfo->setGeometryBoundingBox( bb );
m_fractureActiveCellInfo->setGeometryBoundingBox( bb );
return;
}
@@ -661,54 +670,54 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
activeInfos[1] = m_activeCellInfo.p(); // Last, to make this bb.min become display offset
cvf::BoundingBox bb;
for (int acIdx = 0; acIdx < 2; ++acIdx)
for ( int acIdx = 0; acIdx < 2; ++acIdx )
{
bb.reset();
if (m_mainGrid->nodes().size() == 0)
if ( m_mainGrid->nodes().size() == 0 )
{
bb.add(cvf::Vec3d::ZERO);
bb.add( cvf::Vec3d::ZERO );
}
else
{
std::array<cvf::Vec3d, 8> hexCorners;
for (size_t i = 0; i < m_mainGrid->cellCount(); i++)
for ( size_t i = 0; i < m_mainGrid->cellCount(); i++ )
{
if (activeInfos[acIdx]->isActive(i))
if ( activeInfos[acIdx]->isActive( i ) )
{
m_mainGrid->cellCornerVertices(i, hexCorners.data());
for (const auto& corner : hexCorners)
m_mainGrid->cellCornerVertices( i, hexCorners.data() );
for ( const auto& corner : hexCorners )
{
bb.add(corner);
bb.add( corner );
}
}
}
}
activeInfos[acIdx]->setGeometryBoundingBox(bb);
activeInfos[acIdx]->setGeometryBoundingBox( bb );
}
m_mainGrid->setDisplayModelOffset(bb.min());
m_mainGrid->setDisplayModelOffset( bb.min() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::setActiveFormationNames(RigFormationNames* activeFormationNames)
void RigEclipseCaseData::setActiveFormationNames( RigFormationNames* activeFormationNames )
{
m_matrixModelResults->setActiveFormationNames(activeFormationNames);
m_matrixModelResults->setActiveFormationNames( activeFormationNames );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::setActiveFormationNamesAndUpdatePlots(RigFormationNames* activeFormationNames)
void RigEclipseCaseData::setActiveFormationNamesAndUpdatePlots( RigFormationNames* activeFormationNames )
{
setActiveFormationNames(activeFormationNames);
setActiveFormationNames( activeFormationNames );
RimProject* project = RiaApplication::instance()->project();
if (project)
if ( project )
{
if (project->mainPlotCollection())
if ( project->mainPlotCollection() )
{
project->mainPlotCollection->updatePlotsWithFormations();
}
@@ -726,9 +735,9 @@ RigFormationNames* RigEclipseCaseData::activeFormationNames()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCaseCellResultsData* RigEclipseCaseData::results(RiaDefines::PorosityModelType porosityModel)
RigCaseCellResultsData* RigEclipseCaseData::results( RiaDefines::PorosityModelType porosityModel )
{
if (porosityModel == RiaDefines::MATRIX_MODEL)
if ( porosityModel == RiaDefines::MATRIX_MODEL )
{
return m_matrixModelResults.p();
}
@@ -739,9 +748,9 @@ RigCaseCellResultsData* RigEclipseCaseData::results(RiaDefines::PorosityModelTyp
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigCaseCellResultsData* RigEclipseCaseData::results(RiaDefines::PorosityModelType porosityModel) const
const RigCaseCellResultsData* RigEclipseCaseData::results( RiaDefines::PorosityModelType porosityModel ) const
{
if (porosityModel == RiaDefines::MATRIX_MODEL)
if ( porosityModel == RiaDefines::MATRIX_MODEL )
{
return m_matrixModelResults.p();
}
@@ -752,17 +761,18 @@ const RigCaseCellResultsData* RigEclipseCaseData::results(RiaDefines::PorosityMo
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>* RigEclipseCaseData::resultValues(RiaDefines::PorosityModelType porosityModel,
RiaDefines::ResultCatType type,
const QString& resultName,
size_t timeStepIndex)
const std::vector<double>* RigEclipseCaseData::resultValues( RiaDefines::PorosityModelType porosityModel,
RiaDefines::ResultCatType type,
const QString& resultName,
size_t timeStepIndex )
{
RigCaseCellResultsData* gridCellResults = this->results(porosityModel);
RigCaseCellResultsData* gridCellResults = this->results( porosityModel );
const std::vector<double>* swatResults = nullptr;
if (gridCellResults->ensureKnownResultLoaded(RigEclipseResultAddress(type, resultName)))
if ( gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( type, resultName ) ) )
{
swatResults = &(gridCellResults->cellScalarResults(RigEclipseResultAddress(type, resultName), timeStepIndex));
swatResults = &(
gridCellResults->cellScalarResults( RigEclipseResultAddress( type, resultName ), timeStepIndex ) );
}
return swatResults;

View File

@@ -3,39 +3,37 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RifReaderInterface.h"
#include "RiaEclipseUnitTools.h"
#include "cvfAssert.h"
#include "cvfArray.h"
#include "cvfObject.h"
#include "cvfAssert.h"
#include "cvfCollection.h"
#include "cvfObject.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"
#include "cvfCollection.h"
#include <vector>
#include <map>
#include <set>
#include <vector>
class RigCaseCellResultsData;
class RigFormationNames;
@@ -53,101 +51,121 @@ class RigEquil;
struct RigWellResultPoint;
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RigEclipseCaseData : public cvf::Object
{
public:
explicit RigEclipseCaseData(RimEclipseCase* ownerCase);
explicit RigEclipseCaseData( RimEclipseCase* ownerCase );
~RigEclipseCaseData() override;
RimEclipseCase* ownerCase() const { return m_ownerCase; }
RimEclipseCase* ownerCase() const
{
return m_ownerCase;
}
RigMainGrid* mainGrid();
const RigMainGrid* mainGrid() const;
void setMainGrid(RigMainGrid* mainGrid);
RigMainGrid* mainGrid();
const RigMainGrid* mainGrid() const;
void setMainGrid( RigMainGrid* mainGrid );
void allGrids(std::vector<RigGridBase*>* grids); // To be removed
void allGrids(std::vector<const RigGridBase*>* grids) const;// To be removed
const RigGridBase* grid(size_t index) const;
RigGridBase* grid(size_t index);
size_t gridCount() const;
const RigGridBase* grid(const QString& gridName) const;
void allGrids( std::vector<RigGridBase*>* grids ); // To be removed
void allGrids( std::vector<const RigGridBase*>* grids ) const; // To be removed
const RigGridBase* grid( size_t index ) const;
RigGridBase* grid( size_t index );
size_t gridCount() const;
const RigGridBase* grid( const QString& gridName ) const;
RigCaseCellResultsData* results(RiaDefines::PorosityModelType porosityModel);
const RigCaseCellResultsData* results(RiaDefines::PorosityModelType porosityModel) const;
const std::vector<double>* resultValues(RiaDefines::PorosityModelType porosityModel,
RiaDefines::ResultCatType type,
const QString& resultName,
size_t timeStepIndex);
RigCaseCellResultsData* results( RiaDefines::PorosityModelType porosityModel );
const RigCaseCellResultsData* results( RiaDefines::PorosityModelType porosityModel ) const;
const std::vector<double>* resultValues( RiaDefines::PorosityModelType porosityModel,
RiaDefines::ResultCatType type,
const QString& resultName,
size_t timeStepIndex );
RigActiveCellInfo* activeCellInfo(RiaDefines::PorosityModelType porosityModel);
const RigActiveCellInfo* activeCellInfo(RiaDefines::PorosityModelType porosityModel) const;
void setActiveCellInfo(RiaDefines::PorosityModelType porosityModel, RigActiveCellInfo* activeCellInfo);
RigActiveCellInfo* activeCellInfo( RiaDefines::PorosityModelType porosityModel );
const RigActiveCellInfo* activeCellInfo( RiaDefines::PorosityModelType porosityModel ) const;
void setActiveCellInfo( RiaDefines::PorosityModelType porosityModel, RigActiveCellInfo* activeCellInfo );
bool hasFractureResults() const;
bool hasFractureResults() const;
void setActiveFormationNames(RigFormationNames* activeFormationNames);
void setActiveFormationNamesAndUpdatePlots(RigFormationNames* activeFormationNames);
RigFormationNames* activeFormationNames();
void setActiveFormationNames( RigFormationNames* activeFormationNames );
void setActiveFormationNamesAndUpdatePlots( RigFormationNames* activeFormationNames );
RigFormationNames* activeFormationNames();
void setSimWellData(const cvf::Collection<RigSimWellData>& data);
const cvf::Collection<RigSimWellData>& wellResults() const { return m_simWellData; }
std::set<QString> findSortedWellNames() const;
const RigSimWellData* findSimWellData(QString wellName) const;
const cvf::UByteArray* wellCellsInGrid(size_t gridIndex);
const cvf::UIntArray* gridCellToResultWellIndex(size_t gridIndex);
void setSimWellData( const cvf::Collection<RigSimWellData>& data );
const cvf::Collection<RigSimWellData>& wellResults() const
{
return m_simWellData;
}
std::set<QString> findSortedWellNames() const;
const RigSimWellData* findSimWellData( QString wellName ) const;
const RigCell& cellFromWellResultCell(const RigWellResultPoint& wellResultCell) const;
bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultPoint& sourceWellCellResult, const RigWellResultPoint& otherWellCellResult) const;
const cvf::UByteArray* wellCellsInGrid( size_t gridIndex );
const cvf::UIntArray* gridCellToResultWellIndex( size_t gridIndex );
void computeActiveCellBoundingBoxes();
const RigCell& cellFromWellResultCell( const RigWellResultPoint& wellResultCell ) const;
bool findSharedSourceFace( cvf::StructGridInterface::FaceType& sharedSourceFace,
const RigWellResultPoint& sourceWellCellResult,
const RigWellResultPoint& otherWellCellResult ) const;
RiaEclipseUnitTools::UnitSystem unitsType() const { return m_unitsType; }
void setUnitsType(RiaEclipseUnitTools::UnitSystem unitsType) { m_unitsType = unitsType; }
void computeActiveCellBoundingBoxes();
std::vector<QString> simulationWellNames() const;
bool hasSimulationWell(const QString& simWellName) const;
RiaEclipseUnitTools::UnitSystem unitsType() const
{
return m_unitsType;
}
void setUnitsType( RiaEclipseUnitTools::UnitSystem unitsType )
{
m_unitsType = unitsType;
}
std::vector<const RigWellPath*> simulationWellBranches(const QString& simWellName,
bool includeAllCellCenters,
bool useAutoDetectionOfBranches) const;
std::vector<QString> simulationWellNames() const;
bool hasSimulationWell( const QString& simWellName ) const;
void setVirtualPerforationTransmissibilities(RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities);
const RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities() const;
std::vector<const RigWellPath*> simulationWellBranches( const QString& simWellName,
bool includeAllCellCenters,
bool useAutoDetectionOfBranches ) const;
void clearWellCellsInGridCache() { m_wellCellsInGrid.clear(); }
void setVirtualPerforationTransmissibilities(
RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities );
const RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities() const;
void ensureDeckIsParsedForEquilData(const QString& dataDeckFile, const QString& includeFileAbsolutePathPrefix);
std::vector<RigEquil> equilData() const;
void setEquilData(const std::vector<RigEquil>& equilObjects);
void clearWellCellsInGridCache()
{
m_wellCellsInGrid.clear();
}
void ensureDeckIsParsedForEquilData( const QString& dataDeckFile, const QString& includeFileAbsolutePathPrefix );
std::vector<RigEquil> equilData() const;
void setEquilData( const std::vector<RigEquil>& equilObjects );
private:
void computeActiveCellIJKBBox();
void computeWellCellsPrGrid();
void computeActiveCellsGeometryBoundingBox();
void computeActiveCellIJKBBox();
void computeWellCellsPrGrid();
void computeActiveCellsGeometryBoundingBox();
private:
cvf::ref<RigMainGrid> m_mainGrid;
RimEclipseCase* m_ownerCase;
cvf::ref<RigMainGrid> m_mainGrid;
RimEclipseCase* m_ownerCase;
cvf::ref<RigActiveCellInfo> m_activeCellInfo;
cvf::ref<RigActiveCellInfo> m_fractureActiveCellInfo;
cvf::ref<RigActiveCellInfo> m_activeCellInfo;
cvf::ref<RigActiveCellInfo> m_fractureActiveCellInfo;
cvf::ref<RigCaseCellResultsData> m_matrixModelResults;
cvf::ref<RigCaseCellResultsData> m_fractureModelResults;
cvf::ref<RigCaseCellResultsData> m_matrixModelResults;
cvf::ref<RigCaseCellResultsData> m_fractureModelResults;
cvf::ref<RigVirtualPerforationTransmissibilities> m_virtualPerforationTransmissibilities;
cvf::ref<RigVirtualPerforationTransmissibilities> m_virtualPerforationTransmissibilities;
cvf::Collection<RigSimWellData> m_simWellData; //< A WellResults object for each well in the reservoir
cvf::Collection<cvf::UByteArray> m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling whether the cell is a well cell or not
cvf::Collection<cvf::UIntArray> m_gridCellToResultWellIndex; //< Array pr grid with index to well pr cell telling which well a cell is in
cvf::Collection<RigSimWellData> m_simWellData; //< A WellResults object for each well in the reservoir
cvf::Collection<cvf::UByteArray>
m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling whether the cell is a well cell or not
cvf::Collection<cvf::UIntArray>
m_gridCellToResultWellIndex; //< Array pr grid with index to well pr cell telling which well a cell is in
RiaEclipseUnitTools::UnitSystem m_unitsType;
RiaEclipseUnitTools::UnitSystem m_unitsType;
bool m_hasParsedDeckForEquilData;
std::vector<RigEquil> m_equil;
bool m_hasParsedDeckForEquilData;
std::vector<RigEquil> m_equil;
mutable std::map<std::tuple<QString, bool, bool>, cvf::Collection<RigWellPath>> m_simWellBranchCache;
};

View File

@@ -33,72 +33,73 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract(RigEclipseCaseData* caseData,
int resultTimeStep,
const RigEclipseResultAddress& xAddress,
const RigEclipseResultAddress& yAddress,
RigGridCrossPlotCurveGrouping groupingType,
const RigEclipseResultAddress& groupAddress,
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap)
RigEclipseCrossPlotResult
RigEclipseCrossPlotDataExtractor::extract( RigEclipseCaseData* caseData,
int resultTimeStep,
const RigEclipseResultAddress& xAddress,
const RigEclipseResultAddress& yAddress,
RigGridCrossPlotCurveGrouping groupingType,
const RigEclipseResultAddress& groupAddress,
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap )
{
RigEclipseCrossPlotResult result;
RigCaseCellResultsData* resultData = caseData->results(RiaDefines::MATRIX_MODEL);
if (!resultData) return result;
RigCaseCellResultsData* resultData = caseData->results( RiaDefines::MATRIX_MODEL );
if ( !resultData ) return result;
RigFormationNames* activeFormationNames = resultData->activeFormationNames();
const std::vector<std::vector<double>>* catValuesForAllSteps = nullptr;
const std::vector<std::vector<double>>* catValuesForAllSteps = nullptr;
if (xAddress.isValid() && yAddress.isValid())
if ( xAddress.isValid() && yAddress.isValid() )
{
RigActiveCellInfo* activeCellInfo = resultData->activeCellInfo();
const RigMainGrid* mainGrid = caseData->mainGrid();
if (!resultData->ensureKnownResultLoaded(xAddress))
if ( !resultData->ensureKnownResultLoaded( xAddress ) )
{
return result;
}
if (!resultData->ensureKnownResultLoaded(yAddress))
if ( !resultData->ensureKnownResultLoaded( yAddress ) )
{
return result;
}
const std::vector<std::vector<double>>& xValuesForAllSteps = resultData->cellScalarResults(xAddress);
const std::vector<std::vector<double>>& yValuesForAllSteps = resultData->cellScalarResults(yAddress);
const std::vector<std::vector<double>>& xValuesForAllSteps = resultData->cellScalarResults( xAddress );
const std::vector<std::vector<double>>& yValuesForAllSteps = resultData->cellScalarResults( yAddress );
if (groupingType == GROUP_BY_RESULT && groupAddress.isValid())
if ( groupingType == GROUP_BY_RESULT && groupAddress.isValid() )
{
if (resultData->ensureKnownResultLoaded(groupAddress))
if ( resultData->ensureKnownResultLoaded( groupAddress ) )
{
catValuesForAllSteps = &resultData->cellScalarResults(groupAddress);
catValuesForAllSteps = &resultData->cellScalarResults( groupAddress );
}
}
std::set<int> timeStepsToInclude;
if (resultTimeStep == -1)
if ( resultTimeStep == -1 )
{
size_t nStepsInData = std::max(xValuesForAllSteps.size(), yValuesForAllSteps.size());
size_t nStepsInData = std::max( xValuesForAllSteps.size(), yValuesForAllSteps.size() );
bool xValid = xValuesForAllSteps.size() == 1u || xValuesForAllSteps.size() == nStepsInData;
bool yValid = yValuesForAllSteps.size() == 1u || yValuesForAllSteps.size() == nStepsInData;
if (!(xValid && yValid)) return result;
if ( !( xValid && yValid ) ) return result;
for (size_t i = 0; i < nStepsInData; ++i)
for ( size_t i = 0; i < nStepsInData; ++i )
{
timeStepsToInclude.insert((int)i);
timeStepsToInclude.insert( (int)i );
}
}
else
{
timeStepsToInclude.insert(static_cast<size_t>(resultTimeStep));
timeStepsToInclude.insert( static_cast<size_t>( resultTimeStep ) );
}
for (int timeStep : timeStepsToInclude)
for ( int timeStep : timeStepsToInclude )
{
const cvf::UByteArray* cellVisibility = nullptr;
if (timeStepCellVisibilityMap.count(timeStep))
if ( timeStepCellVisibilityMap.count( timeStep ) )
{
cellVisibility = &timeStepCellVisibilityMap[timeStep];
}
@@ -106,53 +107,54 @@ RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract(RigEclipseCa
int xIndex = timeStep >= (int)xValuesForAllSteps.size() ? 0 : timeStep;
int yIndex = timeStep >= (int)yValuesForAllSteps.size() ? 0 : timeStep;
RigActiveCellsResultAccessor xAccessor(mainGrid, &xValuesForAllSteps[xIndex], activeCellInfo);
RigActiveCellsResultAccessor yAccessor(mainGrid, &yValuesForAllSteps[yIndex], activeCellInfo);
RigActiveCellsResultAccessor xAccessor( mainGrid, &xValuesForAllSteps[xIndex], activeCellInfo );
RigActiveCellsResultAccessor yAccessor( mainGrid, &yValuesForAllSteps[yIndex], activeCellInfo );
std::unique_ptr<RigActiveCellsResultAccessor> catAccessor;
if (catValuesForAllSteps)
if ( catValuesForAllSteps )
{
int catIndex = timeStep >= (int)catValuesForAllSteps->size() ? 0 : timeStep;
catAccessor.reset(
new RigActiveCellsResultAccessor(mainGrid, &(catValuesForAllSteps->at(catIndex)), activeCellInfo));
catAccessor.reset( new RigActiveCellsResultAccessor( mainGrid,
&( catValuesForAllSteps->at( catIndex ) ),
activeCellInfo ) );
}
for (size_t globalCellIdx = 0; globalCellIdx < activeCellInfo->reservoirCellCount(); ++globalCellIdx)
for ( size_t globalCellIdx = 0; globalCellIdx < activeCellInfo->reservoirCellCount(); ++globalCellIdx )
{
if (cellVisibility && !(*cellVisibility)[globalCellIdx]) continue;
if ( cellVisibility && !( *cellVisibility )[globalCellIdx] ) continue;
double xValue = xAccessor.cellScalarGlobIdx(globalCellIdx);
double yValue = yAccessor.cellScalarGlobIdx(globalCellIdx);
double xValue = xAccessor.cellScalarGlobIdx( globalCellIdx );
double yValue = yAccessor.cellScalarGlobIdx( globalCellIdx );
if (xValue == HUGE_VAL || yValue == HUGE_VAL) continue;
if ( xValue == HUGE_VAL || yValue == HUGE_VAL ) continue;
result.xValues.push_back(xValue);
result.yValues.push_back(yValue);
result.xValues.push_back( xValue );
result.yValues.push_back( yValue );
if (groupingType == GROUP_BY_TIME)
if ( groupingType == GROUP_BY_TIME )
{
result.groupValuesDiscrete.push_back(timeStep);
result.groupValuesDiscrete.push_back( timeStep );
}
else if (groupingType == GROUP_BY_FORMATION)
else if ( groupingType == GROUP_BY_FORMATION )
{
if (activeFormationNames)
if ( activeFormationNames )
{
int category = 0;
size_t i(cvf::UNDEFINED_SIZE_T), j(cvf::UNDEFINED_SIZE_T), k(cvf::UNDEFINED_SIZE_T);
if (mainGrid->ijkFromCellIndex(globalCellIdx, &i, &j, &k))
int category = 0;
size_t i( cvf::UNDEFINED_SIZE_T ), j( cvf::UNDEFINED_SIZE_T ), k( cvf::UNDEFINED_SIZE_T );
if ( mainGrid->ijkFromCellIndex( globalCellIdx, &i, &j, &k ) )
{
category = activeFormationNames->formationIndexFromKLayerIdx(k);
category = activeFormationNames->formationIndexFromKLayerIdx( k );
}
result.groupValuesDiscrete.push_back(category);
result.groupValuesDiscrete.push_back( category );
}
}
else if (groupingType == GROUP_BY_RESULT)
else if ( groupingType == GROUP_BY_RESULT )
{
double catValue = HUGE_VAL;
if (catAccessor)
if ( catAccessor )
{
catValue = catAccessor->cellScalarGlobIdx(globalCellIdx);
catValue = catAccessor->cellScalarGlobIdx( globalCellIdx );
}
result.groupValuesContinuous.push_back(catValue);
result.groupValuesContinuous.push_back( catValue );
}
}
}

View File

@@ -19,7 +19,6 @@
#include "RigGridCrossPlotCurveGrouping.h"
#include "cvfArray.h"
#include <map>
@@ -42,11 +41,11 @@ struct RigEclipseCrossPlotResult
class RigEclipseCrossPlotDataExtractor
{
public:
static RigEclipseCrossPlotResult extract(RigEclipseCaseData* eclipseCase,
int resultTimeStep,
const RigEclipseResultAddress& xAddress,
const RigEclipseResultAddress& yAddress,
RigGridCrossPlotCurveGrouping groupingType,
const RigEclipseResultAddress& groupAddress,
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap);
static RigEclipseCrossPlotResult extract( RigEclipseCaseData* eclipseCase,
int resultTimeStep,
const RigEclipseResultAddress& xAddress,
const RigEclipseResultAddress& yAddress,
RigGridCrossPlotCurveGrouping groupingType,
const RigEclipseResultAddress& groupAddress,
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap );
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,103 +20,99 @@
#include "RigEclipseMultiPropertyStatCalc.h"
#include "RigEclipseNativeStatCalc.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseMultiPropertyStatCalc::RigEclipseMultiPropertyStatCalc() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigEclipseMultiPropertyStatCalc::RigEclipseMultiPropertyStatCalc()
void RigEclipseMultiPropertyStatCalc::addStatisticsCalculator( RigStatisticsCalculator* statisticsCalculator )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::addStatisticsCalculator(RigStatisticsCalculator* statisticsCalculator)
{
if (statisticsCalculator)
if ( statisticsCalculator )
{
m_nativeStatisticsCalculators.push_back(statisticsCalculator);
m_nativeStatisticsCalculators.push_back( statisticsCalculator );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
void RigEclipseMultiPropertyStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max )
{
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
for ( size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++ )
{
if (m_nativeStatisticsCalculators.at(i))
if ( m_nativeStatisticsCalculators.at( i ) )
{
m_nativeStatisticsCalculators.at(i)->minMaxCellScalarValues(timeStepIndex, min, max);
m_nativeStatisticsCalculators.at( i )->minMaxCellScalarValues( timeStepIndex, min, max );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
void RigEclipseMultiPropertyStatCalc::posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg )
{
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
for ( size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++ )
{
if (m_nativeStatisticsCalculators.at(i))
if ( m_nativeStatisticsCalculators.at( i ) )
{
m_nativeStatisticsCalculators.at(i)->posNegClosestToZero(timeStepIndex, pos, neg);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount)
{
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
{
if (m_nativeStatisticsCalculators.at(i))
{
m_nativeStatisticsCalculators.at(i)->valueSumAndSampleCount(timeStepIndex, valueSum, sampleCount);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator)
{
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
{
if (m_nativeStatisticsCalculators.at(i))
{
m_nativeStatisticsCalculators.at(i)->addDataToHistogramCalculator(timeStepIndex, histogramCalculator);
m_nativeStatisticsCalculators.at( i )->posNegClosestToZero( timeStepIndex, pos, neg );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::uniqueValues(size_t timeStepIndex, std::set<int>& values)
void RigEclipseMultiPropertyStatCalc::valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount )
{
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
for ( size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++ )
{
if (m_nativeStatisticsCalculators.at(i))
if ( m_nativeStatisticsCalculators.at( i ) )
{
m_nativeStatisticsCalculators.at(i)->uniqueValues(timeStepIndex, values);
m_nativeStatisticsCalculators.at( i )->valueSumAndSampleCount( timeStepIndex, valueSum, sampleCount );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::addDataToHistogramCalculator( size_t timeStepIndex,
RigHistogramCalculator& histogramCalculator )
{
for ( size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++ )
{
if ( m_nativeStatisticsCalculators.at( i ) )
{
m_nativeStatisticsCalculators.at( i )->addDataToHistogramCalculator( timeStepIndex, histogramCalculator );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::uniqueValues( size_t timeStepIndex, std::set<int>& values )
{
for ( size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++ )
{
if ( m_nativeStatisticsCalculators.at( i ) )
{
m_nativeStatisticsCalculators.at( i )->uniqueValues( timeStepIndex, values );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigEclipseMultiPropertyStatCalc::timeStepCount()
{
if (m_nativeStatisticsCalculators.size() > 0)
if ( m_nativeStatisticsCalculators.size() > 0 )
{
return m_nativeStatisticsCalculators[0]->timeStepCount();
}
@@ -125,13 +121,13 @@ size_t RigEclipseMultiPropertyStatCalc::timeStepCount()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseMultiPropertyStatCalc::addNativeStatisticsCalculator(RigCaseCellResultsData* cellResultsData, const RigEclipseResultAddress& eclipseResultAddress)
void RigEclipseMultiPropertyStatCalc::addNativeStatisticsCalculator( RigCaseCellResultsData* cellResultsData,
const RigEclipseResultAddress& eclipseResultAddress )
{
if (eclipseResultAddress.isValid())
if ( eclipseResultAddress.isValid() )
{
this->addStatisticsCalculator(new RigEclipseNativeStatCalc(cellResultsData, eclipseResultAddress));
this->addStatisticsCalculator( new RigEclipseNativeStatCalc( cellResultsData, eclipseResultAddress ) );
}
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,9 +21,8 @@
#include "RigStatisticsCalculator.h"
#include "cvfObject.h"
#include "cvfCollection.h"
#include "cvfObject.h"
#include <vector>
@@ -32,25 +31,26 @@ class RigCaseCellResultsData;
class RigEclipseResultAddress;
//==================================================================================================
///
///
//==================================================================================================
class RigEclipseMultiPropertyStatCalc : public RigStatisticsCalculator
{
public:
RigEclipseMultiPropertyStatCalc();
void addStatisticsCalculator(RigStatisticsCalculator* statisticsCalculator);
void addNativeStatisticsCalculator(RigCaseCellResultsData* cellResultsData, const RigEclipseResultAddress& scalarResultIndices);
void addStatisticsCalculator( RigStatisticsCalculator* statisticsCalculator );
void addNativeStatisticsCalculator( RigCaseCellResultsData* cellResultsData,
const RigEclipseResultAddress& scalarResultIndices );
void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) override;
void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) override;
void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount) override;
void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) override;
void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) override;
void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator) override;
void valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) override;
void uniqueValues(size_t timeStepIndex, std::set<int>& values) override;
void addDataToHistogramCalculator( size_t timeStepIndex, RigHistogramCalculator& histogramCalculator ) override;
size_t timeStepCount() override;
void uniqueValues( size_t timeStepIndex, std::set<int>& values ) override;
size_t timeStepCount() override;
private:
std::vector<RigStatisticsCalculator*> m_nativeStatisticsCalculators;

View File

@@ -2,118 +2,123 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigEclipseNativeStatCalc.h"
#include "RigStatisticsMath.h"
#include "RigCaseCellResultsData.h"
#include "RigStatisticsMath.h"
#include "RigWeightedMeanCalc.h"
#include <cmath> // Needed for HUGE_VAL on Linux
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigEclipseNativeStatCalc::RigEclipseNativeStatCalc(RigCaseCellResultsData* cellResultsData, const RigEclipseResultAddress& eclipseResultAddress)
: m_resultsData(cellResultsData)
, m_eclipseResultAddress(eclipseResultAddress)
RigEclipseNativeStatCalc::RigEclipseNativeStatCalc( RigCaseCellResultsData* cellResultsData,
const RigEclipseResultAddress& eclipseResultAddress )
: m_resultsData( cellResultsData )
, m_eclipseResultAddress( eclipseResultAddress )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
void RigEclipseNativeStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max )
{
MinMaxAccumulator acc(min, max);
traverseCells(acc, timeStepIndex);
MinMaxAccumulator acc( min, max );
traverseCells( acc, timeStepIndex );
min = acc.min;
max = acc.max;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
void RigEclipseNativeStatCalc::posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg )
{
PosNegAccumulator acc(pos, neg);
traverseCells(acc, timeStepIndex);
PosNegAccumulator acc( pos, neg );
traverseCells( acc, timeStepIndex );
pos = acc.pos;
neg = acc.neg;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator)
void RigEclipseNativeStatCalc::addDataToHistogramCalculator( size_t timeStepIndex,
RigHistogramCalculator& histogramCalculator )
{
traverseCells(histogramCalculator, timeStepIndex);
traverseCells( histogramCalculator, timeStepIndex );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeStatCalc::uniqueValues(size_t timeStepIndex, std::set<int>& values)
void RigEclipseNativeStatCalc::uniqueValues( size_t timeStepIndex, std::set<int>& values )
{
UniqueValueAccumulator acc;
traverseCells(acc, timeStepIndex);
traverseCells( acc, timeStepIndex );
values = acc.uniqueValues;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount)
void RigEclipseNativeStatCalc::valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount )
{
SumCountAccumulator acc(valueSum, sampleCount);
traverseCells(acc, timeStepIndex);
valueSum = acc.valueSum;
SumCountAccumulator acc( valueSum, sampleCount );
traverseCells( acc, timeStepIndex );
valueSum = acc.valueSum;
sampleCount = acc.sampleCount;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigEclipseNativeStatCalc::timeStepCount()
{
return m_resultsData->timeStepCount(m_eclipseResultAddress);
return m_resultsData->timeStepCount( m_eclipseResultAddress );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double& mean)
void RigEclipseNativeStatCalc::mobileVolumeWeightedMean( size_t timeStepIndex, double& mean )
{
RigEclipseResultAddress mobPorvAddress(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
RigEclipseResultAddress mobPorvAddress( RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName() );
// For statistics result cases, the pore volume is not available, as RigCaseCellResultsData::createPlaceholderResultEntries
// has not been executed
if (!m_resultsData->ensureKnownResultLoaded(mobPorvAddress))
// For statistics result cases, the pore volume is not available, as
// RigCaseCellResultsData::createPlaceholderResultEntries has not been executed
if ( !m_resultsData->ensureKnownResultLoaded( mobPorvAddress ) )
{
return;
}
const std::vector<double>& weights = m_resultsData->cellScalarResults(mobPorvAddress, 0);
const std::vector<double>& values = m_resultsData->cellScalarResults(m_eclipseResultAddress, timeStepIndex);
const std::vector<double>& weights = m_resultsData->cellScalarResults( mobPorvAddress, 0 );
const std::vector<double>& values = m_resultsData->cellScalarResults( m_eclipseResultAddress, timeStepIndex );
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo();
RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, nullptr, false, actCellInfo, m_resultsData->isUsingGlobalActiveIndex(m_eclipseResultAddress), &mean);
RigWeightedMeanCalc::weightedMeanOverCells( &weights,
&values,
nullptr,
false,
actCellInfo,
m_resultsData->isUsingGlobalActiveIndex( m_eclipseResultAddress ),
&mean );
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,66 +21,67 @@
#include "RigStatisticsCalculator.h"
#include "RigCaseCellResultsData.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
class RigHistogramCalculator;
//==================================================================================================
///
///
//==================================================================================================
class RigEclipseNativeStatCalc : public RigStatisticsCalculator
{
public:
RigEclipseNativeStatCalc(RigCaseCellResultsData* cellResultsData, const RigEclipseResultAddress& eclipseResultAddress);
RigEclipseNativeStatCalc( RigCaseCellResultsData* cellResultsData,
const RigEclipseResultAddress& eclipseResultAddress );
void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) override;
void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) override;
void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount) override;
void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator) override;
void uniqueValues(size_t timeStepIndex, std::set<int>& values) override;
size_t timeStepCount() override;
void mobileVolumeWeightedMean(size_t timeStepIndex, double& mean) override;
void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) override;
void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) override;
void valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) override;
void addDataToHistogramCalculator( size_t timeStepIndex, RigHistogramCalculator& histogramCalculator ) override;
void uniqueValues( size_t timeStepIndex, std::set<int>& values ) override;
size_t timeStepCount() override;
void mobileVolumeWeightedMean( size_t timeStepIndex, double& mean ) override;
private:
RigCaseCellResultsData* m_resultsData;
RigEclipseResultAddress m_eclipseResultAddress;
template <typename StatisticsAccumulator>
void traverseCells(StatisticsAccumulator& accumulator, size_t timeStepIndex)
void traverseCells( StatisticsAccumulator& accumulator, size_t timeStepIndex )
{
if (timeStepIndex >= m_resultsData->cellScalarResults(m_eclipseResultAddress).size())
if ( timeStepIndex >= m_resultsData->cellScalarResults( m_eclipseResultAddress ).size() )
{
return;
}
const std::vector<double>& values = m_resultsData->cellScalarResults(m_eclipseResultAddress, timeStepIndex);
const std::vector<double>& values = m_resultsData->cellScalarResults( m_eclipseResultAddress, timeStepIndex );
if (values.empty())
if ( values.empty() )
{
// Can happen if values do not exist for the current time step index.
return;
}
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo();
size_t cellCount = actCellInfo->reservoirCellCount();
size_t cellCount = actCellInfo->reservoirCellCount();
bool isUsingGlobalActiveIndex = m_resultsData->isUsingGlobalActiveIndex(m_eclipseResultAddress);
for (size_t cIdx = 0; cIdx < cellCount; ++cIdx)
bool isUsingGlobalActiveIndex = m_resultsData->isUsingGlobalActiveIndex( m_eclipseResultAddress );
for ( size_t cIdx = 0; cIdx < cellCount; ++cIdx )
{
// Filter out inactive cells
if (!actCellInfo->isActive(cIdx)) continue;
if ( !actCellInfo->isActive( cIdx ) ) continue;
size_t cellResultIndex = cIdx;
if (isUsingGlobalActiveIndex)
if ( isUsingGlobalActiveIndex )
{
cellResultIndex = actCellInfo->cellResultIndex(cIdx);
cellResultIndex = actCellInfo->cellResultIndex( cIdx );
}
if (cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size())
if ( cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size() )
{
accumulator.addValue(values[cellResultIndex]);
accumulator.addValue( values[cellResultIndex] );
}
}
}

View File

@@ -2,22 +2,21 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigEclipseNativeVisibleCellsStatCalc.h"
#include "RigActiveCellInfo.h"
@@ -28,99 +27,105 @@
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigEclipseNativeVisibleCellsStatCalc::RigEclipseNativeVisibleCellsStatCalc(RigCaseCellResultsData* cellResultsData,
const RigEclipseResultAddress& scalarResultIndex,
const cvf::UByteArray* cellVisibilities)
: m_caseData(cellResultsData),
m_resultAddress(scalarResultIndex),
m_cellVisibilities(cellVisibilities)
RigEclipseNativeVisibleCellsStatCalc::RigEclipseNativeVisibleCellsStatCalc( RigCaseCellResultsData* cellResultsData,
const RigEclipseResultAddress& scalarResultIndex,
const cvf::UByteArray* cellVisibilities )
: m_caseData( cellResultsData )
, m_resultAddress( scalarResultIndex )
, m_cellVisibilities( cellVisibilities )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeVisibleCellsStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
void RigEclipseNativeVisibleCellsStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max )
{
MinMaxAccumulator acc(min, max);
traverseCells(acc, timeStepIndex);
MinMaxAccumulator acc( min, max );
traverseCells( acc, timeStepIndex );
min = acc.min;
max = acc.max;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeVisibleCellsStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
void RigEclipseNativeVisibleCellsStatCalc::posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg )
{
PosNegAccumulator acc(pos, neg);
traverseCells(acc, timeStepIndex);
PosNegAccumulator acc( pos, neg );
traverseCells( acc, timeStepIndex );
pos = acc.pos;
neg = acc.neg;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeVisibleCellsStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount)
void RigEclipseNativeVisibleCellsStatCalc::valueSumAndSampleCount( size_t timeStepIndex,
double& valueSum,
size_t& sampleCount )
{
SumCountAccumulator acc(valueSum, sampleCount);
traverseCells(acc, timeStepIndex);
valueSum = acc.valueSum;
SumCountAccumulator acc( valueSum, sampleCount );
traverseCells( acc, timeStepIndex );
valueSum = acc.valueSum;
sampleCount = acc.sampleCount;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeVisibleCellsStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator)
void RigEclipseNativeVisibleCellsStatCalc::addDataToHistogramCalculator( size_t timeStepIndex,
RigHistogramCalculator& histogramCalculator )
{
traverseCells(histogramCalculator, timeStepIndex);
traverseCells( histogramCalculator, timeStepIndex );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeVisibleCellsStatCalc::uniqueValues(size_t timeStepIndex, std::set<int>& values)
void RigEclipseNativeVisibleCellsStatCalc::uniqueValues( size_t timeStepIndex, std::set<int>& values )
{
UniqueValueAccumulator acc;
traverseCells(acc, timeStepIndex);
traverseCells( acc, timeStepIndex );
values = acc.uniqueValues;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigEclipseNativeVisibleCellsStatCalc::timeStepCount()
{
return m_caseData->timeStepCount(m_resultAddress);
return m_caseData->timeStepCount( m_resultAddress );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseNativeVisibleCellsStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double &result)
void RigEclipseNativeVisibleCellsStatCalc::mobileVolumeWeightedMean( size_t timeStepIndex, double& result )
{
RigEclipseResultAddress mobPorvAddress(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
RigEclipseResultAddress mobPorvAddress( RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName() );
// For statistics result cases, the pore volume is not available, as RigCaseCellResultsData::createPlaceholderResultEntries
// has not been executed
if (!m_caseData->ensureKnownResultLoaded(mobPorvAddress))
// For statistics result cases, the pore volume is not available, as
// RigCaseCellResultsData::createPlaceholderResultEntries has not been executed
if ( !m_caseData->ensureKnownResultLoaded( mobPorvAddress ) )
{
return;
}
m_caseData->ensureKnownResultLoaded(mobPorvAddress);
m_caseData->ensureKnownResultLoaded( mobPorvAddress );
const std::vector<double>& weights = m_caseData->cellScalarResults(mobPorvAddress, 0);
const std::vector<double>& values = m_caseData->cellScalarResults(m_resultAddress, timeStepIndex);
const std::vector<double>& weights = m_caseData->cellScalarResults( mobPorvAddress, 0 );
const std::vector<double>& values = m_caseData->cellScalarResults( m_resultAddress, timeStepIndex );
const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo();
RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, m_cellVisibilities.p(), true, actCellInfo, m_caseData->isUsingGlobalActiveIndex(m_resultAddress), &result);
RigWeightedMeanCalc::weightedMeanOverCells( &weights,
&values,
m_cellVisibilities.p(),
true,
actCellInfo,
m_caseData->isUsingGlobalActiveIndex( m_resultAddress ),
&result );
}

View File

@@ -2,91 +2,83 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
//==================================================================================================
///
///
//==================================================================================================
#include "RigStatisticsCalculator.h"
#include "RigCaseCellResultsData.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "cvfArray.h"
class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator
{
public:
RigEclipseNativeVisibleCellsStatCalc(RigCaseCellResultsData* cellResultsData,
const RigEclipseResultAddress& scalarResultIndex,
const cvf::UByteArray* cellVisibilities);
void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) override;
void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) override;
void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount) override;
void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator) override;
void uniqueValues(size_t timeStepIndex, std::set<int>& values) override;
size_t timeStepCount() override;
void mobileVolumeWeightedMean(size_t timeStepIndex, double &result) override;
RigEclipseNativeVisibleCellsStatCalc( RigCaseCellResultsData* cellResultsData,
const RigEclipseResultAddress& scalarResultIndex,
const cvf::UByteArray* cellVisibilities );
void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) override;
void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) override;
void valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) override;
void addDataToHistogramCalculator( size_t timeStepIndex, RigHistogramCalculator& histogramCalculator ) override;
void uniqueValues( size_t timeStepIndex, std::set<int>& values ) override;
size_t timeStepCount() override;
void mobileVolumeWeightedMean( size_t timeStepIndex, double& result ) override;
private:
RigCaseCellResultsData* m_caseData;
RigEclipseResultAddress m_resultAddress;
cvf::cref<cvf::UByteArray> m_cellVisibilities;
RigCaseCellResultsData* m_caseData;
RigEclipseResultAddress m_resultAddress;
cvf::cref<cvf::UByteArray> m_cellVisibilities;
template <typename StatisticsAccumulator>
void traverseCells(StatisticsAccumulator& accumulator, size_t timeStepIndex)
void traverseCells( StatisticsAccumulator& accumulator, size_t timeStepIndex )
{
const std::vector<double>& values = m_caseData->cellScalarResults(m_resultAddress, timeStepIndex);
const std::vector<double>& values = m_caseData->cellScalarResults( m_resultAddress, timeStepIndex );
if (values.empty())
if ( values.empty() )
{
// Can happen if values do not exist for the current time step index.
return;
}
const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo();
size_t cellCount = actCellInfo->reservoirCellCount();
size_t cellCount = actCellInfo->reservoirCellCount();
CVF_TIGHT_ASSERT(cellCount == m_cellVisibilities->size());
CVF_TIGHT_ASSERT( cellCount == m_cellVisibilities->size() );
for (size_t cIdx = 0; cIdx < cellCount; ++cIdx)
for ( size_t cIdx = 0; cIdx < cellCount; ++cIdx )
{
if (!(*m_cellVisibilities)[cIdx]) continue;
if ( !( *m_cellVisibilities )[cIdx] ) continue;
size_t cellResultIndex = cIdx;
if (m_caseData->isUsingGlobalActiveIndex(m_resultAddress))
if ( m_caseData->isUsingGlobalActiveIndex( m_resultAddress ) )
{
cellResultIndex = actCellInfo->cellResultIndex(cIdx);
cellResultIndex = actCellInfo->cellResultIndex( cIdx );
}
if (cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size())
if ( cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size() )
{
accumulator.addValue(values[cellResultIndex]);
accumulator.addValue( values[cellResultIndex] );
}
}
}
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,29 +25,34 @@ class RigEclipseResultAddress
{
public:
RigEclipseResultAddress()
: m_resultCatType(RiaDefines::UNDEFINED)
, m_timeLapseBaseFrameIdx(NO_TIME_LAPSE)
, m_differenceCaseId(NO_CASE_DIFF)
{}
explicit RigEclipseResultAddress(const QString& resultName)
: m_resultCatType(RiaDefines::UNDEFINED)
, m_resultName(resultName)
, m_timeLapseBaseFrameIdx(NO_TIME_LAPSE)
, m_differenceCaseId(NO_CASE_DIFF)
{}
: m_resultCatType( RiaDefines::UNDEFINED )
, m_timeLapseBaseFrameIdx( NO_TIME_LAPSE )
, m_differenceCaseId( NO_CASE_DIFF )
{
}
explicit RigEclipseResultAddress(RiaDefines::ResultCatType type, const QString& resultName, int timeLapseBaseTimeStep = NO_TIME_LAPSE, int differenceCaseId = NO_CASE_DIFF)
: m_resultCatType(type)
, m_resultName(resultName)
, m_timeLapseBaseFrameIdx(timeLapseBaseTimeStep)
, m_differenceCaseId(differenceCaseId)
{}
explicit RigEclipseResultAddress( const QString& resultName )
: m_resultCatType( RiaDefines::UNDEFINED )
, m_resultName( resultName )
, m_timeLapseBaseFrameIdx( NO_TIME_LAPSE )
, m_differenceCaseId( NO_CASE_DIFF )
{
}
explicit RigEclipseResultAddress( RiaDefines::ResultCatType type,
const QString& resultName,
int timeLapseBaseTimeStep = NO_TIME_LAPSE,
int differenceCaseId = NO_CASE_DIFF )
: m_resultCatType( type )
, m_resultName( resultName )
, m_timeLapseBaseFrameIdx( timeLapseBaseTimeStep )
, m_differenceCaseId( differenceCaseId )
{
}
bool isValid() const
{
if (m_resultName.isEmpty() || m_resultName == RiaDefines::undefinedResultName())
if ( m_resultName.isEmpty() || m_resultName == RiaDefines::undefinedResultName() )
{
return false;
}
@@ -57,58 +62,72 @@ public:
}
}
static constexpr int allTimeLapsesValue() { return ALL_TIME_LAPSES; }
static constexpr int noTimeLapseValue() { return NO_TIME_LAPSE; }
static constexpr int noCaseDiffValue() { return NO_CASE_DIFF; }
bool isTimeLapse() const { return m_timeLapseBaseFrameIdx > NO_TIME_LAPSE;}
bool representsAllTimeLapses() const { return m_timeLapseBaseFrameIdx == ALL_TIME_LAPSES;}
bool hasDifferenceCase() const { return m_differenceCaseId > NO_CASE_DIFF; }
bool operator< (const RigEclipseResultAddress& other ) const
static constexpr int allTimeLapsesValue()
{
if (m_differenceCaseId != other.m_differenceCaseId)
{
return (m_differenceCaseId < other.m_differenceCaseId);
}
if (m_timeLapseBaseFrameIdx != other.m_timeLapseBaseFrameIdx)
{
return (m_timeLapseBaseFrameIdx < other.m_timeLapseBaseFrameIdx);
}
if (m_resultCatType != other.m_resultCatType)
{
return (m_resultCatType < other.m_resultCatType);
}
return (m_resultName < other.m_resultName);
return ALL_TIME_LAPSES;
}
static constexpr int noTimeLapseValue()
{
return NO_TIME_LAPSE;
}
static constexpr int noCaseDiffValue()
{
return NO_CASE_DIFF;
}
bool operator==(const RigEclipseResultAddress& other ) const
bool isTimeLapse() const
{
if ( m_resultCatType != other.m_resultCatType
|| m_resultName != other.m_resultName
|| m_timeLapseBaseFrameIdx != other.m_timeLapseBaseFrameIdx
|| m_differenceCaseId != other.m_differenceCaseId)
return m_timeLapseBaseFrameIdx > NO_TIME_LAPSE;
}
bool representsAllTimeLapses() const
{
return m_timeLapseBaseFrameIdx == ALL_TIME_LAPSES;
}
bool hasDifferenceCase() const
{
return m_differenceCaseId > NO_CASE_DIFF;
}
bool operator<( const RigEclipseResultAddress& other ) const
{
if ( m_differenceCaseId != other.m_differenceCaseId )
{
return ( m_differenceCaseId < other.m_differenceCaseId );
}
if ( m_timeLapseBaseFrameIdx != other.m_timeLapseBaseFrameIdx )
{
return ( m_timeLapseBaseFrameIdx < other.m_timeLapseBaseFrameIdx );
}
if ( m_resultCatType != other.m_resultCatType )
{
return ( m_resultCatType < other.m_resultCatType );
}
return ( m_resultName < other.m_resultName );
}
bool operator==( const RigEclipseResultAddress& other ) const
{
if ( m_resultCatType != other.m_resultCatType || m_resultName != other.m_resultName ||
m_timeLapseBaseFrameIdx != other.m_timeLapseBaseFrameIdx || m_differenceCaseId != other.m_differenceCaseId )
{
return false;
}
return true;
return true;
}
RiaDefines::ResultCatType m_resultCatType;
QString m_resultName;
int m_timeLapseBaseFrameIdx;
int m_differenceCaseId;
int m_timeLapseBaseFrameIdx;
int m_differenceCaseId;
private:
static const int ALL_TIME_LAPSES = -2;
static const int NO_TIME_LAPSE = -1;
static const int NO_CASE_DIFF = -1;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,46 +21,45 @@
#include "cvfAssert.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigEclipseTimeStepInfo::RigEclipseTimeStepInfo(const QDateTime& date, int reportNumber, double daysSinceSimulationStart)
: m_date(date),
m_reportNumber(reportNumber),
m_daysSinceSimulationStart(daysSinceSimulationStart)
RigEclipseTimeStepInfo::RigEclipseTimeStepInfo( const QDateTime& date, int reportNumber, double daysSinceSimulationStart )
: m_date( date )
, m_reportNumber( reportNumber )
, m_daysSinceSimulationStart( daysSinceSimulationStart )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<RigEclipseTimeStepInfo> RigEclipseTimeStepInfo::createTimeStepInfos(std::vector<QDateTime> dates,
std::vector<int> reportNumbers,
std::vector<double> daysSinceSimulationStarts)
std::vector<RigEclipseTimeStepInfo> RigEclipseTimeStepInfo::createTimeStepInfos(
std::vector<QDateTime> dates, std::vector<int> reportNumbers, std::vector<double> daysSinceSimulationStarts )
{
CVF_ASSERT(dates.size() == reportNumbers.size());
CVF_ASSERT(dates.size() == daysSinceSimulationStarts.size());
CVF_ASSERT( dates.size() == reportNumbers.size() );
CVF_ASSERT( dates.size() == daysSinceSimulationStarts.size() );
std::vector<RigEclipseTimeStepInfo> timeStepInfos;
for (size_t i = 0; i < dates.size(); i++)
for ( size_t i = 0; i < dates.size(); i++ )
{
timeStepInfos.push_back(RigEclipseTimeStepInfo(dates[i], reportNumbers[i], daysSinceSimulationStarts[i]));
timeStepInfos.push_back( RigEclipseTimeStepInfo( dates[i], reportNumbers[i], daysSinceSimulationStarts[i] ) );
}
return timeStepInfos;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigEclipseResultInfo::RigEclipseResultInfo(const RigEclipseResultAddress& resultAddress,
bool needsToBeStored,
bool mustBeCalculated,
size_t gridScalarResultIndex)
: m_resultAddress(resultAddress)
, m_needsToBeStored(needsToBeStored)
, m_mustBeCalculated(mustBeCalculated)
, m_gridScalarResultIndex(gridScalarResultIndex)
RigEclipseResultInfo::RigEclipseResultInfo( const RigEclipseResultAddress& resultAddress,
bool needsToBeStored,
bool mustBeCalculated,
size_t gridScalarResultIndex )
: m_resultAddress( resultAddress )
, m_needsToBeStored( needsToBeStored )
, m_mustBeCalculated( mustBeCalculated )
, m_gridScalarResultIndex( gridScalarResultIndex )
{
}
@@ -75,7 +74,7 @@ RiaDefines::ResultCatType RigEclipseResultInfo::resultType() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseResultInfo::setResultType(RiaDefines::ResultCatType newType)
void RigEclipseResultInfo::setResultType( RiaDefines::ResultCatType newType )
{
m_resultAddress.m_resultCatType = newType;
}
@@ -91,7 +90,7 @@ const QString& RigEclipseResultInfo::resultName() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseResultInfo::setResultName(const QString& name)
void RigEclipseResultInfo::setResultName( const QString& name )
{
m_resultAddress.m_resultName = name;
}
@@ -115,7 +114,7 @@ bool RigEclipseResultInfo::mustBeCalculated() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseResultInfo::setMustBeCalculated(bool mustCalculate)
void RigEclipseResultInfo::setMustBeCalculated( bool mustCalculate )
{
m_mustBeCalculated = mustCalculate;
}
@@ -139,53 +138,51 @@ const std::vector<RigEclipseTimeStepInfo>& RigEclipseResultInfo::timeStepInfos()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseResultInfo::setTimeStepInfos(const std::vector<RigEclipseTimeStepInfo>& timeSteps)
void RigEclipseResultInfo::setTimeStepInfos( const std::vector<RigEclipseTimeStepInfo>& timeSteps )
{
m_timeStepInfos = timeSteps;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RigEclipseResultInfo::dates() const
{
std::vector<QDateTime> values;
for (auto v : m_timeStepInfos)
for ( auto v : m_timeStepInfos )
{
values.push_back(v.m_date);
values.push_back( v.m_date );
}
return values;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigEclipseResultInfo::daysSinceSimulationStarts() const
{
std::vector<double> values;
for (auto v : m_timeStepInfos)
for ( auto v : m_timeStepInfos )
{
values.push_back(v.m_daysSinceSimulationStart);
values.push_back( v.m_daysSinceSimulationStart );
}
return values;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<int> RigEclipseResultInfo::reportNumbers() const
{
std::vector<int> values;
for (auto v : m_timeStepInfos)
for ( auto v : m_timeStepInfos )
{
values.push_back(v.m_reportNumber);
values.push_back( v.m_reportNumber );
}
return values;
@@ -194,7 +191,7 @@ std::vector<int> RigEclipseResultInfo::reportNumbers() const
//--------------------------------------------------------------------------------------------------
/// Ordering operator for set storage. Just the type and name are used to find unique addresses.
//--------------------------------------------------------------------------------------------------
bool RigEclipseResultInfo::operator<(const RigEclipseResultInfo& rhs) const
bool RigEclipseResultInfo::operator<( const RigEclipseResultInfo& rhs ) const
{
return m_resultAddress < rhs.m_resultAddress;
return m_resultAddress < rhs.m_resultAddress;
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -28,62 +28,64 @@
#include <vector>
//==================================================================================================
///
///
//==================================================================================================
class RigEclipseTimeStepInfo
{
public:
RigEclipseTimeStepInfo(const QDateTime& date, int reportNumber, double daysSinceSimulationStart);
RigEclipseTimeStepInfo( const QDateTime& date, int reportNumber, double daysSinceSimulationStart );
static std::vector<RigEclipseTimeStepInfo> createTimeStepInfos( std::vector<QDateTime> dates,
std::vector<int> reportNumbers,
std::vector<double> daysSinceSimulationStarts );
static std::vector<RigEclipseTimeStepInfo> createTimeStepInfos(std::vector<QDateTime> dates,
std::vector<int> reportNumbers,
std::vector<double> daysSinceSimulationStarts);
public:
QDateTime m_date;
int m_reportNumber;
double m_daysSinceSimulationStart;
QDateTime m_date;
int m_reportNumber;
double m_daysSinceSimulationStart;
};
//==================================================================================================
///
///
//==================================================================================================
class RigEclipseResultInfo
{
public:
RigEclipseResultInfo(const RigEclipseResultAddress& resultAddress,
bool needsToBeStored = false,
bool mustBeCalculated = false,
size_t gridScalarResultIndex = 0u);
RigEclipseResultInfo( const RigEclipseResultAddress& resultAddress,
bool needsToBeStored = false,
bool mustBeCalculated = false,
size_t gridScalarResultIndex = 0u );
RiaDefines::ResultCatType resultType() const;
const QString& resultName() const;
bool needsToBeStored() const;
RiaDefines::ResultCatType resultType() const;
const QString& resultName() const;
bool needsToBeStored() const;
std::vector<QDateTime> dates() const;
std::vector<double> daysSinceSimulationStarts() const;
std::vector<int> reportNumbers() const;
bool operator<(const RigEclipseResultInfo& rhs) const;
std::vector<QDateTime> dates() const;
std::vector<double> daysSinceSimulationStarts() const;
std::vector<int> reportNumbers() const;
const RigEclipseResultAddress& eclipseResultAddress() const { return m_resultAddress;}
bool operator<( const RigEclipseResultInfo& rhs ) const;
const RigEclipseResultAddress& eclipseResultAddress() const
{
return m_resultAddress;
}
private:
friend class RigCaseCellResultsData;
void setResultType(RiaDefines::ResultCatType newType);
void setResultName(const QString& name);
bool mustBeCalculated() const;
void setMustBeCalculated(bool mustCalculate);
size_t gridScalarResultIndex() const;
void setResultType( RiaDefines::ResultCatType newType );
void setResultName( const QString& name );
bool mustBeCalculated() const;
void setMustBeCalculated( bool mustCalculate );
size_t gridScalarResultIndex() const;
const std::vector<RigEclipseTimeStepInfo>& timeStepInfos() const;
void setTimeStepInfos(const std::vector<RigEclipseTimeStepInfo>& timeSteps);
void setTimeStepInfos( const std::vector<RigEclipseTimeStepInfo>& timeSteps );
RigEclipseResultAddress m_resultAddress;
size_t m_gridScalarResultIndex;
RigEclipseResultAddress m_resultAddress;
size_t m_gridScalarResultIndex;
std::vector<RigEclipseTimeStepInfo> m_timeStepInfos;
bool m_needsToBeStored;
bool m_mustBeCalculated;
bool m_needsToBeStored;
bool m_mustBeCalculated;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -34,171 +34,180 @@
#include <map>
//==================================================================================================
///
///
//==================================================================================================
RigEclipseWellLogExtractor::RigEclipseWellLogExtractor(const RigEclipseCaseData* aCase,
const RigWellPath* wellpath,
const std::string& wellCaseErrorMsgName)
: RigWellLogExtractor(wellpath, wellCaseErrorMsgName)
, m_caseData(aCase)
RigEclipseWellLogExtractor::RigEclipseWellLogExtractor( const RigEclipseCaseData* aCase,
const RigWellPath* wellpath,
const std::string& wellCaseErrorMsgName )
: RigWellLogExtractor( wellpath, wellCaseErrorMsgName )
, m_caseData( aCase )
{
calculateIntersection();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseWellLogExtractor::calculateIntersection()
{
std::map<RigMDCellIdxEnterLeaveKey, HexIntersectionInfo > uniqueIntersections;
std::map<RigMDCellIdxEnterLeaveKey, HexIntersectionInfo> uniqueIntersections;
bool isCellFaceNormalsOut = m_caseData->mainGrid()->isFaceNormalsOutwards();
if (m_wellPath->m_wellPathPoints.empty()) return;
if ( m_wellPath->m_wellPathPoints.empty() ) return;
for (size_t wpp = 0; wpp < m_wellPath->m_wellPathPoints.size() - 1; ++wpp)
for ( size_t wpp = 0; wpp < m_wellPath->m_wellPathPoints.size() - 1; ++wpp )
{
std::vector<HexIntersectionInfo> intersections;
cvf::Vec3d p1 = m_wellPath->m_wellPathPoints[wpp];
cvf::Vec3d p2 = m_wellPath->m_wellPathPoints[wpp+1];
cvf::Vec3d p1 = m_wellPath->m_wellPathPoints[wpp];
cvf::Vec3d p2 = m_wellPath->m_wellPathPoints[wpp + 1];
cvf::BoundingBox bb;
bb.add(p1);
bb.add(p2);
bb.add( p1 );
bb.add( p2 );
std::vector<size_t> closeCellIndices = findCloseCellIndices(bb);
std::vector<size_t> closeCellIndices = findCloseCellIndices( bb );
cvf::Vec3d hexCorners[8];
for (const auto& globalCellIndex : closeCellIndices)
for ( const auto& globalCellIndex : closeCellIndices )
{
const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[globalCellIndex];
if (cell.isInvalid() || cell.subGrid() != nullptr) continue;
if ( cell.isInvalid() || cell.subGrid() != nullptr ) continue;
m_caseData->mainGrid()->cellCornerVertices(globalCellIndex, hexCorners);
m_caseData->mainGrid()->cellCornerVertices( globalCellIndex, hexCorners );
RigHexIntersectionTools::lineHexCellIntersection(p1, p2, hexCorners, globalCellIndex, &intersections);
RigHexIntersectionTools::lineHexCellIntersection( p1, p2, hexCorners, globalCellIndex, &intersections );
}
if (!isCellFaceNormalsOut)
if ( !isCellFaceNormalsOut )
{
for (auto& intersection : intersections)
for ( auto& intersection : intersections )
{
intersection.m_isIntersectionEntering = !intersection.m_isIntersectionEntering;
}
}
// Now, with all the intersections of this piece of line, we need to
// Now, with all the intersections of this piece of line, we need to
// sort them in order, and set the measured depth and corresponding cell index
// Inserting the intersections in this map will remove identical intersections
// and sort them according to MD, CellIdx, Leave/enter
double md1 = m_wellPath->m_measuredDepths[wpp];
double md2 = m_wellPath->m_measuredDepths[wpp+1];
insertIntersectionsInMap(intersections,
p1, md1, p2, md2,
&uniqueIntersections);
double md2 = m_wellPath->m_measuredDepths[wpp + 1];
insertIntersectionsInMap( intersections, p1, md1, p2, md2, &uniqueIntersections );
}
if (uniqueIntersections.empty() && m_wellPath->m_wellPathPoints.size() > 1)
if ( uniqueIntersections.empty() && m_wellPath->m_wellPathPoints.size() > 1 )
{
// When entering this function, all well path points are either completely outside the grid
// or all well path points are inside one cell
cvf::Vec3d firstPoint = m_wellPath->m_wellPathPoints.front();
cvf::Vec3d lastPoint = m_wellPath->m_wellPathPoints.back();
cvf::Vec3d lastPoint = m_wellPath->m_wellPathPoints.back();
{
cvf::BoundingBox bb;
bb.add(firstPoint);
bb.add( firstPoint );
std::vector<size_t> closeCellIndices = findCloseCellIndices(bb);
std::vector<size_t> closeCellIndices = findCloseCellIndices( bb );
cvf::Vec3d hexCorners[8];
for (const auto& globalCellIndex : closeCellIndices)
for ( const auto& globalCellIndex : closeCellIndices )
{
const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[globalCellIndex];
if (cell.isInvalid()) continue;
if ( cell.isInvalid() ) continue;
m_caseData->mainGrid()->cellCornerVertices(globalCellIndex, hexCorners);
m_caseData->mainGrid()->cellCornerVertices( globalCellIndex, hexCorners );
if (RigHexIntersectionTools::isPointInCell(firstPoint, hexCorners))
if ( RigHexIntersectionTools::isPointInCell( firstPoint, hexCorners ) )
{
if (RigHexIntersectionTools::isPointInCell(lastPoint, hexCorners))
if ( RigHexIntersectionTools::isPointInCell( lastPoint, hexCorners ) )
{
{
// Mark the first well path point as entering the cell
bool isEntering = true;
HexIntersectionInfo info(firstPoint, isEntering, cvf::StructGridInterface::NO_FACE, globalCellIndex);
RigMDCellIdxEnterLeaveKey enterLeaveKey(m_wellPath->m_measuredDepths.front(), globalCellIndex, isEntering);
bool isEntering = true;
HexIntersectionInfo info( firstPoint,
isEntering,
cvf::StructGridInterface::NO_FACE,
globalCellIndex );
RigMDCellIdxEnterLeaveKey enterLeaveKey( m_wellPath->m_measuredDepths.front(),
globalCellIndex,
isEntering );
uniqueIntersections.insert(std::make_pair(enterLeaveKey, info));
uniqueIntersections.insert( std::make_pair( enterLeaveKey, info ) );
}
{
// Mark the last well path point as leaving cell
bool isEntering = false;
HexIntersectionInfo info(lastPoint, isEntering, cvf::StructGridInterface::NO_FACE, globalCellIndex);
RigMDCellIdxEnterLeaveKey enterLeaveKey(m_wellPath->m_measuredDepths.back(), globalCellIndex, isEntering);
bool isEntering = false;
HexIntersectionInfo info( lastPoint,
isEntering,
cvf::StructGridInterface::NO_FACE,
globalCellIndex );
RigMDCellIdxEnterLeaveKey enterLeaveKey( m_wellPath->m_measuredDepths.back(),
globalCellIndex,
isEntering );
uniqueIntersections.insert(std::make_pair(enterLeaveKey, info));
uniqueIntersections.insert( std::make_pair( enterLeaveKey, info ) );
}
}
else
{
QString txt = "Detected two points assumed to be in the same cell, but they are in two different cells";
RiaLogging::debug(txt);
QString txt =
"Detected two points assumed to be in the same cell, but they are in two different cells";
RiaLogging::debug( txt );
}
}
}
}
}
this->populateReturnArrays(uniqueIntersections);
this->populateReturnArrays( uniqueIntersections );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigEclipseWellLogExtractor::curveData(const RigResultAccessor* resultAccessor, std::vector<double>* values)
void RigEclipseWellLogExtractor::curveData( const RigResultAccessor* resultAccessor, std::vector<double>* values )
{
CVF_TIGHT_ASSERT(values);
values->resize(m_intersections.size());
CVF_TIGHT_ASSERT( values );
values->resize( m_intersections.size() );
for (size_t cpIdx = 0; cpIdx < m_intersections.size(); ++cpIdx)
for ( size_t cpIdx = 0; cpIdx < m_intersections.size(); ++cpIdx )
{
size_t cellIdx = m_intersectedCellsGlobIdx[cpIdx];
size_t cellIdx = m_intersectedCellsGlobIdx[cpIdx];
cvf::StructGridInterface::FaceType cellFace = m_intersectedCellFaces[cpIdx];
(*values)[cpIdx] = resultAccessor->cellFaceScalarGlobIdx(cellIdx, cellFace);
( *values )[cpIdx] = resultAccessor->cellFaceScalarGlobIdx( cellIdx, cellFace );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<size_t> RigEclipseWellLogExtractor::findCloseCellIndices(const cvf::BoundingBox& bb)
std::vector<size_t> RigEclipseWellLogExtractor::findCloseCellIndices( const cvf::BoundingBox& bb )
{
std::vector<size_t> closeCells;
m_caseData->mainGrid()->findIntersectingCells(bb, &closeCells);
m_caseData->mainGrid()->findIntersectingCells( bb, &closeCells );
return closeCells;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigEclipseWellLogExtractor::calculateLengthInCell(size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint) const
cvf::Vec3d RigEclipseWellLogExtractor::calculateLengthInCell( size_t cellIndex,
const cvf::Vec3d& startPoint,
const cvf::Vec3d& endPoint ) const
{
std::array<cvf::Vec3d, 8> hexCorners;
m_caseData->mainGrid()->cellCornerVertices(cellIndex, hexCorners.data());
m_caseData->mainGrid()->cellCornerVertices( cellIndex, hexCorners.data() );
return RigWellPathIntersectionTools::calculateLengthInCell(hexCorners, startPoint, endPoint);
return RigWellPathIntersectionTools::calculateLengthInCell( hexCorners, startPoint, endPoint );
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,28 +25,33 @@ class RigEclipseCaseData;
class RigWellPath;
class RigResultAccessor;
namespace cvf {
class BoundingBox;
namespace cvf
{
class BoundingBox;
}
//==================================================================================================
///
///
//==================================================================================================
class RigEclipseWellLogExtractor : public RigWellLogExtractor
{
public:
RigEclipseWellLogExtractor(const RigEclipseCaseData* aCase, const RigWellPath* wellpath, const std::string& wellCaseErrorMsgName);
void curveData(const RigResultAccessor* resultAccessor, std::vector<double>* values );
const RigEclipseCaseData* caseData() { return m_caseData.p();}
RigEclipseWellLogExtractor( const RigEclipseCaseData* aCase,
const RigWellPath* wellpath,
const std::string& wellCaseErrorMsgName );
void curveData( const RigResultAccessor* resultAccessor, std::vector<double>* values );
const RigEclipseCaseData* caseData()
{
return m_caseData.p();
}
private:
void calculateIntersection();
std::vector<size_t> findCloseCellIndices(const cvf::BoundingBox& bb);
cvf::Vec3d calculateLengthInCell(size_t cellIndex,
const cvf::Vec3d& startPoint,
const cvf::Vec3d& endPoint) const override;
void calculateIntersection();
std::vector<size_t> findCloseCellIndices( const cvf::BoundingBox& bb );
cvf::Vec3d calculateLengthInCell( size_t cellIndex,
const cvf::Vec3d& startPoint,
const cvf::Vec3d& endPoint ) const override;
cvf::cref<RigEclipseCaseData> m_caseData;
cvf::cref<RigEclipseCaseData> m_caseData;
};

View File

@@ -23,24 +23,24 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEquil::RigEquil(double datumDepth,
double datumDepthPressure,
double waterOilContactDepth,
double waterOilContactCapillaryPressure,
double gasOilContactDepth,
double gasOilContactCapillaryPressure,
bool liveOilInitConstantRs,
bool wetGasInitConstantRv,
int initializationTargetAccuracy)
: datum_depth(datumDepth)
, datum_depth_ps(datumDepthPressure)
, water_oil_contact_depth(waterOilContactDepth)
, water_oil_contact_capillary_pressure(waterOilContactCapillaryPressure)
, gas_oil_contact_depth(gasOilContactDepth)
, gas_oil_contact_capillary_pressure(gasOilContactCapillaryPressure)
, live_oil_init_proc(liveOilInitConstantRs)
, wet_gas_init_proc(wetGasInitConstantRv)
, init_target_accuracy(initializationTargetAccuracy)
RigEquil::RigEquil( double datumDepth,
double datumDepthPressure,
double waterOilContactDepth,
double waterOilContactCapillaryPressure,
double gasOilContactDepth,
double gasOilContactCapillaryPressure,
bool liveOilInitConstantRs,
bool wetGasInitConstantRv,
int initializationTargetAccuracy )
: datum_depth( datumDepth )
, datum_depth_ps( datumDepthPressure )
, water_oil_contact_depth( waterOilContactDepth )
, water_oil_contact_capillary_pressure( waterOilContactCapillaryPressure )
, gas_oil_contact_depth( gasOilContactDepth )
, gas_oil_contact_capillary_pressure( gasOilContactCapillaryPressure )
, live_oil_init_proc( liveOilInitConstantRs )
, wet_gas_init_proc( wetGasInitConstantRv )
, init_target_accuracy( initializationTargetAccuracy )
{
}
@@ -104,21 +104,21 @@ RigEquil RigEquil::defaultObject()
int wetGasInitConstantRv = -1;
int initializationTargetAccuracy = -5;
return RigEquil(datumDepth,
datuDepthPressure,
waterOilContactDepth,
waterOilContactCapillaryPressure,
gasOilContactDepth,
gasOilContactCapillaryPressure,
liveOilInitConstantRs,
wetGasInitConstantRv,
initializationTargetAccuracy);
return RigEquil( datumDepth,
datuDepthPressure,
waterOilContactDepth,
waterOilContactCapillaryPressure,
gasOilContactDepth,
gasOilContactCapillaryPressure,
liveOilInitConstantRs,
wetGasInitConstantRv,
initializationTargetAccuracy );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEquil RigEquil::parseString(const QString& keywordData)
RigEquil RigEquil::parseString( const QString& keywordData )
{
double datumDepth = 0.0;
double datuDepthPressure = 0.0;
@@ -130,55 +130,55 @@ RigEquil RigEquil::parseString(const QString& keywordData)
bool wetGasInitConstantRv = false;
int initializationTargetAccuracy = -5;
QString line(keywordData);
line.replace("\t", " ");
QString line( keywordData );
line.replace( "\t", " " );
QStringList items = line.split(" ");
if (items.size() > 0)
QStringList items = line.split( " " );
if ( items.size() > 0 )
{
datumDepth = items.at(0).toDouble();
datumDepth = items.at( 0 ).toDouble();
}
if (items.size() > 1)
if ( items.size() > 1 )
{
datuDepthPressure = items.at(1).toDouble();
datuDepthPressure = items.at( 1 ).toDouble();
}
if (items.size() > 2)
if ( items.size() > 2 )
{
waterOilContactDepth = items.at(2).toDouble();
waterOilContactDepth = items.at( 2 ).toDouble();
}
if (items.size() > 3)
if ( items.size() > 3 )
{
waterOilContactCapillaryPressure = items.at(3).toDouble();
waterOilContactCapillaryPressure = items.at( 3 ).toDouble();
}
if (items.size() > 4)
if ( items.size() > 4 )
{
gasOilContactDepth = items.at(4).toDouble();
gasOilContactDepth = items.at( 4 ).toDouble();
}
if (items.size() > 5)
if ( items.size() > 5 )
{
gasOilContactCapillaryPressure = items.at(5).toDouble();
gasOilContactCapillaryPressure = items.at( 5 ).toDouble();
}
if (items.size() > 6)
if ( items.size() > 6 )
{
liveOilInitConstantRs = items.at(6).toInt() > 0 ? true : false;
liveOilInitConstantRs = items.at( 6 ).toInt() > 0 ? true : false;
}
if (items.size() > 7)
if ( items.size() > 7 )
{
wetGasInitConstantRv = items.at(7).toInt() > 0 ? true : false;
wetGasInitConstantRv = items.at( 7 ).toInt() > 0 ? true : false;
}
if (items.size() > 8)
if ( items.size() > 8 )
{
initializationTargetAccuracy = items.at(8).toInt();
initializationTargetAccuracy = items.at( 8 ).toInt();
}
return RigEquil(datumDepth,
datuDepthPressure,
waterOilContactDepth,
waterOilContactCapillaryPressure,
gasOilContactDepth,
gasOilContactCapillaryPressure,
liveOilInitConstantRs,
wetGasInitConstantRv,
initializationTargetAccuracy);
return RigEquil( datumDepth,
datuDepthPressure,
waterOilContactDepth,
waterOilContactCapillaryPressure,
gasOilContactDepth,
gasOilContactCapillaryPressure,
liveOilInitConstantRs,
wetGasInitConstantRv,
initializationTargetAccuracy );
}

View File

@@ -28,15 +28,15 @@
class RigEquil
{
public:
explicit RigEquil(double datumDepth,
double datuDepthPressure,
double waterOilContactDepth,
double waterOilContactCapillaryPressure,
double gasOilContactDepth,
double gasOilContactCapillaryPressure,
bool liveOilInitConstantRs,
bool wetGasInitConstantRv,
int initializationTargetAccuracy);
explicit RigEquil( double datumDepth,
double datuDepthPressure,
double waterOilContactDepth,
double waterOilContactCapillaryPressure,
double gasOilContactDepth,
double gasOilContactCapillaryPressure,
bool liveOilInitConstantRs,
bool wetGasInitConstantRv,
int initializationTargetAccuracy );
double datumDepth() const;
double datumDepthPressure() const;
@@ -50,7 +50,7 @@ public:
int initializationTargetAccuracy() const;
static RigEquil defaultObject();
static RigEquil parseString(const QString& keywordData);
static RigEquil parseString( const QString& keywordData );
private:
double datum_depth;

View File

@@ -31,18 +31,18 @@ RigFault::RigFault() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFault::addCellRangeForFace(cvf::StructGridInterface::FaceType face, const cvf::CellRange& cellRange)
void RigFault::addCellRangeForFace( cvf::StructGridInterface::FaceType face, const cvf::CellRange& cellRange )
{
size_t faceIndex = static_cast<size_t>(face);
CVF_ASSERT(faceIndex < 6);
size_t faceIndex = static_cast<size_t>( face );
CVF_ASSERT( faceIndex < 6 );
m_cellRangesForFaces[faceIndex].push_back(cellRange);
m_cellRangesForFaces[faceIndex].push_back( cellRange );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFault::setName(const QString& name)
void RigFault::setName( const QString& name )
{
m_name = name;
}
@@ -90,17 +90,17 @@ const std::vector<size_t>& RigFault::connectionIndices() const
//--------------------------------------------------------------------------------------------------
/// Order FaultCellAndFace by i, j, face then k.
//--------------------------------------------------------------------------------------------------
bool RigFault::ordering(CellAndFace first, CellAndFace second)
bool RigFault::ordering( CellAndFace first, CellAndFace second )
{
size_t i1, i2, j1, j2, k1, k2;
cvf::StructGridInterface::FaceType f1, f2;
std::tie(i1, j1, k1, f1) = first;
std::tie(i2, j2, k2, f2) = second;
if (i1 == i2)
std::tie( i1, j1, k1, f1 ) = first;
std::tie( i2, j2, k2, f2 ) = second;
if ( i1 == i2 )
{
if (j1 == j2)
if ( j1 == j2 )
{
if (f1 == f2)
if ( f1 == f2 )
{
return k1 < k2;
}
@@ -123,40 +123,40 @@ bool RigFault::ordering(CellAndFace first, CellAndFace second)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFault::computeFaultFacesFromCellRanges(const RigMainGrid* mainGrid)
void RigFault::computeFaultFacesFromCellRanges( const RigMainGrid* mainGrid )
{
if (!mainGrid) return;
if ( !mainGrid ) return;
m_faultFaces.clear();
for (size_t faceType = 0; faceType < 6; faceType++)
for ( size_t faceType = 0; faceType < 6; faceType++ )
{
cvf::StructGridInterface::FaceType faceEnum = cvf::StructGridInterface::FaceType(faceType);
cvf::StructGridInterface::FaceType faceEnum = cvf::StructGridInterface::FaceType( faceType );
const std::vector<cvf::CellRange>& cellRanges = m_cellRangesForFaces[faceType];
for (const cvf::CellRange& cellRange : cellRanges)
for ( const cvf::CellRange& cellRange : cellRanges )
{
cvf::Vec3st min, max;
cellRange.range(min, max);
cellRange.range( min, max );
for (size_t i = min.x(); i <= max.x(); i++)
for ( size_t i = min.x(); i <= max.x(); i++ )
{
if (i >= mainGrid->cellCountI())
if ( i >= mainGrid->cellCountI() )
{
continue;
}
for (size_t j = min.y(); j <= max.y(); j++)
for ( size_t j = min.y(); j <= max.y(); j++ )
{
if (j >= mainGrid->cellCountJ())
if ( j >= mainGrid->cellCountJ() )
{
continue;
}
for (size_t k = min.z(); k <= max.z(); k++)
for ( size_t k = min.z(); k <= max.z(); k++ )
{
if (k >= mainGrid->cellCountK())
if ( k >= mainGrid->cellCountK() )
{
continue;
}
@@ -165,13 +165,13 @@ void RigFault::computeFaultFacesFromCellRanges(const RigMainGrid* mainGrid)
// size_t reservoirCellIndex = grid->reservoirCellIndex(gridLocalCellIndex);
size_t ni, nj, nk;
mainGrid->neighborIJKAtCellFace(i, j, k, faceEnum, &ni, &nj, &nk);
if (ni < mainGrid->cellCountI() && nj < mainGrid->cellCountJ() && nk < mainGrid->cellCountK())
mainGrid->neighborIJKAtCellFace( i, j, k, faceEnum, &ni, &nj, &nk );
if ( ni < mainGrid->cellCountI() && nj < mainGrid->cellCountJ() && nk < mainGrid->cellCountK() )
{
size_t gridLocalCellIndex = mainGrid->cellIndexFromIJK(i, j, k);
size_t oppositeCellIndex = mainGrid->cellIndexFromIJK(ni, nj, nk);
size_t gridLocalCellIndex = mainGrid->cellIndexFromIJK( i, j, k );
size_t oppositeCellIndex = mainGrid->cellIndexFromIJK( ni, nj, nk );
m_faultFaces.push_back(FaultFace(gridLocalCellIndex, faceEnum, oppositeCellIndex));
m_faultFaces.push_back( FaultFace( gridLocalCellIndex, faceEnum, oppositeCellIndex ) );
}
else
{
@@ -187,15 +187,16 @@ void RigFault::computeFaultFacesFromCellRanges(const RigMainGrid* mainGrid)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFault::accumulateFaultsPrCell(RigFaultsPrCellAccumulator* faultsPrCellAcc, int faultIdx)
void RigFault::accumulateFaultsPrCell( RigFaultsPrCellAccumulator* faultsPrCellAcc, int faultIdx )
{
for (const FaultFace& ff : m_faultFaces)
for ( const FaultFace& ff : m_faultFaces )
{
// Could detect overlapping faults here .... if (faultsPrCellAcc->faultIdx(ff.m_nativeReservoirCellIndex, ff.m_nativeFace)
// >= 0)
faultsPrCellAcc->setFaultIdx(ff.m_nativeReservoirCellIndex, ff.m_nativeFace, faultIdx);
faultsPrCellAcc->setFaultIdx(
ff.m_oppositeReservoirCellIndex, cvf::StructGridInterface::oppositeFace(ff.m_nativeFace), faultIdx);
faultsPrCellAcc->setFaultIdx( ff.m_nativeReservoirCellIndex, ff.m_nativeFace, faultIdx );
faultsPrCellAcc->setFaultIdx( ff.m_oppositeReservoirCellIndex,
cvf::StructGridInterface::oppositeFace( ff.m_nativeFace ),
faultIdx );
}
}

View File

@@ -2,29 +2,28 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfBoundingBox.h"
#include "cvfStructGrid.h"
#include "cvfCellRange.h"
#include "cvfObject.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"
#include <QString>
@@ -35,43 +34,45 @@
class RigMainGrid;
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RigFaultsPrCellAccumulator : public cvf::Object
{
public:
enum { NO_FAULT = -1, UNKNOWN_FAULT = -2 };
enum
{
NO_FAULT = -1,
UNKNOWN_FAULT = -2
};
public:
explicit RigFaultsPrCellAccumulator(size_t reservoirCellCount)
{
std::array<int, 6> initVals = { NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT};
m_faultIdxForCellFace.resize(reservoirCellCount, initVals);
explicit RigFaultsPrCellAccumulator( size_t reservoirCellCount )
{
std::array<int, 6> initVals = {NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT};
m_faultIdxForCellFace.resize( reservoirCellCount, initVals );
}
inline int faultIdx(size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face) const
inline int faultIdx( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const
{
// Ensure no crash after creating temporary LGRs
if (reservoirCellIndex < m_faultIdxForCellFace.size())
if ( reservoirCellIndex < m_faultIdxForCellFace.size() )
{
return m_faultIdxForCellFace[reservoirCellIndex][face];
}
return NO_FAULT;
}
inline void setFaultIdx(size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face, int faultIdx)
inline void setFaultIdx( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face, int faultIdx )
{
m_faultIdxForCellFace[reservoirCellIndex][face] = faultIdx;
}
private:
std::vector<std::array<int, 6>> m_faultIdxForCellFace;
std::vector<std::array<int, 6>> m_faultIdxForCellFace;
};
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RigFault : public cvf::Object
{
@@ -80,43 +81,46 @@ public:
struct FaultFace
{
FaultFace(size_t nativeReservoirCellIndex, cvf::StructGridInterface::FaceType nativeFace, size_t oppositeReservoirCellIndex) :
m_nativeReservoirCellIndex(nativeReservoirCellIndex),
m_nativeFace(nativeFace),
m_oppositeReservoirCellIndex(oppositeReservoirCellIndex)
{ }
FaultFace( size_t nativeReservoirCellIndex,
cvf::StructGridInterface::FaceType nativeFace,
size_t oppositeReservoirCellIndex )
: m_nativeReservoirCellIndex( nativeReservoirCellIndex )
, m_nativeFace( nativeFace )
, m_oppositeReservoirCellIndex( oppositeReservoirCellIndex )
{
}
size_t m_nativeReservoirCellIndex;
cvf::StructGridInterface::FaceType m_nativeFace;
size_t m_oppositeReservoirCellIndex;
size_t m_nativeReservoirCellIndex;
cvf::StructGridInterface::FaceType m_nativeFace;
size_t m_oppositeReservoirCellIndex;
};
public:
RigFault();
void setName(const QString& name);
void setName( const QString& name );
QString name() const;
void addCellRangeForFace(cvf::StructGridInterface::FaceType face, const cvf::CellRange& cellRange);
void computeFaultFacesFromCellRanges(const RigMainGrid* grid);
void addCellRangeForFace( cvf::StructGridInterface::FaceType face, const cvf::CellRange& cellRange );
void computeFaultFacesFromCellRanges( const RigMainGrid* grid );
void accumulateFaultsPrCell(RigFaultsPrCellAccumulator* faultsPrCellAcc, int faultIdx);
void accumulateFaultsPrCell( RigFaultsPrCellAccumulator* faultsPrCellAcc, int faultIdx );
std::vector<FaultFace>& faultFaces();
const std::vector<FaultFace>& faultFaces() const;
std::vector<FaultFace>& faultFaces();
const std::vector<FaultFace>& faultFaces() const;
std::vector<size_t>& connectionIndices();
const std::vector<size_t>& connectionIndices() const;
std::vector<size_t>& connectionIndices();
const std::vector<size_t>& connectionIndices() const;
static bool ordering(CellAndFace first, CellAndFace second);
static bool ordering( CellAndFace first, CellAndFace second );
private:
QString m_name;
std::array<std::vector<cvf::CellRange>, 6> m_cellRangesForFaces;
std::vector<FaultFace> m_faultFaces;
std::vector<size_t> m_connectionIndices;
std::vector<size_t> m_connectionIndices;
static cvf::ref<RigFaultsPrCellAccumulator> m_faultsPrCellAcc;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,135 +20,153 @@
#include "RimFishbonesMultipleSubs.h"
#include "cvfAssert.h"
#include "RimWellPath.h"
#include "RigWellPath.h"
#include "RimWellPath.h"
#include "cvfAssert.h"
#include "cvfMatrix4.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigFisbonesGeometry::RigFisbonesGeometry(RimFishbonesMultipleSubs* fishbonesSub)
: m_fishbonesSub(fishbonesSub)
RigFisbonesGeometry::RigFisbonesGeometry( RimFishbonesMultipleSubs* fishbonesSub )
: m_fishbonesSub( fishbonesSub )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<cvf::Vec3d, double>> RigFisbonesGeometry::coordsForLateral(size_t subIndex, size_t lateralIndex) const
std::vector<std::pair<cvf::Vec3d, double>> RigFisbonesGeometry::coordsForLateral( size_t subIndex,
size_t lateralIndex ) const
{
CVF_ASSERT(lateralIndex < m_fishbonesSub->lateralLengths().size());
CVF_ASSERT( lateralIndex < m_fishbonesSub->lateralLengths().size() );
bool found = false;
for (auto& sub : m_fishbonesSub->installedLateralIndices())
for ( auto& sub : m_fishbonesSub->installedLateralIndices() )
{
if (sub.subIndex == subIndex)
if ( sub.subIndex == subIndex )
{
auto it = std::find(sub.lateralIndices.begin(), sub.lateralIndices.end(), lateralIndex);
if (it != sub.lateralIndices.end())
auto it = std::find( sub.lateralIndices.begin(), sub.lateralIndices.end(), lateralIndex );
if ( it != sub.lateralIndices.end() )
{
found = true;
break;
}
}
}
CVF_ASSERT(found);
CVF_ASSERT( found );
cvf::Vec3d position;
cvf::Vec3d lateralInitialDirection;
cvf::Mat4d buildAngleRotationMatrix;
computeLateralPositionAndOrientation(subIndex, lateralIndex, &position, &lateralInitialDirection, &buildAngleRotationMatrix);
computeLateralPositionAndOrientation( subIndex,
lateralIndex,
&position,
&lateralInitialDirection,
&buildAngleRotationMatrix );
return computeCoordsAlongLateral(m_fishbonesSub->measuredDepth(subIndex), m_fishbonesSub->lateralLengths()[lateralIndex], position, lateralInitialDirection, buildAngleRotationMatrix);
return computeCoordsAlongLateral( m_fishbonesSub->measuredDepth( subIndex ),
m_fishbonesSub->lateralLengths()[lateralIndex],
position,
lateralInitialDirection,
buildAngleRotationMatrix );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFisbonesGeometry::computeLateralPositionAndOrientation(size_t subIndex, size_t lateralIndex, cvf::Vec3d* startCoord, cvf::Vec3d* startDirection, cvf::Mat4d* buildAngleMatrix) const
void RigFisbonesGeometry::computeLateralPositionAndOrientation( size_t subIndex,
size_t lateralIndex,
cvf::Vec3d* startCoord,
cvf::Vec3d* startDirection,
cvf::Mat4d* buildAngleMatrix ) const
{
RimWellPath* wellPath = nullptr;
m_fishbonesSub->firstAncestorOrThisOfTypeAsserted(wellPath);
m_fishbonesSub->firstAncestorOrThisOfTypeAsserted( wellPath );
RigWellPath* rigWellPath = wellPath->wellPathGeometry();
CVF_ASSERT(rigWellPath);
CVF_ASSERT( rigWellPath );
double measuredDepth = m_fishbonesSub->measuredDepth(subIndex);
double measuredDepth = m_fishbonesSub->measuredDepth( subIndex );
cvf::Vec3d position = rigWellPath->interpolatedPointAlongWellPath(measuredDepth);
cvf::Vec3d position = rigWellPath->interpolatedPointAlongWellPath( measuredDepth );
cvf::Mat4d buildAngleMat;
cvf::Vec3d lateralDirection;
{
cvf::Vec3d lateralInitialDirection = cvf::Vec3d::Z_AXIS;
cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED;
cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED;
rigWellPath->twoClosestPoints(position, &p1, &p2);
cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED;
cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED;
rigWellPath->twoClosestPoints( position, &p1, &p2 );
CVF_ASSERT(!p1.isUndefined() && !p2.isUndefined());
CVF_ASSERT( !p1.isUndefined() && !p2.isUndefined() );
cvf::Vec3d alongWellPath = (p2 - p1).getNormalized();
cvf::Vec3d alongWellPath = ( p2 - p1 ).getNormalized();
if (RigFisbonesGeometry::closestMainAxis(alongWellPath) == cvf::Vec3d::Z_AXIS)
if ( RigFisbonesGeometry::closestMainAxis( alongWellPath ) == cvf::Vec3d::Z_AXIS )
{
// Use Y-AXIS if well path is heading close to Z-AXIS
lateralInitialDirection = cvf::Vec3d::Y_AXIS;
}
{
double intialRotationAngle = m_fishbonesSub->rotationAngle(subIndex);
double intialRotationAngle = m_fishbonesSub->rotationAngle( subIndex );
double lateralOffsetDegrees = 360.0 / m_fishbonesSub->lateralLengths().size();
double lateralOffsetRadians = cvf::Math::toRadians(intialRotationAngle + lateralOffsetDegrees * lateralIndex);
double lateralOffsetRadians = cvf::Math::toRadians( intialRotationAngle +
lateralOffsetDegrees * lateralIndex );
cvf::Mat4d lateralOffsetMatrix = cvf::Mat4d::fromRotation(alongWellPath, lateralOffsetRadians);
cvf::Mat4d lateralOffsetMatrix = cvf::Mat4d::fromRotation( alongWellPath, lateralOffsetRadians );
lateralInitialDirection = lateralInitialDirection.getTransformedVector(lateralOffsetMatrix);
lateralInitialDirection = lateralInitialDirection.getTransformedVector( lateralOffsetMatrix );
}
cvf::Vec3d rotationAxis;
rotationAxis.cross(alongWellPath, lateralInitialDirection);
rotationAxis.cross( alongWellPath, lateralInitialDirection );
double exitAngleRadians = cvf::Math::toRadians(m_fishbonesSub->exitAngle());
cvf::Mat4d lateralRotationMatrix = cvf::Mat4d::fromRotation(rotationAxis, exitAngleRadians);
double exitAngleRadians = cvf::Math::toRadians( m_fishbonesSub->exitAngle() );
cvf::Mat4d lateralRotationMatrix = cvf::Mat4d::fromRotation( rotationAxis, exitAngleRadians );
lateralDirection = alongWellPath.getTransformedVector(lateralRotationMatrix);
lateralDirection = alongWellPath.getTransformedVector( lateralRotationMatrix );
double buildAngleRadians = cvf::Math::toRadians(m_fishbonesSub->buildAngle());
buildAngleMat = cvf::Mat4d::fromRotation(rotationAxis, buildAngleRadians);
double buildAngleRadians = cvf::Math::toRadians( m_fishbonesSub->buildAngle() );
buildAngleMat = cvf::Mat4d::fromRotation( rotationAxis, buildAngleRadians );
}
*startCoord = position;
*startDirection = lateralDirection;
*startCoord = position;
*startDirection = lateralDirection;
*buildAngleMatrix = buildAngleMat;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<cvf::Vec3d, double>> RigFisbonesGeometry::computeCoordsAlongLateral(double startMeasuredDepth, double lateralLength, const cvf::Vec3d& startCoord, const cvf::Vec3d& startDirection, const cvf::Mat4d& buildAngleMatrix)
std::vector<std::pair<cvf::Vec3d, double>>
RigFisbonesGeometry::computeCoordsAlongLateral( double startMeasuredDepth,
double lateralLength,
const cvf::Vec3d& startCoord,
const cvf::Vec3d& startDirection,
const cvf::Mat4d& buildAngleMatrix )
{
std::vector<std::pair<cvf::Vec3d, double>> coords;
cvf::Vec3d lateralDirection(startDirection);
cvf::Vec3d lateralDirection( startDirection );
// Compute coordinates along the lateral by modifying the lateral direction by the build angle for
// Compute coordinates along the lateral by modifying the lateral direction by the build angle for
// every unit vector along the lateral
cvf::Vec3d accumulatedPosition = startCoord;
double measuredDepth = startMeasuredDepth;
double measuredDepth = startMeasuredDepth;
double accumulatedLength = 0.0;
while (accumulatedLength < lateralLength)
while ( accumulatedLength < lateralLength )
{
coords.push_back(std::make_pair(accumulatedPosition, measuredDepth));
coords.push_back( std::make_pair( accumulatedPosition, measuredDepth ) );
double delta = 1.0;
if (lateralLength - accumulatedLength < 1.0)
if ( lateralLength - accumulatedLength < 1.0 )
{
delta = lateralLength - accumulatedLength;
}
@@ -156,40 +174,40 @@ std::vector<std::pair<cvf::Vec3d, double>> RigFisbonesGeometry::computeCoordsAlo
accumulatedPosition += delta * lateralDirection;
// Modify the lateral direction by the build angle for each unit vector
lateralDirection = lateralDirection.getTransformedVector(buildAngleMatrix);
lateralDirection = lateralDirection.getTransformedVector( buildAngleMatrix );
accumulatedLength += delta;
measuredDepth += delta;
}
coords.push_back(std::make_pair(accumulatedPosition, measuredDepth));
coords.push_back( std::make_pair( accumulatedPosition, measuredDepth ) );
return coords;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigFisbonesGeometry::closestMainAxis(const cvf::Vec3d& vec)
cvf::Vec3d RigFisbonesGeometry::closestMainAxis( const cvf::Vec3d& vec )
{
size_t maxComponent = 0;
double maxValue = cvf::Math::abs(vec.x());
if (cvf::Math::abs(vec.y()) > maxValue)
double maxValue = cvf::Math::abs( vec.x() );
if ( cvf::Math::abs( vec.y() ) > maxValue )
{
maxComponent = 1;
maxValue = cvf::Math::abs(vec.y());
maxValue = cvf::Math::abs( vec.y() );
}
if (cvf::Math::abs(vec.z()) > maxValue)
if ( cvf::Math::abs( vec.z() ) > maxValue )
{
maxComponent = 2;
}
if (maxComponent == 0)
if ( maxComponent == 0 )
{
return cvf::Vec3d::X_AXIS;
}
else if (maxComponent == 1)
else if ( maxComponent == 1 )
{
return cvf::Vec3d::Y_AXIS;
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,37 +20,39 @@
#include "cafPdmPointer.h"
#include "cvfVector3.h"
#include "cvfMatrix4.h"
#include "cvfVector3.h"
#include <vector>
class RimFishbonesMultipleSubs;
//==================================================================================================
///
///
///
///
//==================================================================================================
class RigFisbonesGeometry
{
public:
explicit RigFisbonesGeometry(RimFishbonesMultipleSubs* fishbonesSub);
explicit RigFisbonesGeometry( RimFishbonesMultipleSubs* fishbonesSub );
std::vector<std::pair<cvf::Vec3d, double>> coordsForLateral( size_t subIndex, size_t lateralIndex ) const;
std::vector<std::pair<cvf::Vec3d, double>> coordsForLateral(size_t subIndex, size_t lateralIndex) const;
private:
void computeLateralPositionAndOrientation(size_t subIndex, size_t lateralIndex,
cvf::Vec3d* startCoord, cvf::Vec3d* startDirection,
cvf::Mat4d* buildAngleMatrix) const;
static std::vector<std::pair<cvf::Vec3d, double>> computeCoordsAlongLateral(double startMeasuredDepth, double lateralLength,
const cvf::Vec3d& startCoord, const cvf::Vec3d& startDirection,
const cvf::Mat4d& buildAngleMatrix);
void computeLateralPositionAndOrientation( size_t subIndex,
size_t lateralIndex,
cvf::Vec3d* startCoord,
cvf::Vec3d* startDirection,
cvf::Mat4d* buildAngleMatrix ) const;
static cvf::Vec3d closestMainAxis(const cvf::Vec3d& vec);
static std::vector<std::pair<cvf::Vec3d, double>> computeCoordsAlongLateral( double startMeasuredDepth,
double lateralLength,
const cvf::Vec3d& startCoord,
const cvf::Vec3d& startDirection,
const cvf::Mat4d& buildAngleMatrix );
static cvf::Vec3d closestMainAxis( const cvf::Vec3d& vec );
private:
caf::PdmPointer<RimFishbonesMultipleSubs> m_fishbonesSub;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,8 +20,8 @@
#include "RigFlowDiagResultAddress.h"
#include <opm/flowdiagnostics/ConnectivityGraph.hpp>
#include <opm/flowdiagnostics/ConnectionValues.hpp>
#include <opm/flowdiagnostics/ConnectivityGraph.hpp>
#include <opm/flowdiagnostics/Toolbox.hpp>
#include <opm/utility/ECLFluxCalc.hpp>
@@ -34,120 +34,108 @@
#include <utility>
#include <vector>
namespace RigFlowDiagInterfaceTools {
namespace RigFlowDiagInterfaceTools
{
std::vector<Opm::ECLPhaseIndex> getPhases( RigFlowDiagResultAddress::PhaseSelection phaseSelection )
{
std::vector<Opm::ECLPhaseIndex> phases;
std::vector<Opm::ECLPhaseIndex> getPhases(RigFlowDiagResultAddress::PhaseSelection phaseSelection)
if ( phaseSelection & RigFlowDiagResultAddress::PHASE_GAS )
{
std::vector<Opm::ECLPhaseIndex> phases;
if (phaseSelection & RigFlowDiagResultAddress::PHASE_GAS)
{
phases.push_back(Opm::ECLPhaseIndex::Vapour);
}
if (phaseSelection & RigFlowDiagResultAddress::PHASE_OIL)
{
phases.push_back(Opm::ECLPhaseIndex::Liquid);
}
if (phaseSelection & RigFlowDiagResultAddress::PHASE_WAT)
{
phases.push_back(Opm::ECLPhaseIndex::Aqua);
}
return phases;
}
template <class FluxCalc>
inline Opm::FlowDiagnostics::ConnectionValues
extractFluxField(const Opm::ECLGraph& G,
FluxCalc&& getFlux,
std::vector<Opm::ECLPhaseIndex> actPh)
{
using ConnVals = Opm::FlowDiagnostics::ConnectionValues;
auto flux = ConnVals(ConnVals::NumConnections{ G.numConnections() },
ConnVals::NumPhases{ actPh.size() });
auto phas = ConnVals::PhaseID{ 0 };
for (const auto& p : actPh) {
const auto pflux = getFlux(p);
if (!pflux.empty()) {
assert(pflux.size() == flux.numConnections());
auto conn = ConnVals::ConnID{ 0 };
for (const auto& v : pflux) {
flux(conn, phas) = v;
conn.id += 1;
}
}
phas.id += 1;
}
return flux;
}
inline Opm::FlowDiagnostics::ConnectionValues
extractFluxFieldFromRestartFile(const Opm::ECLGraph& G,
const Opm::ECLRestartData& rstrt,
RigFlowDiagResultAddress::PhaseSelection phaseSelection)
{
auto getFlux = [&G, &rstrt]
(const Opm::ECLPhaseIndex p)
{
return G.flux(rstrt, p);
};
return extractFluxField(G, getFlux, getPhases(phaseSelection));
}
inline Opm::FlowDiagnostics::ConnectionValues
calculateFluxField(const Opm::ECLGraph& G,
const Opm::ECLInitFileData& init,
const Opm::ECLRestartData& rstrt,
RigFlowDiagResultAddress::PhaseSelection phaseSelection)
{
auto satfunc = Opm::ECLSaturationFunc(G, init);
Opm::ECLFluxCalc calc(G, init, 9.80665, false);
auto getFlux = [&calc, &rstrt]
(const Opm::ECLPhaseIndex p)
{
return calc.flux(rstrt, p);
};
return extractFluxField(G, getFlux, getPhases(phaseSelection));
}
template <class WellFluxes>
std::map<Opm::FlowDiagnostics::CellSetID, Opm::FlowDiagnostics::CellSetValues>
extractWellFlows(const Opm::ECLGraph& G,
const WellFluxes& well_fluxes)
{
std::map<Opm::FlowDiagnostics::CellSetID, Opm::FlowDiagnostics::CellSetValues> well_flows;
for (const auto& well : well_fluxes) {
Opm::FlowDiagnostics::CellSetValues& inflow = well_flows[Opm::FlowDiagnostics::CellSetID(well.name)];
for (const auto& completion : well.completions) {
const auto& gridName = completion.gridName;
const auto& ijk = completion.ijk;
const int cell_index = G.activeCell(ijk, gridName);
if (cell_index >= 0) {
// Since inflow is a std::map, if the key was not
// already present operator[] will insert a
// value-initialized value (as in T() for a type
// T), which is zero for built-in numerical types,
// including double.
inflow[cell_index] += completion.reservoir_inflow_rate;
}
}
}
return well_flows;
phases.push_back( Opm::ECLPhaseIndex::Vapour );
}
if ( phaseSelection & RigFlowDiagResultAddress::PHASE_OIL )
{
phases.push_back( Opm::ECLPhaseIndex::Liquid );
}
if ( phaseSelection & RigFlowDiagResultAddress::PHASE_WAT )
{
phases.push_back( Opm::ECLPhaseIndex::Aqua );
}
return phases;
}
template <class FluxCalc>
inline Opm::FlowDiagnostics::ConnectionValues
extractFluxField( const Opm::ECLGraph& G, FluxCalc&& getFlux, std::vector<Opm::ECLPhaseIndex> actPh )
{
using ConnVals = Opm::FlowDiagnostics::ConnectionValues;
auto flux = ConnVals( ConnVals::NumConnections{G.numConnections()}, ConnVals::NumPhases{actPh.size()} );
auto phas = ConnVals::PhaseID{0};
for ( const auto& p : actPh )
{
const auto pflux = getFlux( p );
if ( !pflux.empty() )
{
assert( pflux.size() == flux.numConnections() );
auto conn = ConnVals::ConnID{0};
for ( const auto& v : pflux )
{
flux( conn, phas ) = v;
conn.id += 1;
}
}
phas.id += 1;
}
return flux;
}
inline Opm::FlowDiagnostics::ConnectionValues extractFluxFieldFromRestartFile(
const Opm::ECLGraph& G, const Opm::ECLRestartData& rstrt, RigFlowDiagResultAddress::PhaseSelection phaseSelection )
{
auto getFlux = [&G, &rstrt]( const Opm::ECLPhaseIndex p ) { return G.flux( rstrt, p ); };
return extractFluxField( G, getFlux, getPhases( phaseSelection ) );
}
inline Opm::FlowDiagnostics::ConnectionValues calculateFluxField( const Opm::ECLGraph& G,
const Opm::ECLInitFileData& init,
const Opm::ECLRestartData& rstrt,
RigFlowDiagResultAddress::PhaseSelection phaseSelection )
{
auto satfunc = Opm::ECLSaturationFunc( G, init );
Opm::ECLFluxCalc calc( G, init, 9.80665, false );
auto getFlux = [&calc, &rstrt]( const Opm::ECLPhaseIndex p ) { return calc.flux( rstrt, p ); };
return extractFluxField( G, getFlux, getPhases( phaseSelection ) );
}
template <class WellFluxes>
std::map<Opm::FlowDiagnostics::CellSetID, Opm::FlowDiagnostics::CellSetValues>
extractWellFlows( const Opm::ECLGraph& G, const WellFluxes& well_fluxes )
{
std::map<Opm::FlowDiagnostics::CellSetID, Opm::FlowDiagnostics::CellSetValues> well_flows;
for ( const auto& well : well_fluxes )
{
Opm::FlowDiagnostics::CellSetValues& inflow = well_flows[Opm::FlowDiagnostics::CellSetID( well.name )];
for ( const auto& completion : well.completions )
{
const auto& gridName = completion.gridName;
const auto& ijk = completion.ijk;
const int cell_index = G.activeCell( ijk, gridName );
if ( cell_index >= 0 )
{
// Since inflow is a std::map, if the key was not
// already present operator[] will insert a
// value-initialized value (as in T() for a type
// T), which is zero for built-in numerical types,
// including double.
inflow[cell_index] += completion.reservoir_inflow_rate;
}
}
}
return well_flows;
}
} // namespace RigFlowDiagInterfaceTools

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,40 +20,41 @@
namespace caf
{
template<>
void RigFlowDiagResultAddress::PhaseSelectionEnum::setUp()
{
addItem(RigFlowDiagResultAddress::PHASE_ALL, "PHASE_ALL", "All");
addItem(RigFlowDiagResultAddress::PHASE_OIL, "PHASE_OIL", "Oil");
addItem(RigFlowDiagResultAddress::PHASE_GAS, "PHASE_GAS", "Gas");
addItem(RigFlowDiagResultAddress::PHASE_WAT, "PHASE_WAT", "Water");
template <>
void RigFlowDiagResultAddress::PhaseSelectionEnum::setUp()
{
addItem( RigFlowDiagResultAddress::PHASE_ALL, "PHASE_ALL", "All" );
addItem( RigFlowDiagResultAddress::PHASE_OIL, "PHASE_OIL", "Oil" );
addItem( RigFlowDiagResultAddress::PHASE_GAS, "PHASE_GAS", "Gas" );
addItem( RigFlowDiagResultAddress::PHASE_WAT, "PHASE_WAT", "Water" );
setDefault(RigFlowDiagResultAddress::PHASE_ALL);
}
setDefault( RigFlowDiagResultAddress::PHASE_ALL );
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigFlowDiagResultAddress::isNativeResult() const
{
return (((variableName == RIG_FLD_TOF_RESNAME) || (variableName == RIG_FLD_CELL_FRACTION_RESNAME)) && selectedTracerNames.size() <= 1);
return ( ( ( variableName == RIG_FLD_TOF_RESNAME ) || ( variableName == RIG_FLD_CELL_FRACTION_RESNAME ) ) &&
selectedTracerNames.size() <= 1 );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::string RigFlowDiagResultAddress::uiText() const
{
std::string uiVarname = variableName;
std::string uitext = uiVarname;
if (phaseSelection != PHASE_ALL)
if ( phaseSelection != PHASE_ALL )
{
uitext += " (" + RigFlowDiagResultAddress::PhaseSelectionEnum(phaseSelection).uiText().toStdString() + ")";
uitext += " (" + RigFlowDiagResultAddress::PhaseSelectionEnum( phaseSelection ).uiText().toStdString() + ")";
}
uitext += " (";
for (const std::string& tracerName : selectedTracerNames)
for ( const std::string& tracerName : selectedTracerNames )
{
uitext += " " + tracerName;
}
@@ -62,15 +63,14 @@ std::string RigFlowDiagResultAddress::uiText() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::string RigFlowDiagResultAddress::uiShortText() const
{
std::string uitext = variableName;
if (phaseSelection != PHASE_ALL)
if ( phaseSelection != PHASE_ALL )
{
uitext += " (" + RigFlowDiagResultAddress::PhaseSelectionEnum(phaseSelection).uiText().toStdString() + ")";
uitext += " (" + RigFlowDiagResultAddress::PhaseSelectionEnum( phaseSelection ).uiText().toStdString() + ")";
}
return uitext;
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -19,14 +19,14 @@
#include "cafAppEnum.h"
#include <string>
#include <set>
#include <string>
#define RIG_FLD_TOF_RESNAME "TOF"
#define RIG_FLD_CELL_FRACTION_RESNAME "Fraction"
#define RIG_FLD_MAX_FRACTION_TRACER_RESNAME "MaxFractionTracer"
#define RIG_FLD_COMMUNICATION_RESNAME "Communication"
#define RIG_NUM_FLOODED_PV "Water Flooded PV"
#define RIG_FLD_TOF_RESNAME "TOF"
#define RIG_FLD_CELL_FRACTION_RESNAME "Fraction"
#define RIG_FLD_MAX_FRACTION_TRACER_RESNAME "MaxFractionTracer"
#define RIG_FLD_COMMUNICATION_RESNAME "Communication"
#define RIG_NUM_FLOODED_PV "Water Flooded PV"
#define RIG_FLOW_TOTAL_NAME "Total"
#define RIG_FLOW_OIL_NAME "Oil"
@@ -38,7 +38,6 @@
class RigFlowDiagResultAddress
{
public:
enum PhaseSelection
{
@@ -50,17 +49,22 @@ public:
typedef caf::AppEnum<PhaseSelection> PhaseSelectionEnum;
RigFlowDiagResultAddress(const std::string& aVariableName, PhaseSelection phaseSelection, const std::set<std::string>& someSelectedTracerNames)
: variableName(aVariableName),
selectedTracerNames(someSelectedTracerNames),
phaseSelection(phaseSelection)
{}
RigFlowDiagResultAddress(const std::string& aVariableName, PhaseSelection phaseSelection, const std::string& tracerName)
: variableName(aVariableName),
phaseSelection(phaseSelection)
RigFlowDiagResultAddress( const std::string& aVariableName,
PhaseSelection phaseSelection,
const std::set<std::string>& someSelectedTracerNames )
: variableName( aVariableName )
, selectedTracerNames( someSelectedTracerNames )
, phaseSelection( phaseSelection )
{
selectedTracerNames.insert(tracerName);
}
RigFlowDiagResultAddress( const std::string& aVariableName,
PhaseSelection phaseSelection,
const std::string& tracerName )
: variableName( aVariableName )
, phaseSelection( phaseSelection )
{
selectedTracerNames.insert( tracerName );
}
bool isNativeResult() const;
@@ -72,13 +76,13 @@ public:
std::set<std::string> selectedTracerNames;
PhaseSelection phaseSelection;
bool operator< (const RigFlowDiagResultAddress& other) const
bool operator<( const RigFlowDiagResultAddress& other ) const
{
if ( selectedTracerNames != other.selectedTracerNames )
{
return selectedTracerNames < other.selectedTracerNames;
}
if (phaseSelection != other.phaseSelection)
if ( phaseSelection != other.phaseSelection )
{
return phaseSelection < other.phaseSelection;
}
@@ -86,4 +90,3 @@ public:
return variableName < other.variableName;
}
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,43 +22,38 @@
#include "RigFlowDiagResultFrames.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigFlowDiagResultFrames::RigFlowDiagResultFrames(size_t frameCount)
RigFlowDiagResultFrames::RigFlowDiagResultFrames( size_t frameCount )
{
m_dataForEachFrame.resize(frameCount);
m_dataForEachFrame.resize( frameCount );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigFlowDiagResultFrames::~RigFlowDiagResultFrames()
{
}
RigFlowDiagResultFrames::~RigFlowDiagResultFrames() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigFlowDiagResultFrames::frameCount() const
{
return m_dataForEachFrame.size();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<double>& RigFlowDiagResultFrames::frameData(size_t frameIndex)
std::vector<double>& RigFlowDiagResultFrames::frameData( size_t frameIndex )
{
return m_dataForEachFrame[frameIndex];
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RigFlowDiagResultFrames::frameData(size_t frameIndex) const
const std::vector<double>& RigFlowDiagResultFrames::frameData( size_t frameIndex ) const
{
return m_dataForEachFrame[frameIndex];
}

View File

@@ -1,41 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfObject.h"
#include <vector>
class RigFlowDiagResultFrames: public cvf::Object
class RigFlowDiagResultFrames : public cvf::Object
{
public:
explicit RigFlowDiagResultFrames(size_t frameCount);
explicit RigFlowDiagResultFrames( size_t frameCount );
~RigFlowDiagResultFrames() override;
const
std::vector<double>& frameData(size_t frameIndex) const;
std::vector<double>& frameData(size_t frameIndex);
size_t frameCount() const;
const std::vector<double>& frameData( size_t frameIndex ) const;
std::vector<double>& frameData( size_t frameIndex );
size_t frameCount() const;
private:
std::vector< std::vector<double> > m_dataForEachFrame;
std::vector<std::vector<double>> m_dataForEachFrame;
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,24 +23,22 @@
#include "RimFlowDiagSolution.h"
#include "cafPdmPointer.h"
#include "cafAppEnum.h"
#include "cafPdmPointer.h"
#include "cvfObject.h"
#include "cvfArray.h"
#include "cvfObject.h"
#include <vector>
#include <map>
#include <string>
#include <vector>
class RigFlowDiagResultFrames;
class RigStatisticsDataCache;
class RigActiveCellInfo;
class RigFlowDiagResults: public cvf::Object
class RigFlowDiagResults : public cvf::Object
{
public:
enum CellFilter
{
@@ -50,107 +48,118 @@ public:
CELLS_FLOODED,
CELLS_DRAINED,
};
typedef caf::AppEnum<CellFilter> CellFilterEnum;
public:
RigFlowDiagResults(RimFlowDiagSolution* flowSolution, size_t timeStepCount);
RigFlowDiagResults( RimFlowDiagSolution* flowSolution, size_t timeStepCount );
~RigFlowDiagResults() override;
const std::vector<double>* resultValues(const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex);
size_t timeStepCount() { return m_timeStepCount; }
const RigActiveCellInfo * activeCellInfo(const RigFlowDiagResultAddress& resVarAddr);
const std::vector<double>* resultValues( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex );
size_t timeStepCount()
{
return m_timeStepCount;
}
const RigActiveCellInfo* activeCellInfo( const RigFlowDiagResultAddress& resVarAddr );
void minMaxScalarValues (const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* localMin, double* localMax);
void minMaxScalarValues (const RigFlowDiagResultAddress& resVarAddr, double* globalMin, double* globalMax);
void posNegClosestToZero(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* localPosClosestToZero, double* localNegClosestToZero);
void posNegClosestToZero(const RigFlowDiagResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero);
void meanScalarValue(const RigFlowDiagResultAddress& resVarAddr, double* meanValue);
void meanScalarValue(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* meanValue);
void p10p90ScalarValues(const RigFlowDiagResultAddress& resVarAddr, double* p10, double* p90);
void p10p90ScalarValues(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* p10, double* p90);
void sumScalarValue(const RigFlowDiagResultAddress& resVarAddr, double* sum);
void sumScalarValue(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* sum);
const std::vector<size_t>& scalarValuesHistogram(const RigFlowDiagResultAddress& resVarAddr);
const std::vector<size_t>& scalarValuesHistogram(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex);
const std::vector<int>& uniqueCellScalarValues(const RigFlowDiagResultAddress& resVarAddr);
const std::vector<int>& uniqueCellScalarValues(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex);
void mobileVolumeWeightedMean(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* mean);
void minMaxScalarValues( const RigFlowDiagResultAddress& resVarAddr,
int timeStepIndex,
double* localMin,
double* localMax );
void minMaxScalarValues( const RigFlowDiagResultAddress& resVarAddr, double* globalMin, double* globalMax );
void posNegClosestToZero( const RigFlowDiagResultAddress& resVarAddr,
int timeStepIndex,
double* localPosClosestToZero,
double* localNegClosestToZero );
void posNegClosestToZero( const RigFlowDiagResultAddress& resVarAddr,
double* globalPosClosestToZero,
double* globalNegClosestToZero );
void meanScalarValue( const RigFlowDiagResultAddress& resVarAddr, double* meanValue );
void meanScalarValue( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* meanValue );
void p10p90ScalarValues( const RigFlowDiagResultAddress& resVarAddr, double* p10, double* p90 );
void p10p90ScalarValues( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* p10, double* p90 );
void sumScalarValue( const RigFlowDiagResultAddress& resVarAddr, double* sum );
void sumScalarValue( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* sum );
const std::vector<size_t>& scalarValuesHistogram( const RigFlowDiagResultAddress& resVarAddr );
const std::vector<size_t>& scalarValuesHistogram( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex );
const std::vector<int>& uniqueCellScalarValues( const RigFlowDiagResultAddress& resVarAddr );
const std::vector<int>& uniqueCellScalarValues( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex );
void mobileVolumeWeightedMean( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* mean );
std::pair<double, double> injectorProducerPairFluxes(const std::string& injTracername, const std::string& prodTracerName, int timeStepIndex);
double maxAbsPairFlux(int timeStepIndex);
std::pair<double, double> injectorProducerPairFluxes( const std::string& injTracername,
const std::string& prodTracerName,
int timeStepIndex );
double maxAbsPairFlux( int timeStepIndex );
std::vector<int> calculatedTimeSteps(RigFlowDiagResultAddress::PhaseSelection phaseSelection);
std::vector<int> calculatedTimeSteps( RigFlowDiagResultAddress::PhaseSelection phaseSelection );
RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame flowCharacteristicsResults(int timeStepIndex,
CellFilter cellSelection,
const std::vector<QString>& tracerNames,
double max_pv_fraction,
double minCommunication,
int maxTof);
RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame
flowCharacteristicsResults( int timeStepIndex,
CellFilter cellSelection,
const std::vector<QString>& tracerNames,
double max_pv_fraction,
double minCommunication,
int maxTof );
RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame flowCharacteristicsResults(int timeStepIndex,
const std::vector<char>& visibleActiveCells,
double max_pv_fraction);
RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame flowCharacteristicsResults(
int timeStepIndex, const std::vector<char>& visibleActiveCells, double max_pv_fraction );
RimFlowDiagSolution* flowDiagSolution();
RimFlowDiagSolution* flowDiagSolution();
private:
const std::vector<double>* findOrCalculateResult (const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex);
void calculateNativeResultsIfNotPreviouslyAttempted(size_t timeStepIndex, RigFlowDiagResultAddress::PhaseSelection phaseSelection);
const std::vector<double>* findOrCalculateResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex );
void calculateNativeResultsIfNotPreviouslyAttempted( size_t timeStepIndex,
RigFlowDiagResultAddress::PhaseSelection phaseSelection );
std::vector<double>* calculateDerivedResult(const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex);
std::vector<double>* calculateDerivedResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex );
std::vector<double>* calculateAverageTOFResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex );
std::vector<double>* calculateSumOfFractionsResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex );
std::vector<double>* calculateTracerWithMaxFractionResult( const RigFlowDiagResultAddress& resVarAddr,
size_t timeStepIndex );
std::vector<double>* calculateCommunicationResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex );
void calculateNumFloodedPV( const RigFlowDiagResultAddress& resVarAddr );
std::vector<const std::vector<double>*>
findResultsForSelectedTracers( const RigFlowDiagResultAddress& resVarAddr,
size_t timeStepIndex,
const std::string& nativeResultName,
RimFlowDiagSolution::TracerStatusType wantedTracerType );
std::vector<std::pair<std::string, const std::vector<double>*>>
findNamedResultsForSelectedTracers( const RigFlowDiagResultAddress& resVarAddr,
size_t timeStepIndex,
const std::string& nativeResultName,
RimFlowDiagSolution::TracerStatusType wantedTracerType );
void calculateSumOfFractionAndFractionMultTOF( size_t activeCellCount,
const std::vector<const std::vector<double>*>& injectorFractions,
const std::vector<const std::vector<double>*>& injectorTOFs,
std::vector<double>* injectorTotalFractions,
std::vector<double>* injectorFractMultTof );
std::vector<double>* calculateAverageTOFResult(const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex);
std::vector<double>* calculateSumOfFractionsResult(const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex);
std::vector<double>* calculateTracerWithMaxFractionResult(const RigFlowDiagResultAddress &resVarAddr, size_t timeStepIndex);
std::vector<double>* calculateCommunicationResult(const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex);
void calculateNumFloodedPV(const RigFlowDiagResultAddress& resVarAddr);
void calculateSumOfFractions( const std::vector<const std::vector<double>*>& fractions,
size_t activeCellCount,
std::vector<double>* sumOfFractions );
RigStatisticsDataCache* statistics( const RigFlowDiagResultAddress& resVarAddr );
std::vector<const std::vector<double>* > findResultsForSelectedTracers(const RigFlowDiagResultAddress& resVarAddr,
size_t timeStepIndex,
const std::string& nativeResultName,
RimFlowDiagSolution::TracerStatusType wantedTracerType);
std::vector< std::pair<std::string, const std::vector<double>*> >
findNamedResultsForSelectedTracers(const RigFlowDiagResultAddress& resVarAddr,
size_t timeStepIndex,
const std::string& nativeResultName,
RimFlowDiagSolution::TracerStatusType wantedTracerType);
RigFlowDiagResultFrames* createScalarResult( const RigFlowDiagResultAddress& resVarAddr );
RigFlowDiagResultFrames* findScalarResult( const RigFlowDiagResultAddress& resVarAddr );
std::vector<double>* findScalarResultFrame( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex );
void calculateSumOfFractionAndFractionMultTOF(size_t activeCellCount,
const std::vector<const std::vector<double> *>& injectorFractions,
const std::vector<const std::vector<double> *>& injectorTOFs,
std::vector<double> *injectorTotalFractions,
std::vector<double> *injectorFractMultTof);
// void deleteScalarResult(const RigFlowDiagResultAddress& resVarAddr);
void calculateSumOfFractions(const std::vector<const std::vector<double> *> &fractions,
size_t activeCellCount,
std::vector<double>* sumOfFractions);
RigFlowDiagSolverInterface* solverInterface();
RigStatisticsDataCache* statistics(const RigFlowDiagResultAddress& resVarAddr);
RigFlowDiagResultFrames* createScalarResult(const RigFlowDiagResultAddress& resVarAddr);
RigFlowDiagResultFrames* findScalarResult (const RigFlowDiagResultAddress& resVarAddr) ;
std::vector<double>* findScalarResultFrame (const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex);
size_t m_timeStepCount;
caf::PdmPointer<RimFlowDiagSolution> m_flowDiagSolution;
//void deleteScalarResult(const RigFlowDiagResultAddress& resVarAddr);
std::vector<std::map<RigFlowDiagResultAddress::PhaseSelection, bool>> m_hasAtemptedNativeResults;
RigFlowDiagSolverInterface* solverInterface();
std::map<RigFlowDiagResultAddress, cvf::ref<RigFlowDiagResultFrames>> m_resultSets;
std::map<RigFlowDiagResultAddress, cvf::ref<RigStatisticsDataCache>> m_resultStatistics;
size_t m_timeStepCount;
caf::PdmPointer<RimFlowDiagSolution> m_flowDiagSolution;
std::vector< std::map<RigFlowDiagResultAddress::PhaseSelection, bool > > m_hasAtemptedNativeResults;
std::map< RigFlowDiagResultAddress, cvf::ref<RigFlowDiagResultFrames> > m_resultSets;
std::map< RigFlowDiagResultAddress, cvf::ref<RigStatisticsDataCache> > m_resultStatistics;
using InjectorProducerCommunicationMap = std::map< std::pair<std::string, std::string>, std::pair<double, double> >;
std::vector< std::map<RigFlowDiagResultAddress::PhaseSelection, InjectorProducerCommunicationMap> > m_injProdPairFluxCommunicationTimesteps;
using InjectorProducerCommunicationMap = std::map<std::pair<std::string, std::string>, std::pair<double, double>>;
std::vector<std::map<RigFlowDiagResultAddress::PhaseSelection, InjectorProducerCommunicationMap>>
m_injProdPairFluxCommunicationTimesteps;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -19,45 +19,52 @@
#include "RigFlowDiagResultAddress.h"
#include "cvfObject.h"
#include "cafPdmPointer.h"
#include "cvfObject.h"
#include <map>
#include <string>
#include <vector>
#include <map>
class RimEclipseResultCase;
class RimFlowDiagSolution;
class RigFlowDiagTimeStepResult
{
public:
explicit RigFlowDiagTimeStepResult(size_t activeCellCount);
explicit RigFlowDiagTimeStepResult( size_t activeCellCount );
void setTracerTOF (const std::string& tracerName, RigFlowDiagResultAddress::PhaseSelection phaseSelection, const std::map<int, double>& cellValues);
void setTracerFraction(const std::string& tracerName, RigFlowDiagResultAddress::PhaseSelection phaseSelection, const std::map<int, double>& cellValues);
void setInjProdWellPairFlux(const std::string& injectorTracerName,
const std::string& producerTracerName,
const std::pair<double, double>& injProdFluxes) ;
void setTracerTOF( const std::string& tracerName,
RigFlowDiagResultAddress::PhaseSelection phaseSelection,
const std::map<int, double>& cellValues );
void setTracerFraction( const std::string& tracerName,
RigFlowDiagResultAddress::PhaseSelection phaseSelection,
const std::map<int, double>& cellValues );
void setInjProdWellPairFlux( const std::string& injectorTracerName,
const std::string& producerTracerName,
const std::pair<double, double>& injProdFluxes );
using Curve = std::pair< std::vector<double>, std::vector<double> >;
using Curve = std::pair<std::vector<double>, std::vector<double>>;
// Used to "steal" the data from this one using swap
std::map<RigFlowDiagResultAddress, std::vector<double> >& nativeResults() { return m_nativeResults; }
std::map<std::pair<std::string, std::string>, std::pair<double, double> > & injProdWellPairFluxes() { return m_injProdWellPairFluxes; }
std::map<RigFlowDiagResultAddress, std::vector<double>>& nativeResults()
{
return m_nativeResults;
}
std::map<std::pair<std::string, std::string>, std::pair<double, double>>& injProdWellPairFluxes()
{
return m_injProdWellPairFluxes;
}
private:
void addResult( const RigFlowDiagResultAddress& resAddr, const std::map<int, double>& cellValues );
void addResult(const RigFlowDiagResultAddress& resAddr, const std::map<int, double>& cellValues);
std::map<RigFlowDiagResultAddress, std::vector<double> > m_nativeResults;
std::map<std::pair<std::string, std::string>, std::pair<double, double> > m_injProdWellPairFluxes;
std::map<RigFlowDiagResultAddress, std::vector<double>> m_nativeResults;
std::map<std::pair<std::string, std::string>, std::pair<double, double>> m_injProdWellPairFluxes;
size_t m_activeCellCount;
};
class RigEclipseCaseData;
class RigOpmFlowDiagStaticData;
@@ -68,17 +75,29 @@ public:
{
FlowCharacteristicsResultFrame();
using Curve = std::pair< std::vector<double>, std::vector<double> >;
using Curve = std::pair<std::vector<double>, std::vector<double>>;
Curve m_storageCapFlowCapCurve;
Curve m_dimensionlessTimeSweepEfficiencyCurve;
Curve m_storageCapFlowCapCurve;
Curve m_dimensionlessTimeSweepEfficiencyCurve;
double m_lorenzCoefficient;
};
struct RelPermCurve
{
enum Ident { KRW, KRG, KROW, KROG, PCOW, PCOG };
enum EpsMode { EPS_ON, EPS_OFF };
enum Ident
{
KRW,
KRG,
KROW,
KROG,
PCOW,
PCOG
};
enum EpsMode
{
EPS_ON,
EPS_OFF
};
Ident ident;
std::string name;
@@ -89,14 +108,25 @@ public:
enum PvtCurveType
{
PVT_CT_FVF,
PVT_CT_FVF,
PVT_CT_VISCOSITY
};
struct PvtCurve
{
enum Phase { OIL, GAS };
enum Ident { Unknown, Bo, Bg, Visc_o, Visc_g };
enum Phase
{
OIL,
GAS
};
enum Ident
{
Unknown,
Bo,
Bg,
Visc_o,
Visc_g
};
Ident ident;
Phase phase;
@@ -106,40 +136,36 @@ public:
};
public:
explicit RigFlowDiagSolverInterface(RimEclipseResultCase * eclipseCase);
explicit RigFlowDiagSolverInterface( RimEclipseResultCase* eclipseCase );
~RigFlowDiagSolverInterface() override;
RigFlowDiagTimeStepResult calculate(size_t timeStepIdx,
RigFlowDiagResultAddress::PhaseSelection phaseSelection,
std::map<std::string, std::vector<int> > injectorTracers,
std::map<std::string, std::vector<int> > producerTracers);
RigFlowDiagTimeStepResult calculate( size_t timeStepIdx,
RigFlowDiagResultAddress::PhaseSelection phaseSelection,
std::map<std::string, std::vector<int>> injectorTracers,
std::map<std::string, std::vector<int>> producerTracers );
FlowCharacteristicsResultFrame calculateFlowCharacteristics(const std::vector<double>* injector_tof,
const std::vector<double>* producer_tof,
const std::vector<size_t>& selected_cell_indices,
double max_pv_fraction);
FlowCharacteristicsResultFrame calculateFlowCharacteristics( const std::vector<double>* injector_tof,
const std::vector<double>* producer_tof,
const std::vector<size_t>& selected_cell_indices,
double max_pv_fraction );
std::vector<RelPermCurve> calculateRelPermCurves(size_t activeCellIndex);
std::vector<PvtCurve> calculatePvtCurves(PvtCurveType pvtCurveType, size_t activeCellIndex);
bool calculatePvtDynamicPropertiesFvf(size_t activeCellIndex, double pressure, double rs, double rv, double* bo, double* bg);
bool calculatePvtDynamicPropertiesViscosity(size_t activeCellIndex, double pressure, double rs, double rv, double* mu_o, double* mu_g);
std::vector<RelPermCurve> calculateRelPermCurves( size_t activeCellIndex );
std::vector<PvtCurve> calculatePvtCurves( PvtCurveType pvtCurveType, size_t activeCellIndex );
bool calculatePvtDynamicPropertiesFvf(
size_t activeCellIndex, double pressure, double rs, double rv, double* bo, double* bg );
bool calculatePvtDynamicPropertiesViscosity(
size_t activeCellIndex, double pressure, double rs, double rv, double* mu_o, double* mu_g );
private:
std::string getInitFileName() const;
bool ensureStaticDataObjectInstanceCreated();
void assignPhaseCorrecedPORV(RigFlowDiagResultAddress::PhaseSelection phaseSelection,
size_t timeStepIdx);
void reportRelPermCurveError(const QString &message);
void reportPvtCurveError(const QString &message);
std::string getInitFileName() const;
bool ensureStaticDataObjectInstanceCreated();
void assignPhaseCorrecedPORV( RigFlowDiagResultAddress::PhaseSelection phaseSelection, size_t timeStepIdx );
void reportRelPermCurveError( const QString& message );
void reportPvtCurveError( const QString& message );
RimEclipseResultCase * m_eclipseCase;
RimEclipseResultCase* m_eclipseCase;
cvf::ref<RigOpmFlowDiagStaticData> m_opmFlowDiagStaticData;
int m_pvtCurveErrorCount;
int m_relpermCurveErrorCount;
int m_pvtCurveErrorCount;
int m_relpermCurveErrorCount;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -29,80 +29,80 @@
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigFlowDiagStatCalc::RigFlowDiagStatCalc(RigFlowDiagResults* flowDiagResults, const RigFlowDiagResultAddress& resVarAddr)
: m_resVarAddr(resVarAddr)
RigFlowDiagStatCalc::RigFlowDiagStatCalc( RigFlowDiagResults* flowDiagResults, const RigFlowDiagResultAddress& resVarAddr )
: m_resVarAddr( resVarAddr )
{
m_resultsData = flowDiagResults;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
void RigFlowDiagStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max )
{
MinMaxAccumulator minMaxCalc(min, max);
const std::vector<double>* vals = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
MinMaxAccumulator minMaxCalc( min, max );
const std::vector<double>* vals = m_resultsData->resultValues( m_resVarAddr, timeStepIndex );
if (vals) minMaxCalc.addData(*vals);
if ( vals ) minMaxCalc.addData( *vals );
min = minMaxCalc.min;
max = minMaxCalc.max;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
void RigFlowDiagStatCalc::posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg )
{
PosNegAccumulator posNegCalc(pos, neg);
const std::vector<double>* vals = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
PosNegAccumulator posNegCalc( pos, neg );
const std::vector<double>* vals = m_resultsData->resultValues( m_resVarAddr, timeStepIndex );
if ( vals ) posNegCalc.addData(*vals);
if ( vals ) posNegCalc.addData( *vals );
pos = posNegCalc.pos;
neg = posNegCalc.neg;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount)
void RigFlowDiagStatCalc::valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount )
{
SumCountAccumulator sumCountCalc(valueSum, sampleCount);
const std::vector<double>* vals = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
SumCountAccumulator sumCountCalc( valueSum, sampleCount );
const std::vector<double>* vals = m_resultsData->resultValues( m_resVarAddr, timeStepIndex );
if ( vals ) sumCountCalc.addData(*vals);
if ( vals ) sumCountCalc.addData( *vals );
valueSum = sumCountCalc.valueSum;
sampleCount = sumCountCalc.sampleCount;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator)
void RigFlowDiagStatCalc::addDataToHistogramCalculator( size_t timeStepIndex, RigHistogramCalculator& histogramCalculator )
{
const std::vector<double>* vals = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
const std::vector<double>* vals = m_resultsData->resultValues( m_resVarAddr, timeStepIndex );
if ( vals ) histogramCalculator.addData(*vals);
if ( vals ) histogramCalculator.addData( *vals );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagStatCalc::uniqueValues(size_t timeStepIndex, std::set<int>& uniqueValues)
void RigFlowDiagStatCalc::uniqueValues( size_t timeStepIndex, std::set<int>& uniqueValues )
{
const std::vector<double>* vals = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
const std::vector<double>* vals = m_resultsData->resultValues( m_resVarAddr, timeStepIndex );
if ( vals ) for ( double val : (*vals) ) uniqueValues.insert(static_cast<int>(val));
if ( vals )
for ( double val : ( *vals ) )
uniqueValues.insert( static_cast<int>( val ) );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigFlowDiagStatCalc::timeStepCount()
{
@@ -110,24 +110,24 @@ size_t RigFlowDiagStatCalc::timeStepCount()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double& mean)
void RigFlowDiagStatCalc::mobileVolumeWeightedMean( size_t timeStepIndex, double& mean )
{
RimEclipseResultCase* eclCase = nullptr;
m_resultsData->flowDiagSolution()->firstAncestorOrThisOfType(eclCase);
if (!eclCase) return;
m_resultsData->flowDiagSolution()->firstAncestorOrThisOfType( eclCase );
if ( !eclCase ) return;
RigCaseCellResultsData* caseCellResultsData = eclCase->results(RiaDefines::MATRIX_MODEL);
RigEclipseResultAddress mobPoreVolResAddr(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
RigCaseCellResultsData* caseCellResultsData = eclCase->results( RiaDefines::MATRIX_MODEL );
RigEclipseResultAddress mobPoreVolResAddr( RiaDefines::ResultCatType::STATIC_NATIVE,
RiaDefines::mobilePoreVolumeName() );
caseCellResultsData->ensureKnownResultLoaded(mobPoreVolResAddr);
caseCellResultsData->ensureKnownResultLoaded( mobPoreVolResAddr );
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(mobPoreVolResAddr, 0);
const std::vector<double>* values = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
const std::vector<double>& weights = caseCellResultsData->cellScalarResults( mobPoreVolResAddr, 0 );
const std::vector<double>* values = m_resultsData->resultValues( m_resVarAddr, timeStepIndex );
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo( m_resVarAddr );
RigWeightedMeanCalc::weightedMeanOverCells(&weights, values, nullptr, false, actCellInfo, true, &mean);
RigWeightedMeanCalc::weightedMeanOverCells( &weights, values, nullptr, false, actCellInfo, true, &mean );
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -26,26 +26,23 @@ class RigHistogramCalculator;
class RigFlowDiagResults;
//==================================================================================================
///
///
//==================================================================================================
class RigFlowDiagStatCalc : public RigStatisticsCalculator
{
public:
RigFlowDiagStatCalc(RigFlowDiagResults* flowDiagResults, const RigFlowDiagResultAddress& resVarAddr);
RigFlowDiagStatCalc( RigFlowDiagResults* flowDiagResults, const RigFlowDiagResultAddress& resVarAddr );
void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) override;
void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) override;
void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount) override;
void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator) override;
void uniqueValues(size_t timeStepIndex, std::set<int>& values) override;
size_t timeStepCount() override;
void mobileVolumeWeightedMean(size_t timeStepIndex, double& mean) override;
void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) override;
void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) override;
void valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) override;
void addDataToHistogramCalculator( size_t timeStepIndex, RigHistogramCalculator& histogramCalculator ) override;
void uniqueValues( size_t timeStepIndex, std::set<int>& values ) override;
size_t timeStepCount() override;
void mobileVolumeWeightedMean( size_t timeStepIndex, double& mean ) override;
private:
RigFlowDiagResults* m_resultsData;
RigFlowDiagResultAddress m_resVarAddr;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -29,69 +29,71 @@
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigFlowDiagVisibleCellsStatCalc::RigFlowDiagVisibleCellsStatCalc(RigFlowDiagResults* resultsData,
const RigFlowDiagResultAddress& resVarAddr,
const cvf::UByteArray* cellVisibilities)
: m_resultsData(resultsData), m_resVarAddr(resVarAddr), m_cellVisibilities(cellVisibilities)
RigFlowDiagVisibleCellsStatCalc::RigFlowDiagVisibleCellsStatCalc( RigFlowDiagResults* resultsData,
const RigFlowDiagResultAddress& resVarAddr,
const cvf::UByteArray* cellVisibilities )
: m_resultsData( resultsData )
, m_resVarAddr( resVarAddr )
, m_cellVisibilities( cellVisibilities )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagVisibleCellsStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
void RigFlowDiagVisibleCellsStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max )
{
MinMaxAccumulator acc(min, max);
traverseElementNodes(acc, timeStepIndex);
MinMaxAccumulator acc( min, max );
traverseElementNodes( acc, timeStepIndex );
min = acc.min;
max = acc.max;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagVisibleCellsStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
void RigFlowDiagVisibleCellsStatCalc::posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg )
{
PosNegAccumulator acc(pos, neg);
traverseElementNodes(acc, timeStepIndex);
PosNegAccumulator acc( pos, neg );
traverseElementNodes( acc, timeStepIndex );
pos = acc.pos;
neg = acc.neg;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagVisibleCellsStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount)
void RigFlowDiagVisibleCellsStatCalc::valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount )
{
SumCountAccumulator acc(valueSum, sampleCount);
traverseElementNodes(acc, timeStepIndex);
valueSum = acc.valueSum;
SumCountAccumulator acc( valueSum, sampleCount );
traverseElementNodes( acc, timeStepIndex );
valueSum = acc.valueSum;
sampleCount = acc.sampleCount;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagVisibleCellsStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator)
void RigFlowDiagVisibleCellsStatCalc::addDataToHistogramCalculator( size_t timeStepIndex,
RigHistogramCalculator& histogramCalculator )
{
traverseElementNodes(histogramCalculator, timeStepIndex);
traverseElementNodes( histogramCalculator, timeStepIndex );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagVisibleCellsStatCalc::uniqueValues(size_t timeStepIndex, std::set<int>& values)
void RigFlowDiagVisibleCellsStatCalc::uniqueValues( size_t timeStepIndex, std::set<int>& values )
{
UniqueValueAccumulator acc;
traverseElementNodes(acc, timeStepIndex);
traverseElementNodes( acc, timeStepIndex );
values = acc.uniqueValues;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigFlowDiagVisibleCellsStatCalc::timeStepCount()
{
@@ -99,24 +101,23 @@ size_t RigFlowDiagVisibleCellsStatCalc::timeStepCount()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagVisibleCellsStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double &result)
void RigFlowDiagVisibleCellsStatCalc::mobileVolumeWeightedMean( size_t timeStepIndex, double& result )
{
RimEclipseResultCase* eclCase = nullptr;
m_resultsData->flowDiagSolution()->firstAncestorOrThisOfType(eclCase);
if (!eclCase) return;
m_resultsData->flowDiagSolution()->firstAncestorOrThisOfType( eclCase );
if ( !eclCase ) return;
RigCaseCellResultsData* caseCellResultsData = eclCase->results(RiaDefines::MATRIX_MODEL);
RigCaseCellResultsData* caseCellResultsData = eclCase->results( RiaDefines::MATRIX_MODEL );
RigEclipseResultAddress mobPorvAddr(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
RigEclipseResultAddress mobPorvAddr( RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName() );
caseCellResultsData->ensureKnownResultLoaded(mobPorvAddr);
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(mobPorvAddr, 0);
const std::vector<double>* values = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
caseCellResultsData->ensureKnownResultLoaded( mobPorvAddr );
const std::vector<double>& weights = caseCellResultsData->cellScalarResults( mobPorvAddr, 0 );
const std::vector<double>* values = m_resultsData->resultValues( m_resVarAddr, timeStepIndex );
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo( m_resVarAddr );
RigWeightedMeanCalc::weightedMeanOverCells(&weights, values, m_cellVisibilities.p(), true, actCellInfo, true, &result);
RigWeightedMeanCalc::weightedMeanOverCells( &weights, values, m_cellVisibilities.p(), true, actCellInfo, true, &result );
}

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,12 +20,12 @@
#pragma once
//==================================================================================================
///
///
//==================================================================================================
#include "RigStatisticsCalculator.h"
#include "RigActiveCellInfo.h"
#include "RigFlowDiagResultAddress.h"
#include "RigFlowDiagResults.h"
#include "RigActiveCellInfo.h"
#include "RigStatisticsCalculator.h"
#include "cvfArray.h"
@@ -35,42 +35,42 @@ class RigActiveCellInfo;
class RigFlowDiagVisibleCellsStatCalc : public RigStatisticsCalculator
{
public:
RigFlowDiagVisibleCellsStatCalc(RigFlowDiagResults* resultsData,
const RigFlowDiagResultAddress& resVarAddr,
const cvf::UByteArray* cellVisibilities);
RigFlowDiagVisibleCellsStatCalc( RigFlowDiagResults* resultsData,
const RigFlowDiagResultAddress& resVarAddr,
const cvf::UByteArray* cellVisibilities );
void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) override;
void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) override;
void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount) override;
void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator) override;
void uniqueValues(size_t timeStepIndex, std::set<int>& values) override;
size_t timeStepCount() override;
void mobileVolumeWeightedMean(size_t timeStepIndex, double &result) override;
void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) override;
void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) override;
void valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) override;
void addDataToHistogramCalculator( size_t timeStepIndex, RigHistogramCalculator& histogramCalculator ) override;
void uniqueValues( size_t timeStepIndex, std::set<int>& values ) override;
size_t timeStepCount() override;
void mobileVolumeWeightedMean( size_t timeStepIndex, double& result ) override;
private:
RigFlowDiagResults* m_resultsData;
RigFlowDiagResultAddress m_resVarAddr;
cvf::cref<cvf::UByteArray> m_cellVisibilities;
RigFlowDiagResults* m_resultsData;
RigFlowDiagResultAddress m_resVarAddr;
cvf::cref<cvf::UByteArray> m_cellVisibilities;
template <typename StatisticsAccumulator>
void traverseElementNodes(StatisticsAccumulator& accumulator, size_t timeStepIndex)
void traverseElementNodes( StatisticsAccumulator& accumulator, size_t timeStepIndex )
{
const std::vector<double>* values = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
if (!values) return;
const std::vector<double>* values = m_resultsData->resultValues( m_resVarAddr, timeStepIndex );
if ( !values ) return;
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo( m_resVarAddr );
size_t cellCount = actCellInfo->reservoirCellCount();
CVF_TIGHT_ASSERT(cellCount == m_cellVisibilities->size());
CVF_TIGHT_ASSERT( cellCount == m_cellVisibilities->size() );
for ( size_t cIdx = 0; cIdx < cellCount; ++cIdx )
{
if ( !(*m_cellVisibilities)[cIdx] ) continue;
if ( !( *m_cellVisibilities )[cIdx] ) continue;
size_t cellResultIndex = actCellInfo->cellResultIndex(cIdx);
size_t cellResultIndex = actCellInfo->cellResultIndex( cIdx );
if ( cellResultIndex != cvf::UNDEFINED_SIZE_T ) accumulator.addValue((*values)[cellResultIndex]);
if ( cellResultIndex != cvf::UNDEFINED_SIZE_T ) accumulator.addValue( ( *values )[cellResultIndex] );
}
}
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -19,47 +19,41 @@
#include "RigFormationNames.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigFormationNames::RigFormationNames()
RigFormationNames::RigFormationNames() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFormationNames::~RigFormationNames() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigFormationNames::formationNameFromKLayerIdx( size_t Kidx )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFormationNames::~RigFormationNames()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigFormationNames::formationNameFromKLayerIdx(size_t Kidx)
{
int idx = formationIndexFromKLayerIdx(Kidx);
if(idx >= static_cast<int>(m_formationNames.size())) return "";
if(idx == -1) return "";
int idx = formationIndexFromKLayerIdx( Kidx );
if ( idx >= static_cast<int>( m_formationNames.size() ) ) return "";
if ( idx == -1 ) return "";
return m_formationNames[idx];
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFormationNames::appendFormationRange(const QString& name, int kStartIdx, int kEndIdx)
void RigFormationNames::appendFormationRange( const QString& name, int kStartIdx, int kEndIdx )
{
CVF_ASSERT(kStartIdx <= kEndIdx);
int nameIdx = static_cast<int>(m_formationNames.size());
m_formationNames.push_back(name);
CVF_ASSERT( kStartIdx <= kEndIdx );
if ( kEndIdx >= static_cast<int>(m_nameIndexPrKLayer.size()) )
int nameIdx = static_cast<int>( m_formationNames.size() );
m_formationNames.push_back( name );
if ( kEndIdx >= static_cast<int>( m_nameIndexPrKLayer.size() ) )
{
m_nameIndexPrKLayer.resize(kEndIdx + 1, -1);
m_nameIndexPrKLayer.resize( kEndIdx + 1, -1 );
}
for ( int kIdx = kStartIdx; kIdx <= kEndIdx; ++kIdx )
@@ -68,21 +62,20 @@ void RigFormationNames::appendFormationRange(const QString& name, int kStartIdx,
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigFormationNames::appendFormationRangeHeight(const QString& name, int kLayerCount)
void RigFormationNames::appendFormationRangeHeight( const QString& name, int kLayerCount )
{
if (kLayerCount < 1) return;
if ( kLayerCount < 1 ) return;
int nameIdx = static_cast<int>(m_formationNames.size());
int nameIdx = static_cast<int>( m_formationNames.size() );
m_formationNames.push_back(name);
m_formationNames.push_back( name );
int kStartIdx = static_cast<int>(m_nameIndexPrKLayer.size());
m_nameIndexPrKLayer.resize(kStartIdx + kLayerCount, -1);
int kStartIdx = static_cast<int>( m_nameIndexPrKLayer.size() );
m_nameIndexPrKLayer.resize( kStartIdx + kLayerCount, -1 );
for ( int kIdx = kStartIdx; kIdx < kStartIdx + kLayerCount; ++kIdx )
{

View File

@@ -1,52 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfObject.h"
#include <QString>
#include <vector>
class RigFormationNames: public cvf::Object
class RigFormationNames : public cvf::Object
{
public:
RigFormationNames();
~RigFormationNames() override;
int formationIndexFromKLayerIdx(size_t Kidx)
int formationIndexFromKLayerIdx( size_t Kidx )
{
if(Kidx >= m_nameIndexPrKLayer.size()) return -1;
if ( Kidx >= m_nameIndexPrKLayer.size() ) return -1;
return m_nameIndexPrKLayer[Kidx];
}
QString formationNameFromKLayerIdx(size_t Kidx);
QString formationNameFromKLayerIdx( size_t Kidx );
const std::vector<QString>& formationNames() const { return m_formationNames;}
const std::vector<QString>& formationNames() const
{
return m_formationNames;
}
void appendFormationRange(const QString& name, int kStartIdx, int kEndIdx);
void appendFormationRangeHeight(const QString& name, int kLayerCount);
void appendFormationRange( const QString& name, int kStartIdx, int kEndIdx );
void appendFormationRangeHeight( const QString& name, int kLayerCount );
private:
std::vector<int> m_nameIndexPrKLayer;
std::vector<int> m_nameIndexPrKLayer;
std::vector<QString> m_formationNames;
};

View File

@@ -25,11 +25,11 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFractureCell::RigFractureCell(std::vector<cvf::Vec3d> polygon, size_t i, size_t j)
: m_polygon(polygon)
, m_i(i)
, m_j(j)
, m_conductivityValue(0.0)
RigFractureCell::RigFractureCell( std::vector<cvf::Vec3d> polygon, size_t i, size_t j )
: m_polygon( polygon )
, m_i( i )
, m_j( j )
, m_conductivityValue( 0.0 )
{
}
@@ -76,7 +76,7 @@ bool RigFractureCell::hasNonZeroConductivity() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFractureCell::setConductivityValue(double cond)
void RigFractureCell::setConductivityValue( double cond )
{
m_conductivityValue = cond;
}
@@ -87,7 +87,7 @@ void RigFractureCell::setConductivityValue(double cond)
double RigFractureCell::cellSizeX() const
{
// The polygon corners are always stored in the same order
if (m_polygon.size() > 1) return (m_polygon[1] - m_polygon[0]).length();
if ( m_polygon.size() > 1 ) return ( m_polygon[1] - m_polygon[0] ).length();
return cvf::UNDEFINED_DOUBLE;
}
@@ -96,6 +96,6 @@ double RigFractureCell::cellSizeX() const
//--------------------------------------------------------------------------------------------------
double RigFractureCell::cellSizeZ() const
{
if (m_polygon.size() > 2) return (m_polygon[2] - m_polygon[1]).length();
if ( m_polygon.size() > 2 ) return ( m_polygon[2] - m_polygon[1] ).length();
return cvf::UNDEFINED_DOUBLE;
}

View File

@@ -1,48 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfVector3.h"
#include <vector>
//==================================================================================================
///
///
///
///
//==================================================================================================
class RigFractureCell
class RigFractureCell
{
public:
RigFractureCell(std::vector<cvf::Vec3d> polygon, size_t i, size_t j);
RigFractureCell( std::vector<cvf::Vec3d> polygon, size_t i, size_t j );
const std::vector<cvf::Vec3d>& getPolygon() const;
double getConductivityValue() const;
size_t getI() const;
size_t getJ() const;
double getConductivityValue() const;
size_t getI() const;
size_t getJ() const;
bool hasNonZeroConductivity() const;
void setConductivityValue(double cond);
bool hasNonZeroConductivity() const;
void setConductivityValue( double cond );
double cellSizeX() const;
double cellSizeZ() const;
double cellSizeX() const;
double cellSizeZ() const;
private:
std::vector<cvf::Vec3d> m_polygon;

View File

@@ -26,15 +26,15 @@
///
//--------------------------------------------------------------------------------------------------
RigFractureGrid::RigFractureGrid()
: m_iCellCount(0)
, m_jCellCount(0)
: m_iCellCount( 0 )
, m_jCellCount( 0 )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFractureGrid::setFractureCells(std::vector<RigFractureCell> fractureCells)
void RigFractureGrid::setFractureCells( std::vector<RigFractureCell> fractureCells )
{
m_fractureCells = fractureCells;
}
@@ -42,7 +42,7 @@ void RigFractureGrid::setFractureCells(std::vector<RigFractureCell> fractureCell
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFractureGrid::setWellCenterFractureCellIJ(std::pair<size_t, size_t> wellCenterFractureCellIJ)
void RigFractureGrid::setWellCenterFractureCellIJ( std::pair<size_t, size_t> wellCenterFractureCellIJ )
{
m_wellCenterFractureCellIJ = wellCenterFractureCellIJ;
}
@@ -50,7 +50,7 @@ void RigFractureGrid::setWellCenterFractureCellIJ(std::pair<size_t, size_t> well
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFractureGrid::setICellCount(size_t iCellCount)
void RigFractureGrid::setICellCount( size_t iCellCount )
{
m_iCellCount = iCellCount;
}
@@ -58,7 +58,7 @@ void RigFractureGrid::setICellCount(size_t iCellCount)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFractureGrid::setJCellCount(size_t jCellCount)
void RigFractureGrid::setJCellCount( size_t jCellCount )
{
m_jCellCount = jCellCount;
}
@@ -74,7 +74,7 @@ const std::vector<RigFractureCell>& RigFractureGrid::fractureCells() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigFractureGrid::getGlobalIndexFromIJ(size_t i, size_t j) const
size_t RigFractureGrid::getGlobalIndexFromIJ( size_t i, size_t j ) const
{
return i * m_jCellCount + j;
}
@@ -82,9 +82,9 @@ size_t RigFractureGrid::getGlobalIndexFromIJ(size_t i, size_t j) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigFractureCell& RigFractureGrid::cellFromIndex(size_t index) const
const RigFractureCell& RigFractureGrid::cellFromIndex( size_t index ) const
{
if (index < m_fractureCells.size())
if ( index < m_fractureCells.size() )
{
const RigFractureCell& cell = m_fractureCells[index];
return cell;
@@ -92,8 +92,8 @@ const RigFractureCell& RigFractureGrid::cellFromIndex(size_t index) const
else
{
// TODO: Better error handling?
RiaLogging::error(QString("Requesting non-existent StimPlanCell"));
RiaLogging::error(QString("Returning cell 0, results will be invalid"));
RiaLogging::error( QString( "Requesting non-existent StimPlanCell" ) );
RiaLogging::error( QString( "Returning cell 0, results will be invalid" ) );
const RigFractureCell& cell = m_fractureCells[0];
return cell;
}

View File

@@ -1,52 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfObject.h"
#include "RigFractureCell.h"
#include "cvfObject.h"
#include <vector>
class RigFractureCell;
//==================================================================================================
///
///
///
///
//==================================================================================================
class RigFractureGrid : public cvf::Object
{
public:
RigFractureGrid();
void setFractureCells(std::vector<RigFractureCell> fractureCells);
void setWellCenterFractureCellIJ(std::pair<size_t, size_t> wellCenterFractureCellIJ);
void setICellCount(size_t iCellCount);
void setJCellCount(size_t jCellCount);
void setFractureCells( std::vector<RigFractureCell> fractureCells );
void setWellCenterFractureCellIJ( std::pair<size_t, size_t> wellCenterFractureCellIJ );
void setICellCount( size_t iCellCount );
void setJCellCount( size_t jCellCount );
const std::vector<RigFractureCell>& fractureCells() const;
size_t getGlobalIndexFromIJ(size_t i, size_t j) const;
const RigFractureCell& cellFromIndex(size_t index) const;
size_t jCellCount() const;
size_t iCellCount() const;
const std::vector<RigFractureCell>& fractureCells() const;
size_t getGlobalIndexFromIJ( size_t i, size_t j ) const;
const RigFractureCell& cellFromIndex( size_t index ) const;
size_t jCellCount() const;
size_t iCellCount() const;
std::pair<size_t, size_t> fractureCellAtWellCenter() const;
std::pair<size_t, size_t> fractureCellAtWellCenter() const;
private:
std::vector<RigFractureCell> m_fractureCells;

View File

@@ -9,150 +9,149 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGeoMechBoreHoleStressCalculator::RigGeoMechBoreHoleStressCalculator(const caf::Ten3d& tensor,
double porePressure,
double poissonRatio,
double uniaxialCompressiveStrength,
int nThetaSubSamples)
: m_tensor(tensor)
, m_porePressure(porePressure)
, m_poissonRatio(poissonRatio)
, m_uniaxialCompressiveStrength(uniaxialCompressiveStrength)
, m_nThetaSubSamples(nThetaSubSamples)
RigGeoMechBoreHoleStressCalculator::RigGeoMechBoreHoleStressCalculator( const caf::Ten3d& tensor,
double porePressure,
double poissonRatio,
double uniaxialCompressiveStrength,
int nThetaSubSamples )
: m_tensor( tensor )
, m_porePressure( porePressure )
, m_poissonRatio( poissonRatio )
, m_uniaxialCompressiveStrength( uniaxialCompressiveStrength )
, m_nThetaSubSamples( nThetaSubSamples )
{
calculateStressComponents();
}
//--------------------------------------------------------------------------------------------------
/// Simple bisection method for now
//--------------------------------------------------------------------------------------------------
double RigGeoMechBoreHoleStressCalculator::solveFractureGradient(double* thetaOut)
double RigGeoMechBoreHoleStressCalculator::solveFractureGradient( double* thetaOut )
{
MemberFunc fn = &RigGeoMechBoreHoleStressCalculator::sigmaTMinOfMin;
return solveSecant(fn, thetaOut);
return solveSecant( fn, thetaOut );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGeoMechBoreHoleStressCalculator::solveStassiDalia(double* thetaOut)
double RigGeoMechBoreHoleStressCalculator::solveStassiDalia( double* thetaOut )
{
MemberFunc fn = &RigGeoMechBoreHoleStressCalculator::stassiDalia;
return solveSecant(fn, thetaOut);
return solveSecant( fn, thetaOut );
}
//--------------------------------------------------------------------------------------------------
/// Bi-section root finding method: https://en.wikipedia.org/wiki/Bisection_method
/// Used as fall-back in case the secant method doesn't converge.
//--------------------------------------------------------------------------------------------------
double RigGeoMechBoreHoleStressCalculator::solveBisection(double minPw, double maxPw, MemberFunc fn, double* thetaOut)
double RigGeoMechBoreHoleStressCalculator::solveBisection( double minPw, double maxPw, MemberFunc fn, double* thetaOut )
{
const int N = 50;
const int N = 50;
const double epsilon = 1.0e-10;
double theta = 0.0;
std::pair<double, double> largestNegativeValue(0.0, -std::numeric_limits<double>::infinity());
std::pair<double, double> smallestPositiveValue (0.0, std::numeric_limits<double>::infinity());
for (int i = 0; i <= N; ++i)
std::pair<double, double> largestNegativeValue( 0.0, -std::numeric_limits<double>::infinity() );
std::pair<double, double> smallestPositiveValue( 0.0, std::numeric_limits<double>::infinity() );
for ( int i = 0; i <= N; ++i )
{
double pw = minPw + (maxPw - minPw) * i / static_cast<double>(N);
double f_pw = (this->*fn)(pw, &theta);
if (f_pw >= 0.0 && f_pw < smallestPositiveValue.second)
double pw = minPw + ( maxPw - minPw ) * i / static_cast<double>( N );
double f_pw = ( this->*fn )( pw, &theta );
if ( f_pw >= 0.0 && f_pw < smallestPositiveValue.second )
{
smallestPositiveValue = std::make_pair(pw, f_pw);
smallestPositiveValue = std::make_pair( pw, f_pw );
}
if (f_pw < 0.0 && f_pw > largestNegativeValue.second)
if ( f_pw < 0.0 && f_pw > largestNegativeValue.second )
{
largestNegativeValue = std::make_pair(pw, f_pw);
}
largestNegativeValue = std::make_pair( pw, f_pw );
}
}
// TODO: Provide a warning if there was no solution to the equation
if (largestNegativeValue.second == -std::numeric_limits<double>::infinity())
if ( largestNegativeValue.second == -std::numeric_limits<double>::infinity() )
{
// No solution. Function is always positive. Pick smallest value.
return smallestPositiveValue.first;
}
if (smallestPositiveValue.second == std::numeric_limits<double>::infinity())
if ( smallestPositiveValue.second == std::numeric_limits<double>::infinity() )
{
// No solution. Function is always negative. Pick largest value.
return largestNegativeValue.first;
return largestNegativeValue.first;
}
minPw = largestNegativeValue.first;
minPw = largestNegativeValue.first;
double minPwFuncVal = largestNegativeValue.second;
maxPw = smallestPositiveValue.first;
maxPw = smallestPositiveValue.first;
double maxPwFuncVal = smallestPositiveValue.second;
double range = std::abs(maxPw - minPw);
double range = std::abs( maxPw - minPw );
int i = 0;
for (; i <= N && range > m_porePressure * epsilon; ++i)
for ( ; i <= N && range > m_porePressure * epsilon; ++i )
{
double midPw = (minPw + maxPw) * 0.5;
double midPwFuncVal = (this->*fn)(midPw, &theta);
if (midPwFuncVal * minPwFuncVal < 0.0)
double midPw = ( minPw + maxPw ) * 0.5;
double midPwFuncVal = ( this->*fn )( midPw, &theta );
if ( midPwFuncVal * minPwFuncVal < 0.0 )
{
maxPw = midPw;
maxPw = midPw;
maxPwFuncVal = midPwFuncVal;
}
else
{
minPw = midPw;
minPw = midPw;
minPwFuncVal = midPwFuncVal;
}
range = std::abs(maxPw - minPw);
range = std::abs( maxPw - minPw );
}
CVF_ASSERT(i < N); // Otherwise it hasn't converged
CVF_ASSERT( i < N ); // Otherwise it hasn't converged
if (thetaOut)
if ( thetaOut )
{
*thetaOut = theta;
}
// Return average of minPw and maxPw.
return 0.5 * (maxPw + minPw);
return 0.5 * ( maxPw + minPw );
}
//--------------------------------------------------------------------------------------------------
/// Secant root finding method: https://en.wikipedia.org/wiki/Secant_method
/// Basically a Newton's method using finite differences for the derivative.
//--------------------------------------------------------------------------------------------------
double RigGeoMechBoreHoleStressCalculator::solveSecant(MemberFunc fn, double* thetaOut)
double RigGeoMechBoreHoleStressCalculator::solveSecant( MemberFunc fn, double* thetaOut )
{
const double epsilon = 1.0e-10;
const int N = 50;
double theta = 0.0;
const int N = 50;
double theta = 0.0;
double x_0 = 0.0;
double f_x0 = (this->*fn)(x_0, &theta);
double x_1 = m_porePressure;
double f_x1 = (this->*fn)(x_1, &theta);
double x = 0.0;
double f_x = 0.0;
int i = 0;
for (; i <= N && std::abs(f_x1 - f_x0) > epsilon; ++i)
double x_0 = 0.0;
double f_x0 = ( this->*fn )( x_0, &theta );
double x_1 = m_porePressure;
double f_x1 = ( this->*fn )( x_1, &theta );
double x = 0.0;
double f_x = 0.0;
int i = 0;
for ( ; i <= N && std::abs( f_x1 - f_x0 ) > epsilon; ++i )
{
x = x_1 - f_x1 * (x_1 - x_0) / (f_x1 - f_x0);
f_x = (this->*fn)(x, &theta);
if (std::abs(f_x) < epsilon * m_porePressure) break;
x = x_1 - f_x1 * ( x_1 - x_0 ) / ( f_x1 - f_x0 );
f_x = ( this->*fn )( x, &theta );
if ( std::abs( f_x ) < epsilon * m_porePressure ) break;
// Update iteration variables
x_0 = x_1;
x_0 = x_1;
f_x0 = f_x1;
x_1 = x;
f_x1 = f_x;
x_1 = x;
f_x1 = f_x;
}
if (i == N || std::abs(f_x) > epsilon * m_porePressure)
if ( i == N || std::abs( f_x ) > epsilon * m_porePressure )
{
// Fallback to bisection if secant doesn't converge or converged to a wrong solution.
return solveBisection(0.0, m_porePressure * 2.0, fn, thetaOut);
return solveBisection( 0.0, m_porePressure * 2.0, fn, thetaOut );
}
if (thetaOut)
if ( thetaOut )
{
*thetaOut = theta;
}
@@ -162,21 +161,23 @@ double RigGeoMechBoreHoleStressCalculator::solveSecant(MemberFunc fn, double* th
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGeoMechBoreHoleStressCalculator::sigmaTMinOfMin(double wellPressure, double* thetaAtMin) const
double RigGeoMechBoreHoleStressCalculator::sigmaTMinOfMin( double wellPressure, double* thetaAtMin ) const
{
CVF_ASSERT(thetaAtMin);
CVF_ASSERT( thetaAtMin );
double sigma_t_min_min = std::numeric_limits<double>::max();
for (const cvf::Vec4d& stressComponentsForAngle : m_stressComponents)
for ( const cvf::Vec4d& stressComponentsForAngle : m_stressComponents )
{
// Perform all these internal calculations in double to reduce significance errors
double sigma_theta = stressComponentsForAngle[1] - wellPressure;
const double& sigma_z = stressComponentsForAngle[2];
double tauSqrx4 = std::pow(stressComponentsForAngle[3], 2) * 4.0;
double sigma_t_min = 0.5 * ((sigma_z + sigma_theta) - std::sqrt(std::pow(sigma_z - sigma_theta, 2) + tauSqrx4)) - m_porePressure;
if (sigma_t_min < sigma_t_min_min)
double sigma_theta = stressComponentsForAngle[1] - wellPressure;
const double& sigma_z = stressComponentsForAngle[2];
double tauSqrx4 = std::pow( stressComponentsForAngle[3], 2 ) * 4.0;
double sigma_t_min = 0.5 * ( ( sigma_z + sigma_theta ) -
std::sqrt( std::pow( sigma_z - sigma_theta, 2 ) + tauSqrx4 ) ) -
m_porePressure;
if ( sigma_t_min < sigma_t_min_min )
{
sigma_t_min_min = sigma_t_min;
*thetaAtMin = stressComponentsForAngle[0];
*thetaAtMin = stressComponentsForAngle[0];
}
}
return sigma_t_min_min;
@@ -185,27 +186,32 @@ double RigGeoMechBoreHoleStressCalculator::sigmaTMinOfMin(double wellPressure, d
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGeoMechBoreHoleStressCalculator::stassiDalia(double wellPressure, double* thetaAtMin) const
double RigGeoMechBoreHoleStressCalculator::stassiDalia( double wellPressure, double* thetaAtMin ) const
{
CVF_ASSERT(thetaAtMin);
CVF_ASSERT( thetaAtMin );
double minStassiDalia = std::numeric_limits<double>::max();
for (const cvf::Vec4d& stressComponentsForAngle : m_stressComponents)
for ( const cvf::Vec4d& stressComponentsForAngle : m_stressComponents )
{
double sigma_theta = stressComponentsForAngle[1] - wellPressure;
const double& sigma_z = stressComponentsForAngle[2];
double tauSqrx4 = std::pow(stressComponentsForAngle[3], 2) * 4.0;
double sigma_theta = stressComponentsForAngle[1] - wellPressure;
const double& sigma_z = stressComponentsForAngle[2];
double tauSqrx4 = std::pow( stressComponentsForAngle[3], 2 ) * 4.0;
double sigma_1 = wellPressure - m_porePressure;
double sigma_2 = 0.5 * ((sigma_z + sigma_theta) + std::sqrt(std::pow(sigma_z - sigma_theta, 2) + tauSqrx4)) - m_porePressure;
double sigma_3 = 0.5 * ((sigma_z + sigma_theta) - std::sqrt(std::pow(sigma_z - sigma_theta, 2) + tauSqrx4)) - m_porePressure;
double sigma_2 = 0.5 * ( ( sigma_z + sigma_theta ) +
std::sqrt( std::pow( sigma_z - sigma_theta, 2 ) + tauSqrx4 ) ) -
m_porePressure;
double sigma_3 = 0.5 * ( ( sigma_z + sigma_theta ) -
std::sqrt( std::pow( sigma_z - sigma_theta, 2 ) + tauSqrx4 ) ) -
m_porePressure;
double stassiDalia = std::pow(sigma_1 - sigma_2, 2) + std::pow(sigma_2 - sigma_3, 2) + std::pow(sigma_1 - sigma_3, 2)
- 2 * m_uniaxialCompressiveStrength * (sigma_1 + sigma_2 + sigma_3);
double stassiDalia = std::pow( sigma_1 - sigma_2, 2 ) + std::pow( sigma_2 - sigma_3, 2 ) +
std::pow( sigma_1 - sigma_3, 2 ) -
2 * m_uniaxialCompressiveStrength * ( sigma_1 + sigma_2 + sigma_3 );
if (stassiDalia < minStassiDalia)
if ( stassiDalia < minStassiDalia )
{
minStassiDalia = stassiDalia;
*thetaAtMin = stressComponentsForAngle[0];
*thetaAtMin = stressComponentsForAngle[0];
}
}
return minStassiDalia;
@@ -216,37 +222,34 @@ double RigGeoMechBoreHoleStressCalculator::stassiDalia(double wellPressure, doub
//--------------------------------------------------------------------------------------------------
void RigGeoMechBoreHoleStressCalculator::calculateStressComponents()
{
m_stressComponents.reserve(m_nThetaSubSamples);
m_stressComponents.reserve( m_nThetaSubSamples );
for (int i = 0; i < m_nThetaSubSamples; ++i)
for ( int i = 0; i < m_nThetaSubSamples; ++i )
{
double theta = (i *cvf::PI_F) / (m_nThetaSubSamples - 1.0);
cvf::Vec4d stressComponentsForAngle = calculateStressComponentsForSegmentAngle(theta);
m_stressComponents.push_back(stressComponentsForAngle);
double theta = ( i * cvf::PI_F ) / ( m_nThetaSubSamples - 1.0 );
cvf::Vec4d stressComponentsForAngle = calculateStressComponentsForSegmentAngle( theta );
m_stressComponents.push_back( stressComponentsForAngle );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec4d RigGeoMechBoreHoleStressCalculator::calculateStressComponentsForSegmentAngle(double theta) const
cvf::Vec4d RigGeoMechBoreHoleStressCalculator::calculateStressComponentsForSegmentAngle( double theta ) const
{
cvf::Vec4d stressComponents;
const double& sx = m_tensor[caf::Ten3d::SXX];
const double& sy = m_tensor[caf::Ten3d::SYY];
const double& sz = m_tensor[caf::Ten3d::SZZ];
const double& sx = m_tensor[caf::Ten3d::SXX];
const double& sy = m_tensor[caf::Ten3d::SYY];
const double& sz = m_tensor[caf::Ten3d::SZZ];
const double& txy = m_tensor[caf::Ten3d::SXY];
const double& txz = m_tensor[caf::Ten3d::SZX];
const double& tyz = m_tensor[caf::Ten3d::SYZ];
stressComponents[0] = theta;
stressComponents[1] = sx + sy - 2 * (sx - sy) * cos(2 * theta) - 4 * txy * sin(2 * theta);
stressComponents[2] = sz - m_poissonRatio * (2 * (sx - sy) * cos(2 * theta) + 4 * txy * sin(2 * theta));
stressComponents[3] = 2 * (tyz * cos(theta) - txz * sin(theta));
stressComponents[1] = sx + sy - 2 * ( sx - sy ) * cos( 2 * theta ) - 4 * txy * sin( 2 * theta );
stressComponents[2] = sz - m_poissonRatio * ( 2 * ( sx - sy ) * cos( 2 * theta ) + 4 * txy * sin( 2 * theta ) );
stressComponents[3] = 2 * ( tyz * cos( theta ) - txz * sin( theta ) );
return stressComponents;
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -27,24 +27,27 @@
class RigGeoMechBoreHoleStressCalculator
{
public:
RigGeoMechBoreHoleStressCalculator(const caf::Ten3d& tensor, double porePressure, double poissonRatio, double uniaxialCompressiveStrength, int nThetaSubSamples);
double solveFractureGradient(double* thetaOut = nullptr);
double solveStassiDalia(double* thetaOut = nullptr);
RigGeoMechBoreHoleStressCalculator( const caf::Ten3d& tensor,
double porePressure,
double poissonRatio,
double uniaxialCompressiveStrength,
int nThetaSubSamples );
double solveFractureGradient( double* thetaOut = nullptr );
double solveStassiDalia( double* thetaOut = nullptr );
private:
typedef double (RigGeoMechBoreHoleStressCalculator::*MemberFunc)(double pw, double* thetaOut) const;
double solveBisection(double minPw, double maxPw, MemberFunc fn, double* thetaOut);
double solveSecant(MemberFunc fn, double* thetaOut);
double sigmaTMinOfMin(double wellPressure, double* thetaAtMin) const;
double stassiDalia(double wellPressure, double* thetaAtMin) const;
void calculateStressComponents();
cvf::Vec4d calculateStressComponentsForSegmentAngle(double theta) const;
typedef double ( RigGeoMechBoreHoleStressCalculator::*MemberFunc )( double pw, double* thetaOut ) const;
double solveBisection( double minPw, double maxPw, MemberFunc fn, double* thetaOut );
double solveSecant( MemberFunc fn, double* thetaOut );
double sigmaTMinOfMin( double wellPressure, double* thetaAtMin ) const;
double stassiDalia( double wellPressure, double* thetaAtMin ) const;
void calculateStressComponents();
cvf::Vec4d calculateStressComponentsForSegmentAngle( double theta ) const;
caf::Ten3d m_tensor;
double m_porePressure;
double m_poissonRatio;
double m_uniaxialCompressiveStrength;
int m_nThetaSubSamples;
caf::Ten3d m_tensor;
double m_porePressure;
double m_poissonRatio;
double m_uniaxialCompressiveStrength;
int m_nThetaSubSamples;
std::vector<cvf::Vec4d> m_stressComponents;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,9 +25,8 @@
#include "cafTensor3.h"
#include "cvfObject.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"
@@ -38,26 +37,28 @@ class RigFemResultAddress;
class RigGeoMechCaseData;
class RigWellPath;
namespace cvf {
class BoundingBox;
namespace cvf
{
class BoundingBox;
}
//==================================================================================================
///
///
//==================================================================================================
class RigGeoMechWellLogExtractor : public RigWellLogExtractor
{
public:
RigGeoMechWellLogExtractor(RigGeoMechCaseData* aCase, const RigWellPath* wellpath, const std::string& wellCaseErrorMsgName);
RigGeoMechWellLogExtractor( RigGeoMechCaseData* aCase,
const RigWellPath* wellpath,
const std::string& wellCaseErrorMsgName );
void curveData(const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values );
const RigGeoMechCaseData* caseData();
void setRkbDiff(double rkbDiff);
void setWellLogMdAndMudWeightKgPerM3(const std::vector<std::pair<double, double>>& mudWeightKgPerM3);
void setWellLogMdAndUcsBar(const std::vector<std::pair<double, double>>& ucsValues);
void setWellLogMdAndPoissonRatio(const std::vector<std::pair<double, double>>& poissonRatio);
void curveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values );
const RigGeoMechCaseData* caseData();
void setRkbDiff( double rkbDiff );
void setWellLogMdAndMudWeightKgPerM3( const std::vector<std::pair<double, double>>& mudWeightKgPerM3 );
void setWellLogMdAndUcsBar( const std::vector<std::pair<double, double>>& ucsValues );
void setWellLogMdAndPoissonRatio( const std::vector<std::pair<double, double>>& poissonRatio );
private:
enum WellPathTangentCalculation
@@ -66,41 +67,51 @@ private:
TangentConstantWithinCell
};
float calculatePorePressureInSegment(int64_t intersectionIdx, float averageSegmentPorePressureBar, double hydroStaticPorePressureBar, double effectiveDepthMeters, const std::vector<float>& poreElementPressuresPascal) const;
float calculatePoissonRatio(int64_t intersectionIdx, const std::vector<float>& poissonRatios) const;
float calculateUcs(int64_t intersectionIdx, const std::vector<float>& ucsValuesPascal) const;
float calculatePorePressureInSegment( int64_t intersectionIdx,
float averageSegmentPorePressureBar,
double hydroStaticPorePressureBar,
double effectiveDepthMeters,
const std::vector<float>& poreElementPressuresPascal ) const;
float calculatePoissonRatio( int64_t intersectionIdx, const std::vector<float>& poissonRatios ) const;
float calculateUcs( int64_t intersectionIdx, const std::vector<float>& ucsValuesPascal ) const;
void wellPathAngles(const RigFemResultAddress& resAddr, std::vector<double>* values);
void wellPathScaledCurveData(const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values);
void wellPathAngles( const RigFemResultAddress& resAddr, std::vector<double>* values );
void wellPathScaledCurveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values );
void wellBoreWallCurveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values );
void wellBoreWallCurveData(const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values);
template <typename T>
T interpolateGridResultValue( RigFemResultPosEnum resultPosType,
const std::vector<T>& gridResultValues,
int64_t intersectionIdx,
bool averageNodeElementResults ) const;
size_t gridResultIndexFace( size_t elementIdx, cvf::StructGridInterface::FaceType cellFace, int faceLocalNodeIdx ) const;
void calculateIntersection();
std::vector<size_t> findCloseCells( const cvf::BoundingBox& bb );
cvf::Vec3d calculateLengthInCell( size_t cellIndex,
const cvf::Vec3d& startPoint,
const cvf::Vec3d& endPoint ) const override;
cvf::Vec3d calculateWellPathTangent( int64_t intersectionIdx, WellPathTangentCalculation calculationType ) const;
static caf::Ten3d transformTensorToWellPathOrientation( const cvf::Vec3d& wellPathTangent,
const caf::Ten3d& wellPathTensor );
template<typename T>
T interpolateGridResultValue(RigFemResultPosEnum resultPosType, const std::vector<T>& gridResultValues, int64_t intersectionIdx, bool averageNodeElementResults) const;
size_t gridResultIndexFace(size_t elementIdx, cvf::StructGridInterface::FaceType cellFace, int faceLocalNodeIdx) const;
void calculateIntersection();
std::vector<size_t> findCloseCells(const cvf::BoundingBox& bb);
cvf::Vec3d calculateLengthInCell(size_t cellIndex,
const cvf::Vec3d& startPoint,
const cvf::Vec3d& endPoint) const override;
cvf::Vec3d calculateWellPathTangent(int64_t intersectionIdx, WellPathTangentCalculation calculationType) const;
static caf::Ten3d transformTensorToWellPathOrientation(const cvf::Vec3d& wellPathTangent,
const caf::Ten3d& wellPathTensor);
cvf::Vec3f cellCentroid( size_t intersectionIdx ) const;
double getWellLogSegmentValue( size_t intersectionIdx,
const std::vector<std::pair<double, double>>& wellLogValues ) const;
cvf::Vec3f cellCentroid(size_t intersectionIdx) const;
double getWellLogSegmentValue(size_t intersectionIdx, const std::vector<std::pair<double, double>>& wellLogValues) const;
template <typename T>
bool averageIntersectionValuesToSegmentValue( size_t intersectionIdx,
const std::vector<T>& intersectionValues,
const T& invalidValue,
T* averagedSegmentValue ) const;
static double pascalToBar( double pascalValue );
template<typename T>
bool averageIntersectionValuesToSegmentValue(size_t intersectionIdx, const std::vector<T>& intersectionValues, const T& invalidValue, T* averagedSegmentValue) const;
static double pascalToBar(double pascalValue);
private:
cvf::ref<RigGeoMechCaseData> m_caseData;
double m_rkbDiff;
cvf::ref<RigGeoMechCaseData> m_caseData;
double m_rkbDiff;
std::vector<std::pair<double, double>> m_wellLogMdAndMudWeightKgPerM3;
std::vector<std::pair<double, double>> m_wellLogMdAndUcsBar;
std::vector<std::pair<double, double>> m_wellLogMdAndPoissonRatios;
static const double UNIT_WEIGHT_OF_WATER;
static const double UNIT_WEIGHT_OF_WATER;
};

View File

@@ -3,36 +3,35 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigGridBase.h"
#include "RigMainGrid.h"
#include "RigCell.h"
#include "RigCaseCellResultsData.h"
#include "RigCell.h"
#include "RigMainGrid.h"
#include "RigResultAccessorFactory.h"
#include "cvfAssert.h"
RigGridBase::RigGridBase(RigMainGrid* mainGrid):
m_gridPointDimensions(0,0,0),
m_indexToStartOfCells(0),
m_mainGrid(mainGrid)
RigGridBase::RigGridBase( RigMainGrid* mainGrid )
: m_gridPointDimensions( 0, 0, 0 )
, m_indexToStartOfCells( 0 )
, m_mainGrid( mainGrid )
{
if (mainGrid == nullptr)
if ( mainGrid == nullptr )
{
m_gridIndex = 0;
m_gridId = 0;
@@ -40,25 +39,22 @@ RigGridBase::RigGridBase(RigMainGrid* mainGrid):
else
{
m_gridIndex = cvf::UNDEFINED_SIZE_T;
m_gridId = cvf::UNDEFINED_INT;
m_gridId = cvf::UNDEFINED_INT;
}
}
RigGridBase::~RigGridBase(void)
{
}
RigGridBase::~RigGridBase( void ) {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigGridBase::setGridName(const std::string& gridName)
void RigGridBase::setGridName( const std::string& gridName )
{
m_gridName = gridName;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::string RigGridBase::gridName() const
{
@@ -68,168 +64,166 @@ std::string RigGridBase::gridName() const
//--------------------------------------------------------------------------------------------------
/// Do we need this ?
//--------------------------------------------------------------------------------------------------
RigCell& RigGridBase::cell(size_t gridLocalCellIndex)
RigCell& RigGridBase::cell( size_t gridLocalCellIndex )
{
CVF_ASSERT(m_mainGrid);
CVF_ASSERT( m_mainGrid );
CVF_ASSERT(m_indexToStartOfCells + gridLocalCellIndex < m_mainGrid->globalCellArray().size());
return m_mainGrid->globalCellArray()[m_indexToStartOfCells + gridLocalCellIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigCell& RigGridBase::cell(size_t gridLocalCellIndex) const
{
CVF_ASSERT(m_mainGrid);
CVF_ASSERT( m_indexToStartOfCells + gridLocalCellIndex < m_mainGrid->globalCellArray().size() );
return m_mainGrid->globalCellArray()[m_indexToStartOfCells + gridLocalCellIndex];
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
const RigCell& RigGridBase::cell( size_t gridLocalCellIndex ) const
{
CVF_ASSERT( m_mainGrid );
return m_mainGrid->globalCellArray()[m_indexToStartOfCells + gridLocalCellIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridBase::initSubGridParentPointer()
{
RigGridBase* grid = this;
size_t cellIdx;
for (cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx)
for ( cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx )
{
RigCell& cell = grid->cell(cellIdx);
if (cell.subGrid())
RigCell& cell = grid->cell( cellIdx );
if ( cell.subGrid() )
{
cell.subGrid()->setParentGrid(grid);
cell.subGrid()->setParentGrid( grid );
}
}
}
//--------------------------------------------------------------------------------------------------
/// Find the cell index to the maingrid cell containing this cell, and store it as
/// Find the cell index to the maingrid cell containing this cell, and store it as
/// m_mainGridCellIndex in each cell.
//--------------------------------------------------------------------------------------------------
void RigGridBase::initSubCellsMainGridCellIndex()
{
RigGridBase* grid = this;
if (grid->isMainGrid())
if ( grid->isMainGrid() )
{
size_t cellIdx;
for (cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx)
for ( cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx )
{
RigCell& cell = grid->cell(cellIdx);
cell.setMainGridCellIndex(cellIdx);
RigCell& cell = grid->cell( cellIdx );
cell.setMainGridCellIndex( cellIdx );
}
}
else
{
size_t cellIdx;
for (cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx)
for ( cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx )
{
RigLocalGrid* localGrid = static_cast<RigLocalGrid*>(grid);
RigGridBase* parentGrid = localGrid->parentGrid();
RigLocalGrid* localGrid = static_cast<RigLocalGrid*>( grid );
RigGridBase* parentGrid = localGrid->parentGrid();
RigCell& cell = localGrid->cell(cellIdx);
size_t parentCellIndex = cell.parentCellIndex();
RigCell& cell = localGrid->cell( cellIdx );
size_t parentCellIndex = cell.parentCellIndex();
while (!parentGrid->isMainGrid())
while ( !parentGrid->isMainGrid() )
{
const RigCell& parentCell = parentGrid->cell(parentCellIndex);
parentCellIndex = parentCell.parentCellIndex();
const RigCell& parentCell = parentGrid->cell( parentCellIndex );
parentCellIndex = parentCell.parentCellIndex();
localGrid = static_cast<RigLocalGrid*>(parentGrid);
localGrid = static_cast<RigLocalGrid*>( parentGrid );
parentGrid = localGrid->parentGrid();
}
cell.setMainGridCellIndex(parentCellIndex);
cell.setMainGridCellIndex( parentCellIndex );
}
}
}
//--------------------------------------------------------------------------------------------------
/// For main grid, this will work with reservoirCellIndices retreiving the correct lgr cells as well.
/// the cell() call retreives correct cell, because main grid has offset of 0, and we access the global
/// the cell() call retreives correct cell, because main grid has offset of 0, and we access the global
/// cell array in main grid.
//--------------------------------------------------------------------------------------------------
void RigGridBase::cellCornerVertices(size_t cellIndex, cvf::Vec3d vertices[8]) const
void RigGridBase::cellCornerVertices( size_t cellIndex, cvf::Vec3d vertices[8] ) const
{
const std::array<size_t, 8>& indices = cell(cellIndex).cornerIndices();
vertices[0].set(m_mainGrid->nodes()[indices[0]]);
vertices[1].set(m_mainGrid->nodes()[indices[1]]);
vertices[2].set(m_mainGrid->nodes()[indices[2]]);
vertices[3].set(m_mainGrid->nodes()[indices[3]]);
vertices[4].set(m_mainGrid->nodes()[indices[4]]);
vertices[5].set(m_mainGrid->nodes()[indices[5]]);
vertices[6].set(m_mainGrid->nodes()[indices[6]]);
vertices[7].set(m_mainGrid->nodes()[indices[7]]);
const std::array<size_t, 8>& indices = cell( cellIndex ).cornerIndices();
vertices[0].set( m_mainGrid->nodes()[indices[0]] );
vertices[1].set( m_mainGrid->nodes()[indices[1]] );
vertices[2].set( m_mainGrid->nodes()[indices[2]] );
vertices[3].set( m_mainGrid->nodes()[indices[3]] );
vertices[4].set( m_mainGrid->nodes()[indices[4]] );
vertices[5].set( m_mainGrid->nodes()[indices[5]] );
vertices[6].set( m_mainGrid->nodes()[indices[6]] );
vertices[7].set( m_mainGrid->nodes()[indices[7]] );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::cellIndexFromIJK(size_t i, size_t j, size_t k) const
size_t RigGridBase::cellIndexFromIJK( size_t i, size_t j, size_t k ) const
{
CVF_TIGHT_ASSERT(i != cvf::UNDEFINED_SIZE_T && j != cvf::UNDEFINED_SIZE_T && k != cvf::UNDEFINED_SIZE_T );
CVF_TIGHT_ASSERT(i < m_gridPointDimensions.x() && j < m_gridPointDimensions.y() && k < m_gridPointDimensions.z() );
CVF_TIGHT_ASSERT( i != cvf::UNDEFINED_SIZE_T && j != cvf::UNDEFINED_SIZE_T && k != cvf::UNDEFINED_SIZE_T );
CVF_TIGHT_ASSERT( i < m_gridPointDimensions.x() && j < m_gridPointDimensions.y() && k < m_gridPointDimensions.z() );
size_t ci = i + j*(m_gridPointDimensions.x() - 1) + k*((m_gridPointDimensions.x() - 1)*(m_gridPointDimensions.y() - 1));
size_t ci = i + j * ( m_gridPointDimensions.x() - 1 ) +
k * ( ( m_gridPointDimensions.x() - 1 ) * ( m_gridPointDimensions.y() - 1 ) );
return ci;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigGridBase::cellMinMaxCordinates(size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate) const
void RigGridBase::cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate ) const
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigGridBase::ijkFromCellIndex(size_t cellIndex, size_t* i, size_t* j, size_t* k) const
bool RigGridBase::ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const
{
CVF_TIGHT_ASSERT(cellIndex < cellCount());
CVF_TIGHT_ASSERT( cellIndex < cellCount() );
size_t index = cellIndex;
if (cellCountI() <= 0 || cellCountJ() <= 0)
if ( cellCountI() <= 0 || cellCountJ() <= 0 )
{
return false;
}
*k = index/(cellCountI()*cellCountJ());
index -= (*k)*(cellCountI()*cellCountJ());
*j = index/cellCountI();
index -= (*j)*cellCountI();
*i = index;
*k = index / ( cellCountI() * cellCountJ() );
index -= ( *k ) * ( cellCountI() * cellCountJ() );
*j = index / cellCountI();
index -= ( *j ) * cellCountI();
*i = index;
return true;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::gridPointIndexFromIJK(size_t i, size_t j, size_t k) const
size_t RigGridBase::gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const
{
return 0;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigGridBase::cellIJKFromCoordinate(const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k) const
bool RigGridBase::cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigGridBase::gridPointCoordinate(size_t i, size_t j, size_t k) const
cvf::Vec3d RigGridBase::gridPointCoordinate( size_t i, size_t j, size_t k ) const
{
cvf::Vec3d pos;
@@ -237,7 +231,7 @@ cvf::Vec3d RigGridBase::gridPointCoordinate(size_t i, size_t j, size_t k) const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigGridBase::minCoordinate() const
{
@@ -247,7 +241,7 @@ cvf::Vec3d RigGridBase::minCoordinate() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::gridPointCountI() const
{
@@ -255,7 +249,7 @@ size_t RigGridBase::gridPointCountI() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::gridPointCountJ() const
{
@@ -263,7 +257,7 @@ size_t RigGridBase::gridPointCountJ() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::gridPointCountK() const
{
@@ -271,9 +265,9 @@ size_t RigGridBase::gridPointCountK() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigGridBase::cellCentroid(size_t cellIndex) const
cvf::Vec3d RigGridBase::cellCentroid( size_t cellIndex ) const
{
cvf::Vec3d v;
@@ -281,7 +275,7 @@ cvf::Vec3d RigGridBase::cellCentroid(size_t cellIndex) const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigGridBase::maxCoordinate() const
{
@@ -290,46 +284,44 @@ cvf::Vec3d RigGridBase::maxCoordinate() const
return v;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigGridBase::isCellValid(size_t i, size_t j, size_t k) const
bool RigGridBase::isCellValid( size_t i, size_t j, size_t k ) const
{
if (i >= cellCountI() || j >= cellCountJ() || k >= cellCountK())
if ( i >= cellCountI() || j >= cellCountJ() || k >= cellCountK() )
{
return false;
}
size_t idx = cellIndexFromIJK(i, j, k);
const RigCell& c = cell(idx);
size_t idx = cellIndexFromIJK( i, j, k );
const RigCell& c = cell( idx );
return !c.isInvalid();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigGridBase::cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex) const
bool RigGridBase::cellIJKNeighbor( size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex ) const
{
size_t ni, nj, nk;
neighborIJKAtCellFace(i, j, k, face, &ni, &nj, &nk);
neighborIJKAtCellFace( i, j, k, face, &ni, &nj, &nk );
if (!isCellValid(ni, nj, nk))
if ( !isCellValid( ni, nj, nk ) )
{
return false;
}
if (neighborCellIndex)
if ( neighborCellIndex )
{
*neighborCellIndex = cellIndexFromIJK(ni, nj, nk);
*neighborCellIndex = cellIndexFromIJK( ni, nj, nk );
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigGridBase::isMainGrid() const
{
@@ -357,27 +349,26 @@ double RigGridBase::characteristicIJCellSize() const
double characteristicCellSize = HUGE_VAL;
double cellSizeI, cellSizeJ, cellSizeK;
this->characteristicCellSizes(&cellSizeI, &cellSizeJ, &cellSizeK);
this->characteristicCellSizes( &cellSizeI, &cellSizeJ, &cellSizeK );
if (cellSizeI < characteristicCellSize) characteristicCellSize = cellSizeI;
if (cellSizeJ < characteristicCellSize) characteristicCellSize = cellSizeJ;
if ( cellSizeI < characteristicCellSize ) characteristicCellSize = cellSizeI;
if ( cellSizeJ < characteristicCellSize ) characteristicCellSize = cellSizeJ;
return characteristicCellSize;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::reservoirCellIndex(size_t gridLocalCellIndex) const
size_t RigGridBase::reservoirCellIndex( size_t gridLocalCellIndex ) const
{
return m_indexToStartOfCells + gridLocalCellIndex;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::addCoarseningBox(size_t i1, size_t i2, size_t j1, size_t j2, size_t k1, size_t k2)
size_t RigGridBase::addCoarseningBox( size_t i1, size_t i2, size_t j1, size_t j2, size_t k1, size_t k2 )
{
std::array<size_t, 6> box;
box[0] = i1;
@@ -387,22 +378,22 @@ size_t RigGridBase::addCoarseningBox(size_t i1, size_t i2, size_t j1, size_t j2,
box[4] = k1;
box[5] = k2;
m_coarseningBoxInfo.push_back(box);
m_coarseningBoxInfo.push_back( box );
size_t coarseningBoxIndex = m_coarseningBoxInfo.size() - 1;
for (size_t k = k1; k <= k2; k++)
for ( size_t k = k1; k <= k2; k++ )
{
for (size_t j = j1; j <= j2; j++)
for ( size_t j = j1; j <= j2; j++ )
{
for (size_t i = i1; i <= i2; i++)
for ( size_t i = i1; i <= i2; i++ )
{
size_t cellIdx = this->cellIndexFromIJK(i, j, k);
size_t cellIdx = this->cellIndexFromIJK( i, j, k );
RigCell& c = this->cell(cellIdx);
CVF_ASSERT(c.coarseningBoxIndex() == cvf::UNDEFINED_SIZE_T);
RigCell& c = this->cell( cellIdx );
CVF_ASSERT( c.coarseningBoxIndex() == cvf::UNDEFINED_SIZE_T );
c.setCoarseningBoxIndex(coarseningBoxIndex);
c.setCoarseningBoxIndex( coarseningBoxIndex );
}
}
}
@@ -411,89 +402,91 @@ size_t RigGridBase::addCoarseningBox(size_t i1, size_t i2, size_t j1, size_t j2,
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigGridBase::coarseningBox(size_t coarseningBoxIndex, size_t* i1, size_t* i2, size_t* j1, size_t* j2, size_t* k1, size_t* k2) const
void RigGridBase::coarseningBox(
size_t coarseningBoxIndex, size_t* i1, size_t* i2, size_t* j1, size_t* j2, size_t* k1, size_t* k2 ) const
{
CVF_ASSERT(coarseningBoxIndex < m_coarseningBoxInfo.size());
CVF_ASSERT( coarseningBoxIndex < m_coarseningBoxInfo.size() );
CVF_ASSERT(i1 && i2 && j1 && j2 && k1 && k2);
CVF_ASSERT( i1 && i2 && j1 && j2 && k1 && k2 );
const std::array<size_t, 6>& box = m_coarseningBoxInfo[coarseningBoxIndex];
*i1 = box[0];
*i2 = box[1];
*j1 = box[2];
*j2 = box[3];
*k1 = box[4];
*k2 = box[5];
*i1 = box[0];
*i2 = box[1];
*j1 = box[2];
*j2 = box[3];
*k1 = box[4];
*k2 = box[5];
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RigGridBase::boundingBox()
{
if (!m_boundingBox.isValid())
if ( !m_boundingBox.isValid() )
{
cvf::Vec3d cornerVerts[8];
for (size_t i = 0; i < cellCount(); i++)
for ( size_t i = 0; i < cellCount(); i++ )
{
cellCornerVertices(i, cornerVerts);
cellCornerVertices( i, cornerVerts );
for (size_t j = 0; j < 8; j++)
for ( size_t j = 0; j < 8; j++ )
{
m_boundingBox.add(cornerVerts[j]);
m_boundingBox.add( cornerVerts[j] );
}
}
}
return m_boundingBox;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigGridCellFaceVisibilityFilter::isFaceVisible(size_t i, size_t j, size_t k, cvf::StructGridInterface::FaceType face, const cvf::UByteArray* cellVisibility) const
bool RigGridCellFaceVisibilityFilter::isFaceVisible(
size_t i, size_t j, size_t k, cvf::StructGridInterface::FaceType face, const cvf::UByteArray* cellVisibility ) const
{
CVF_TIGHT_ASSERT(m_grid);
CVF_TIGHT_ASSERT( m_grid );
size_t cellIndex = m_grid->cellIndexFromIJK(i, j, k);
if (m_grid->cell(cellIndex).subGrid())
size_t cellIndex = m_grid->cellIndexFromIJK( i, j, k );
if ( m_grid->cell( cellIndex ).subGrid() )
{
// Do not show any faces in the place where a LGR is present
return false;
return false;
}
size_t ni, nj, nk;
cvf::StructGridInterface::neighborIJKAtCellFace(i, j, k, face, &ni, &nj, &nk);
cvf::StructGridInterface::neighborIJKAtCellFace( i, j, k, face, &ni, &nj, &nk );
// If the cell is on the edge of the grid, Interpret as having an invisible neighbour
if (ni >= m_grid->cellCountI() || nj >= m_grid->cellCountJ() || nk >= m_grid->cellCountK())
if ( ni >= m_grid->cellCountI() || nj >= m_grid->cellCountJ() || nk >= m_grid->cellCountK() )
{
return true;
}
size_t neighborCellIndex = m_grid->cellIndexFromIJK(ni, nj, nk);
size_t neighborCellIndex = m_grid->cellIndexFromIJK( ni, nj, nk );
// Do show the faces in the boarder between this grid and a possible LGR. Some of the LGR cells
// might not be visible.
if (m_grid->cell(neighborCellIndex).subGrid())
if ( m_grid->cell( neighborCellIndex ).subGrid() )
{
return true;
}
// Do not show cell geometry if a fault is present to avoid z fighting between surfaces
// It will always be a better solution to avoid geometry creation instead of part priority and polygon offset
size_t nativeResvCellIndex = m_grid->reservoirCellIndex(cellIndex);
const RigFault* fault = m_grid->mainGrid()->findFaultFromCellIndexAndCellFace(nativeResvCellIndex, face);
if (fault)
size_t nativeResvCellIndex = m_grid->reservoirCellIndex( cellIndex );
const RigFault* fault = m_grid->mainGrid()->findFaultFromCellIndexAndCellFace( nativeResvCellIndex, face );
if ( fault )
{
return false;
}
// If the neighbour cell is invisible, we need to draw the face
if ((cellVisibility != nullptr) && !(*cellVisibility)[neighborCellIndex])
if ( ( cellVisibility != nullptr ) && !( *cellVisibility )[neighborCellIndex] )
{
return true;
}

View File

@@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,16 +23,13 @@
#include "RifReaderInterface.h"
#include "RigFault.h"
#include "cvfVector3.h"
#include "cvfBoundingBox.h"
#include "cvfStructGrid.h"
#include "cvfStructGridGeometryGenerator.h"
#include "cvfVector3.h"
#include <vector>
#include <string>
#include <vector>
class RigMainGrid;
class RigCell;
@@ -41,47 +38,78 @@ class RigActiveCellInfo;
class RigGridBase : public cvf::StructGridInterface
{
public:
explicit RigGridBase(RigMainGrid* mainGrid);
explicit RigGridBase( RigMainGrid* mainGrid );
~RigGridBase() override;
void setGridPointDimensions(const cvf::Vec3st& gridDimensions) { m_gridPointDimensions = gridDimensions;}
cvf::Vec3st gridPointDimensions() { return m_gridPointDimensions; }
void setGridPointDimensions( const cvf::Vec3st& gridDimensions )
{
m_gridPointDimensions = gridDimensions;
}
cvf::Vec3st gridPointDimensions()
{
return m_gridPointDimensions;
}
size_t cellCount() const { return cellCountI() * cellCountJ() * cellCountK(); }
RigCell& cell(size_t gridLocalCellIndex);
const RigCell& cell(size_t gridLocalCellIndex) const;
size_t reservoirCellIndex(size_t gridLocalCellIndex) const;
void setIndexToStartOfCells(size_t indexToStartOfCells) { m_indexToStartOfCells = indexToStartOfCells; }
void setGridIndex(size_t index) { m_gridIndex = index; }
size_t gridIndex() const { return m_gridIndex; }
size_t cellCount() const
{
return cellCountI() * cellCountJ() * cellCountK();
}
RigCell& cell( size_t gridLocalCellIndex );
const RigCell& cell( size_t gridLocalCellIndex ) const;
void setGridId(int id) { m_gridId = id; }
int gridId() const { return m_gridId; }
size_t reservoirCellIndex( size_t gridLocalCellIndex ) const;
void setIndexToStartOfCells( size_t indexToStartOfCells )
{
m_indexToStartOfCells = indexToStartOfCells;
}
double characteristicIJCellSize() const;
void setGridIndex( size_t index )
{
m_gridIndex = index;
}
size_t gridIndex() const
{
return m_gridIndex;
}
std::string gridName() const;
void setGridName(const std::string& gridName);
void setGridId( int id )
{
m_gridId = id;
}
int gridId() const
{
return m_gridId;
}
bool isMainGrid() const;
RigMainGrid* mainGrid() const { return m_mainGrid; }
double characteristicIJCellSize() const;
size_t coarseningBoxCount() const { return m_coarseningBoxInfo.size(); }
size_t addCoarseningBox(size_t i1, size_t i2, size_t j1, size_t j2, size_t k1, size_t k2);
std::string gridName() const;
void setGridName( const std::string& gridName );
void coarseningBox(size_t coarseningBoxIndex, size_t* i1, size_t* i2, size_t* j1, size_t* j2, size_t* k1, size_t* k2) const;
bool isMainGrid() const;
RigMainGrid* mainGrid() const
{
return m_mainGrid;
}
cvf::BoundingBox boundingBox();
size_t coarseningBoxCount() const
{
return m_coarseningBoxInfo.size();
}
size_t addCoarseningBox( size_t i1, size_t i2, size_t j1, size_t j2, size_t k1, size_t k2 );
virtual bool isTempGrid() const = 0;
virtual const std::string& associatedWellPathName() const = 0;
void coarseningBox(
size_t coarseningBoxIndex, size_t* i1, size_t* i2, size_t* j1, size_t* j2, size_t* k1, size_t* k2 ) const;
cvf::BoundingBox boundingBox();
virtual bool isTempGrid() const = 0;
virtual const std::string& associatedWellPathName() const = 0;
protected:
friend class RigMainGrid;//::initAllSubGridsParentGridPointer();
void initSubGridParentPointer();
void initSubCellsMainGridCellIndex();
friend class RigMainGrid; //::initAllSubGridsParentGridPointer();
void initSubGridParentPointer();
void initSubCellsMainGridCellIndex();
// Interface implementation
public:
@@ -94,42 +122,45 @@ public:
cvf::Vec3d displayModelOffset() const override;
size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override;
bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override;
bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override;
bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const override;
void cellCornerVertices( size_t cellIndex, cvf::Vec3d vertices[8] ) const override;
bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const override;
void cellCornerVertices( size_t cellIndex, cvf::Vec3d vertices[8] ) const override;
cvf::Vec3d cellCentroid( size_t cellIndex ) const override;
void cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate ) const override;
size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const override;
size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const override;
cvf::Vec3d gridPointCoordinate( size_t i, size_t j, size_t k ) const override;
bool isCellValid( size_t i, size_t j, size_t k ) const override;
bool cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex ) const override;
bool cellIJKNeighbor( size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex ) const override;
private:
std::string m_gridName;
cvf::Vec3st m_gridPointDimensions;
size_t m_indexToStartOfCells; ///< Index into the global cell array stored in main-grid where this grids cells starts.
size_t m_gridIndex; ///< The LGR index of this grid. Starts with 1. Main grid has index 0.
int m_gridId; ///< The LGR id of this grid. Main grid has id 0.
RigMainGrid* m_mainGrid;
cvf::BoundingBox m_boundingBox;
std::string m_gridName;
cvf::Vec3st m_gridPointDimensions;
size_t m_indexToStartOfCells; ///< Index into the global cell array stored in main-grid where this grids cells starts.
size_t m_gridIndex; ///< The LGR index of this grid. Starts with 1. Main grid has index 0.
int m_gridId; ///< The LGR id of this grid. Main grid has id 0.
RigMainGrid* m_mainGrid;
cvf::BoundingBox m_boundingBox;
std::vector<std::array<size_t, 6>> m_coarseningBoxInfo;
std::vector<std::array<size_t, 6>> m_coarseningBoxInfo;
};
class RigGridCellFaceVisibilityFilter : public cvf::CellFaceVisibilityFilter
{
public:
explicit RigGridCellFaceVisibilityFilter(const RigGridBase* grid)
: m_grid(grid)
explicit RigGridCellFaceVisibilityFilter( const RigGridBase* grid )
: m_grid( grid )
{
}
bool isFaceVisible( size_t i, size_t j, size_t k, cvf::StructGridInterface::FaceType face, const cvf::UByteArray* cellVisibility ) const override;
bool isFaceVisible( size_t i,
size_t j,
size_t k,
cvf::StructGridInterface::FaceType face,
const cvf::UByteArray* cellVisibility ) const override;
private:
const RigGridBase* m_grid;

View File

@@ -24,4 +24,3 @@ enum RigGridCrossPlotCurveGrouping
GROUP_BY_FORMATION,
GROUP_BY_RESULT
};

View File

@@ -24,22 +24,22 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridManager::addCase(RigEclipseCaseData* eclipseCase)
void RigGridManager::addCase( RigEclipseCaseData* eclipseCase )
{
cvf::ref<CaseToGridMap> caseAndGrid = new CaseToGridMap(eclipseCase, eclipseCase->mainGrid());
m_caseToGrid.push_back(caseAndGrid.p());
cvf::ref<CaseToGridMap> caseAndGrid = new CaseToGridMap( eclipseCase, eclipseCase->mainGrid() );
m_caseToGrid.push_back( caseAndGrid.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridManager::removeCase(RigEclipseCaseData* eclipseCase)
void RigGridManager::removeCase( RigEclipseCaseData* eclipseCase )
{
for (size_t i = 0; i < m_caseToGrid.size(); i++)
for ( size_t i = 0; i < m_caseToGrid.size(); i++ )
{
if (m_caseToGrid[i]->m_eclipseCase == eclipseCase)
if ( m_caseToGrid[i]->m_eclipseCase == eclipseCase )
{
m_caseToGrid.eraseAt(i);
m_caseToGrid.eraseAt( i );
return;
}
}
@@ -48,12 +48,12 @@ void RigGridManager::removeCase(RigEclipseCaseData* eclipseCase)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigMainGrid* RigGridManager::findEqualGrid(RigMainGrid* candidateGrid)
RigMainGrid* RigGridManager::findEqualGrid( RigMainGrid* candidateGrid )
{
for (size_t i = 0; i < m_caseToGrid.size(); i++)
for ( size_t i = 0; i < m_caseToGrid.size(); i++ )
{
RigMainGrid* mainGrid = m_caseToGrid.at(i)->m_mainGrid;
if (RigGridManager::isEqual(mainGrid, candidateGrid))
RigMainGrid* mainGrid = m_caseToGrid.at( i )->m_mainGrid;
if ( RigGridManager::isEqual( mainGrid, candidateGrid ) )
{
return mainGrid;
}
@@ -64,19 +64,19 @@ RigMainGrid* RigGridManager::findEqualGrid(RigMainGrid* candidateGrid)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGridManager::isEqual(RigMainGrid* gridA, RigMainGrid* gridB)
bool RigGridManager::isEqual( RigMainGrid* gridA, RigMainGrid* gridB )
{
if (gridA == nullptr || gridB == nullptr) return false;
if ( gridA == nullptr || gridB == nullptr ) return false;
if (gridA == gridB) return true;
if ( gridA == gridB ) return true;
if (gridA->gridCount() != gridB->gridCount()) return false;
if ( gridA->gridCount() != gridB->gridCount() ) return false;
if (gridA->nodes().size() != gridB->nodes().size()) return false;
if ( gridA->nodes().size() != gridB->nodes().size() ) return false;
for (size_t i = 0; i < gridA->nodes().size(); i++)
for ( size_t i = 0; i < gridA->nodes().size(); i++ )
{
if (!gridA->nodes()[i].equals(gridB->nodes()[i]))
if ( !gridA->nodes()[i].equals( gridB->nodes()[i] ) )
{
return false;
}
@@ -96,22 +96,22 @@ void RigGridManager::clear()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGridManager::isGridDimensionsEqual(const std::vector<std::vector<int>>& mainCaseGridDimensions,
const std::vector<std::vector<int>>& caseGridDimensions)
bool RigGridManager::isGridDimensionsEqual( const std::vector<std::vector<int>>& mainCaseGridDimensions,
const std::vector<std::vector<int>>& caseGridDimensions )
{
if (mainCaseGridDimensions.size() != caseGridDimensions.size())
if ( mainCaseGridDimensions.size() != caseGridDimensions.size() )
{
return false;
}
for (size_t j = 0; j < mainCaseGridDimensions.size(); j++)
for ( size_t j = 0; j < mainCaseGridDimensions.size(); j++ )
{
if (mainCaseGridDimensions[j].size() != 4) return false;
if (caseGridDimensions[j].size() != 4) return false;
if ( mainCaseGridDimensions[j].size() != 4 ) return false;
if ( caseGridDimensions[j].size() != 4 ) return false;
if (mainCaseGridDimensions[j][0] != caseGridDimensions[j][0]) return false; // nx
if (mainCaseGridDimensions[j][1] != caseGridDimensions[j][1]) return false; // ny
if (mainCaseGridDimensions[j][2] != caseGridDimensions[j][2]) return false; // nz
if ( mainCaseGridDimensions[j][0] != caseGridDimensions[j][0] ) return false; // nx
if ( mainCaseGridDimensions[j][1] != caseGridDimensions[j][1] ) return false; // ny
if ( mainCaseGridDimensions[j][2] != caseGridDimensions[j][2] ) return false; // nz
}
return true;
@@ -120,15 +120,15 @@ bool RigGridManager::isGridDimensionsEqual(const std::vector<std::vector<int>>&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGridManager::isMainGridDimensionsEqual(RigMainGrid* gridA, RigMainGrid* gridB)
bool RigGridManager::isMainGridDimensionsEqual( RigMainGrid* gridA, RigMainGrid* gridB )
{
if (gridA == nullptr || gridB == nullptr) return false;
if ( gridA == nullptr || gridB == nullptr ) return false;
if (gridA == gridB) return true;
if ( gridA == gridB ) return true;
if (gridA->cellCountI() != gridB->cellCountI()) return false;
if (gridA->cellCountJ() != gridB->cellCountJ()) return false;
if (gridA->cellCountK() != gridB->cellCountK()) return false;
if ( gridA->cellCountI() != gridB->cellCountI() ) return false;
if ( gridA->cellCountJ() != gridB->cellCountJ() ) return false;
if ( gridA->cellCountK() != gridB->cellCountK() ) return false;
return true;
}
@@ -136,8 +136,8 @@ bool RigGridManager::isMainGridDimensionsEqual(RigMainGrid* gridA, RigMainGrid*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGridManager::CaseToGridMap::CaseToGridMap(RigEclipseCaseData* eclipseCase, RigMainGrid* mainGrid)
: m_eclipseCase(eclipseCase)
, m_mainGrid(mainGrid)
RigGridManager::CaseToGridMap::CaseToGridMap( RigEclipseCaseData* eclipseCase, RigMainGrid* mainGrid )
: m_eclipseCase( eclipseCase )
, m_mainGrid( mainGrid )
{
}

View File

@@ -18,7 +18,6 @@
#pragma once
#include "cvfCollection.h"
#include "cvfObject.h"
@@ -30,24 +29,24 @@ class RigEclipseCaseData;
class RigGridManager : public cvf::Object
{
public:
void addCase(RigEclipseCaseData* eclipseCase);
void addCase( RigEclipseCaseData* eclipseCase );
void removeCase(RigEclipseCaseData* eclipseCase);
void removeCase( RigEclipseCaseData* eclipseCase );
RigMainGrid* findEqualGrid(RigMainGrid* candidateGrid);
RigMainGrid* findEqualGrid( RigMainGrid* candidateGrid );
void clear();
static bool isEqual(RigMainGrid* gridA, RigMainGrid* gridB);
static bool isMainGridDimensionsEqual(RigMainGrid* gridA, RigMainGrid* gridB);
static bool isGridDimensionsEqual(const std::vector<std::vector<int>>& mainCaseGridDimensions,
const std::vector<std::vector<int>>& caseGridDimensions);
static bool isEqual( RigMainGrid* gridA, RigMainGrid* gridB );
static bool isMainGridDimensionsEqual( RigMainGrid* gridA, RigMainGrid* gridB );
static bool isGridDimensionsEqual( const std::vector<std::vector<int>>& mainCaseGridDimensions,
const std::vector<std::vector<int>>& caseGridDimensions );
private:
class CaseToGridMap : public cvf::Object
{
public:
CaseToGridMap(RigEclipseCaseData* eclipseCase, RigMainGrid* mainGrid);
CaseToGridMap( RigEclipseCaseData* eclipseCase, RigMainGrid* mainGrid );
RigEclipseCaseData* m_eclipseCase;
RigMainGrid* m_mainGrid;

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,179 +20,179 @@
#include "cvfLibCore.h"
#include "cvfObject.h"
#include "cvfAssert.h"
#include "cvfObject.h"
#include "RigMainGrid.h"
#include "RigCaseCellResultsData.h"
#include "RigActiveCellInfo.h"
#include "RigGridBase.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigGridBase.h"
#include "RigMainGrid.h"
#include <math.h>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RigGridAllCellsScalarDataAccess : public cvf::StructGridScalarDataAccess
{
public:
RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector<double>* reservoirResultValues);
RigGridAllCellsScalarDataAccess( const RigGridBase* grid, std::vector<double>* reservoirResultValues );
virtual double cellScalar(size_t gridLocalCellIndex) const;
virtual void setCellScalar(size_t cellIndex, double value);
virtual double cellScalar( size_t gridLocalCellIndex ) const;
virtual void setCellScalar( size_t cellIndex, double value );
private:
const RigGridBase* m_grid;
std::vector<double>* m_reservoirResultValues;
const RigGridBase* m_grid;
std::vector<double>* m_reservoirResultValues;
};
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector<double>* reservoirResultValues)
: m_grid(grid),
m_reservoirResultValues(reservoirResultValues)
RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess( const RigGridBase* grid,
std::vector<double>* reservoirResultValues )
: m_grid( grid )
, m_reservoirResultValues( reservoirResultValues )
{
CVF_ASSERT(reservoirResultValues != NULL);
CVF_ASSERT(grid != NULL);
CVF_ASSERT( reservoirResultValues != NULL );
CVF_ASSERT( grid != NULL );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigGridAllCellsScalarDataAccess::cellScalar(size_t gridLocalCellIndex) const
double RigGridAllCellsScalarDataAccess::cellScalar( size_t gridLocalCellIndex ) const
{
if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
if ( m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex);
CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size());
size_t globalGridCellIndex = m_grid->globalGridCellIndex( gridLocalCellIndex );
CVF_TIGHT_ASSERT( globalGridCellIndex < m_reservoirResultValues->size() );
return m_reservoirResultValues->at(globalGridCellIndex);
return m_reservoirResultValues->at( globalGridCellIndex );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigGridAllCellsScalarDataAccess::setCellScalar(size_t gridLocalCellIndex, double scalarValue)
void RigGridAllCellsScalarDataAccess::setCellScalar( size_t gridLocalCellIndex, double scalarValue )
{
size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex);
CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size());
size_t globalGridCellIndex = m_grid->globalGridCellIndex( gridLocalCellIndex );
CVF_TIGHT_ASSERT( globalGridCellIndex < m_reservoirResultValues->size() );
(*m_reservoirResultValues)[globalGridCellIndex] = scalarValue;
( *m_reservoirResultValues )[globalGridCellIndex] = scalarValue;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RigGridActiveCellsScalarDataAccess : public cvf::StructGridScalarDataAccess
{
public:
RigGridActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector<double>* reservoirResultValues, const RigActiveCellInfo* activeCellInfo)
: m_grid(grid),
m_reservoirResultValues(reservoirResultValues),
m_activeCellInfo(activeCellInfo)
{
RigGridActiveCellsScalarDataAccess( const RigGridBase* grid,
std::vector<double>* reservoirResultValues,
const RigActiveCellInfo* activeCellInfo )
: m_grid( grid )
, m_reservoirResultValues( reservoirResultValues )
, m_activeCellInfo( activeCellInfo )
{
CVF_ASSERT( grid != NULL );
}
CVF_ASSERT(grid != NULL);
}
virtual double cellScalar( size_t gridLocalCellIndex ) const
{
if ( m_reservoirResultValues == NULL || m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
virtual double cellScalar(size_t gridLocalCellIndex) const
{
if (m_reservoirResultValues == NULL || m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
size_t globalGridCellIndex = m_grid->globalGridCellIndex( gridLocalCellIndex );
size_t resultValueIndex = m_activeCellInfo->cellResultIndex( globalGridCellIndex );
if ( resultValueIndex == cvf::UNDEFINED_SIZE_T ) return HUGE_VAL;
size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex);
size_t resultValueIndex = m_activeCellInfo->cellResultIndex(globalGridCellIndex);
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
CVF_TIGHT_ASSERT( resultValueIndex < m_reservoirResultValues->size() );
CVF_TIGHT_ASSERT(resultValueIndex < m_reservoirResultValues->size());
return m_reservoirResultValues->at( resultValueIndex );
}
return m_reservoirResultValues->at(resultValueIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
virtual void setCellScalar( size_t gridLocalCellIndex, double scalarValue )
{
size_t globalGridCellIndex = m_grid->globalGridCellIndex( gridLocalCellIndex );
size_t resultValueIndex = m_activeCellInfo->cellResultIndex( globalGridCellIndex );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
virtual void setCellScalar(size_t gridLocalCellIndex, double scalarValue)
{
size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex);
size_t resultValueIndex = m_activeCellInfo->cellResultIndex(globalGridCellIndex);
CVF_TIGHT_ASSERT( m_reservoirResultValues != NULL && resultValueIndex < m_reservoirResultValues->size() );
CVF_TIGHT_ASSERT(m_reservoirResultValues != NULL && resultValueIndex < m_reservoirResultValues->size());
(*m_reservoirResultValues)[resultValueIndex] = scalarValue;
}
( *m_reservoirResultValues )[resultValueIndex] = scalarValue;
}
private:
const RigActiveCellInfo* m_activeCellInfo;
const RigGridBase* m_grid;
std::vector<double>* m_reservoirResultValues;
const RigActiveCellInfo* m_activeCellInfo;
const RigGridBase* m_grid;
std::vector<double>* m_reservoirResultValues;
};
class StructGridScalarDataAccessHugeVal : public cvf::StructGridScalarDataAccess
{
public:
virtual double cellScalar(size_t cellIndex) const
virtual double cellScalar( size_t cellIndex ) const
{
return HUGE_VAL;
}
virtual void setCellScalar(size_t cellIndex, double value)
{
}
virtual void setCellScalar( size_t cellIndex, double value ) {}
};
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::StructGridScalarDataAccess> RigResultAccessObjectFactory::createNativeDataAccessObject(RigCaseData* eclipseCase,
size_t gridIndex,
RifReaderInterface::PorosityModelResultType porosityModel,
size_t timeStepIndex,
size_t scalarSetIndex)
cvf::ref<cvf::StructGridScalarDataAccess>
RigResultAccessObjectFactory::createNativeDataAccessObject( RigCaseData* eclipseCase,
size_t gridIndex,
RifReaderInterface::PorosityModelResultType porosityModel,
size_t timeStepIndex,
size_t scalarSetIndex )
{
CVF_ASSERT(gridIndex < eclipseCase->gridCount());
CVF_ASSERT(eclipseCase);
CVF_ASSERT(eclipseCase->results(porosityModel));
CVF_ASSERT(eclipseCase->activeCellInfo(porosityModel));
CVF_ASSERT( gridIndex < eclipseCase->gridCount() );
CVF_ASSERT( eclipseCase );
CVF_ASSERT( eclipseCase->results( porosityModel ) );
CVF_ASSERT( eclipseCase->activeCellInfo( porosityModel ) );
RigGridBase *grid = eclipseCase->grid(gridIndex);
RigGridBase* grid = eclipseCase->grid( gridIndex );
if (!eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel))
if ( !eclipseCase || !eclipseCase->results( porosityModel ) || !eclipseCase->activeCellInfo( porosityModel ) )
{
return NULL;
}
std::vector< std::vector<double> >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarSetIndex);
std::vector<std::vector<double>>& scalarSetResults = eclipseCase->results( porosityModel )
->cellScalarResults( scalarSetIndex );
// A generated result with a generated results for a subset of time steps, will end up with a result container with less entries than time steps
// See RiaSetGridProperty command in RiaPropertyDataCommands
// A generated result with a generated results for a subset of time steps, will end up with a result container with
// less entries than time steps See RiaSetGridProperty command in RiaPropertyDataCommands
//
// Some functions requires a valid data access object to be present, these might be rewritten to avoid this dummy object always returning HUGE_VAL
if (timeStepIndex >= scalarSetResults.size())
// Some functions requires a valid data access object to be present, these might be rewritten to avoid this dummy
// object always returning HUGE_VAL
if ( timeStepIndex >= scalarSetResults.size() )
{
cvf::ref<cvf::StructGridScalarDataAccess> object = new StructGridScalarDataAccessHugeVal;
cvf::ref<cvf::StructGridScalarDataAccess> object = new StructGridScalarDataAccessHugeVal;
return object;
return object;
}
std::vector<double>* resultValues = NULL;
if (timeStepIndex < scalarSetResults.size())
if ( timeStepIndex < scalarSetResults.size() )
{
resultValues = &(scalarSetResults[timeStepIndex]);
resultValues = &( scalarSetResults[timeStepIndex] );
}
bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex);
if (useGlobalActiveIndex)
bool useGlobalActiveIndex = eclipseCase->results( porosityModel )->isUsingGlobalActiveIndex( scalarSetIndex );
if ( useGlobalActiveIndex )
{
cvf::ref<cvf::StructGridScalarDataAccess> object = new RigGridActiveCellsScalarDataAccess(grid, resultValues, eclipseCase->activeCellInfo(porosityModel));
cvf::ref<cvf::StructGridScalarDataAccess> object =
new RigGridActiveCellsScalarDataAccess( grid, resultValues, eclipseCase->activeCellInfo( porosityModel ) );
return object;
}
else
{
cvf::ref<cvf::StructGridScalarDataAccess> object = new RigGridAllCellsScalarDataAccess(grid, resultValues);
cvf::ref<cvf::StructGridScalarDataAccess> object = new RigGridAllCellsScalarDataAccess( grid, resultValues );
return object;
}
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,55 +25,57 @@
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
int RigHexIntersectionTools::lineHexCellIntersection(const cvf::Vec3d p1,
const cvf::Vec3d p2,
const cvf::Vec3d hexCorners[8],
const size_t hexIndex,
std::vector<HexIntersectionInfo>* intersections)
int RigHexIntersectionTools::lineHexCellIntersection( const cvf::Vec3d p1,
const cvf::Vec3d p2,
const cvf::Vec3d hexCorners[8],
const size_t hexIndex,
std::vector<HexIntersectionInfo>* intersections )
{
CVF_ASSERT(intersections != nullptr);
CVF_ASSERT( intersections != nullptr );
std::set<HexIntersectionInfo> uniqueIntersections;
for ( int face = 0; face < 6 ; ++face )
for ( int face = 0; face < 6; ++face )
{
cvf::ubyte faceVertexIndices[4];
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( static_cast<cvf::StructGridInterface::FaceType>( face ),
faceVertexIndices );
cvf::Vec3d intersection;
bool isEntering = false;
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]],
hexCorners[faceVertexIndices[1]],
hexCorners[faceVertexIndices[2]],
hexCorners[faceVertexIndices[3]]);
bool isEntering = false;
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter( hexCorners[faceVertexIndices[0]],
hexCorners[faceVertexIndices[1]],
hexCorners[faceVertexIndices[2]],
hexCorners[faceVertexIndices[3]] );
for ( int i = 0; i < 4; ++i )
{
int next = i < 3 ? i+1 : 0;
int next = i < 3 ? i + 1 : 0;
int intsStatus = cvf::GeometryTools::intersectLineSegmentTriangle(p1, p2,
hexCorners[faceVertexIndices[i]],
hexCorners[faceVertexIndices[next]],
faceCenter,
&intersection,
&isEntering);
int intsStatus = cvf::GeometryTools::intersectLineSegmentTriangle( p1,
p2,
hexCorners[faceVertexIndices[i]],
hexCorners[faceVertexIndices[next]],
faceCenter,
&intersection,
&isEntering );
if ( intsStatus == 1 )
{
uniqueIntersections.insert(HexIntersectionInfo(intersection,
isEntering,
static_cast<cvf::StructGridInterface::FaceType>(face), hexIndex));
uniqueIntersections.insert( HexIntersectionInfo( intersection,
isEntering,
static_cast<cvf::StructGridInterface::FaceType>( face ),
hexIndex ) );
}
}
}
int intersectionCount = 0;
for ( const auto& intersection: uniqueIntersections)
for ( const auto& intersection : uniqueIntersections )
{
intersections->push_back(intersection);
intersections->push_back( intersection );
++intersectionCount;
}
@@ -83,31 +85,35 @@ int RigHexIntersectionTools::lineHexCellIntersection(const cvf::Vec3d p1,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigHexIntersectionTools::lineIntersectsHexCell(const cvf::Vec3d p1, const cvf::Vec3d p2, const cvf::Vec3d hexCorners[8])
bool RigHexIntersectionTools::lineIntersectsHexCell( const cvf::Vec3d p1,
const cvf::Vec3d p2,
const cvf::Vec3d hexCorners[8] )
{
for (int face = 0; face < 6; ++face)
for ( int face = 0; face < 6; ++face )
{
cvf::ubyte faceVertexIndices[4];
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( static_cast<cvf::StructGridInterface::FaceType>( face ),
faceVertexIndices );
cvf::Vec3d intersection;
bool isEntering = false;
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]],
hexCorners[faceVertexIndices[1]],
hexCorners[faceVertexIndices[2]],
hexCorners[faceVertexIndices[3]]);
bool isEntering = false;
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter( hexCorners[faceVertexIndices[0]],
hexCorners[faceVertexIndices[1]],
hexCorners[faceVertexIndices[2]],
hexCorners[faceVertexIndices[3]] );
for (int i = 0; i < 4; ++i)
for ( int i = 0; i < 4; ++i )
{
int next = i < 3 ? i + 1 : 0;
int intsStatus = cvf::GeometryTools::intersectLineSegmentTriangle(p1, p2,
hexCorners[faceVertexIndices[i]],
hexCorners[faceVertexIndices[next]],
faceCenter,
&intersection,
&isEntering);
if (intsStatus == 1)
int intsStatus = cvf::GeometryTools::intersectLineSegmentTriangle( p1,
p2,
hexCorners[faceVertexIndices[i]],
hexCorners[faceVertexIndices[next]],
faceCenter,
&intersection,
&isEntering );
if ( intsStatus == 1 )
{
return true;
}
@@ -117,28 +123,28 @@ bool RigHexIntersectionTools::lineIntersectsHexCell(const cvf::Vec3d p1, const c
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigHexIntersectionTools::isPointInCell(const cvf::Vec3d point,
const cvf::Vec3d hexCorners[8])
bool RigHexIntersectionTools::isPointInCell( const cvf::Vec3d point, const cvf::Vec3d hexCorners[8] )
{
cvf::Ray ray;
ray.setOrigin(point);
ray.setOrigin( point );
size_t intersections = 0;
for ( int face = 0; face < 6; ++face )
{
cvf::ubyte faceVertexIndices[4];
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]],
hexCorners[faceVertexIndices[1]],
hexCorners[faceVertexIndices[2]],
hexCorners[faceVertexIndices[3]]);
cvf::StructGridInterface::cellFaceVertexIndices( static_cast<cvf::StructGridInterface::FaceType>( face ),
faceVertexIndices );
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter( hexCorners[faceVertexIndices[0]],
hexCorners[faceVertexIndices[1]],
hexCorners[faceVertexIndices[2]],
hexCorners[faceVertexIndices[3]] );
for ( int i = 0; i < 4; ++i )
{
int next = i < 3 ? i + 1 : 0;
if ( ray.triangleIntersect(hexCorners[faceVertexIndices[i]], hexCorners[faceVertexIndices[next]], faceCenter) )
if ( ray.triangleIntersect( hexCorners[faceVertexIndices[i]], hexCorners[faceVertexIndices[next]], faceCenter ) )
{
++intersections;
}
@@ -148,79 +154,96 @@ bool RigHexIntersectionTools::isPointInCell(const cvf::Vec3d point,
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigHexIntersectionTools::planeHexCellIntersection(cvf::Vec3d* hexCorners, const cvf::Plane& fracturePlane, std::list<std::pair<cvf::Vec3d, cvf::Vec3d > >& intersectionLineSegments)
bool RigHexIntersectionTools::planeHexCellIntersection( cvf::Vec3d* hexCorners,
const cvf::Plane& fracturePlane,
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>>& intersectionLineSegments )
{
bool isCellIntersected = false;
cvf::ubyte faceVertexIndices[4];
caf::HexGridIntersectionTools::ClipVx triangleIntersectionPoint1;
caf::HexGridIntersectionTools::ClipVx triangleIntersectionPoint2;
bool isMostVxesOnPositiveSideOfP1 = false;
bool isCellIntersected = false;
cvf::ubyte faceVertexIndices[4];
caf::HexGridIntersectionTools::ClipVx triangleIntersectionPoint1;
caf::HexGridIntersectionTools::ClipVx triangleIntersectionPoint2;
bool isMostVxesOnPositiveSideOfP1 = false;
for (int face = 0; face < 6; ++face)
for ( int face = 0; face < 6; ++face )
{
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
cvf::StructGridInterface::cellFaceVertexIndices( static_cast<cvf::StructGridInterface::FaceType>( face ),
faceVertexIndices );
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]], hexCorners[faceVertexIndices[1]], hexCorners[faceVertexIndices[2]], hexCorners[faceVertexIndices[3]]);
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter( hexCorners[faceVertexIndices[0]],
hexCorners[faceVertexIndices[1]],
hexCorners[faceVertexIndices[2]],
hexCorners[faceVertexIndices[3]] );
for (int i = 0; i < 4; i++)
for ( int i = 0; i < 4; i++ )
{
int next = i < 3 ? i + 1 : 0;
bool isIntersectingPlane = caf::HexGridIntersectionTools::planeTriangleIntersection(fracturePlane,
hexCorners[faceVertexIndices[i]], 0,
hexCorners[faceVertexIndices[next]], 1,
faceCenter, 2,
&triangleIntersectionPoint1, &triangleIntersectionPoint2, &isMostVxesOnPositiveSideOfP1);
bool isIntersectingPlane =
caf::HexGridIntersectionTools::planeTriangleIntersection( fracturePlane,
hexCorners[faceVertexIndices[i]],
0,
hexCorners[faceVertexIndices[next]],
1,
faceCenter,
2,
&triangleIntersectionPoint1,
&triangleIntersectionPoint2,
&isMostVxesOnPositiveSideOfP1 );
if (isIntersectingPlane)
if ( isIntersectingPlane )
{
isCellIntersected = true;
intersectionLineSegments.emplace_back( triangleIntersectionPoint1.vx, triangleIntersectionPoint2.vx );
}
}
} return isCellIntersected;
}
return isCellIntersected;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigHexIntersectionTools::planeHexIntersectionPolygons(std::array<cvf::Vec3d, 8> hexCorners,
cvf::Mat4d transformMatrixForPlane,
std::vector<std::vector<cvf::Vec3d> >& polygons)
bool RigHexIntersectionTools::planeHexIntersectionPolygons( std::array<cvf::Vec3d, 8> hexCorners,
cvf::Mat4d transformMatrixForPlane,
std::vector<std::vector<cvf::Vec3d>>& polygons )
{
bool isCellIntersected = false;
cvf::Plane fracturePlane;
fracturePlane.setFromPointAndNormal(transformMatrixForPlane.translation(),
static_cast<cvf::Vec3d>(transformMatrixForPlane.col(2)));
fracturePlane.setFromPointAndNormal( transformMatrixForPlane.translation(),
static_cast<cvf::Vec3d>( transformMatrixForPlane.col( 2 ) ) );
//Find line-segments where cell and fracture plane intersects
std::list<std::pair<cvf::Vec3d, cvf::Vec3d > > intersectionLineSegments;
// Find line-segments where cell and fracture plane intersects
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>> intersectionLineSegments;
isCellIntersected = planeHexCellIntersection(hexCorners.data(), fracturePlane, intersectionLineSegments);
isCellIntersected = planeHexCellIntersection( hexCorners.data(), fracturePlane, intersectionLineSegments );
RigCellGeometryTools::createPolygonFromLineSegments(intersectionLineSegments, polygons);
RigCellGeometryTools::createPolygonFromLineSegments( intersectionLineSegments, polygons );
return isCellIntersected;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool operator<(const HexIntersectionInfo& hi1, const HexIntersectionInfo& hi2)
bool operator<( const HexIntersectionInfo& hi1, const HexIntersectionInfo& hi2 )
{
const double tolerance = 1e-6;
if ( hi1.m_hexIndex != hi2.m_hexIndex ) return hi1.m_hexIndex < hi2.m_hexIndex;
if ( hi1.m_face != hi2.m_face ) return hi1.m_face < hi2.m_face;
if ( hi1.m_isIntersectionEntering != hi2.m_isIntersectionEntering ) return hi1.m_isIntersectionEntering < hi2.m_isIntersectionEntering;
if ( hi1.m_isIntersectionEntering != hi2.m_isIntersectionEntering )
return hi1.m_isIntersectionEntering < hi2.m_isIntersectionEntering;
if ( hi1.m_face != hi2.m_face ) return hi1.m_face < hi2.m_face;
if ( cvf::Math::abs(hi2.m_intersectionPoint.x() - hi1.m_intersectionPoint.x()) > tolerance ) return hi1.m_intersectionPoint.x() < hi2.m_intersectionPoint.x();
if ( cvf::Math::abs(hi2.m_intersectionPoint.y() - hi1.m_intersectionPoint.y()) > tolerance ) return hi1.m_intersectionPoint.y() < hi2.m_intersectionPoint.y();
if ( cvf::Math::abs(hi2.m_intersectionPoint.z() - hi1.m_intersectionPoint.z()) > tolerance ) return hi1.m_intersectionPoint.z() < hi2.m_intersectionPoint.z();
if ( cvf::Math::abs( hi2.m_intersectionPoint.x() - hi1.m_intersectionPoint.x() ) > tolerance )
return hi1.m_intersectionPoint.x() < hi2.m_intersectionPoint.x();
if ( cvf::Math::abs( hi2.m_intersectionPoint.y() - hi1.m_intersectionPoint.y() ) > tolerance )
return hi1.m_intersectionPoint.y() < hi2.m_intersectionPoint.y();
if ( cvf::Math::abs( hi2.m_intersectionPoint.z() - hi1.m_intersectionPoint.z() ) > tolerance )
return hi1.m_intersectionPoint.z() < hi2.m_intersectionPoint.z();
return false;
}

View File

@@ -1,79 +1,74 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfVector3.h"
#include "cvfStructGrid.h"
#include "cvfPlane.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"
#include <array>
//==================================================================================================
/// Internal class for intersection point info
/// Internal class for intersection point info
//==================================================================================================
struct HexIntersectionInfo
{
public:
HexIntersectionInfo( cvf::Vec3d intersectionPoint,
bool isIntersectionEntering,
cvf::StructGridInterface::FaceType face,
size_t hexIndex)
: m_intersectionPoint(intersectionPoint),
m_isIntersectionEntering(isIntersectionEntering),
m_face(face),
m_hexIndex(hexIndex) {}
HexIntersectionInfo( cvf::Vec3d intersectionPoint,
bool isIntersectionEntering,
cvf::StructGridInterface::FaceType face,
size_t hexIndex )
: m_intersectionPoint( intersectionPoint )
, m_isIntersectionEntering( isIntersectionEntering )
, m_face( face )
, m_hexIndex( hexIndex )
{
}
cvf::Vec3d m_intersectionPoint;
bool m_isIntersectionEntering;
cvf::StructGridInterface::FaceType m_face;
size_t m_hexIndex;
cvf::Vec3d m_intersectionPoint;
bool m_isIntersectionEntering;
cvf::StructGridInterface::FaceType m_face;
size_t m_hexIndex;
};
bool operator<( const HexIntersectionInfo& hi1, const HexIntersectionInfo& hi2);
bool operator<( const HexIntersectionInfo& hi1, const HexIntersectionInfo& hi2 );
//--------------------------------------------------------------------------------------------------
/// Specialized Line - Hex intersection
//--------------------------------------------------------------------------------------------------
struct RigHexIntersectionTools
{
static int lineHexCellIntersection(const cvf::Vec3d p1,
const cvf::Vec3d p2,
const cvf::Vec3d hexCorners[8],
const size_t hexIndex,
std::vector<HexIntersectionInfo>* intersections);
static int lineHexCellIntersection( const cvf::Vec3d p1,
const cvf::Vec3d p2,
const cvf::Vec3d hexCorners[8],
const size_t hexIndex,
std::vector<HexIntersectionInfo>* intersections );
static bool lineIntersectsHexCell(const cvf::Vec3d p1,
const cvf::Vec3d p2,
const cvf::Vec3d hexCorners[8]);
static bool lineIntersectsHexCell( const cvf::Vec3d p1, const cvf::Vec3d p2, const cvf::Vec3d hexCorners[8] );
static bool isPointInCell(const cvf::Vec3d point, const cvf::Vec3d hexCorners[8]);
static bool isPointInCell( const cvf::Vec3d point, const cvf::Vec3d hexCorners[8] );
static bool planeHexCellIntersection(cvf::Vec3d* hexCorners,
const cvf::Plane& fracturePlane,
std::list<std::pair<cvf::Vec3d, cvf::Vec3d > >& intersectionLineSegments);
static bool planeHexCellIntersection( cvf::Vec3d* hexCorners,
const cvf::Plane& fracturePlane,
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>>& intersectionLineSegments );
static bool planeHexIntersectionPolygons(std::array<cvf::Vec3d, 8> hexCorners,
cvf::Mat4d transformMatrixForPlane,
std::vector<std::vector<cvf::Vec3d> > & polygons);
static bool planeHexIntersectionPolygons( std::array<cvf::Vec3d, 8> hexCorners,
cvf::Mat4d transformMatrixForPlane,
std::vector<std::vector<cvf::Vec3d>>& polygons );
};

Some files were not shown because too many files have changed in this diff Show More