Skip to content

Commit

Permalink
Fault Reactivation: Update element sets (#11191)
Browse files Browse the repository at this point in the history
* Update element sets based on active cells
* Bonus: Fix viewer crash
  • Loading branch information
jonjenssen authored Feb 12, 2024
1 parent fa8d8e3 commit 336dc57
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 204 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,33 +361,6 @@ const std::vector<double> RigFaultReactivationModelGenerator::partition( double
return parts;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<int> RigFaultReactivationModelGenerator::elementKLayers( const std::vector<size_t>& cellIndexColumn )
{
std::vector<int> kLayers;

size_t i, j, k;
for ( auto idx : cellIndexColumn )
{
m_grid->ijkFromCellIndexUnguarded( idx, &i, &j, &k );

if ( m_activeCellInfo->isActive( idx ) )
{
kLayers.push_back( (int)k );
}
else
{
kLayers.push_back( -1 * (int)k );
}
}

std::reverse( kLayers.begin(), kLayers.end() );

return kLayers;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -543,11 +516,6 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta
std::map<double, cvf::Vec3d> layersFront;
std::vector<size_t> cellColumnFront = buildCellColumn( oppositeStartCellIdx, oppositeStartFace, layersFront );

// identify k layers used to classify reservoir/inter-reservoir

auto kLayersBack = elementKLayers( cellColumnBack );
auto kLayersFront = elementKLayers( cellColumnFront );

// add extra fault buffer below the fault, starting at the deepest bottom-most cell on either side of the fault

double front_bottom = layersFront.begin()->first;
Expand Down Expand Up @@ -588,11 +556,11 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta

// make sure layers aren't too small or too thick

mergeTinyLayers( layersFront, kLayersFront, m_minCellHeight );
mergeTinyLayers( layersBack, kLayersBack, m_minCellHeight );
mergeTinyLayers( layersFront, m_minCellHeight );
mergeTinyLayers( layersBack, m_minCellHeight );

splitLargeLayers( layersFront, kLayersFront, m_maxCellHeight );
splitLargeLayers( layersBack, kLayersBack, m_maxCellHeight );
splitLargeLayers( layersFront, m_maxCellHeight );
splitLargeLayers( layersBack, m_maxCellHeight );

std::vector<cvf::Vec3d> frontReservoirLayers;
for ( auto& kvp : layersFront )
Expand All @@ -608,7 +576,6 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta

frontPart->generateGeometry( m_frontPoints,
frontReservoirLayers,
kLayersFront,
m_maxCellHeight,
m_cellSizeHeightFactor,
m_horizontalPartition,
Expand All @@ -618,7 +585,6 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta
m_faultZoneCells );
backPart->generateGeometry( m_backPoints,
backReservoirLayers,
kLayersBack,
m_maxCellHeight,
m_cellSizeHeightFactor,
m_horizontalPartition,
Expand Down Expand Up @@ -674,9 +640,8 @@ cvf::Vec3d RigFaultReactivationModelGenerator::extrapolatePoint( cvf::Vec3d star
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFaultReactivationModelGenerator::mergeTinyLayers( std::map<double, cvf::Vec3d>& layers, std::vector<int>& kLayers, double minHeight )
void RigFaultReactivationModelGenerator::mergeTinyLayers( std::map<double, cvf::Vec3d>& layers, double minHeight )
{
std::vector<int> newKLayers;
std::vector<cvf::Vec3d> newLayers;

const int nLayers = (int)layers.size();
Expand All @@ -692,7 +657,6 @@ void RigFaultReactivationModelGenerator::mergeTinyLayers( std::map<double, cvf::

// bottom layer must always be included
newLayers.push_back( vals.front() );
newKLayers.push_back( kLayers.front() );

// remove any layer that is less than minHeight above the previous layer, starting at the bottom
for ( int k = 1; k < nLayers - 1; k++ )
Expand All @@ -701,7 +665,6 @@ void RigFaultReactivationModelGenerator::mergeTinyLayers( std::map<double, cvf::
{
continue;
}
newKLayers.push_back( kLayers[k] );
newLayers.push_back( vals[k] );
}
// top layer must always be included
Expand All @@ -713,7 +676,6 @@ void RigFaultReactivationModelGenerator::mergeTinyLayers( std::map<double, cvf::
{
if ( std::abs( newLayers[nNewLayers - 1].z() - newLayers[nNewLayers - 2].z() ) < minHeight )
{
newKLayers.pop_back();
newLayers.pop_back();
newLayers.pop_back();
newLayers.push_back( vals.back() );
Expand All @@ -725,25 +687,16 @@ void RigFaultReactivationModelGenerator::mergeTinyLayers( std::map<double, cvf::
{
layers[p.z()] = p;
}

kLayers.clear();
for ( auto k : newKLayers )
{
kLayers.push_back( k );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFaultReactivationModelGenerator::splitLargeLayers( std::map<double, cvf::Vec3d>& layers, std::vector<int>& kLayers, double maxHeight )
void RigFaultReactivationModelGenerator::splitLargeLayers( std::map<double, cvf::Vec3d>& layers, double maxHeight )
{
std::vector<cvf::Vec3d> additionalPoints;

std::vector<int> newKLayers;

const int nLayers = (int)layers.size();
const int nKLayers = (int)kLayers.size();
const int nLayers = (int)layers.size();

std::vector<double> keys;
std::vector<cvf::Vec3d> vals;
Expand All @@ -764,23 +717,15 @@ void RigFaultReactivationModelGenerator::splitLargeLayers( std::map<double, cvf:
for ( auto& p : points )
{
additionalPoints.push_back( p );
newKLayers.push_back( kLayers[k - 1] );
}
}
}
if ( k < nKLayers ) newKLayers.push_back( kLayers[k] );
}

for ( auto& p : additionalPoints )
{
layers[p.z()] = p;
}

kLayers.clear();
for ( auto k : newKLayers )
{
kLayers.push_back( k );
}
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ class RigFaultReactivationModelGenerator : cvf::Object
static std::pair<FaceType, FaceType> sideFacesIJ( FaceType face );

static cvf::Vec3d extrapolatePoint( cvf::Vec3d startPoint, cvf::Vec3d endPoint, double stopDepth );
static void splitLargeLayers( std::map<double, cvf::Vec3d>& layers, std::vector<int>& kLayers, double maxHeight );
static void mergeTinyLayers( std::map<double, cvf::Vec3d>& layers, std::vector<int>& kLayers, double minHeight );

std::vector<int> elementKLayers( const std::vector<size_t>& cellIndexColumn );
static void splitLargeLayers( std::map<double, cvf::Vec3d>& layers, double maxHeight );
static void mergeTinyLayers( std::map<double, cvf::Vec3d>& layers, double minHeight );

std::vector<size_t> buildCellColumn( size_t startCell, FaceType startFace, std::map<double, cvf::Vec3d>& layers );

Expand Down
Loading

0 comments on commit 336dc57

Please sign in to comment.