mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Roff: improve property handling: handle more data types and map ACTNUM.
This commit is contained in:
@@ -493,7 +493,59 @@ void RifRoffFileTools::convertToReservoirIndexOrder( int n
|
|||||||
int ny,
|
int ny,
|
||||||
int nz,
|
int nz,
|
||||||
const std::vector<float>& in,
|
const std::vector<float>& in,
|
||||||
std::vector<float>& out )
|
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() );
|
CAF_ASSERT( static_cast<size_t>( nx ) * ny * nz == in.size() );
|
||||||
|
|
||||||
@@ -571,8 +623,13 @@ bool RifRoffFileTools::createInputProperties( const QString& fileName, RigEclips
|
|||||||
{
|
{
|
||||||
QString newResultName = eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )
|
QString newResultName = eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )
|
||||||
->makeResultNameUnique( QString::fromStdString( keyword ) );
|
->makeResultNameUnique( QString::fromStdString( keyword ) );
|
||||||
|
// Special handling for active.data ==> ACTNUM
|
||||||
|
if ( newResultName == "active.data" )
|
||||||
|
{
|
||||||
|
newResultName = "ACTNUM";
|
||||||
|
}
|
||||||
|
|
||||||
if ( !appendNewInputPropertyResult( eclipseCaseData, newResultName, keyword, reader ) )
|
if ( !appendNewInputPropertyResult( eclipseCaseData, newResultName, keyword, kind, reader ) )
|
||||||
{
|
{
|
||||||
RiaLogging::error( QString( "Unable to import result '%1' from %2" )
|
RiaLogging::error( QString( "Unable to import result '%1' from %2" )
|
||||||
.arg( QString::fromStdString( keyword ) )
|
.arg( QString::fromStdString( keyword ) )
|
||||||
@@ -591,25 +648,55 @@ bool RifRoffFileTools::createInputProperties( const QString& fileName, RigEclips
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<double>
|
||||||
|
RifRoffFileTools::readAndConvertToDouble( int nx, int ny, int nz, const std::string& keyword, Token::Kind kind, Reader& reader )
|
||||||
|
{
|
||||||
|
std::vector<double> doubleVals;
|
||||||
|
|
||||||
|
if ( kind == Token::Kind::FLOAT )
|
||||||
|
{
|
||||||
|
std::vector<float> values = reader.getFloatArray( keyword );
|
||||||
|
convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals );
|
||||||
|
}
|
||||||
|
else if ( kind == Token::Kind::BOOL )
|
||||||
|
{
|
||||||
|
std::vector<char> values = reader.getByteArray( keyword );
|
||||||
|
convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals );
|
||||||
|
}
|
||||||
|
else if ( kind == Token::Kind::INT )
|
||||||
|
{
|
||||||
|
std::vector<int> values = reader.getIntArray( keyword );
|
||||||
|
convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RiaLogging::error( QString( "Unsupported property type '%1' for keyword '%2'." )
|
||||||
|
.arg( QString::fromStdString( Token::kindToString( kind ) ) )
|
||||||
|
.arg( QString::fromStdString( keyword ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return doubleVals;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RifRoffFileTools::appendNewInputPropertyResult( RigEclipseCaseData* caseData,
|
bool RifRoffFileTools::appendNewInputPropertyResult( RigEclipseCaseData* caseData,
|
||||||
const QString& resultName,
|
const QString& resultName,
|
||||||
const std::string& keyword,
|
const std::string& keyword,
|
||||||
|
Token::Kind kind,
|
||||||
Reader& reader )
|
Reader& reader )
|
||||||
{
|
{
|
||||||
CVF_ASSERT( caseData );
|
CVF_ASSERT( caseData );
|
||||||
|
|
||||||
std::vector<float> values = reader.getFloatArray( keyword );
|
int nx = caseData->mainGrid()->cellCountI();
|
||||||
CAF_ASSERT( values.size() == caseData->mainGrid()->cellCount() );
|
int ny = caseData->mainGrid()->cellCountJ();
|
||||||
|
int nz = caseData->mainGrid()->cellCountK();
|
||||||
int nx = caseData->mainGrid()->cellCountI();
|
std::vector<double> values = readAndConvertToDouble( nx, ny, nz, keyword, kind, reader );
|
||||||
int ny = caseData->mainGrid()->cellCountJ();
|
if ( values.size() != caseData->mainGrid()->cellCount() ) return false;
|
||||||
int nz = caseData->mainGrid()->cellCountK();
|
|
||||||
|
|
||||||
std::vector<float> valuesReservoirOrder;
|
|
||||||
convertToReservoirIndexOrder( nx, ny, nz, values, valuesReservoirOrder );
|
|
||||||
|
|
||||||
RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::INPUT_PROPERTY, resultName );
|
RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::INPUT_PROPERTY, resultName );
|
||||||
caseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->createResultEntry( resAddr, false );
|
caseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->createResultEntry( resAddr, false );
|
||||||
@@ -617,10 +704,7 @@ bool RifRoffFileTools::appendNewInputPropertyResult( RigEclipseCaseData* caseDat
|
|||||||
auto newPropertyData =
|
auto newPropertyData =
|
||||||
caseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->modifiableCellScalarResultTimesteps( resAddr );
|
caseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->modifiableCellScalarResultTimesteps( resAddr );
|
||||||
|
|
||||||
std::vector<double> doubleVals;
|
newPropertyData->push_back( values );
|
||||||
doubleVals.insert( doubleVals.begin(), valuesReservoirOrder.begin(), valuesReservoirOrder.end() );
|
|
||||||
|
|
||||||
newPropertyData->push_back( doubleVals );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Token.hpp"
|
||||||
|
|
||||||
class RigEclipseCaseData;
|
class RigEclipseCaseData;
|
||||||
class RigMainGrid;
|
class RigMainGrid;
|
||||||
class Reader;
|
class Reader;
|
||||||
@@ -56,7 +58,12 @@ private:
|
|||||||
convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<char>& activeIn, std::vector<int>& activeOut );
|
convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<char>& activeIn, std::vector<int>& activeOut );
|
||||||
|
|
||||||
static void
|
static void
|
||||||
convertToReservoirIndexOrder( int nx, int ny, int nz, const std::vector<float>& in, std::vector<float>& out );
|
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 );
|
||||||
|
|
||||||
@@ -70,8 +77,12 @@ private:
|
|||||||
|
|
||||||
static double interpolate( const cvf::Vec3d& top, const cvf::Vec3d& bottom, double z, int idx );
|
static double interpolate( const cvf::Vec3d& top, const cvf::Vec3d& bottom, double z, int idx );
|
||||||
|
|
||||||
|
static std::vector<double>
|
||||||
|
readAndConvertToDouble( int nx, int ny, int nz, const std::string& keyword, Token::Kind kind, Reader& reader );
|
||||||
|
|
||||||
static bool appendNewInputPropertyResult( RigEclipseCaseData* caseData,
|
static bool appendNewInputPropertyResult( RigEclipseCaseData* caseData,
|
||||||
const QString& resultName,
|
const QString& resultName,
|
||||||
const std::string& keyword,
|
const std::string& keyword,
|
||||||
|
Token::Kind token,
|
||||||
Reader& reader );
|
Reader& reader );
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user