mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4259 Implement mapaxes keyword with possibility to export in local coordinates
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
|
||||
#include "ert/ecl/ecl_box.hpp"
|
||||
#include "ert/ecl/ecl_kw.h"
|
||||
#include "ert/ecl/ecl_grid.hpp"
|
||||
|
||||
QString includeKeyword("INCLUDE");
|
||||
QString faultsKeyword("FAULTS");
|
||||
@@ -212,6 +213,16 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName,
|
||||
mainGrid->setFaults(faults);
|
||||
}
|
||||
|
||||
bool useMapAxes = ecl_grid_use_mapaxes(inputGrid);
|
||||
eclipseCase->mainGrid()->setUseMapAxes(useMapAxes);
|
||||
|
||||
if (useMapAxes)
|
||||
{
|
||||
std::array<double, 6> mapAxesValues;
|
||||
ecl_grid_init_mapaxes_data_double(inputGrid, mapAxesValues.data());
|
||||
eclipseCase->mainGrid()->setMapAxes(mapAxesValues);
|
||||
}
|
||||
|
||||
progress.setProgress(8);
|
||||
progress.setProgressDescription("Cleaning up ...");
|
||||
|
||||
@@ -233,6 +244,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
|
||||
RigEclipseCaseData* eclipseCase,
|
||||
bool exportInLocalCoordinates,
|
||||
const cvf::UByteArray* cellVisibilityOverrideForActnum,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& maxIn,
|
||||
@@ -271,6 +283,20 @@ bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
|
||||
std::vector<int*> ecl_coords;
|
||||
ecl_coords.reserve(mainGrid->cellCount() * cellsPerOriginal);
|
||||
|
||||
std::array<float, 6> mapAxes = mainGrid->mapAxesF();
|
||||
cvf::Mat4d mapAxisTrans = mainGrid->mapAxisTransform();
|
||||
if (exportInLocalCoordinates)
|
||||
{
|
||||
cvf::Vec3d minPoint3d(mainGrid->boundingBox().min());
|
||||
cvf::Vec2f minPoint2f(minPoint3d.x(), minPoint3d.y());
|
||||
cvf::Vec2f origin(mapAxes[2] - minPoint2f.x(), mapAxes[3] - minPoint2f.y());
|
||||
cvf::Vec2f xPoint = cvf::Vec2f(mapAxes[4], mapAxes[5]) - minPoint2f;
|
||||
cvf::Vec2f yPoint = cvf::Vec2f(mapAxes[0], mapAxes[1]) - minPoint2f;
|
||||
mapAxes = { yPoint.x(), yPoint.y(), origin.x(), origin.y(), xPoint.x(), xPoint.y() };
|
||||
|
||||
mapAxisTrans.setTranslation(mapAxisTrans.translation() - minPoint3d);
|
||||
}
|
||||
|
||||
const size_t* cellMappingECLRi = RifReaderEclipseOutput::eclipseCellIndexMapping();
|
||||
|
||||
int incrementalIndex = 0;
|
||||
@@ -306,6 +332,14 @@ bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
|
||||
std::array<cvf::Vec3d, 8> cellCorners;
|
||||
mainGrid->cellCornerVertices(mainIndex, cellCorners.data());
|
||||
|
||||
if (mainGrid->useMapAxes())
|
||||
{
|
||||
for (cvf::Vec3d& corner : cellCorners)
|
||||
{
|
||||
corner.transformPoint(mapAxisTrans);
|
||||
}
|
||||
}
|
||||
|
||||
auto refinedCoords =
|
||||
RiaCellDividingTools::createHexCornerCoords(cellCorners, refinement.x(), refinement.y(), refinement.z());
|
||||
|
||||
@@ -317,7 +351,7 @@ bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
|
||||
float* ecl_cell_corners = new float[24];
|
||||
for (size_t cIdx = 0; cIdx < 8; ++cIdx)
|
||||
{
|
||||
cvf::Vec3d cellCorner = refinedCoords[subIndex * 8 + cIdx];
|
||||
cvf::Vec3d cellCorner = refinedCoords[subIndex * 8 + cIdx];
|
||||
ecl_cell_corners[cellMappingECLRi[cIdx] * 3] = cellCorner[0];
|
||||
ecl_cell_corners[cellMappingECLRi[cIdx] * 3 + 1] = cellCorner[1];
|
||||
ecl_cell_corners[cellMappingECLRi[cIdx] * 3 + 2] = -cellCorner[2];
|
||||
@@ -332,7 +366,7 @@ bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
|
||||
}
|
||||
|
||||
ecl_grid_type* mainEclGrid =
|
||||
ecl_grid_alloc_GRID_data((int)ecl_coords.size(), ecl_nx, ecl_ny, ecl_nz, 5, &ecl_coords[0], &ecl_corners[0], false, NULL);
|
||||
ecl_grid_alloc_GRID_data((int)ecl_coords.size(), ecl_nx, ecl_ny, ecl_nz, 5, &ecl_coords[0], &ecl_corners[0], false, mapAxes.data());
|
||||
progress.setProgress(mainGrid->cellCount());
|
||||
|
||||
for (float* floatArray : ecl_corners)
|
||||
@@ -399,7 +433,12 @@ bool RifEclipseInputFileTools::exportKeywords(const QString& result
|
||||
std::vector<double> resultValues;
|
||||
|
||||
RigEclipseResultAddress resAddr(RiaDefines::STATIC_NATIVE, keyword);
|
||||
CVF_ASSERT(cellResultsData->hasResultEntry(resAddr));
|
||||
|
||||
cellResultsData->ensureKnownResultLoaded(resAddr);
|
||||
|
||||
CVF_ASSERT(!cellResultsData->cellScalarResults(resAddr).empty());
|
||||
|
||||
resultValues = cellResultsData->cellScalarResults(resAddr)[0];
|
||||
CVF_ASSERT(!resultValues.empty());
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
|
||||
static bool exportGrid(const QString& gridFileName,
|
||||
RigEclipseCaseData* eclipseCase,
|
||||
bool exportInLocalCoordinates,
|
||||
const cvf::UByteArray* cellVisibilityOverrideForActnum = nullptr,
|
||||
const cvf::Vec3st& min = cvf::Vec3st::ZERO,
|
||||
const cvf::Vec3st& max = cvf::Vec3st::UNDEFINED,
|
||||
|
||||
Reference in New Issue
Block a user