mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
107
ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp
Normal file
107
ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp
Normal 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();
|
||||
}
|
||||
47
ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h
Normal file
47
ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h
Normal 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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user