mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Moved Faluts to MainGrid. New fault calculation
Now finding the uncovered geometrical faults and adds them to a separate generated fault.
This commit is contained in:
@@ -165,7 +165,7 @@ void RivFaultGeometryGenerator::computeArrays()
|
||||
if (!m_computeNativeFaultFaces)
|
||||
{
|
||||
cellIndex = faultFaces[fIdx].m_oppositeGlobalCellIndex;
|
||||
face = faultFaces[fIdx].m_oppositeFace;
|
||||
face = cvf::StructGridInterface::oppositeFace(faultFaces[fIdx].m_nativeFace);
|
||||
}
|
||||
|
||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||
|
||||
@@ -182,14 +182,7 @@ RigMainGrid* RimAnalysisModels::registerCaseInGridCollection(RigCaseData* rigEcl
|
||||
// This is the first insertion of this grid, compute cached data
|
||||
rigEclipseCase->mainGrid()->computeCachedData();
|
||||
|
||||
std::vector<RigGridBase*> grids;
|
||||
rigEclipseCase->allGrids(&grids);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < grids.size(); i++)
|
||||
{
|
||||
grids[i]->computeFaults();
|
||||
}
|
||||
rigEclipseCase->mainGrid()->calculateFaults();
|
||||
|
||||
equalGrid = rigEclipseCase->mainGrid();
|
||||
}
|
||||
|
||||
@@ -315,15 +315,7 @@ void RimCase::computeCachedData()
|
||||
rigEclipseCase->computeActiveCellBoundingBoxes();
|
||||
|
||||
rigEclipseCase->mainGrid()->computeCachedData();
|
||||
|
||||
std::vector<RigGridBase*> grids;
|
||||
rigEclipseCase->allGrids(&grids);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < grids.size(); i++)
|
||||
{
|
||||
grids[i]->computeFaults();
|
||||
}
|
||||
rigEclipseCase->mainGrid()->calculateFaults();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1096,7 +1096,7 @@ bool RimReservoirView::pickInfo(size_t gridIndex, size_t cellIndex, const cvf::V
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get the current scalar value for the display face at the given index
|
||||
/// Append fault name and result value for the given cell to the string
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText)
|
||||
{
|
||||
@@ -1172,12 +1172,13 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
|
||||
if (gridIndex == 0)
|
||||
{
|
||||
bool foundFault = false;
|
||||
RigMainGrid* mainGrid = grid->mainGrid();
|
||||
|
||||
for (size_t i = 0; i < grid->faults().size(); i++)
|
||||
for (size_t i = 0; i < mainGrid->faults().size(); i++)
|
||||
{
|
||||
if (foundFault) continue;
|
||||
|
||||
const RigFault* rigFault = grid->faults().at(i);
|
||||
const RigFault* rigFault = mainGrid->faults().at(i);
|
||||
const std::vector<RigFault::FaultFace>& faultFaces = rigFault->faultFaces();
|
||||
|
||||
for (size_t fIdx = 0; fIdx < faultFaces.size(); fIdx++)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "RigFault.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
cvf::ref<RigFaultsPrCellAccumulator> RigFault::m_faultsPrCellAcc;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -118,15 +119,13 @@ void RigFault::computeFaultFacesFromCellRanges(const RigMainGrid* grid)
|
||||
// Do not need to compute global grid cell index as for a maingrid localIndex == globalIndex
|
||||
//size_t globalCellIndex = grid->globalGridCellIndex(localCellIndex);
|
||||
|
||||
cvf::StructGridInterface::FaceType oppositeFace = grid->oppositeFace(faceEnum);
|
||||
|
||||
size_t ni, nj, nk;
|
||||
grid->ijkFromCellIndex(localCellIndex, &i, &j, &k);
|
||||
grid->neighborIJKAtCellFace(i, j, k, faceEnum, &ni, &nj, &nk);
|
||||
|
||||
size_t oppositeCellIndex = grid->cellIndexFromIJK(ni, nj, nk);
|
||||
|
||||
m_faultFaces.push_back(FaultFace(localCellIndex, faceEnum, oppositeCellIndex, oppositeFace));
|
||||
m_faultFaces.push_back(FaultFace(localCellIndex, faceEnum, oppositeCellIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,3 +134,17 @@ void RigFault::computeFaultFacesFromCellRanges(const RigMainGrid* grid)
|
||||
}
|
||||
|
||||
|
||||
void RigFault::accumulateFaultsPrCell(RigFaultsPrCellAccumulator* faultsPrCellAcc, int faultIdx)
|
||||
{
|
||||
|
||||
for (size_t ffIdx = 0; ffIdx < m_faultFaces.size(); ffIdx)
|
||||
{
|
||||
const FaultFace& ff = m_faultFaces[ffIdx];
|
||||
|
||||
// Could detect overlapping faults here .... if (faultsPrCellAcc->faultIdx(ff.m_nativeGlobalCellIndex, ff.m_nativeFace) >= 0)
|
||||
|
||||
faultsPrCellAcc->setFaultIdx(ff.m_nativeGlobalCellIndex, ff.m_nativeFace, faultIdx);
|
||||
faultsPrCellAcc->setFaultIdx(ff.m_oppositeGlobalCellIndex, cvf::StructGridInterface::oppositeFace(ff.m_nativeFace), faultIdx);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,33 @@
|
||||
|
||||
class RigMainGrid;
|
||||
|
||||
class RigFaultsPrCellAccumulator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
enum { NO_FAULT = -1, UNKNOWN_FAULT = -2 };
|
||||
|
||||
public:
|
||||
RigFaultsPrCellAccumulator(size_t globalCellCount)
|
||||
{
|
||||
const int initVals[6] = { NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT};
|
||||
caf::IntArray6 initVal;
|
||||
initVal = initVals;
|
||||
m_faultIdxForCellFace.resize(globalCellCount, initVal);
|
||||
}
|
||||
|
||||
inline int faultIdx(size_t globalCellIdx, cvf::StructGridInterface::FaceType face)
|
||||
{
|
||||
return m_faultIdxForCellFace[globalCellIdx][face];
|
||||
}
|
||||
|
||||
inline void setFaultIdx(size_t globalCellIdx, cvf::StructGridInterface::FaceType face, int faultIdx)
|
||||
{
|
||||
m_faultIdxForCellFace[globalCellIdx][face] = faultIdx;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector< caf::IntArray6 > m_faultIdxForCellFace;
|
||||
};
|
||||
|
||||
class RigFault : public cvf::Object
|
||||
{
|
||||
@@ -39,17 +66,15 @@ public:
|
||||
|
||||
struct FaultFace
|
||||
{
|
||||
FaultFace(size_t nativeGlobalCellIndex, cvf::StructGridInterface::FaceType nativeFace, size_t oppositeGlobalCellIndex, cvf::StructGridInterface::FaceType oppositeFace) :
|
||||
FaultFace(size_t nativeGlobalCellIndex, cvf::StructGridInterface::FaceType nativeFace, size_t oppositeGlobalCellIndex) :
|
||||
m_nativeGlobalCellIndex(nativeGlobalCellIndex),
|
||||
m_nativeFace(nativeFace),
|
||||
m_oppositeGlobalCellIndex(oppositeGlobalCellIndex),
|
||||
m_oppositeFace(oppositeFace)
|
||||
m_oppositeGlobalCellIndex(oppositeGlobalCellIndex)
|
||||
{ }
|
||||
|
||||
size_t m_nativeGlobalCellIndex;
|
||||
cvf::StructGridInterface::FaceType m_nativeFace;
|
||||
size_t m_oppositeGlobalCellIndex;
|
||||
cvf::StructGridInterface::FaceType m_oppositeFace;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -61,13 +86,24 @@ public:
|
||||
void addCellRangeForFace(cvf::StructGridInterface::FaceType face, const cvf::CellRange& cellRange);
|
||||
void computeFaultFacesFromCellRanges(const RigMainGrid* grid);
|
||||
|
||||
void accumulateFaultsPrCell(RigFaultsPrCellAccumulator* faultsPrCellAcc, int faultIdx);
|
||||
|
||||
std::vector<FaultFace>& faultFaces();
|
||||
const std::vector<FaultFace>& faultFaces() const;
|
||||
|
||||
std::vector<size_t>& connectionIndices() { return m_connectionIndices; }
|
||||
const std::vector<size_t>& connectionIndices() const { return m_connectionIndices; }
|
||||
|
||||
static RigFaultsPrCellAccumulator* faultsPrCellAccumulator() { CVF_ASSERT(m_faultsPrCellAcc.notNull()); return m_faultsPrCellAcc.p();}
|
||||
static void initFaultsPrCellAccumulator(size_t globalCellCount) { m_faultsPrCellAcc = new RigFaultsPrCellAccumulator(globalCellCount); }
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
|
||||
caf::FixedArray<std::vector<cvf::CellRange>, 6> m_cellRangesForFaces;
|
||||
|
||||
std::vector<FaultFace> m_faultFaces;
|
||||
std::vector<size_t> m_connectionIndices;
|
||||
|
||||
static cvf::ref<RigFaultsPrCellAccumulator> m_faultsPrCellAcc;
|
||||
};
|
||||
|
||||
@@ -307,7 +307,7 @@ bool RigGridBase::isCellValid(size_t i, size_t j, size_t k) const
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// TODO: Use structgrid::neighborIJKAtCellFace
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigGridBase::cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex) const
|
||||
{
|
||||
@@ -327,91 +327,6 @@ bool RigGridBase::cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, s
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigGridBase::computeFaults()
|
||||
{
|
||||
//size_t k;
|
||||
#pragma omp parallel for
|
||||
for (int k = 0; k < static_cast<int>(cellCountK()); k++)
|
||||
{
|
||||
size_t j;
|
||||
for (j = 0; j < cellCountJ(); j++)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < cellCountI(); i++)
|
||||
{
|
||||
size_t idx = cellIndexFromIJK(i, j, k);
|
||||
|
||||
RigCell& currentCell = cell(idx);
|
||||
|
||||
if (currentCell.isInvalid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t faceIdx;
|
||||
for (faceIdx = 0; faceIdx < 6; faceIdx++)
|
||||
{
|
||||
cvf::StructGridInterface::FaceType face = static_cast<cvf::StructGridInterface::FaceType>(faceIdx);
|
||||
|
||||
size_t cellNeighbourIdx = 0;
|
||||
if (!cellIJKNeighbor(i, j, k, face, &cellNeighbourIdx))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const RigCell& neighbourCell = cell(cellNeighbourIdx);
|
||||
if (neighbourCell.isInvalid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
cvf::Vec3d currentCellFaceVertices[4];
|
||||
{
|
||||
caf::SizeTArray4 faceVxIndices;
|
||||
currentCell.faceIndices(face, &faceVxIndices);
|
||||
|
||||
currentCellFaceVertices[0].set(m_mainGrid->nodes()[faceVxIndices[0]]);
|
||||
currentCellFaceVertices[1].set(m_mainGrid->nodes()[faceVxIndices[1]]);
|
||||
currentCellFaceVertices[2].set(m_mainGrid->nodes()[faceVxIndices[2]]);
|
||||
currentCellFaceVertices[3].set(m_mainGrid->nodes()[faceVxIndices[3]]);
|
||||
}
|
||||
|
||||
cvf::Vec3d neighbourCellFaceVertices[4];
|
||||
{
|
||||
caf::SizeTArray4 faceVxIndices;
|
||||
currentCell.faceIndices(StructGridInterface::oppositeFace(face), &faceVxIndices);
|
||||
|
||||
neighbourCellFaceVertices[0].set(m_mainGrid->nodes()[faceVxIndices[0]]);
|
||||
neighbourCellFaceVertices[1].set(m_mainGrid->nodes()[faceVxIndices[3]]);
|
||||
neighbourCellFaceVertices[2].set(m_mainGrid->nodes()[faceVxIndices[2]]);
|
||||
neighbourCellFaceVertices[3].set(m_mainGrid->nodes()[faceVxIndices[1]]);
|
||||
}
|
||||
|
||||
bool sharedFaceVertices = true;
|
||||
|
||||
// Check if vertices are matching
|
||||
double tolerance = 1e-6;
|
||||
for (size_t cellFaceIdx = 0; cellFaceIdx < 4; cellFaceIdx++)
|
||||
{
|
||||
if (currentCellFaceVertices[cellFaceIdx].pointDistance(neighbourCellFaceVertices[cellFaceIdx]) > tolerance )
|
||||
{
|
||||
sharedFaceVertices = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sharedFaceVertices)
|
||||
{
|
||||
currentCell.setCellFaceFault(face);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -535,20 +450,6 @@ cvf::BoundingBox RigGridBase::boundingBox()
|
||||
return m_boundingBox;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigGridBase::setFaults(const cvf::Collection<RigFault>& faults)
|
||||
{
|
||||
m_faults = faults;
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < m_faults.size(); i++)
|
||||
{
|
||||
m_faults[i]->computeFaultFacesFromCellRanges(this->mainGrid());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
std::string gridName() const;
|
||||
void setGridName(const std::string& gridName);
|
||||
|
||||
void computeFaults();
|
||||
bool isMainGrid() const;
|
||||
RigMainGrid* mainGrid() const { return m_mainGrid; }
|
||||
|
||||
@@ -78,8 +77,6 @@ public:
|
||||
|
||||
cvf::BoundingBox boundingBox();
|
||||
|
||||
void setFaults(const cvf::Collection<RigFault>& faults);
|
||||
const cvf::Collection<RigFault>& faults() { return m_faults; }
|
||||
|
||||
protected:
|
||||
friend class RigMainGrid;//::initAllSubGridsParentGridPointer();
|
||||
@@ -122,7 +119,6 @@ private:
|
||||
|
||||
std::vector<caf::SizeTArray6> m_coarseningBoxInfo;
|
||||
|
||||
cvf::Collection<RigFault> m_faults;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -192,3 +192,122 @@ RigNNCData* RigMainGrid::nncData()
|
||||
return m_nncData.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMainGrid::setFaults(const cvf::Collection<RigFault>& faults)
|
||||
{
|
||||
m_faults = faults;
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < m_faults.size(); i++)
|
||||
{
|
||||
m_faults[i]->computeFaultFacesFromCellRanges(this->mainGrid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMainGrid::calculateFaults()
|
||||
{
|
||||
//RigFault::initFaultsPrCellAccumulator(m_cells.size());
|
||||
cvf::ref<RigFaultsPrCellAccumulator> faultsPrCellAcc = new RigFaultsPrCellAccumulator(m_cells.size());
|
||||
|
||||
// Spread fault idx'es on the cells from the faults
|
||||
for (size_t fIdx = 0 ; fIdx < m_faults.size(); ++fIdx)
|
||||
{
|
||||
m_faults[fIdx]->accumulateFaultsPrCell(faultsPrCellAcc.p(), static_cast<int>(fIdx));
|
||||
}
|
||||
|
||||
// Find the geometrical faults that is in addition
|
||||
|
||||
RigFault * unNamedFault = new RigFault;
|
||||
int unNamedFaultIdx = static_cast<int>(m_faults.size());
|
||||
|
||||
for (size_t gcIdx = 0 ; gcIdx < m_cells.size(); ++gcIdx)
|
||||
{
|
||||
if ( m_cells[gcIdx].isInvalid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t neighborGlobalCellIdx;
|
||||
size_t neighborGridCellIdx;
|
||||
size_t i, j, k;
|
||||
RigGridBase* hostGrid; ;
|
||||
bool firstNO_FAULTFaceForCell = true;
|
||||
|
||||
for (char faceIdx = 0; faceIdx < 6; ++faceIdx)
|
||||
{
|
||||
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::FaceType(faceIdx);
|
||||
|
||||
if (faultsPrCellAcc->faultIdx(gcIdx, face) == RigFaultsPrCellAccumulator::NO_FAULT)
|
||||
{
|
||||
// Find neighbor cell
|
||||
if (firstNO_FAULTFaceForCell) // To avoid doing this for every face, and only when detecting a NO_FAULT
|
||||
{
|
||||
hostGrid = m_cells[gcIdx].hostGrid();
|
||||
hostGrid->ijkFromCellIndex(m_cells[gcIdx].cellIndex(), &i,&j, &k);
|
||||
firstNO_FAULTFaceForCell = false;
|
||||
}
|
||||
|
||||
if(!hostGrid->cellIJKNeighbor(i, j, k, face, &neighborGridCellIdx))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
neighborGlobalCellIdx = hostGrid->globalGridCellIndex(neighborGridCellIdx);
|
||||
if (m_cells[neighborGlobalCellIdx].isInvalid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double tolerance = 1e-6;
|
||||
|
||||
|
||||
caf::SizeTArray4 faceIdxs;
|
||||
m_cells[gcIdx].faceIndices(face, &faceIdxs);
|
||||
caf::SizeTArray4 nbFaceIdxs;
|
||||
m_cells[neighborGlobalCellIdx].faceIndices(StructGridInterface::oppositeFace(face), &nbFaceIdxs);
|
||||
|
||||
const std::vector<cvf::Vec3d>& vxs = m_mainGrid->nodes();
|
||||
|
||||
bool sharedFaceVertices = true;
|
||||
if (sharedFaceVertices && vxs[faceIdxs[0]].pointDistance(vxs[nbFaceIdxs[0]]) > tolerance ) sharedFaceVertices = false;
|
||||
if (sharedFaceVertices && vxs[faceIdxs[1]].pointDistance(vxs[nbFaceIdxs[3]]) > tolerance ) sharedFaceVertices = false;
|
||||
if (sharedFaceVertices && vxs[faceIdxs[2]].pointDistance(vxs[nbFaceIdxs[2]]) > tolerance ) sharedFaceVertices = false;
|
||||
if (sharedFaceVertices && vxs[faceIdxs[3]].pointDistance(vxs[nbFaceIdxs[1]]) > tolerance ) sharedFaceVertices = false;
|
||||
|
||||
if (sharedFaceVertices)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// To avoid doing this calculation for the opposite face
|
||||
|
||||
faultsPrCellAcc->setFaultIdx(gcIdx, face, unNamedFaultIdx);
|
||||
faultsPrCellAcc->setFaultIdx(neighborGlobalCellIdx, StructGridInterface::oppositeFace(face), unNamedFaultIdx);
|
||||
|
||||
// Add as fault face only if the grid index is less than the neighbors
|
||||
|
||||
if (gcIdx < neighborGlobalCellIdx)
|
||||
{
|
||||
RigFault::FaultFace ff(gcIdx, cvf::StructGridInterface::FaceType(faceIdx), neighborGlobalCellIdx);
|
||||
unNamedFault->faultFaces().push_back(ff);
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false); // Should never occur. because we flag the opposite face in the faultsPrCellAcc
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (unNamedFault->faultFaces().size())
|
||||
{
|
||||
unNamedFault->setName("Unnamed grid faults");
|
||||
m_faults.push_back(unNamedFault);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@ public:
|
||||
RigGridBase* gridById(int localGridId);
|
||||
|
||||
RigNNCData* nncData();
|
||||
void setFaults(const cvf::Collection<RigFault>& faults);
|
||||
const cvf::Collection<RigFault>& faults() { return m_faults; }
|
||||
void calculateFaults();
|
||||
|
||||
void computeCachedData();
|
||||
|
||||
@@ -68,6 +71,8 @@ private:
|
||||
cvf::Collection<RigLocalGrid> m_localGrids; ///< List of all the LGR's in this reservoir
|
||||
std::vector<size_t> m_gridIdToIndexMapping; ///< Mapping from LGR Id to index.
|
||||
|
||||
|
||||
cvf::Collection<RigFault> m_faults;
|
||||
cvf::ref<RigNNCData> m_nncData;
|
||||
|
||||
cvf::Vec3d m_displayModelOffset;
|
||||
|
||||
Reference in New Issue
Block a user