mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Streamlines: New generator and UI usability improvements (#7424)
Co-authored-by: jonjenssen <jonjenssen@users.noreply.github.com> Co-authored-by: Magne Sjaastad <magne.sjaastad@ceetronsolutions.com>
This commit is contained in:
@@ -83,6 +83,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RigGocadData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigElasticProperties.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigHistogramData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigVisibleTracerFilter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigTracerPoint.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigTracer.h
|
||||
)
|
||||
|
||||
|
||||
@@ -163,6 +165,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RigGocadData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigElasticProperties.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigHistogramData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigVisibleTracerFilter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigTracerPoint.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigTracer.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -74,6 +74,28 @@ cvf::Vec3d RigCell::center() const
|
||||
return avg;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get the coordinates of the 4 corners of the given face
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::array<cvf::Vec3d, 4> RigCell::faceCorners( cvf::StructGridInterface::FaceType face ) const
|
||||
{
|
||||
std::array<cvf::Vec3d, 4> corners;
|
||||
cvf::ubyte faceVertexIndices[4];
|
||||
cvf::StructGridInterface::cellFaceVertexIndices( face, faceVertexIndices );
|
||||
|
||||
const std::vector<cvf::Vec3d>& nodeCoords = m_hostGrid->mainGrid()->nodes();
|
||||
|
||||
for ( size_t i = 0; i < 4; i++ )
|
||||
{
|
||||
corners[i] = nodeCoords[m_cornerIndices[faceVertexIndices[i]]];
|
||||
}
|
||||
|
||||
return corners;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool isNear( const cvf::Vec3d& p1, const cvf::Vec3d& p2, double tolerance )
|
||||
{
|
||||
if ( cvf::Math::abs( p1[0] - p2[0] ) < tolerance && cvf::Math::abs( p1[1] - p2[1] ) < tolerance &&
|
||||
@@ -418,3 +440,52 @@ cvf::BoundingBox RigCell::boundingBox() const
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Return the neighbor cell of the given face
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigCell RigCell::neighborCell( cvf::StructGridInterface::FaceType face ) const
|
||||
{
|
||||
size_t i, j, k;
|
||||
|
||||
m_hostGrid->ijkFromCellIndexUnguarded( mainGridCellIndex(), &i, &j, &k );
|
||||
|
||||
size_t neighborIdx;
|
||||
if ( m_hostGrid->cellIJKNeighbor( i, j, k, face, &neighborIdx ) )
|
||||
{
|
||||
return m_hostGrid->cell( neighborIdx );
|
||||
}
|
||||
|
||||
RigCell retcell;
|
||||
retcell.setInvalid( true );
|
||||
return retcell;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Find and return the main grid cell index of all up to 26 neighbor cells to the given cell
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<size_t> RigCell::allNeighborMainGridCellIndexes() const
|
||||
{
|
||||
std::vector<size_t> neighbors;
|
||||
|
||||
size_t ni, nj, nk;
|
||||
|
||||
m_hostGrid->ijkFromCellIndexUnguarded( mainGridCellIndex(), &ni, &nj, &nk );
|
||||
|
||||
for ( size_t i = ni - 1; i <= ni + 1; i++ )
|
||||
{
|
||||
for ( size_t j = nj - 1; j <= nj + 1; j++ )
|
||||
{
|
||||
for ( size_t k = nk - 1; k <= nk + 1; k++ )
|
||||
{
|
||||
if ( m_hostGrid->isCellValid( i, j, k ) )
|
||||
{
|
||||
size_t cellIndex = m_hostGrid->cellIndexFromIJK( i, j, k );
|
||||
if ( ( ni == i ) && ( nj == j ) && ( nk == k ) ) continue;
|
||||
neighbors.push_back( cellIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
@@ -65,10 +65,11 @@ public:
|
||||
size_t coarseningBoxIndex() const { return m_coarseningBoxIndex; }
|
||||
void setCoarseningBoxIndex( size_t coarseningBoxIndex ) { m_coarseningBoxIndex = coarseningBoxIndex; }
|
||||
|
||||
cvf::Vec3d center() const;
|
||||
cvf::Vec3d faceCenter( cvf::StructGridInterface::FaceType face ) const;
|
||||
cvf::Vec3d faceNormalWithAreaLength( cvf::StructGridInterface::FaceType face ) const;
|
||||
double volume() const;
|
||||
cvf::Vec3d center() const;
|
||||
std::array<cvf::Vec3d, 4> faceCorners( cvf::StructGridInterface::FaceType face ) const;
|
||||
cvf::Vec3d faceCenter( cvf::StructGridInterface::FaceType face ) const;
|
||||
cvf::Vec3d faceNormalWithAreaLength( cvf::StructGridInterface::FaceType face ) const;
|
||||
double volume() const;
|
||||
|
||||
int firstIntersectionPoint( const cvf::Ray& ray, cvf::Vec3d* intersectionPoint ) const;
|
||||
bool isLongPyramidCell( double maxHeightFactor = 5, double nodeNearTolerance = 1e-3 ) const;
|
||||
@@ -76,6 +77,9 @@ public:
|
||||
|
||||
cvf::BoundingBox boundingBox() const;
|
||||
|
||||
RigCell neighborCell( cvf::StructGridInterface::FaceType face ) const;
|
||||
std::vector<size_t> allNeighborMainGridCellIndexes() const;
|
||||
|
||||
private:
|
||||
std::array<size_t, 8> m_cornerIndices;
|
||||
|
||||
|
||||
106
ApplicationLibCode/ReservoirDataModel/RigTracer.cpp
Normal file
106
ApplicationLibCode/ReservoirDataModel/RigTracer.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 - Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigTracer.h"
|
||||
#include "RigTracerPoint.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigTracer::RigTracer()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigTracer::RigTracer( const RigTracer& other )
|
||||
: cvf::Object()
|
||||
{
|
||||
for ( auto p : other.m_points )
|
||||
{
|
||||
appendPoint( p.position(), p.direction(), p.phaseType() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigTracer::~RigTracer()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTracer::appendPoint( cvf::Vec3d position, cvf::Vec3d direction, RiaDefines::PhaseType dominantPhase )
|
||||
{
|
||||
m_points.push_back( RigTracerPoint( position, direction, dominantPhase ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<RigTracerPoint>& RigTracer::tracerPoints() const
|
||||
{
|
||||
return m_points;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigTracer::size() const
|
||||
{
|
||||
return m_points.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigTracer::totalDistance() const
|
||||
{
|
||||
if ( m_points.size() < 2 ) return 0.0;
|
||||
|
||||
cvf::Vec3d sp = m_points.front().position();
|
||||
|
||||
double distance = 0.0;
|
||||
for ( size_t i = 1; i < m_points.size(); i++ )
|
||||
{
|
||||
distance += sp.pointDistance( m_points[i].position() );
|
||||
sp = m_points[i].position();
|
||||
}
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTracer::reverse()
|
||||
{
|
||||
if ( m_points.empty() ) return;
|
||||
|
||||
// Reverse ordering of all tracer points
|
||||
std::reverse( m_points.begin(), m_points.end() );
|
||||
|
||||
for ( auto& p : m_points )
|
||||
{
|
||||
// Reverse the flow direction in tracer point
|
||||
p.reverse();
|
||||
}
|
||||
}
|
||||
51
ApplicationLibCode/ReservoirDataModel/RigTracer.h
Normal file
51
ApplicationLibCode/ReservoirDataModel/RigTracer.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 - Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RigTracerPoint;
|
||||
|
||||
//==================================================================================================
|
||||
/// Class representing one streamline tracer line, with position and direction given for each
|
||||
/// time increment.
|
||||
//==================================================================================================
|
||||
class RigTracer : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RigTracer();
|
||||
explicit RigTracer( const RigTracer& other );
|
||||
~RigTracer() override;
|
||||
|
||||
void appendPoint( cvf::Vec3d position, cvf::Vec3d direction, RiaDefines::PhaseType dominantPhase );
|
||||
size_t size() const;
|
||||
double totalDistance() const;
|
||||
|
||||
void reverse();
|
||||
|
||||
const std::vector<RigTracerPoint>& tracerPoints() const;
|
||||
|
||||
private:
|
||||
std::vector<RigTracerPoint> m_points;
|
||||
};
|
||||
77
ApplicationLibCode/ReservoirDataModel/RigTracerPoint.cpp
Normal file
77
ApplicationLibCode/ReservoirDataModel/RigTracerPoint.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 - Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigTracerPoint.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigTracerPoint::RigTracerPoint( cvf::Vec3d position, cvf::Vec3d direction, RiaDefines::PhaseType phase )
|
||||
: m_position( position )
|
||||
, m_direction( direction )
|
||||
, m_phaseType( phase )
|
||||
{
|
||||
m_absValue = m_direction.length();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigTracerPoint::~RigTracerPoint()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::Vec3d& RigTracerPoint::position() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::Vec3d& RigTracerPoint::direction() const
|
||||
{
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigTracerPoint::absValue() const
|
||||
{
|
||||
return m_absValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaDefines::PhaseType RigTracerPoint::phaseType() const
|
||||
{
|
||||
return m_phaseType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTracerPoint::reverse()
|
||||
{
|
||||
m_direction *= -1.0;
|
||||
}
|
||||
48
ApplicationLibCode/ReservoirDataModel/RigTracerPoint.h
Normal file
48
ApplicationLibCode/ReservoirDataModel/RigTracerPoint.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 - Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
//==================================================================================================
|
||||
/// Class representing one single point in a streamline tracer. The point has a position and
|
||||
/// and a direction vector. The absolute value of the direction vector is precalculated to save
|
||||
/// some calculation time later on.
|
||||
/// A phaseType flag indicates what was the dominant phase at this position.
|
||||
//==================================================================================================
|
||||
class RigTracerPoint
|
||||
{
|
||||
public:
|
||||
RigTracerPoint( cvf::Vec3d position, cvf::Vec3d direction, RiaDefines::PhaseType phase );
|
||||
~RigTracerPoint();
|
||||
|
||||
const cvf::Vec3d& position() const;
|
||||
const cvf::Vec3d& direction() const;
|
||||
double absValue() const;
|
||||
RiaDefines::PhaseType phaseType() const;
|
||||
|
||||
void reverse();
|
||||
|
||||
private:
|
||||
cvf::Vec3d m_position;
|
||||
cvf::Vec3d m_direction;
|
||||
double m_absValue;
|
||||
RiaDefines::PhaseType m_phaseType;
|
||||
};
|
||||
Reference in New Issue
Block a user