mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9601 Roff: templatize method for converting to reservoir index order.
This commit is contained in:
parent
b108cdb72d
commit
1d4140e854
@ -181,7 +181,7 @@ bool RifRoffFileTools::openGridFile( const QString& fileName, RigEclipseCaseData
|
|||||||
cvf::Vec3d scale( xScale, yScale, zScale );
|
cvf::Vec3d scale( xScale, yScale, zScale );
|
||||||
|
|
||||||
std::vector<int> activeCells;
|
std::vector<int> activeCells;
|
||||||
convertToReservoirIndexOrder( nx, ny, nz, active, activeCells );
|
convertToReservoirIndexOrder<char, int>( nx, ny, nz, active, activeCells );
|
||||||
|
|
||||||
// Precompute the active cell matrix index
|
// Precompute the active cell matrix index
|
||||||
size_t numActiveCells = computeActiveCellMatrixIndex( activeCells );
|
size_t numActiveCells = computeActiveCellMatrixIndex( activeCells );
|
||||||
@ -459,114 +459,6 @@ void RifRoffFileTools::interpretSplitenzData( int nz,
|
|||||||
if ( it_zcorn != nzcorn ) throw std::runtime_error( "Incorrect size of zcorn." );
|
if ( it_zcorn != nzcorn ) throw std::runtime_error( "Incorrect size of zcorn." );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RifRoffFileTools::convertToReservoirIndexOrder( int nx,
|
|
||||||
int ny,
|
|
||||||
int nz,
|
|
||||||
const std::vector<char>& activeIn,
|
|
||||||
std::vector<int>& activeOut )
|
|
||||||
{
|
|
||||||
CAF_ASSERT( static_cast<size_t>( nx ) * ny * nz == activeIn.size() );
|
|
||||||
|
|
||||||
activeOut.resize( activeIn.size(), -1 );
|
|
||||||
|
|
||||||
int outIdx = 0;
|
|
||||||
for ( int k = 0; k < nz; k++ )
|
|
||||||
{
|
|
||||||
for ( int j = 0; j < ny; j++ )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < nx; i++ )
|
|
||||||
{
|
|
||||||
int inIdx = i * ny * nz + j * nz + ( nz - k - 1 );
|
|
||||||
activeOut[outIdx] = static_cast<int>( activeIn[inIdx] );
|
|
||||||
outIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RifRoffFileTools::convertToReservoirIndexOrder( int nx,
|
|
||||||
int ny,
|
|
||||||
int nz,
|
|
||||||
const std::vector<float>& in,
|
|
||||||
std::vector<double>& out )
|
|
||||||
{
|
|
||||||
CAF_ASSERT( static_cast<size_t>( nx ) * ny * nz == in.size() );
|
|
||||||
|
|
||||||
out.resize( in.size(), 0.0 );
|
|
||||||
|
|
||||||
int outIdx = 0;
|
|
||||||
for ( int k = 0; k < nz; k++ )
|
|
||||||
{
|
|
||||||
for ( int j = 0; j < ny; j++ )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < nx; i++ )
|
|
||||||
{
|
|
||||||
int inIdx = i * ny * nz + j * nz + ( nz - k - 1 );
|
|
||||||
out[outIdx] = in[inIdx];
|
|
||||||
outIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RifRoffFileTools::convertToReservoirIndexOrder( int nx,
|
|
||||||
int ny,
|
|
||||||
int nz,
|
|
||||||
const std::vector<char>& in,
|
|
||||||
std::vector<double>& out )
|
|
||||||
{
|
|
||||||
CAF_ASSERT( static_cast<size_t>( nx ) * ny * nz == in.size() );
|
|
||||||
|
|
||||||
out.resize( in.size(), 0.0 );
|
|
||||||
|
|
||||||
int outIdx = 0;
|
|
||||||
for ( int k = 0; k < nz; k++ )
|
|
||||||
{
|
|
||||||
for ( int j = 0; j < ny; j++ )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < nx; i++ )
|
|
||||||
{
|
|
||||||
int inIdx = i * ny * nz + j * nz + ( nz - k - 1 );
|
|
||||||
out[outIdx] = in[inIdx];
|
|
||||||
outIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RifRoffFileTools::convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<int>& in, std::vector<double>& out )
|
|
||||||
{
|
|
||||||
CAF_ASSERT( static_cast<size_t>( nx ) * ny * nz == in.size() );
|
|
||||||
|
|
||||||
out.resize( in.size(), 0.0 );
|
|
||||||
|
|
||||||
int outIdx = 0;
|
|
||||||
for ( int k = 0; k < nz; k++ )
|
|
||||||
{
|
|
||||||
for ( int j = 0; j < ny; j++ )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < nx; i++ )
|
|
||||||
{
|
|
||||||
int inIdx = i * ny * nz + j * nz + ( nz - k - 1 );
|
|
||||||
out[outIdx] = in[inIdx];
|
|
||||||
outIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -669,17 +561,17 @@ std::vector<double> RifRoffFileTools::readAndConvertToDouble( int
|
|||||||
if ( kind == roff::Token::Kind::FLOAT )
|
if ( kind == roff::Token::Kind::FLOAT )
|
||||||
{
|
{
|
||||||
std::vector<float> values = reader.getFloatArray( keyword );
|
std::vector<float> values = reader.getFloatArray( keyword );
|
||||||
convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals );
|
convertToReservoirIndexOrder<float, double>( nx, ny, nz, values, doubleVals );
|
||||||
}
|
}
|
||||||
else if ( kind == roff::Token::Kind::BOOL )
|
else if ( kind == roff::Token::Kind::BOOL )
|
||||||
{
|
{
|
||||||
std::vector<char> values = reader.getByteArray( keyword );
|
std::vector<char> values = reader.getByteArray( keyword );
|
||||||
convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals );
|
convertToReservoirIndexOrder<char, double>( nx, ny, nz, values, doubleVals );
|
||||||
}
|
}
|
||||||
else if ( kind == roff::Token::Kind::INT )
|
else if ( kind == roff::Token::Kind::INT )
|
||||||
{
|
{
|
||||||
std::vector<int> values = reader.getIntArray( keyword );
|
std::vector<int> values = reader.getIntArray( keyword );
|
||||||
convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals );
|
convertToReservoirIndexOrder<int, double>( nx, ny, nz, values, doubleVals );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
|
#include "cafAssert.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -60,17 +62,6 @@ private:
|
|||||||
const std::vector<float>& zdata,
|
const std::vector<float>& zdata,
|
||||||
std::vector<float>& zcornsv );
|
std::vector<float>& zcornsv );
|
||||||
|
|
||||||
static void
|
|
||||||
convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<char>& activeIn, std::vector<int>& activeOut );
|
|
||||||
|
|
||||||
static void
|
|
||||||
convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<float>& in, std::vector<double>& out );
|
|
||||||
|
|
||||||
static void convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<int>& in, std::vector<double>& out );
|
|
||||||
|
|
||||||
static void
|
|
||||||
convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<char>& in, std::vector<double>& out );
|
|
||||||
|
|
||||||
static size_t computeActiveCellMatrixIndex( std::vector<int>& activeCells );
|
static size_t computeActiveCellMatrixIndex( std::vector<int>& activeCells );
|
||||||
|
|
||||||
static cvf::Vec3d getCorner( const RigMainGrid& grid,
|
static cvf::Vec3d getCorner( const RigMainGrid& grid,
|
||||||
@ -91,4 +82,26 @@ private:
|
|||||||
const std::string& keyword,
|
const std::string& keyword,
|
||||||
roff::Token::Kind token,
|
roff::Token::Kind token,
|
||||||
roff::Reader& reader );
|
roff::Reader& reader );
|
||||||
|
|
||||||
|
template <typename IN, typename OUT>
|
||||||
|
static void convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<IN>& in, std::vector<OUT>& out )
|
||||||
|
{
|
||||||
|
CAF_ASSERT( static_cast<size_t>( nx ) * ny * nz == in.size() );
|
||||||
|
|
||||||
|
out.resize( in.size(), -1 );
|
||||||
|
|
||||||
|
int outIdx = 0;
|
||||||
|
for ( int k = 0; k < nz; k++ )
|
||||||
|
{
|
||||||
|
for ( int j = 0; j < ny; j++ )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < nx; i++ )
|
||||||
|
{
|
||||||
|
int inIdx = i * ny * nz + j * nz + ( nz - k - 1 );
|
||||||
|
out[outIdx] = static_cast<OUT>( in[inIdx] );
|
||||||
|
outIdx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user