Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Feb 27, 2024
1 parent 672fbe1 commit 3c40552
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ std::pair<bool, std::string> RifFaultReactivationModelExporter::printParts(
for ( auto [boundary, boundaryName] : boundaries )
{
// Create boundary condition sets for each side of the parts (except top).
auto boundaryNodes = grid->boundaryNodes();
auto boundaryElements = grid->boundaryElements();
const auto& boundaryNodes = grid->boundaryNodes();
const auto& boundaryElements = grid->boundaryElements();

const std::vector<unsigned int>& nodes = boundaryNodes[boundary];
const std::vector<unsigned int>& nodes = boundaryNodes.at( boundary );
RifInpExportTools::printNodeSet( stream, boundaryName, false, nodes );

const std::vector<unsigned int>& elements = boundaryElements[boundary];
const std::vector<unsigned int>& elements = boundaryElements.at( boundary );
RifInpExportTools::printElementSet( stream, boundaryName, false, elements );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ enum class Boundary
{
FarSide,
Bottom,
Fault
Fault,
Reservoir
};

enum class ElementSets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include "RimEclipseCase.h"

#include "cafLine.h"

#include <limits>

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -259,8 +261,13 @@ void RigFaultReactivationModel::postProcessElementSets( const RimEclipseCase* eC

auto cellInfo = eCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );

auto [top, bottom] = faultTopBottom();
caf::Line<double> line( top, bottom );

for ( auto part : allGridParts() )
{
m_3dparts[part]->postProcessElementSets( eCase->mainGrid(), cellInfo );
auto gridPart = m_3dparts[part];
gridPart->postProcessElementSets( eCase->mainGrid(), cellInfo );
// gridPart->postProcessBoundaryNodes( line );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta
m_modelThickness,
m_topReservoirFront.z(),
m_modelNormal,
m_faultZoneCells );
m_faultZoneCells,
faultTopBottomPoints() );
backPart->generateGeometry( m_backPoints,
backReservoirLayers,
m_maxCellHeight,
Expand All @@ -591,7 +592,8 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta
m_modelThickness,
m_topReservoirBack.z(),
-1.0 * m_modelNormal,
m_faultZoneCells );
m_faultZoneCells,
faultTopBottomPoints() );

frontPart->generateLocalNodes( m_localCoordTransform );
backPart->generateLocalNodes( m_localCoordTransform );
Expand Down
60 changes: 51 additions & 9 deletions ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "cvfBoundingBox.h"
#include "cvfTextureImage.h"

#include "cafLine.h"

#include <cmath>
#include <map>

Expand Down Expand Up @@ -207,7 +209,8 @@ void RigGriddedPart3d::generateGeometry( const std::array<cvf::Vec3d, 12>& input
double modelThickness,
double topHeight,
cvf::Vec3d thicknessDirection,
int nFaultZoneCells )
int nFaultZoneCells,
std::pair<cvf::Vec3d, cvf::Vec3d> topBottomFaultPoints )
{
reset();

Expand All @@ -224,9 +227,10 @@ void RigGriddedPart3d::generateGeometry( const std::array<cvf::Vec3d, 12>& input
layersPerRegion[Regions::LowerUnderburden].pop_back(); // to avoid overlap with bottom of next region
layersPerRegion[Regions::Reservoir].pop_back(); // to avoid overlap with bottom of next region

m_boundaryNodes[Boundary::Bottom] = {};
m_boundaryNodes[Boundary::FarSide] = {};
m_boundaryNodes[Boundary::Fault] = {};
m_boundaryNodes[Boundary::Bottom] = {};
m_boundaryNodes[Boundary::FarSide] = {};
m_boundaryNodes[Boundary::Fault] = {};
m_boundaryNodes[Boundary::Reservoir] = {};

size_t nVertCells = 0;
const size_t nHorzCells = horizontalPartition.size() - 1;
Expand All @@ -236,9 +240,16 @@ void RigGriddedPart3d::generateGeometry( const std::array<cvf::Vec3d, 12>& input
nVertCells += layersPerRegion[region].size();
}

const std::vector<double> thicknessFactors = { -1.0, 0.0, 1.0 };
const int nThicknessCells = 2;
cvf::Vec3d tVec = modelThickness * thicknessDirection;
const std::vector<double> thicknessFactors = { -1.0, 0.0, 1.0 };
const int nThicknessCells = 2;
cvf::Vec3d tVec = modelThickness * thicknessDirection;
std::vector<caf::Line<double>> faultLines;

for ( int i = 0; i <= nThicknessCells; i++ )
{
faultLines.push_back( caf::Line<double>( topBottomFaultPoints.first + thicknessFactors[i] * tVec,
topBottomFaultPoints.second + thicknessFactors[i] * tVec ) );
}

size_t reserveSize = ( nVertCells + 1 ) * ( nHorzCells + 1 ) * ( nThicknessCells + 1 );
m_nodes.reserve( reserveSize );
Expand Down Expand Up @@ -316,11 +327,26 @@ void RigGriddedPart3d::generateGeometry( const std::array<cvf::Vec3d, 12>& input

for ( int h = 0; h <= (int)nHorzCells; h++ )
{
p = toPos - horizontalPartition[h] * stepHorz;
if ( h == (int)nHorzCells )
{
p = toPos;
}
else
{
p = toPos - horizontalPartition[h] * stepHorz;
}

for ( int t = 0; t <= nThicknessCells; t++, nodeIndex++ )
{
m_nodes.push_back( p + thicknessFactors[t] * tVec );
auto nodePoint = p + thicknessFactors[t] * tVec;

if ( ( h == (int)nHorzCells ) &&
( ( region == Regions::Reservoir ) || region == Regions::LowerOverburden || region == Regions::UpperUnderburden ) )
{
nodePoint = faultLines[t].closestPointOnLine( nodePoint );
}

m_nodes.push_back( nodePoint );

if ( h == (int)nHorzCells )
{
Expand All @@ -342,6 +368,11 @@ void RigGriddedPart3d::generateGeometry( const std::array<cvf::Vec3d, 12>& input
else if ( h == (int)nHorzCells )
{
m_boundaryNodes[Boundary::Fault].push_back( nodeIndex );

if ( region == Regions::Reservoir )
{
m_boundaryNodes[Boundary::Reservoir].push_back( nodeIndex );
}
}
}
}
Expand Down Expand Up @@ -767,3 +798,14 @@ void RigGriddedPart3d::updateElementSet( ElementSets elSet,
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGriddedPart3d::postProcessBoundaryNodes( const caf::Line<double>& faultLine )
{
for ( auto nodeIdx : m_boundaryNodes.at( RimFaultReactivation::Boundary::Reservoir ) )
{
m_nodes[nodeIdx] = faultLine.closestPointOnLine( m_nodes[nodeIdx] );
}
}
6 changes: 5 additions & 1 deletion ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "cvfObject.h"
#include "cvfVector3.h"

#include "cafLine.h"

#include <array>
#include <map>
#include <set>
Expand Down Expand Up @@ -55,12 +57,14 @@ class RigGriddedPart3d : public cvf::Object
double modelThickness,
double topHeight,
cvf::Vec3d thicknessDirection,
int nFaultZoneCells );
int nFaultZoneCells,
std::pair<cvf::Vec3d, cvf::Vec3d> topBottomFaultPoints );

void generateLocalNodes( const cvf::Mat4d transform );
void setUseLocalCoordinates( bool useLocalCoordinates );

void postProcessElementSets( const RigMainGrid* mainGrid, const RigActiveCellInfo* cellInfo );
void postProcessBoundaryNodes( const caf::Line<double>& faultLine );

bool useLocalCoordinates() const;
double topHeight() const;
Expand Down
2 changes: 2 additions & 0 deletions Fwk/AppFwk/cafVizExtensions/cafLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class Line

Line findLineBetweenNearestPoints( const Line& otherLine, bool* withinLineSegments = nullptr );

cvf::Vector3<S> closestPointOnLine( const cvf::Vector3<S>& point ) const;

private:
cvf::Vector3<S> m_start;
cvf::Vector3<S> m_end;
Expand Down
24 changes: 24 additions & 0 deletions Fwk/AppFwk/cafVizExtensions/cafLine.inl
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,27 @@ caf::Line<S> caf::Line<S>::findLineBetweenNearestPoints( const Line& otherLine,
}
return Line( start() + s * d1, otherLine.start() + t * d2 );
}

//--------------------------------------------------------------------------------------------------
/// Returns the closest point on the line segment to the given point
/// From https://paulbourke.net/geometry/pointlineplane/
//--------------------------------------------------------------------------------------------------
template <typename S>
cvf::Vector3<S> caf::Line<S>::closestPointOnLine( const cvf::Vector3<S>& point ) const
{
S distance = vector().length();

const double u = ( ( ( point.x() - start().x() ) * ( end().x() - start().x() ) ) +
( ( point.y() - start().y() ) * ( end().y() - start().y() ) ) +
( ( point.z() - start().z() ) * ( end().z() - start().z() ) ) ) /
( distance * distance );

if ( u < 0.0 ) return start();
if ( u > 1.0 ) return end();

cvf::Vector3<S> projectedPoint( ( start().x() + u * ( end().x() - start().x() ) ),
( start().y() + u * ( end().y() - start().y() ) ),
( start().z() + u * ( end().z() - start().z() ) ) );

return projectedPoint;
}

0 comments on commit 3c40552

Please sign in to comment.