Moved result interface from struct grid to struct grid scalar data access

Use this concept to configure result data values to use for vizualization. Created data access object for RegGrid.
p4#: 20334
This commit is contained in:
Magne Sjaastad 2013-02-01 12:25:34 +01:00
parent 602c9f5535
commit 01f3fb8e94
12 changed files with 244 additions and 28 deletions

View File

@ -100,6 +100,7 @@ list( APPEND CPP_SOURCES
ReservoirDataModel/RigReservoir.cpp
ReservoirDataModel/RigReservoirBuilderMock.cpp
ReservoirDataModel/RigWellResults.cpp
ReservoirDataModel/RigGridScalarDataAccess.cpp
)
list( APPEND CPP_SOURCES
@ -154,6 +155,7 @@ qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} )
set( RAW_SOURCES ${CPP_SOURCES} )
list( REMOVE_ITEM RAW_SOURCES RIStdInclude.cpp)
list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigReaderInterfaceECL.cpp)
list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigGridScalarDataAccess.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivCellEdgeEffectGenerator.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivPipeGeometryGenerator.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellPipesPartMgr.cpp)

View File

@ -40,6 +40,7 @@ set( RESERVOIRDATAMODEL_CPP_SOURCES
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigWellResults.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp
${ResInsight_SOURCE_DIR}/cafUserInterface/cafProgressInfo.cpp
)

View File

@ -27,6 +27,7 @@
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimCellEdgeResultSlot.h"
#include "RigGridScalarDataAccess.h"
//--------------------------------------------------------------------------------------------------
@ -35,7 +36,8 @@
RivGridPartMgr::RivGridPartMgr(const RigGridBase* grid, size_t gridIdx)
: m_surfaceGenerator(grid),
m_faultGenerator(grid),
m_gridIdx(gridIdx),
m_gridIdx(gridIdx),
m_grid(grid),
m_surfaceFaceFilter(grid),
m_faultFaceFilter(grid),
m_opacityLevel(1.0f),
@ -217,10 +219,13 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
size_t resTimeStepIdx = timeStepIndex;
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
cvf::ref<RigGridScalarDataAccess> dataAccessObject = m_grid->dataAccessObject(timeStepIndex, scalarSetIndex);
if (dataAccessObject.isNull()) return;
// Outer surface
if (m_surfaceFaces.notNull())
{
m_surfaceGenerator.textureCoordinates(m_surfaceFacesTextureCoords.p(), resTimeStepIdx, scalarSetIndex, mapper);
m_surfaceGenerator.textureCoordinates(m_surfaceFacesTextureCoords.p(), dataAccessObject.p(), mapper);
for(size_t i = 0; i < m_surfaceFacesTextureCoords->size(); ++i)
{
@ -246,7 +251,7 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
// Faults
if (m_faultFaces.notNull())
{
m_faultGenerator.textureCoordinates(m_faultFacesTextureCoords.p(), resTimeStepIdx, scalarSetIndex, mapper);
m_faultGenerator.textureCoordinates(m_faultFacesTextureCoords.p(), dataAccessObject.p(), mapper);
for(size_t i = 0; i < m_faultFacesTextureCoords->size(); ++i)
{

View File

@ -69,6 +69,8 @@ private:
private:
size_t m_gridIdx;
cvf::cref<RigGridBase> m_grid;
cvf::ref<cvf::Transform> m_scaleTransform;
float m_opacityLevel;
cvf::Color3f m_defaultColor;

View File

@ -21,6 +21,7 @@
#include "RigMainGrid.h"
#include "RigCell.h"
#include "RigReservoirCellResults.h"
#include "RigGridScalarDataAccess.h"
#include "cvfAssert.h"
@ -579,6 +580,22 @@ void RigGridBase::computeMatrixAndFractureModelActiveCellCount()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigGridScalarDataAccess> RigGridBase::dataAccessObject(size_t timeStepIndex, size_t scalarSetIndex) const
{
if (timeStepIndex != cvf::UNDEFINED_SIZE_T &&
scalarSetIndex != cvf::UNDEFINED_SIZE_T)
{
cvf::ref<RigGridScalarDataAccess> dataAccess = new RigGridScalarDataAccess(this, timeStepIndex, scalarSetIndex);
return dataAccess;
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -27,10 +27,12 @@
#include <vector>
#include <string>
#include "cvfStructGridScalarDataAccess.h"
class RigMainGrid;
class RigCell;
class RigGridScalarDataAccess;
class RigGridBase : public cvf::StructGridInterface
{
@ -102,6 +104,8 @@ public:
virtual bool isCellValid( size_t i, size_t j, size_t k ) const;
virtual bool cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex ) const;
cvf::ref<RigGridScalarDataAccess> dataAccessObject(size_t timeStepIndex, size_t scalarSetIndex) const;
private:
std::string m_gridName;
cvf::Vec3st m_gridPointDimensions;
@ -111,6 +115,7 @@ private:
size_t m_matrixModelActiveCellCount;
size_t m_fractureModelActiveCellCount;
};

View File

@ -0,0 +1,107 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library 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.
//
// This library 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 "RigGridScalarDataAccess.h"
#include "cvfLibCore.h"
#include "cvfBase.h"
#include "cvfAssert.h"
#include "RigMainGrid.h"
#include "RigReservoirCellResults.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGridScalarDataAccess::RigGridScalarDataAccess(const RigGridBase* grid, size_t timeStepIndex, size_t scalarSetIndex)
{
CVF_ASSERT(grid);
CVF_ASSERT(grid->mainGrid());
CVF_ASSERT(grid->mainGrid()->results());
m_grid = grid;
m_useGlobalActiveIndex = m_grid->mainGrid()->results()->isUsingGlobalActiveIndex(scalarSetIndex);
std::vector< std::vector<double> > & scalarSetResults = m_grid->mainGrid()->results()->cellScalarResults(scalarSetIndex);
CVF_ASSERT(timeStepIndex < scalarSetResults.size());
m_resultValues = &(scalarSetResults[timeStepIndex]);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGridScalarDataAccess::cellScalar(size_t i, size_t j, size_t k) const
{
size_t cellIndex = m_grid->cellIndexFromIJK(i, j, k);
return cellScalar(cellIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGridScalarDataAccess::cellScalar(size_t cellIndex) const
{
size_t resultValueIndex = cellIndex;
if (m_useGlobalActiveIndex)
{
resultValueIndex = m_grid->cell(cellIndex).activeIndexInMatrixModel();
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
}
return m_resultValues->at(resultValueIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGridScalarDataAccess::gridPointScalar(size_t i, size_t j, size_t k) const
{
CVF_ASSERT(false);
return 0.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridScalarDataAccess::cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const
{
CVF_ASSERT(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGridScalarDataAccess::pointScalar(const cvf::Vec3d& p, double* scalarValue) const
{
CVF_ASSERT(false);
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::Vec3d* RigGridScalarDataAccess::cellVector(size_t i, size_t j, size_t k) const
{
CVF_ASSERT(false);
return new cvf::Vec3d();
}

View File

@ -0,0 +1,47 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library 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.
//
// This library 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 "cvfStructGridScalarDataAccess.h"
#include "RigGridBase.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RigGridScalarDataAccess : public cvf::StructGridScalarDataAccess
{
public:
RigGridScalarDataAccess(const RigGridBase* grid, size_t timeStepIndex, size_t scalarSetIndex);
virtual double cellScalar(size_t i, size_t j, size_t k) const;
virtual double cellScalar(size_t cellIndex) const;
virtual void cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const;
virtual double gridPointScalar(size_t i, size_t j, size_t k) const;
virtual bool pointScalar(const cvf::Vec3d& p, double* scalarValue) const;
virtual const cvf::Vec3d* cellVector(size_t i, size_t j, size_t k) const;
private:
cvf::cref<RigGridBase> m_grid;
bool m_useGlobalActiveIndex;
std::vector<double>* m_resultValues;
};

View File

@ -21,9 +21,7 @@
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfArray.h"
#include <vector>
namespace cvf {
@ -72,7 +70,6 @@ public:
virtual size_t cellIndexFromIJK(size_t i, size_t j, size_t k) const = 0;
virtual bool ijkFromCellIndex(size_t cellIndex, size_t* i, size_t* j, size_t* k) const = 0;
// Ta med toleranse?
virtual bool cellIJKFromCoordinate(const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k) const = 0;
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d vertices[8]) const = 0;
@ -83,24 +80,6 @@ public:
virtual cvf::Vec3d gridPointCoordinate(size_t i, size_t j, size_t k) const = 0;
// Scalar results
virtual size_t scalarSetCount() const = 0;
virtual double cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t i, size_t j, size_t k) const = 0;
virtual double cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t cellIndex) const = 0;
virtual void cellCornerScalars(size_t timeStepIndex, size_t scalarSetIndex, size_t i, size_t j, size_t k, double scalars[8]) const = 0;
// Trenger vi denne? Kan erstattes av cellCornerScalars for kuttplan
double gridPointScalar(size_t scalarSetIndex, size_t i, size_t j, size_t k) const;
bool pointScalar(size_t scalarSetIndex, const cvf::Vec3d& p, double* scalarValue) const;
// Vector results
virtual size_t vectorSetCount() const = 0;
virtual const cvf::Vec3d* cellVector(size_t vectorSetIndex, size_t i, size_t j, size_t k) const = 0;
//void filteredCellCenterResultVectors(Vec3dArray& positions, Vec3dArray& resultVectors, const double minPositionDistance, const double resultVectorLengthThreshold) const;
//void filteredCellCenterResultVectors(Vec3dArray& positions, Vec3dArray& resultVectors, uint vectorSetIndex, uint stride, const double resultVectorLengthThreshold) const;
public:
static void cellFaceVertexIndices(FaceType face, cvf::ubyte vertexIndices[4]);
static FaceType oppositeFace(FaceType face);

View File

@ -18,8 +18,11 @@
//##################################################################################################
#include "cvfBase.h"
#include "cvfStructGrid.h"
#include "cvfStructGridGeometryGenerator.h"
#include "cvfStructGridScalarDataAccess.h"
#include "cvfDebugTimer.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfPrimitiveSetIndexedUInt.h"
@ -385,8 +388,10 @@ void StructGridGeometryGenerator::computeArrays()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords, size_t timeStepIndex, size_t scalarSetIndex, const ScalarMapper* mapper) const
void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords, const StructGridScalarDataAccess* dataAccessObject, const ScalarMapper* mapper) const
{
if (!dataAccessObject) return;
size_t numVertices = m_quadsToGridCells.size()*4;
textureCoords->resize(numVertices);
@ -398,7 +403,7 @@ void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords,
#pragma omp parallel for private(texCoord, cellScalarValue)
for (int i = 0; i < static_cast<int>(m_quadsToGridCells.size()); i++)
{
cellScalarValue = m_grid->cellScalar(timeStepIndex, scalarSetIndex, m_quadsToGridCells[i]);
cellScalarValue = dataAccessObject->cellScalar(m_quadsToGridCells[i]);
texCoord = mapper->mapToTextureCoord(cellScalarValue);
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
{

View File

@ -28,7 +28,7 @@ namespace cvf {
class DrawableGeo;
class ScalarMapper;
class StructGridScalarDataAccess;
//--------------------------------------------------------------------------------------------------
///
@ -129,7 +129,7 @@ public:
const StructGridInterface* activeGrid() { return m_grid.p(); }
void textureCoordinates(Vec2fArray* textureCoords, size_t timeStepIndex, size_t scalarSetIndex, const ScalarMapper* mapper) const;
void textureCoordinates(Vec2fArray* textureCoords, const StructGridScalarDataAccess* dataAccessObject, const ScalarMapper* mapper) const;
// Mapping between cells and geometry
ref<cvf::Array<size_t> >

View File

@ -0,0 +1,46 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library 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.
//
// This library 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 "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
namespace cvf {
class StructGridScalarDataAccess : public Object
{
public:
virtual double cellScalar(size_t i, size_t j, size_t k) const = 0;
virtual double cellScalar(size_t cellIndex) const = 0;
virtual void cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const = 0;
// Trenger vi denne? Kan erstattes av cellCornerScalars for kuttplan
virtual double gridPointScalar(size_t i, size_t j, size_t k) const = 0;
virtual bool pointScalar(const cvf::Vec3d& p, double* scalarValue) const = 0;
// Vector results
virtual const cvf::Vec3d* cellVector(size_t i, size_t j, size_t k) const = 0;
};
} // namespace cvf