From 51b591138e7970bd409a01e05f86ccda4ab38e1e Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Fri, 8 Mar 2024 14:38:46 +0100 Subject: [PATCH 1/3] Generate model based on an origin in the fault to improve calculation accuracy. --- .../RigFaultReactivationModelGenerator.cpp | 48 +++++++++++++-- .../RigFaultReactivationModelGenerator.h | 7 ++- .../ReservoirDataModel/RigGriddedPart3d.cpp | 58 +++++++++---------- .../ReservoirDataModel/RigGriddedPart3d.h | 4 +- 4 files changed, 78 insertions(+), 39 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp index d21b9d7fd4..81a808c5f5 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp @@ -574,6 +574,10 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta generatePointsFrontBack(); + // use temp origin in start position, at zero depth + cvf::Vec3d origin( m_startPosition ); + origin.z() = 0.0; + cvf::Vec3d tVec = m_modelThickness * m_modelNormal; std::vector thicknessVectors; std::vector> faultLines; @@ -581,12 +585,28 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta for ( int i = 0; i < 3; i++ ) { - faultLines.push_back( caf::Line( m_topFault + thicknessFactors[i] * tVec, m_bottomFault + thicknessFactors[i] * tVec ) ); + faultLines.push_back( + caf::Line( m_topFault - origin + thicknessFactors[i] * tVec, m_bottomFault - origin + thicknessFactors[i] * tVec ) ); thicknessVectors.push_back( thicknessFactors[i] * tVec ); } - frontPart->generateGeometry( m_frontPoints, - frontReservoirLayers, + std::array shiftedFrontPoints; + for ( int i = 0; i < shiftedFrontPoints.size(); i++ ) + { + shiftedFrontPoints[i] = m_frontPoints[i] - origin; + } + + std::array shiftedBackPoints; + for ( int i = 0; i < shiftedBackPoints.size(); i++ ) + { + shiftedBackPoints[i] = m_backPoints[i] - origin; + } + + std::vector frontResZ = extractZValues( frontReservoirLayers ); + std::vector backResZ = extractZValues( backReservoirLayers ); + + frontPart->generateGeometry( shiftedFrontPoints, + frontResZ, m_maxCellHeight, m_cellSizeHeightFactor, m_horizontalPartition, @@ -598,8 +618,8 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta std::reverse( faultLines.begin(), faultLines.end() ); std::reverse( thicknessVectors.begin(), thicknessVectors.end() ); - backPart->generateGeometry( m_backPoints, - backReservoirLayers, + backPart->generateGeometry( shiftedBackPoints, + backResZ, m_maxCellHeight, m_cellSizeHeightFactor, m_horizontalPartition, @@ -608,6 +628,9 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta m_topReservoirBack.z(), m_faultZoneCells ); + frontPart->shiftNodes( origin ); + backPart->shiftNodes( origin ); + frontPart->generateLocalNodes( m_localCoordTransform ); backPart->generateLocalNodes( m_localCoordTransform ); @@ -792,3 +815,18 @@ std::pair RigFaultReactivationModelGenerator::depthTopBottom() c { return { -m_startDepth, m_bottomDepth }; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigFaultReactivationModelGenerator::extractZValues( const std::vector& points ) +{ + std::vector layers; + + for ( auto& p : points ) + { + layers.push_back( p.z() ); + } + + return layers; +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h index 5a110a5151..9ef12183e9 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h @@ -74,9 +74,10 @@ class RigFaultReactivationModelGenerator : cvf::Object static const std::vector partition( double distance, double startSize, double sizeFactor ); static std::pair sideFacesIJ( FaceType face ); - static cvf::Vec3d extrapolatePoint( cvf::Vec3d startPoint, cvf::Vec3d endPoint, double stopDepth ); - static void splitLargeLayers( std::map& layers, double maxHeight ); - static void mergeTinyLayers( std::map& layers, double minHeight ); + static cvf::Vec3d extrapolatePoint( cvf::Vec3d startPoint, cvf::Vec3d endPoint, double stopDepth ); + static void splitLargeLayers( std::map& layers, double maxHeight ); + static void mergeTinyLayers( std::map& layers, double minHeight ); + static std::vector extractZValues( const std::vector& points ); std::vector buildCellColumn( size_t startCell, FaceType startFace, std::map& layers ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp index 43566a56eb..739f6a7b8a 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp @@ -165,21 +165,6 @@ std::vector RigGriddedPart3d::generateGrowingLayers( double zFrom, doubl return layers; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RigGriddedPart3d::extractZValues( const std::vector& points ) -{ - std::vector layers; - - for ( auto& p : points ) - { - layers.push_back( p.z() ); - } - - return layers; -} - //-------------------------------------------------------------------------------------------------- /// Point index in input /// @@ -203,7 +188,7 @@ std::vector RigGriddedPart3d::extractZValues( const std::vector& inputPoints, - const std::vector& reservoirLayers, + const std::vector& reservoirZ, double maxCellHeight, double cellSizeFactor, const std::vector& horizontalPartition, @@ -220,8 +205,9 @@ void RigGriddedPart3d::generateGeometry( const std::array& in layersPerRegion[Regions::LowerUnderburden] = generateGrowingLayers( inputPoints[1].z(), inputPoints[0].z(), maxCellHeight, cellSizeFactor ); layersPerRegion[Regions::UpperUnderburden] = generateConstantLayers( inputPoints[1].z(), inputPoints[2].z(), maxCellHeight ); - layersPerRegion[Regions::Reservoir] = extractZValues( reservoirLayers ); - layersPerRegion[Regions::LowerOverburden] = generateConstantLayers( inputPoints[3].z(), inputPoints[4].z(), maxCellHeight ); + layersPerRegion[Regions::Reservoir] = reservoirZ; + + layersPerRegion[Regions::LowerOverburden] = generateConstantLayers( inputPoints[3].z(), inputPoints[4].z(), maxCellHeight ); layersPerRegion[Regions::UpperOverburden] = generateGrowingLayers( inputPoints[4].z(), inputPoints[5].z(), maxCellHeight, cellSizeFactor ); layersPerRegion[Regions::LowerUnderburden].pop_back(); // to avoid overlap with bottom of next region @@ -304,8 +290,10 @@ void RigGriddedPart3d::generateGeometry( const std::array& in } else if ( region == Regions::Reservoir ) { - toPos = reservoirLayers[v]; - fromPos.z() = toPos.z(); + fromPos.z() = reservoirZ[v]; + cvf::Plane zPlane; + zPlane.setFromPointAndNormal( fromPos, cvf::Vec3d::Z_AXIS ); + zPlane.intersect( faultLines[1].start(), faultLines[1].end(), &toPos ); } cvf::Vec3d stepHorz = toPos - fromPos; @@ -318,14 +306,7 @@ void RigGriddedPart3d::generateGeometry( const std::array& in for ( int h = 0; h <= (int)nHorzCells; h++ ) { - if ( h == (int)nHorzCells ) - { - p = toPos; - } - else - { - p = toPos - horizontalPartition[h] * stepHorz; - } + p = toPos - horizontalPartition[h] * stepHorz; for ( int t = 0; t <= nThicknessCells; t++, nodeIndex++ ) { @@ -336,7 +317,7 @@ void RigGriddedPart3d::generateGeometry( const std::array& in ( ( region == Regions::Reservoir ) || region == Regions::LowerOverburden || region == Regions::UpperUnderburden ) ) { cvf::Plane zPlane; - zPlane.setFromPointAndNormal( nodePoint, cvf::Vec3d::Z_AXIS ); + zPlane.setFromPointAndNormal( p, cvf::Vec3d::Z_AXIS ); zPlane.intersect( faultLines[t].start(), faultLines[t].end(), &nodePoint ); } @@ -687,6 +668,25 @@ void RigGriddedPart3d::generateLocalNodes( const cvf::Mat4d transform ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGriddedPart3d::shiftNodes( const cvf::Vec3d offset ) +{ + for ( int i = 0; i < m_nodes.size(); i++ ) + { + m_nodes[i] += offset; + } + + for ( int i = 0; i < m_meshLines.size(); i++ ) + { + for ( int j = 0; j < m_meshLines[i].size(); j++ ) + { + m_meshLines[i][j] += offset; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h index 554cea6400..13167d21f8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h @@ -50,7 +50,7 @@ class RigGriddedPart3d : public cvf::Object void reset(); void generateGeometry( const std::array& inputPoints, - const std::vector& reservoirLayers, + const std::vector& reservoirZ, double maxCellHeight, double cellSizeFactor, const std::vector& horizontalPartition, @@ -59,6 +59,7 @@ class RigGriddedPart3d : public cvf::Object double topHeight, int nFaultZoneCells ); + void shiftNodes( const cvf::Vec3d offset ); void generateLocalNodes( const cvf::Mat4d transform ); void setUseLocalCoordinates( bool useLocalCoordinates ); @@ -89,7 +90,6 @@ class RigGriddedPart3d : public cvf::Object static cvf::Vec3d stepVector( cvf::Vec3d start, cvf::Vec3d stop, int nSteps ); static std::vector generateConstantLayers( double zFrom, double zTo, double maxSize ); static std::vector generateGrowingLayers( double zFrom, double zTo, double maxSize, double growfactor ); - static std::vector extractZValues( const std::vector& points ); void generateVerticalMeshlines( const std::vector& cornerPoints, const std::vector& horzPartition ); From 0e9c42639e0cfc3d558a3018c82ea23f13d246ab Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Fri, 8 Mar 2024 15:02:39 +0100 Subject: [PATCH 2/3] Build fix --- ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp index 739f6a7b8a..2a693b37ef 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp @@ -673,14 +673,14 @@ void RigGriddedPart3d::generateLocalNodes( const cvf::Mat4d transform ) //-------------------------------------------------------------------------------------------------- void RigGriddedPart3d::shiftNodes( const cvf::Vec3d offset ) { - for ( int i = 0; i < m_nodes.size(); i++ ) + for ( int i = 0; i < (int)m_nodes.size(); i++ ) { m_nodes[i] += offset; } - for ( int i = 0; i < m_meshLines.size(); i++ ) + for ( int i = 0; i < (int)m_meshLines.size(); i++ ) { - for ( int j = 0; j < m_meshLines[i].size(); j++ ) + for ( int j = 0; j < (int)m_meshLines[i].size(); j++ ) { m_meshLines[i][j] += offset; } From 6ca2a21a967a87b4a9b990e1b67e96efc70382fa Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Fri, 8 Mar 2024 15:28:25 +0100 Subject: [PATCH 3/3] Minor adjustment --- .../RigFaultReactivationModelGenerator.cpp | 27 +++++++++++-------- .../RigFaultReactivationModelGenerator.h | 9 ++++--- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp index 81a808c5f5..137c7c8525 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp @@ -488,6 +488,20 @@ std::pair RigFaultReactivationModelGenerator::findCellWithInters return { i, j }; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::array RigFaultReactivationModelGenerator::shiftOrigin( const std::array& points, + const cvf::Vec3d& newOrigin ) +{ + std::array retPoints; + for ( int i = 0; i < (int)points.size(); i++ ) + { + retPoints[i] = points[i] - newOrigin; + } + return retPoints; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -590,17 +604,8 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta thicknessVectors.push_back( thicknessFactors[i] * tVec ); } - std::array shiftedFrontPoints; - for ( int i = 0; i < shiftedFrontPoints.size(); i++ ) - { - shiftedFrontPoints[i] = m_frontPoints[i] - origin; - } - - std::array shiftedBackPoints; - for ( int i = 0; i < shiftedBackPoints.size(); i++ ) - { - shiftedBackPoints[i] = m_backPoints[i] - origin; - } + std::array shiftedFrontPoints = shiftOrigin( m_frontPoints, origin ); + std::array shiftedBackPoints = shiftOrigin( m_backPoints, origin ); std::vector frontResZ = extractZValues( frontReservoirLayers ); std::vector backResZ = extractZValues( backReservoirLayers ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h index 9ef12183e9..7a4ef26bbc 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h @@ -74,10 +74,11 @@ class RigFaultReactivationModelGenerator : cvf::Object static const std::vector partition( double distance, double startSize, double sizeFactor ); static std::pair sideFacesIJ( FaceType face ); - static cvf::Vec3d extrapolatePoint( cvf::Vec3d startPoint, cvf::Vec3d endPoint, double stopDepth ); - static void splitLargeLayers( std::map& layers, double maxHeight ); - static void mergeTinyLayers( std::map& layers, double minHeight ); - static std::vector extractZValues( const std::vector& points ); + static cvf::Vec3d extrapolatePoint( cvf::Vec3d startPoint, cvf::Vec3d endPoint, double stopDepth ); + static void splitLargeLayers( std::map& layers, double maxHeight ); + static void mergeTinyLayers( std::map& layers, double minHeight ); + static std::vector extractZValues( const std::vector& points ); + static std::array shiftOrigin( const std::array& points, const cvf::Vec3d& newOrigin ); std::vector buildCellColumn( size_t startCell, FaceType startFace, std::map& layers );