Compute DEPTH, DX, DY, DZ, TOP and BOTTOM if not present. Added flag in Preferences to control if ResInsight automatically computes these values. Improved statistical computations by skipping HUGE_VAL.

p4#: 19287
This commit is contained in:
Magne Sjaastad 2012-10-24 10:52:44 +02:00
parent 6792ce1f4a
commit ddc555d590
5 changed files with 180 additions and 26 deletions

View File

@ -46,7 +46,8 @@ RIPreferences::RIPreferences(void)
CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", "");
lastUsedProjectFileName.setUiHidden(true);
CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "Compute SOIL if not on disk", "", "", "");
CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "SOIL", "", "SOIL = 1.0 - SGAS - SWAT", "");
CAF_PDM_InitField(&autocomputeDepthRelatedProperties,"autocomputeDepth", true, "DEPTH related properties", "", "DEPTH, DX, DY, DZ, TOP, BOTTOM", "");
}
//--------------------------------------------------------------------------------------------------
@ -88,8 +89,8 @@ void RIPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& u
defaultSettingsGroup->add(&defaultScaleFactorZ);
defaultSettingsGroup->add(&defaultGridLines);
caf::PdmUiGroup* autoComputeGroup = uiOrdering.addNewGroup("Compute when loading new case");
autoComputeGroup->add(&autocomputeSOIL);
autoComputeGroup->add(&autocomputeDepthRelatedProperties);
}

View File

@ -45,6 +45,7 @@ public: // Pdm Fields
caf::PdmField<QString> lastUsedProjectFileName;
caf::PdmField<bool> autocomputeSOIL;
caf::PdmField<bool> autocomputeDepthRelatedProperties;
protected:

View File

@ -34,6 +34,10 @@
#include "RifEclipseInputFileTools.h"
#include "cafProgressInfo.h"
#include "RIApplication.h"
#include "RIPreferences.h"
CAF_PDM_SOURCE_INIT(RimInputReservoir, "RimInputReservoir");
//--------------------------------------------------------------------------------------------------
///
@ -150,34 +154,42 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames)
bool RimInputReservoir::openEclipseGridFile()
{
// Early exit if reservoir data is created
if (m_rigReservoir.notNull()) return true;
cvf::ref<RifReaderInterface> readerInterface;
if (caseName().contains("Input Mock Debug Model"))
if (m_rigReservoir.isNull())
{
readerInterface = this->createMockModel(this->caseName());
}
else
{
RigReservoir* reservoir = new RigReservoir;
readerInterface = new RifReaderEclipseInput;
if (!readerInterface->open(m_gridFileName, reservoir))
cvf::ref<RifReaderInterface> readerInterface;
if (caseName().contains("Input Mock Debug Model"))
{
delete reservoir;
return false;
readerInterface = this->createMockModel(this->caseName());
}
else
{
RigReservoir* reservoir = new RigReservoir;
readerInterface = new RifReaderEclipseInput;
if (!readerInterface->open(m_gridFileName, reservoir))
{
delete reservoir;
return false;
}
m_rigReservoir = reservoir;
loadAndSyncronizeInputProperties();
}
m_rigReservoir = reservoir;
loadAndSyncronizeInputProperties();
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(readerInterface.notNull());
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData();
}
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(readerInterface.notNull());
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData();
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results();
RIApplication* app = RIApplication::instance();
if (app->preferences()->autocomputeDepthRelatedProperties)
{
results->computeDepthRelatedResults();
}
return true;
}

View File

@ -106,6 +106,11 @@ void RigReservoirCellResults::minMaxCellScalarValues(size_t scalarResultIndex, s
size_t i;
for (i = 0; i < values.size(); i++)
{
if (values[i] == HUGE_VAL)
{
continue;
}
if (values[i] < min)
{
min = values[i];
@ -437,6 +442,118 @@ void RigReservoirCellResults::loadOrComputeSOIL()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::computeDepthRelatedResults()
{
size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH");
size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX");
size_t dyResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY");
size_t dzResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DZ");
size_t topResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "TOP");
size_t bottomResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM");
bool computeDepth = false;
bool computeDx = false;
bool computeDy = false;
bool computeDz = false;
bool computeTop = false;
bool computeBottom = false;
size_t resultValueCount = m_ownerMainGrid->cells().size();
if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
depthResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", resultValueCount);
computeDepth = true;
}
if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dxResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", resultValueCount);
computeDx = true;
}
if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dyResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", resultValueCount);
computeDy = true;
}
if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dzResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", resultValueCount);
computeDz = true;
}
if (topResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
topResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOP", resultValueCount);
computeTop = true;
}
if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
bottomResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", resultValueCount);
computeBottom = true;
}
std::vector< std::vector<double> >& depth = cellScalarResults(depthResultGridIndex);
std::vector< std::vector<double> >& dx = cellScalarResults(dxResultGridIndex);
std::vector< std::vector<double> >& dy = cellScalarResults(dyResultGridIndex);
std::vector< std::vector<double> >& dz = cellScalarResults(dzResultGridIndex);
std::vector< std::vector<double> >& top = cellScalarResults(topResultGridIndex);
std::vector< std::vector<double> >& bottom = cellScalarResults(bottomResultGridIndex);
bool computeValuesForActiveCellsOnly = m_ownerMainGrid->numActiveCells() > 0;
size_t cellIdx = 0;
for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++)
{
const RigCell& cell = m_ownerMainGrid->cells()[cellIdx];
if (computeValuesForActiveCellsOnly && !cell.active())
{
continue;
}
if (computeDepth)
{
depth[0][cellIdx] = cvf::Math::abs(cell.center().z());
}
if (computeDx)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I);
dx[0][cellIdx] = cellWidth.length();
}
if (computeDy)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J);
dy[0][cellIdx] = cellWidth.length();
}
if (computeDz)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K);
dz[0][cellIdx] = cellWidth.length();
}
if (computeTop)
{
top[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::POS_K).z());
}
if (computeBottom)
{
bottom[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::NEG_K).z());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -626,3 +743,17 @@ void RigReservoirCellResults::clearAllResults()
m_cellScalarResults[i].clear();
}
}
//--------------------------------------------------------------------------------------------------
/// Add a result with given type and name, and allocate one result vector for the static result values
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount)
{
size_t resultIdx = addEmptyScalarResult(type, resultName);
m_cellScalarResults[resultIdx].push_back(std::vector<double>());
m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL);
return resultIdx;
}

View File

@ -67,11 +67,15 @@ public:
void clearAllResults();
void loadOrComputeSOIL();
void computeDepthRelatedResults();
// Access the results data
std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex);
double cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex);
private:
size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount);
private:
std::vector< std::vector< std::vector<double> > > m_cellScalarResults; ///< Scalar results for each timestep for each Result index (ResultVariable)
std::vector< std::pair<double, double> > m_maxMinValues; ///< Max min values for each Result index
@ -127,6 +131,11 @@ public:
CVF_ASSERT(m_histogram);
for (size_t i = 0; i < data.size(); ++i)
{
if (data[i] == HUGE_VAL)
{
continue;
}
size_t index = 0;
if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range);