mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Export Completion: Fix missing segments and connections for LGR grids
* Compute characteristic cell size based on active cells * Compute cell face normal based on a suitable active cells Using all cells as basis for face normal is fragile. Some models have highly distorted/twisted cells, but all active cells should be geometrically more stable.
This commit is contained in:
@@ -979,6 +979,27 @@ bool RimEclipseCase::openReserviorCase()
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( eclipseCaseData() && eclipseCaseData()->mainGrid() &&
|
||||
!eclipseCaseData()->mainGrid()->hasValidCharacteristicCellSizes() )
|
||||
{
|
||||
RigMainGrid* mainGrid = eclipseCaseData()->mainGrid();
|
||||
|
||||
auto activeCellInfo = eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||
if ( activeCellInfo )
|
||||
{
|
||||
std::vector<size_t> reservoirCellIndices;
|
||||
for ( size_t i = 0; i < mainGrid->cellCount(); i++ )
|
||||
{
|
||||
if ( activeCellInfo->isActive( i ) )
|
||||
{
|
||||
reservoirCellIndices.push_back( i );
|
||||
}
|
||||
}
|
||||
mainGrid->computeCharacteristicCellSize( reservoirCellIndices );
|
||||
mainGrid->computeFaceNormalsDirection( reservoirCellIndices );
|
||||
}
|
||||
}
|
||||
|
||||
bool createPlaceholderEntries = true;
|
||||
if ( dynamic_cast<RimEclipseStatisticsCase*>( this ) )
|
||||
{
|
||||
|
@@ -46,6 +46,9 @@ RigMainGrid::RigMainGrid()
|
||||
m_useMapAxes = false;
|
||||
m_mapAxes = defaultMapAxes();
|
||||
m_dualPorosity = false;
|
||||
|
||||
m_isFaceNormalsOutwards = true;
|
||||
m_isFaceNormalsOutwardsComputed = false;
|
||||
}
|
||||
|
||||
RigMainGrid::~RigMainGrid()
|
||||
@@ -650,6 +653,23 @@ void RigMainGrid::distributeNNCsToFaults()
|
||||
/// but if (only) one of the flipX/Y is done, the cell is back to normal
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigMainGrid::isFaceNormalsOutwards() const
|
||||
{
|
||||
if ( !m_isFaceNormalsOutwardsComputed )
|
||||
{
|
||||
std::vector<size_t> reservoirCellIndices;
|
||||
reservoirCellIndices.resize( cellCount() );
|
||||
std::iota( reservoirCellIndices.begin(), reservoirCellIndices.end(), 0 );
|
||||
|
||||
computeFaceNormalsDirection( reservoirCellIndices );
|
||||
}
|
||||
|
||||
return m_isFaceNormalsOutwards;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMainGrid::computeFaceNormalsDirection( const std::vector<size_t>& reservoirCellIndices ) const
|
||||
{
|
||||
auto isValidAndFaceNormalDir = []( const double ijSize,
|
||||
const double kSize,
|
||||
@@ -679,8 +699,9 @@ bool RigMainGrid::isFaceNormalsOutwards() const
|
||||
characteristicCellSizes( &iSize, &jSize, &kSize );
|
||||
const double characteristicVolume = iSize * jSize * kSize;
|
||||
|
||||
for ( const auto& cell : m_cells )
|
||||
for ( const auto& index : reservoirCellIndices )
|
||||
{
|
||||
const auto& cell = m_cells[index];
|
||||
if ( !cell.isInvalid() )
|
||||
{
|
||||
// Some cells can be very twisted and distorted. Use a volume criteria to find a reasonably regular cell.
|
||||
@@ -701,21 +722,25 @@ bool RigMainGrid::isFaceNormalsOutwards() const
|
||||
if ( direction1 && direction2 && direction3 && direction4 )
|
||||
{
|
||||
// All face normals pointing outwards
|
||||
return true;
|
||||
m_isFaceNormalsOutwards = true;
|
||||
m_isFaceNormalsOutwardsComputed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !direction1 && !direction2 && !direction3 && !direction4 )
|
||||
{
|
||||
// All cell face normals pointing inwards
|
||||
return false;
|
||||
m_isFaceNormalsOutwards = false;
|
||||
m_isFaceNormalsOutwardsComputed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// This is a mixed case, where some faces are outwards and some are inwards
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
// If this code is reached, it was not possible to get a consistent answer on the direction of a cell surface
|
||||
// normal. Set a default direction for face normals.
|
||||
m_isFaceNormalsOutwards = true;
|
||||
m_isFaceNormalsOutwardsComputed = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -87,6 +87,7 @@ public:
|
||||
const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face ) const;
|
||||
bool isFaceNormalsOutwards() const;
|
||||
void computeFaceNormalsDirection( const std::vector<size_t>& reservoirCellIndices ) const;
|
||||
|
||||
void computeCachedData( std::string* aabbTreeInfo = nullptr );
|
||||
void initAllSubGridsParentGridPointer();
|
||||
@@ -142,4 +143,7 @@ private:
|
||||
std::array<double, 6> m_mapAxes;
|
||||
|
||||
bool m_dualPorosity;
|
||||
|
||||
mutable bool m_isFaceNormalsOutwards;
|
||||
mutable bool m_isFaceNormalsOutwardsComputed;
|
||||
};
|
||||
|
Reference in New Issue
Block a user