2013-12-10 15:44:40 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-24 00:14:52 -05:00
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2013-12-10 15:44:40 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2013-12-10 15:44:40 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2013-12-10 15:44:40 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RigNNCData.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RigEclipseResultAddress.h"
|
2013-12-10 15:44:40 -06:00
|
|
|
#include "RigMainGrid.h"
|
2013-12-11 07:55:14 -06:00
|
|
|
#include "cvfGeometryTools.h"
|
2013-12-10 15:44:40 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2013-12-10 15:44:40 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RigNNCData::RigNNCData() {}
|
2013-12-10 15:44:40 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2013-12-10 15:44:40 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RigNNCData::processConnections( const RigMainGrid& mainGrid )
|
2013-12-10 15:44:40 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
// cvf::Trace::show("NNC: Total number: " + cvf::String((int)m_connections.size()));
|
2013-12-11 07:55:14 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t cnIdx = 0; cnIdx < m_connections.size(); ++cnIdx )
|
2013-12-10 15:44:40 -06:00
|
|
|
{
|
2015-11-24 07:21:02 -06:00
|
|
|
const RigCell& c1 = mainGrid.globalCellArray()[m_connections[cnIdx].m_c1GlobIdx];
|
|
|
|
const RigCell& c2 = mainGrid.globalCellArray()[m_connections[cnIdx].m_c2GlobIdx];
|
2013-12-10 15:44:40 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<size_t> connectionPolygon;
|
|
|
|
std::vector<cvf::Vec3d> connectionIntersections;
|
2017-11-02 03:31:09 -05:00
|
|
|
cvf::StructGridInterface::FaceType connectionFace = cvf::StructGridInterface::NO_FACE;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
connectionFace = calculateCellFaceOverlap( c1, c2, mainGrid, &connectionPolygon, &connectionIntersections );
|
2013-12-11 07:55:14 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( connectionFace != cvf::StructGridInterface::NO_FACE )
|
2017-11-02 03:31:09 -05:00
|
|
|
{
|
|
|
|
// Found an overlap polygon. Store data about connection
|
|
|
|
|
|
|
|
m_connections[cnIdx].m_c1Face = connectionFace;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t pIdx = 0; pIdx < connectionPolygon.size(); ++pIdx )
|
2017-11-02 03:31:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( connectionPolygon[pIdx] < mainGrid.nodes().size() )
|
|
|
|
m_connections[cnIdx].m_polygon.push_back( mainGrid.nodes()[connectionPolygon[pIdx]] );
|
2017-11-02 03:31:09 -05:00
|
|
|
else
|
2019-09-06 03:40:57 -05:00
|
|
|
m_connections[cnIdx].m_polygon.push_back(
|
|
|
|
connectionIntersections[connectionPolygon[pIdx] - mainGrid.nodes().size()] );
|
2017-11-02 03:31:09 -05:00
|
|
|
}
|
2013-12-10 15:44:40 -06:00
|
|
|
|
2017-11-02 03:31:09 -05:00
|
|
|
// Add to search map, possibly not needed
|
2019-09-06 03:40:57 -05:00
|
|
|
// m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c1GlobIdx][connectionFace].push_back(cnIdx);
|
|
|
|
// m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c2GlobIdx][cvf::StructGridInterface::oppositeFace(connectionFace].push_back(cnIdx);
|
2017-11-02 03:31:09 -05:00
|
|
|
}
|
|
|
|
else
|
2013-12-10 15:44:40 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
// cvf::Trace::show("NNC: No overlap found for : C1: " + cvf::String((int)m_connections[cnIdx].m_c1GlobIdx)
|
|
|
|
// + "C2: " + cvf::String((int)m_connections[cnIdx].m_c2GlobIdx));
|
2017-11-02 03:31:09 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-02 03:31:09 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::StructGridInterface::FaceType RigNNCData::calculateCellFaceOverlap( const RigCell& c1,
|
|
|
|
const RigCell& c2,
|
|
|
|
const RigMainGrid& mainGrid,
|
|
|
|
std::vector<size_t>* connectionPolygon,
|
|
|
|
std::vector<cvf::Vec3d>* connectionIntersections )
|
2017-11-02 03:31:09 -05:00
|
|
|
{
|
|
|
|
// Try to find the shared face
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
bool isPossibleNeighborInDirection[6] = {true, true, true, true, true, true};
|
2017-11-02 03:31:09 -05:00
|
|
|
|
|
|
|
if ( c1.hostGrid() == c2.hostGrid() )
|
|
|
|
{
|
|
|
|
char hasNeighbourInAnyDirection = 0;
|
|
|
|
|
|
|
|
size_t i1, j1, k1;
|
2019-09-06 03:40:57 -05:00
|
|
|
c1.hostGrid()->ijkFromCellIndex( c1.gridLocalCellIndex(), &i1, &j1, &k1 );
|
2017-11-02 03:31:09 -05:00
|
|
|
size_t i2, j2, k2;
|
2019-09-06 03:40:57 -05:00
|
|
|
c2.hostGrid()->ijkFromCellIndex( c2.gridLocalCellIndex(), &i2, &j2, &k2 );
|
|
|
|
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_I] = ( ( i1 + 1 ) == i2 );
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_I] = ( ( i2 + 1 ) == i1 );
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_J] = ( ( j1 + 1 ) == j2 );
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_J] = ( ( j2 + 1 ) == j1 );
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_K] = ( ( k1 + 1 ) == k2 );
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_K] = ( ( k2 + 1 ) == k1 );
|
|
|
|
|
|
|
|
hasNeighbourInAnyDirection = isPossibleNeighborInDirection[cvf::StructGridInterface::POS_I] +
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_I] +
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_J] +
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_J] +
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_K] +
|
|
|
|
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_K];
|
|
|
|
|
|
|
|
// If cell 2 is not adjancent with respect to any of the six ijk directions,
|
2017-11-02 03:31:09 -05:00
|
|
|
// assume that we have no overlapping area.
|
2013-12-10 15:44:40 -06:00
|
|
|
|
2017-11-02 03:31:09 -05:00
|
|
|
if ( !hasNeighbourInAnyDirection )
|
|
|
|
{
|
|
|
|
// Add to search map
|
2019-09-06 03:40:57 -05:00
|
|
|
// m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c1GlobIdx][cvf::StructGridInterface::NO_FACE].push_back(cnIdx);
|
|
|
|
// m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c2GlobIdx][cvf::StructGridInterface::NO_FACE].push_back(cnIdx);
|
2013-12-11 07:55:14 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
// cvf::Trace::show("NNC: No direct neighbors : C1: " + cvf::String((int)m_connections[cnIdx].m_c1GlobIdx) +
|
|
|
|
// " C2: " + cvf::String((int)m_connections[cnIdx].m_c2GlobIdx));
|
2017-11-02 03:31:09 -05:00
|
|
|
return cvf::StructGridInterface::NO_FACE;
|
2013-12-11 07:55:14 -06:00
|
|
|
}
|
2017-11-02 03:31:09 -05:00
|
|
|
}
|
2013-12-11 07:55:14 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#if 0
|
2017-11-02 03:31:09 -05:00
|
|
|
// Possibly do some testing to avoid unneccesary overlap calculations
|
|
|
|
cvf::Vec3d normal;
|
|
|
|
for ( char fIdx = 0; fIdx < 6; ++fIdx )
|
|
|
|
{
|
|
|
|
if ( isPossibleNeighborInDirection[fIdx] )
|
2013-12-11 07:55:14 -06:00
|
|
|
{
|
2017-11-02 03:31:09 -05:00
|
|
|
cvf::Vec3d fc1 = c1.faceCenter((cvf::StructGridInterface::FaceType)(fIdx));
|
|
|
|
cvf::Vec3d fc2 = c2.faceCenter(cvf::StructGridInterface::oppositeFace((cvf::StructGridInterface::FaceType)(fIdx)));
|
|
|
|
cvf::Vec3d fc1ToFc2 = fc2 - fc1;
|
|
|
|
normal = c1.faceNormalWithAreaLenght((cvf::StructGridInterface::FaceType)(fIdx));
|
|
|
|
normal.normalize();
|
|
|
|
// Check that face centers are approx in the face plane
|
|
|
|
if ( normal.dot(fc1ToFc2) < 0.01*fc1ToFc2.length() )
|
2013-12-10 15:44:40 -06:00
|
|
|
{
|
2017-11-02 03:31:09 -05:00
|
|
|
|
2013-12-11 07:55:14 -06:00
|
|
|
}
|
|
|
|
}
|
2017-11-02 03:31:09 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
#endif
|
2013-12-16 07:25:27 -06:00
|
|
|
|
2018-02-23 15:38:46 -06:00
|
|
|
for ( unsigned char fIdx = 0; fIdx < 6; ++fIdx )
|
2017-11-02 03:31:09 -05:00
|
|
|
{
|
|
|
|
if ( !isPossibleNeighborInDirection[fIdx] )
|
2013-12-11 07:55:14 -06:00
|
|
|
{
|
2017-11-02 03:31:09 -05:00
|
|
|
continue;
|
2013-12-10 15:44:40 -06:00
|
|
|
}
|
2013-12-16 07:25:27 -06:00
|
|
|
|
2017-11-02 03:31:09 -05:00
|
|
|
// Calculate connection polygon
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<size_t> polygon;
|
2017-11-02 03:31:09 -05:00
|
|
|
std::vector<cvf::Vec3d> intersections;
|
2019-09-06 03:40:57 -05:00
|
|
|
std::array<size_t, 4> face1;
|
|
|
|
std::array<size_t, 4> face2;
|
|
|
|
c1.faceIndices( ( cvf::StructGridInterface::FaceType )( fIdx ), &face1 );
|
|
|
|
c2.faceIndices( cvf::StructGridInterface::oppositeFace( ( cvf::StructGridInterface::FaceType )( fIdx ) ), &face2 );
|
|
|
|
|
2019-11-04 08:08:09 -06:00
|
|
|
bool foundOverlap =
|
|
|
|
cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
|
|
|
|
&intersections,
|
|
|
|
(cvf::EdgeIntersectStorage<size_t>*)nullptr,
|
|
|
|
cvf::wrapArrayConst( &mainGrid.nodes() ),
|
|
|
|
face1.data(),
|
|
|
|
face2.data(),
|
|
|
|
1e-6 );
|
2017-11-02 03:31:09 -05:00
|
|
|
|
|
|
|
if ( foundOverlap )
|
2013-12-16 07:25:27 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( connectionPolygon ) ( *connectionPolygon ) = polygon;
|
|
|
|
if ( connectionIntersections ) ( *connectionIntersections ) = intersections;
|
|
|
|
return ( cvf::StructGridInterface::FaceType )( fIdx );
|
2013-12-16 07:25:27 -06:00
|
|
|
}
|
2013-12-11 07:55:14 -06:00
|
|
|
}
|
2017-11-02 03:31:09 -05:00
|
|
|
|
|
|
|
return cvf::StructGridInterface::NO_FACE;
|
2013-12-11 07:55:14 -06:00
|
|
|
}
|
2014-09-04 02:28:39 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2014-09-04 02:28:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<double>& RigNNCData::makeStaticConnectionScalarResult( QString nncDataType )
|
2014-09-04 02:28:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<std::vector<double>>& results = m_connectionResults[nncDataType];
|
|
|
|
results.resize( 1 );
|
|
|
|
results[0].resize( m_connections.size(), HUGE_VAL );
|
2017-06-26 03:25:08 -05:00
|
|
|
return results[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-06-26 03:25:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<double>* RigNNCData::staticConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString nncDataType = getNNCDataTypeFromScalarResultIndex( resVarAddr );
|
|
|
|
if ( nncDataType.isNull() ) return nullptr;
|
2017-06-26 03:25:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::map<QString, std::vector<std::vector<double>>>::const_iterator it = m_connectionResults.find( nncDataType );
|
2017-06-29 04:19:07 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != m_connectionResults.end() )
|
2017-06-29 04:19:07 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( it->second.size() == 1 );
|
|
|
|
return &( it->second[0] );
|
2017-06-29 04:19:07 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-06-29 04:19:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<double>* RigNNCData::staticConnectionScalarResultByName( const QString& nncDataType ) const
|
2017-06-29 04:19:07 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::map<QString, std::vector<std::vector<double>>>::const_iterator it = m_connectionResults.find( nncDataType );
|
2017-06-26 03:25:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != m_connectionResults.end() )
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( it->second.size() == 1 );
|
|
|
|
return &( it->second[0] );
|
2017-06-26 03:25:08 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-06-26 03:25:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<std::vector<double>>& RigNNCData::makeDynamicConnectionScalarResult( QString nncDataType,
|
|
|
|
size_t timeStepCount )
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
|
|
|
auto& results = m_connectionResults[nncDataType];
|
2019-09-06 03:40:57 -05:00
|
|
|
results.resize( timeStepCount );
|
2014-09-04 02:28:39 -05:00
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2014-09-04 02:28:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<std::vector<double>>*
|
|
|
|
RigNNCData::dynamicConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const
|
2014-09-04 02:28:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString nncDataType = getNNCDataTypeFromScalarResultIndex( resVarAddr );
|
|
|
|
if ( nncDataType.isNull() ) return nullptr;
|
2017-06-26 03:25:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
2017-06-26 03:25:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != m_connectionResults.end() )
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second );
|
2017-06-26 03:25:08 -05:00
|
|
|
}
|
2014-09-04 02:28:39 -05:00
|
|
|
else
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-09-04 02:28:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2014-09-04 02:28:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<double>* RigNNCData::dynamicConnectionScalarResult( const RigEclipseResultAddress& resVarAddr,
|
|
|
|
size_t timeStep ) const
|
2014-09-04 02:28:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString nncDataType = getNNCDataTypeFromScalarResultIndex( resVarAddr );
|
|
|
|
if ( nncDataType.isNull() ) return nullptr;
|
2017-06-26 03:25:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
2017-06-26 03:25:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != m_connectionResults.end() )
|
2014-09-24 06:28:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it->second.size() > timeStep )
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second[timeStep] );
|
2017-06-26 03:25:08 -05:00
|
|
|
}
|
2014-09-24 06:28:08 -05:00
|
|
|
}
|
2017-06-26 03:25:08 -05:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-06-26 03:25:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<std::vector<double>>* RigNNCData::dynamicConnectionScalarResultByName( const QString& nncDataType ) const
|
2017-06-29 04:19:07 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
|
|
|
if ( it != m_connectionResults.end() )
|
2017-06-29 04:19:07 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second );
|
2017-06-29 04:19:07 -05:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-06-29 04:19:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<double>* RigNNCData::dynamicConnectionScalarResultByName( const QString& nncDataType,
|
|
|
|
size_t timeStep ) const
|
2017-06-29 04:19:07 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
|
|
|
if ( it != m_connectionResults.end() )
|
2017-06-29 04:19:07 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it->second.size() > timeStep )
|
2017-06-29 04:19:07 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second[timeStep] );
|
2017-06-29 04:19:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<std::vector<double>>& RigNNCData::makeGeneratedConnectionScalarResult( QString nncDataType,
|
|
|
|
size_t timeStepCount )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
|
|
|
auto& results = m_connectionResults[nncDataType];
|
2019-09-06 03:40:57 -05:00
|
|
|
results.resize( timeStepCount );
|
2017-08-08 06:12:43 -05:00
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<std::vector<double>>*
|
|
|
|
RigNNCData::generatedConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString nncDataType = getNNCDataTypeFromScalarResultIndex( resVarAddr );
|
|
|
|
if ( nncDataType.isNull() ) return nullptr;
|
2017-08-08 06:12:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
2017-08-08 06:12:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != m_connectionResults.end() )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<double>* RigNNCData::generatedConnectionScalarResult( const RigEclipseResultAddress& resVarAddr,
|
|
|
|
size_t timeStep ) const
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString nncDataType = getNNCDataTypeFromScalarResultIndex( resVarAddr );
|
|
|
|
if ( nncDataType.isNull() ) return nullptr;
|
2017-08-08 06:12:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
2017-08-08 06:12:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != m_connectionResults.end() )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it->second.size() > timeStep )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second[timeStep] );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<std::vector<double>>* RigNNCData::generatedConnectionScalarResult( const RigEclipseResultAddress& resVarAddr )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString nncDataType = getNNCDataTypeFromScalarResultIndex( resVarAddr );
|
|
|
|
if ( nncDataType.isNull() ) return nullptr;
|
2017-08-08 06:12:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
2017-08-08 06:12:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != m_connectionResults.end() )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<double>* RigNNCData::generatedConnectionScalarResult( const RigEclipseResultAddress& resVarAddr,
|
|
|
|
size_t timeStep )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString nncDataType = getNNCDataTypeFromScalarResultIndex( resVarAddr );
|
|
|
|
if ( nncDataType.isNull() ) return nullptr;
|
2017-08-08 06:12:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
2017-08-08 06:12:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != m_connectionResults.end() )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it->second.size() > timeStep )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second[timeStep] );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<std::vector<double>>* RigNNCData::generatedConnectionScalarResultByName( const QString& nncDataType ) const
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
|
|
|
if ( it != m_connectionResults.end() )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<double>* RigNNCData::generatedConnectionScalarResultByName( const QString& nncDataType,
|
|
|
|
size_t timeStep ) const
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
|
|
|
if ( it != m_connectionResults.end() )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it->second.size() > timeStep )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second[timeStep] );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<std::vector<double>>* RigNNCData::generatedConnectionScalarResultByName( const QString& nncDataType )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
|
|
|
if ( it != m_connectionResults.end() )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-08 06:12:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<double>* RigNNCData::generatedConnectionScalarResultByName( const QString& nncDataType, size_t timeStep )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
|
|
|
if ( it != m_connectionResults.end() )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it->second.size() > timeStep )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return &( it->second[timeStep] );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-08-07 08:28:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-07 08:28:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<QString> RigNNCData::availableProperties( NNCResultType resultType ) const
|
2017-08-07 08:28:27 -05:00
|
|
|
{
|
|
|
|
std::vector<QString> properties;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto it : m_connectionResults )
|
2017-08-07 08:28:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( resultType == NNC_STATIC && it.second.size() == 1 && it.second[0].size() > 0 && isNative( it.first ) )
|
2017-08-07 08:28:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
properties.push_back( it.first );
|
2017-08-07 08:28:27 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( resultType == NNC_DYNAMIC && it.second.size() > 1 && it.second[0].size() > 0 && isNative( it.first ) )
|
2017-08-08 06:12:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
properties.push_back( it.first );
|
2017-08-08 06:12:43 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( resultType == NNC_GENERATED && !isNative( it.first ) )
|
2017-08-07 08:28:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
properties.push_back( it.first );
|
2017-08-07 08:28:27 -05:00
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2017-08-07 08:28:27 -05:00
|
|
|
return properties;
|
|
|
|
}
|
|
|
|
|
2017-06-29 04:19:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-06-29 04:19:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RigNNCData::setEclResultAddress( const QString& nncDataType, const RigEclipseResultAddress& resVarAddr )
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
2019-01-25 05:58:07 -06:00
|
|
|
m_resultAddrToNNCDataType[resVarAddr] = nncDataType;
|
2014-09-04 02:28:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2014-09-04 02:28:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RigNNCData::hasScalarValues( const RigEclipseResultAddress& resVarAddr )
|
2014-09-04 02:28:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString nncDataType = getNNCDataTypeFromScalarResultIndex( resVarAddr );
|
|
|
|
if ( nncDataType.isNull() ) return false;
|
2017-06-26 03:25:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_connectionResults.find( nncDataType );
|
|
|
|
return ( it != m_connectionResults.end() );
|
2014-09-04 02:28:39 -05:00
|
|
|
}
|
|
|
|
|
2017-06-26 03:25:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-06-26 03:25:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const QString RigNNCData::getNNCDataTypeFromScalarResultIndex( const RigEclipseResultAddress& resVarAddr ) const
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = m_resultAddrToNNCDataType.find( resVarAddr );
|
|
|
|
if ( it != m_resultAddrToNNCDataType.end() )
|
2017-06-26 03:25:08 -05:00
|
|
|
{
|
2017-06-29 04:19:07 -05:00
|
|
|
return it->second;
|
2017-06-26 03:25:08 -05:00
|
|
|
}
|
2017-06-29 04:19:07 -05:00
|
|
|
return QString();
|
2017-06-26 03:25:08 -05:00
|
|
|
}
|
|
|
|
|
2013-12-11 07:55:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2013-12-11 07:55:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RigNNCData::isNative( QString nncDataType ) const
|
2013-12-11 07:55:14 -06:00
|
|
|
{
|
2020-01-13 07:45:39 -06:00
|
|
|
if ( nncDataType == RiaDefines::propertyNameCombTrans() || nncDataType == RiaDefines::propertyNameFluxGas() ||
|
|
|
|
nncDataType == RiaDefines::propertyNameFluxOil() || nncDataType == RiaDefines::propertyNameFluxWat() ||
|
|
|
|
nncDataType == RiaDefines::propertyNameRiCombMult() || nncDataType == RiaDefines::propertyNameRiCombTrans() ||
|
|
|
|
nncDataType == RiaDefines::propertyNameRiCombTransByArea() )
|
2013-12-11 07:55:14 -06:00
|
|
|
{
|
2017-08-08 06:12:43 -05:00
|
|
|
return true;
|
2013-12-11 07:55:14 -06:00
|
|
|
}
|
2017-08-08 06:12:43 -05:00
|
|
|
return false;
|
2013-12-10 15:44:40 -06:00
|
|
|
}
|