(#401) WIP: First cell filtering Eclipse Geomec grid visible.

Not working very well. BB matching is not good enough.
This commit is contained in:
Jacob Støren 2015-09-15 14:30:52 +02:00
parent 36bc2f8f69
commit 7a6c7149e1
6 changed files with 149 additions and 16 deletions

View File

@ -34,6 +34,8 @@
#include "RivFemElmVisibilityCalculator.h"
#include "RigFemPartResultsCollection.h"
#include "RimGeoMechPropertyFilterCollection.h"
#include "RimView.h"
#include "RimViewLink.h"
//--------------------------------------------------------------------------------------------------
///
@ -138,8 +140,11 @@ void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum
std::vector<RivGeoMechPartMgrCache::Key> RivGeoMechVizLogic::keysToVisiblePartMgrs(int timeStepIndex)
{
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs;
if (timeStepIndex >= 0 && m_geomechView->propertyFilterCollection()->hasActiveFilters())
if (m_geomechView->controllingViewLink() && m_geomechView->controllingViewLink()->syncVisibleCells())
{
visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(OVERRIDDEN_CELL_VISIBILITY, -1));
}
else if (timeStepIndex >= 0 && m_geomechView->propertyFilterCollection()->hasActiveFilters())
{
visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(PROPERTY_FILTERED, timeStepIndex));
}

View File

@ -62,6 +62,7 @@
#include <limits.h>
#include "RimViewLinker.h"
#include "RimViewLink.h"
@ -330,11 +331,17 @@ void RimEclipseView::createDisplayModel()
// For property filtered geometry : just set all the models as empty scenes
// updateCurrentTimeStep requests the actual parts
if (!this->propertyFilterCollection()->hasActiveFilters())
if (this->controllingViewLink() && this->controllingViewLink()->syncVisibleCells()
|| !this->propertyFilterCollection()->hasActiveFilters())
{
std::vector<RivCellSetEnum> geometryTypesToAdd;
if (this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells())
if (this->controllingViewLink() && this->controllingViewLink()->syncVisibleCells())
{
geometryTypesToAdd.push_back(OVERRIDDEN_CELL_VISIBILITY);
}
else if (this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells())
{
geometryTypesToAdd.push_back(RANGE_FILTERED);
geometryTypesToAdd.push_back(RANGE_FILTERED_WELL_CELLS);
@ -716,6 +723,7 @@ void RimEclipseView::initAfterRead()
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateStaticCellColors()
{
updateStaticCellColors( OVERRIDDEN_CELL_VISIBILITY);
updateStaticCellColors( ACTIVE);
updateStaticCellColors( ALL_WELL_CELLS);
updateStaticCellColors( VISIBLE_WELL_CELLS);

View File

@ -126,6 +126,7 @@ public:
virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) = 0;
void scheduleCreateDisplayModelAndRedraw();
void createDisplayModelAndRedraw();
RimViewLink* controllingViewLink();
cvf::ref<cvf::UByteArray> currentTotalCellVisibility();

View File

@ -66,7 +66,7 @@ RimViewLink::RimViewLink(void)
CAF_PDM_InitField(&syncCellResult, "SyncCellResult", false, "Cell Result", "", "", "");
CAF_PDM_InitField(&syncVisibleCells, "SyncVisibleCells", false, "Visible Cells", "", "", "");
syncVisibleCells.uiCapability()->setUiHidden(true); // For now
//syncVisibleCells.uiCapability()->setUiHidden(true); // For now
CAF_PDM_InitField(&syncRangeFilters, "SyncRangeFilters", true, "Range Filters", "", "", "");
CAF_PDM_InitField(&syncPropertyFilters, "SyncPropertyFilters", true,"Property Filters", "", "", "");

View File

@ -19,6 +19,7 @@
#include "RigCaseToCaseCellMapper.h"
#include "RigFemPart.h"
#include "RigMainGrid.h"
//--------------------------------------------------------------------------------------------------
@ -32,6 +33,118 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, Rig
{
m_masterCellOrIntervalIndex.resize(dependentFemPart->elementCount(), cvf::UNDEFINED_INT);
#if 0
// First search K=1 diagonally for a seed cell; A cell without collapsings, and without faults
size_t minIJCount = masterEclGrid->cellCountI();
if (minIJCount > masterEclGrid->cellCountJ())
minIJCount = masterEclGrid->cellCountJ();
for (size_t ij = 0; ij < minIJCount; ++ij )
{
size_t localCellIdx = masterEclGrid->cellIndexFromIJK(ij, ij, 0);
size_t reservoirCellIdx = masterEclGrid->reservoirCellIndex(localCellIdx);
cvf::Vec3d vertices[8];
masterEclGrid->cellCornerVertices(localCellIdx, vertices);
if (!isCellNormal(vertices))
continue;
const RigFault* fault = masterEclGrid->findFaultFromCellIndexAndCellFace(reservoirCellIdx, cvf::StructGridInterface::POS_I);
}
#endif
// Brute force:
const std::vector<cvf::Vec3f>& nodeCoords = dependentFemPart->nodes().coordinates;
double cellSizeI, cellSizeJ, cellSizeK;
masterEclGrid->characteristicCellSizes(&cellSizeI, &cellSizeJ, &cellSizeK);
double xyTolerance = cellSizeI* 0;
double zTolerance = cellSizeK* 0;
int elementCount = dependentFemPart->elementCount();
cvf::Vec3d elmCorners[8];
for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx)
{
if (dependentFemPart->elementType(elmIdx) != HEX8) continue;
const int* cornerIndices = dependentFemPart->connectivities(elmIdx);
elmCorners[0] = cvf::Vec3d(nodeCoords[cornerIndices[0]]);
elmCorners[1] = cvf::Vec3d(nodeCoords[cornerIndices[1]]);
elmCorners[2] = cvf::Vec3d(nodeCoords[cornerIndices[2]]);
elmCorners[3] = cvf::Vec3d(nodeCoords[cornerIndices[3]]);
elmCorners[4] = cvf::Vec3d(nodeCoords[cornerIndices[4]]);
elmCorners[5] = cvf::Vec3d(nodeCoords[cornerIndices[5]]);
elmCorners[6] = cvf::Vec3d(nodeCoords[cornerIndices[6]]);
elmCorners[7] = cvf::Vec3d(nodeCoords[cornerIndices[7]]);
cvf::BoundingBox elmBBox;
for (int i = 0; i < 8 ; ++i) elmBBox.add(elmCorners[i]);
std::vector<size_t> closeCells;
masterEclGrid->findIntersectingCells(elmBBox, &closeCells);
std::vector<int> matchingCells;
for (size_t ccIdx = 0; ccIdx < closeCells.size(); ++ccIdx)
{
cvf::Vec3d cellCorners[8];
size_t localCellIdx = masterEclGrid->cells()[closeCells[ccIdx]].gridLocalCellIndex();
masterEclGrid->cellCornerVertices(localCellIdx, cellCorners);
bool isMatching = false;
#if 1 // Inside Bounding box test
cvf::BoundingBox cellBBox;
for (int i = 0; i < 8 ; ++i) cellBBox.add(elmCorners[i]);
cvf::Vec3d cs = cellBBox.min();
cvf::Vec3d cl = cellBBox.max();
cvf::Vec3d es = elmBBox.min();
cvf::Vec3d el = elmBBox.max();
if ( ( (cs.x() + xyTolerance) >= es.x() && (cl.x() - xyTolerance) <= el.x())
&& ( (cs.y() + xyTolerance) >= es.y() && (cl.y() - xyTolerance) <= el.y())
&& ( (cs.z() + zTolerance ) >= es.z() && (cl.z() - zTolerance ) <= el.z()) )
{
// Cell bb equal or inside Elm bb
isMatching = true;
}
if ( ( (es.x() + xyTolerance) >= cs.x() && (el.x() - xyTolerance) <= cl.x())
&& ( (es.y() + xyTolerance) >= cs.y() && (el.y() - xyTolerance) <= cl.y())
&& ( (es.z() + zTolerance ) >= cs.z() && (el.z() - zTolerance ) <= cl.z()) )
{
// Elm bb equal or inside Cell bb
isMatching = true;
}
#endif
if (isMatching)
{
matchingCells.push_back(static_cast<int>(closeCells[ccIdx]));
}
else
{
// Try fault corrections on the eclipse cell
// Try zero volume correction
}
}
if (matchingCells.size() == 1)
{
m_masterCellOrIntervalIndex[elmIdx] = matchingCells[0];
}
else if (matchingCells.size() > 1)
{
m_masterCellOrIntervalIndex[elmIdx] = -((int)(m_masterCellIndexSeries.size()));
m_masterCellIndexSeries.push_back(matchingCells);
}
}
}
//--------------------------------------------------------------------------------------------------
@ -43,6 +156,7 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, Rig
m_masterFemPart(NULL),
m_dependentFemPart(NULL)
{
m_masterCellOrIntervalIndex.resize(dependentEclGrid->cells().size(), cvf::UNDEFINED_INT);
}
@ -55,7 +169,7 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigM
m_masterFemPart(masterFemPart),
m_dependentFemPart(NULL)
{
m_masterCellOrIntervalIndex.resize(dependentEclGrid->cells().size(), cvf::UNDEFINED_INT);
}
//--------------------------------------------------------------------------------------------------
@ -67,7 +181,7 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigF
m_masterFemPart(masterFemPart),
m_dependentFemPart(dependentFemPart)
{
m_masterCellOrIntervalIndex.resize(dependentFemPart->elementCount(), cvf::UNDEFINED_INT);
}
@ -95,3 +209,17 @@ const int * RigCaseToCaseCellMapper::masterCaseCellIndices(int dependentCaseRese
return &(m_masterCellOrIntervalIndex[dependentCaseReservoirCellIndex]);
}
}
#if 0
enum RigHexIntersectResult
{
MATCH,
UNRELATED
};
RigHexIntersectResult matchCells(const cvf::Vec3d hex1[8], const cvf::Vec3d hex2[8], double tolerance)
{
}
#endif

View File

@ -49,16 +49,7 @@ public:
const RigFemPart* dependentFemPart() const { return m_dependentFemPart;}
private:
#if 0
cvf::Vec3i m_ecToGmOffset;
cvf::Matrix3<int> m_ecToGmAxisTransform;
std::vector<int> m_ecgmCellOrIntervalIndex;
std::vector<std::vector<int> > m_ecgmCellIndexIntervals;
std::vector<int> m_gmecCellOrIntervalIndex;
std::vector<std::vector<int> > m_gmecCellIndexIntervals;
#endif
std::vector<int> m_masterCellOrIntervalIndex;
std::vector<std::vector<int> > m_masterCellIndexSeries;