Fault Reactivation updates (#10727)

* Generate reservoir element sets
* Add support for materials
* Add local coordinate system support for exported model
This commit is contained in:
jonjenssen
2023-10-18 09:10:08 +02:00
committed by GitHub
parent 18e9ef0558
commit 7494302275
20 changed files with 613 additions and 188 deletions

View File

@@ -18,15 +18,18 @@
#include "RigGriddedPart3d.h"
#include "RigMainGrid.h"
#include "RimFaultReactivationDataAccess.h"
#include "cvfBoundingBox.h"
#include "cvfTextureImage.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGriddedPart3d::RigGriddedPart3d( bool flipFrontBack )
: m_flipFrontBack( flipFrontBack )
: m_useLocalCoordinates( false )
{
}
@@ -46,8 +49,10 @@ void RigGriddedPart3d::reset()
m_boundaryNodes.clear();
m_borderSurfaceElements.clear();
m_nodes.clear();
m_localNodes.clear();
m_elementIndices.clear();
m_meshLines.clear();
m_elementSets.clear();
clearModelData();
}
@@ -101,15 +106,15 @@ void RigGriddedPart3d::generateGeometry( std::vector<cvf::Vec3d> inputPoints,
{
reset();
cvf::Vec3d step0to1 = stepVector( inputPoints[0], inputPoints[1], nVertCellsLower );
cvf::Vec3d step1to2 = stepVector( inputPoints[1], inputPoints[2], nVertCellsMiddle );
cvf::Vec3d step2to3 = stepVector( inputPoints[2], inputPoints[3], nVertCellsUpper );
const cvf::Vec3d step0to1 = stepVector( inputPoints[0], inputPoints[1], nVertCellsLower );
const cvf::Vec3d step1to2 = stepVector( inputPoints[1], inputPoints[2], nVertCellsMiddle );
const cvf::Vec3d step2to3 = stepVector( inputPoints[2], inputPoints[3], nVertCellsUpper );
cvf::Vec3d step4to5 = stepVector( inputPoints[4], inputPoints[5], nVertCellsLower );
cvf::Vec3d step5to6 = stepVector( inputPoints[5], inputPoints[6], nVertCellsMiddle );
cvf::Vec3d step6to7 = stepVector( inputPoints[6], inputPoints[7], nVertCellsUpper );
const cvf::Vec3d step4to5 = stepVector( inputPoints[4], inputPoints[5], nVertCellsLower );
const cvf::Vec3d step5to6 = stepVector( inputPoints[5], inputPoints[6], nVertCellsMiddle );
const cvf::Vec3d step6to7 = stepVector( inputPoints[6], inputPoints[7], nVertCellsUpper );
cvf::Vec3d step0to4 = stepVector( inputPoints[0], inputPoints[4], nHorzCells );
const cvf::Vec3d step0to4 = stepVector( inputPoints[0], inputPoints[4], nHorzCells );
cvf::Vec3d tVec = step0to4 ^ step0to1;
tVec.normalize();
@@ -123,13 +128,8 @@ void RigGriddedPart3d::generateGeometry( std::vector<cvf::Vec3d> inputPoints,
const std::vector<cvf::Vec3d> firstSteps = { step0to1, step1to2, step2to3 };
const std::vector<cvf::Vec3d> lastSteps = { step4to5, step5to6, step6to7 };
const Boundary boundaryBack = m_flipFrontBack ? Boundary::Front : Boundary::Back;
const Boundary boundaryFront = m_flipFrontBack ? Boundary::Back : Boundary::Front;
// ** generate nodes
m_boundaryNodes[boundaryFront] = {};
m_boundaryNodes[boundaryBack] = {};
m_boundaryNodes[Boundary::Bottom] = {};
m_boundaryNodes[Boundary::FarSide] = {};
@@ -160,14 +160,6 @@ void RigGriddedPart3d::generateGeometry( std::vector<cvf::Vec3d> inputPoints,
{
m_boundaryNodes[Boundary::FarSide].push_back( nodeIndex );
}
if ( t == 0 )
{
m_boundaryNodes[boundaryFront].push_back( nodeIndex );
}
else if ( t == nThicknessCells )
{
m_boundaryNodes[boundaryBack].push_back( nodeIndex );
}
}
p += stepHorz;
@@ -181,12 +173,10 @@ void RigGriddedPart3d::generateGeometry( std::vector<cvf::Vec3d> inputPoints,
m_elementIndices.resize( (size_t)( nVertCells * nHorzCells * nThicknessCells ) );
m_borderSurfaceElements[BorderSurface::UpperSurface] = {};
m_borderSurfaceElements[BorderSurface::FaultSurface] = {};
m_borderSurfaceElements[BorderSurface::LowerSurface] = {};
m_borderSurfaceElements[RimFaultReactivation::BorderSurface::UpperSurface] = {};
m_borderSurfaceElements[RimFaultReactivation::BorderSurface::FaultSurface] = {};
m_borderSurfaceElements[RimFaultReactivation::BorderSurface::LowerSurface] = {};
m_boundaryElements[boundaryFront] = {};
m_boundaryElements[boundaryBack] = {};
m_boundaryElements[Boundary::Bottom] = {};
m_boundaryElements[Boundary::FarSide] = {};
@@ -194,15 +184,15 @@ void RigGriddedPart3d::generateGeometry( std::vector<cvf::Vec3d> inputPoints,
int elementIdx = 0;
layer = 0;
BorderSurface currentSurfaceRegion = BorderSurface::LowerSurface;
RimFaultReactivation::BorderSurface currentSurfaceRegion = RimFaultReactivation::BorderSurface::LowerSurface;
const int nextLayerIdxOff = ( nHorzCells + 1 ) * ( nThicknessCells + 1 );
const int nThicknessOff = nThicknessCells + 1;
for ( int v = 0; v < nVertCells; v++, layer++ )
{
if ( v >= nVertCellsLower ) currentSurfaceRegion = BorderSurface::FaultSurface;
if ( v >= nVertCellsLower + nVertCellsMiddle ) currentSurfaceRegion = BorderSurface::UpperSurface;
if ( v >= nVertCellsLower ) currentSurfaceRegion = RimFaultReactivation::BorderSurface::FaultSurface;
if ( v >= nVertCellsLower + nVertCellsMiddle ) currentSurfaceRegion = RimFaultReactivation::BorderSurface::UpperSurface;
int i = layerIndexOffset;
@@ -228,14 +218,6 @@ void RigGriddedPart3d::generateGeometry( std::vector<cvf::Vec3d> inputPoints,
{
m_boundaryElements[Boundary::FarSide].push_back( elementIdx );
}
if ( t == 0 )
{
m_boundaryElements[boundaryFront].push_back( elementIdx );
}
else if ( t == ( nThicknessCells - 1 ) )
{
m_boundaryElements[boundaryBack].push_back( elementIdx );
}
}
i += nThicknessOff;
}
@@ -252,6 +234,13 @@ void RigGriddedPart3d::generateGeometry( std::vector<cvf::Vec3d> inputPoints,
generateMeshlines( { inputPoints[0], inputPoints[1], inputPoints[5], inputPoints[4] }, nHorzCells, nVertCellsLower );
generateMeshlines( { inputPoints[1], inputPoints[2], inputPoints[6], inputPoints[5] }, nHorzCells, nVertCellsMiddle );
generateMeshlines( { inputPoints[2], inputPoints[3], inputPoints[7], inputPoints[6] }, nHorzCells, nVertCellsUpper );
// store the reservoir part corners for later
m_reservoirRect.clear();
for ( auto i : { 1, 2, 6, 5 } )
{
m_reservoirRect.push_back( inputPoints[i] );
}
}
//--------------------------------------------------------------------------------------------------
@@ -267,7 +256,7 @@ void RigGriddedPart3d::generateGeometry( std::vector<cvf::Vec3d> inputPoints,
///
/// Assumes 0->3 and 1->2 is parallel
//--------------------------------------------------------------------------------------------------
void RigGriddedPart3d::generateMeshlines( std::vector<cvf::Vec3d> cornerPoints, int numHorzCells, int numVertCells )
void RigGriddedPart3d::generateMeshlines( const std::vector<cvf::Vec3d>& cornerPoints, int numHorzCells, int numVertCells )
{
cvf::Vec3d step0to1 = stepVector( cornerPoints[0], cornerPoints[1], numVertCells );
cvf::Vec3d step0to3 = stepVector( cornerPoints[0], cornerPoints[3], numHorzCells );
@@ -300,13 +289,38 @@ void RigGriddedPart3d::generateMeshlines( std::vector<cvf::Vec3d> cornerPoints,
}
//--------------------------------------------------------------------------------------------------
///
/// returns node in either global or local coords depending on m_useLocalCoordinates flag
//--------------------------------------------------------------------------------------------------
const std::vector<cvf::Vec3d>& RigGriddedPart3d::nodes() const
{
if ( m_useLocalCoordinates ) return m_localNodes;
return m_nodes;
}
//--------------------------------------------------------------------------------------------------
/// Always returns nodes in global coordinates
//--------------------------------------------------------------------------------------------------
const std::vector<cvf::Vec3d>& RigGriddedPart3d::globalNodes() const
{
return m_nodes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGriddedPart3d::setUseLocalCoordinates( bool useLocalCoordinates )
{
m_useLocalCoordinates = useLocalCoordinates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGriddedPart3d::useLocalCoordinates() const
{
return m_useLocalCoordinates;
}
//--------------------------------------------------------------------------------------------------
/// Output elements will be of type HEX8
///
@@ -328,7 +342,7 @@ const std::vector<std::vector<unsigned int>>& RigGriddedPart3d::elementIndices()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::map<RigGriddedPart3d::BorderSurface, std::vector<unsigned int>>& RigGriddedPart3d::borderSurfaceElements() const
const std::map<RimFaultReactivation::BorderSurface, std::vector<unsigned int>>& RigGriddedPart3d::borderSurfaceElements() const
{
return m_borderSurfaceElements;
}
@@ -344,7 +358,7 @@ const std::vector<std::vector<cvf::Vec3d>>& RigGriddedPart3d::meshLines() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::map<RigGriddedPart3d::Boundary, std::vector<unsigned int>>& RigGriddedPart3d::boundaryElements() const
const std::map<RimFaultReactivation::Boundary, std::vector<unsigned int>>& RigGriddedPart3d::boundaryElements() const
{
return m_boundaryElements;
}
@@ -352,11 +366,19 @@ const std::map<RigGriddedPart3d::Boundary, std::vector<unsigned int>>& RigGridde
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::map<RigGriddedPart3d::Boundary, std::vector<unsigned int>>& RigGriddedPart3d::boundaryNodes() const
const std::map<RimFaultReactivation::Boundary, std::vector<unsigned int>>& RigGriddedPart3d::boundaryNodes() const
{
return m_boundaryNodes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::map<RimFaultReactivation::ElementSets, std::vector<unsigned int>>& RigGriddedPart3d::elementSets() const
{
return m_elementSets;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -382,3 +404,125 @@ void RigGriddedPart3d::extractModelData( RimFaultReactivationDataAccess* dataAcc
m_nodePorePressure[outputTimeStep].push_back( pressure );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<int, int> RigGriddedPart3d::reservoirZTopBottom( const RigMainGrid* grid ) const
{
cvf::BoundingBox resBb;
for ( const auto& p : m_reservoirRect )
{
resBb.add( p );
}
std::vector<size_t> intersectingCells;
grid->findIntersectingCells( resBb, &intersectingCells );
resBb.reset();
for ( auto cellIdx : intersectingCells )
{
resBb.add( grid->cell( cellIdx ).boundingBox() );
}
auto maxZ = resBb.max().z();
auto minZ = resBb.min().z();
return std::make_pair( maxZ, minZ );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGriddedPart3d::generateElementSets( const RimFaultReactivationDataAccess* dataAccess, const RigMainGrid* grid )
{
m_elementSets[ElementSets::OverBurden] = {};
m_elementSets[ElementSets::Reservoir] = {};
m_elementSets[ElementSets::IntraReservoir] = {};
m_elementSets[ElementSets::UnderBurden] = {};
auto [topResZ, bottomResZ] = reservoirZTopBottom( grid );
for ( unsigned int i = 0; i < m_elementIndices.size(); i++ )
{
auto corners = elementCorners( i );
if ( dataAccess->elementHasValidData( corners ) )
{
m_elementSets[ElementSets::Reservoir].push_back( i );
}
else
{
if ( elementIsAboveReservoir( corners, topResZ ) )
{
m_elementSets[ElementSets::OverBurden].push_back( i );
}
else if ( elementIsBelowReservoir( corners, bottomResZ ) )
{
m_elementSets[ElementSets::UnderBurden].push_back( i );
}
else
{
m_elementSets[ElementSets::IntraReservoir].push_back( i );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGriddedPart3d::generateLocalNodes( const cvf::Mat4d transform )
{
m_localNodes.clear();
for ( auto& node : m_nodes )
{
m_localNodes.push_back( node.getTransformedPoint( transform ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RigGriddedPart3d::elementCorners( size_t elementIndex ) const
{
if ( elementIndex >= m_elementIndices.size() ) return {};
std::vector<cvf::Vec3d> corners;
for ( auto nodeIdx : m_elementIndices[elementIndex] )
{
if ( nodeIdx >= m_nodes.size() ) continue;
corners.push_back( m_nodes[nodeIdx] );
}
return corners;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGriddedPart3d::elementIsAboveReservoir( const std::vector<cvf::Vec3d>& cornerPoints, double threshold ) const
{
int nValid = 0;
for ( auto& p : cornerPoints )
{
if ( p.z() > threshold ) nValid++;
}
return nValid > 4;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGriddedPart3d::elementIsBelowReservoir( const std::vector<cvf::Vec3d>& cornerPoints, double threshold ) const
{
int nValid = 0;
for ( auto& p : cornerPoints )
{
if ( p.z() < threshold ) nValid++;
}
return nValid > 4;
}