#3017 Restructure UI

This commit is contained in:
Magne Sjaastad 2018-06-07 16:50:50 +02:00
parent 350d0bbee4
commit dae054cf8f
4 changed files with 75 additions and 122 deletions

View File

@ -23,23 +23,8 @@
#include "RimFractureTemplate.h"
#include "RimProject.h"
#include "cafPdmUiSliderEditor.h"
CAF_PDM_SOURCE_INIT(RimFractureContainment, "FractureContainment");
namespace caf
{
template<>
void caf::AppEnum<RimFractureContainment::FaultTruncType>::setUp()
{
addItem(RimFractureContainment::DISABLED, "DISABLED", "Continue Across");
addItem(RimFractureContainment::TRUNCATE_AT_FAULT, "TRUNCATE_AT_FAULT", "Truncate At Faults");
addItem(RimFractureContainment::CONTINUE_IN_CONTAINMENT_ZONE, "CONTINUE_IN_CONTAINMENT_ZONE", "Continue in Containment Zone");
setDefault(RimFractureContainment::DISABLED);
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -47,20 +32,13 @@ RimFractureContainment::RimFractureContainment()
{
CAF_PDM_InitObject("Fracture Containment", "", "", "");
CAF_PDM_InitField(
&m_isUsingFractureContainment_OBSOLETE, "IsUsingFractureContainment", false, "Fracture Containment", "", "", "");
m_isUsingFractureContainment_OBSOLETE.xmlCapability()->setIOWritable(false);
m_isUsingFractureContainment_OBSOLETE.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_useContainment, "IsUsingFractureContainment", false, "Use Containment", "", "", "");
CAF_PDM_InitField(&m_topKLayer, "TopKLayer", 0, " Top Layer", "", "", "");
CAF_PDM_InitField(&m_baseKLayer, "BaseKLayer", 0, " Base Layer", "", "", "");
CAF_PDM_InitField(&m_topKLayer, "TopKLayer", 0, "Top Layer", "", "", "");
// m_topKLayer.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_baseKLayer, "BaseKLayer", 0, "Base Layer", "", "", "");
// m_topKLayer.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_faultTruncation, "FaultTruncationType", "Fault Truncation", "", "", "");
CAF_PDM_InitField(&m_useFaultThrow, "UseFaultThrow", false, "Use Fault Throw", "", "", "");
CAF_PDM_InitField(&m_faultThrowValue, "FaultThrowValue", 0.0f, " Fault Throw", "", "", "");
CAF_PDM_InitField(&m_truncateAtFaults, "TruncateAtFaults", false, "Truncate At Faults", "", "", "");
CAF_PDM_InitField(&m_useFaultThrow, "UseFaultThrow", false, " Use Fault Throw", "", "", "");
CAF_PDM_InitField(&m_maximumFaultThrow, "FaultThrowValue", 0.0f, " Maximum Fault Throw", "", "", "");
}
//--------------------------------------------------------------------------------------------------
@ -71,32 +49,11 @@ RimFractureContainment::~RimFractureContainment() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimFractureContainment::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly)
double RimFractureContainment::maximumFaultThrow() const
{
// TODO: Remove this
return caf::PdmObject::calculateValueOptions(fieldNeedingOptions, useOptionsOnly);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureContainment::initAfterRead()
{
if (m_isUsingFractureContainment_OBSOLETE())
if (m_truncateAtFaults() && m_useFaultThrow())
{
m_faultTruncation = CONTINUE_IN_CONTAINMENT_ZONE;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFractureContainment::faultThrow() const
{
if ((m_faultTruncation() == CONTINUE_IN_CONTAINMENT_ZONE || m_faultTruncation() == TRUNCATE_AT_FAULT) && m_useFaultThrow())
{
return m_faultThrowValue;
return m_maximumFaultThrow;
}
return -1.0;
@ -107,7 +64,7 @@ double RimFractureContainment::faultThrow() const
//--------------------------------------------------------------------------------------------------
bool RimFractureContainment::isEnabled() const
{
return m_faultTruncation() != DISABLED;
return (m_useContainment() || m_truncateAtFaults());
}
//--------------------------------------------------------------------------------------------------
@ -120,7 +77,7 @@ bool RimFractureContainment::isEclipseCellWithinContainment(const RigMainGrid*
{
if (!isEnabled()) return true;
if (m_faultTruncation() == CONTINUE_IN_CONTAINMENT_ZONE || m_faultTruncation() == TRUNCATE_AT_FAULT)
if (m_useContainment())
{
CVF_ASSERT(mainGrid);
@ -140,7 +97,7 @@ bool RimFractureContainment::isEclipseCellWithinContainment(const RigMainGrid*
}
}
if (m_faultTruncation() == TRUNCATE_AT_FAULT)
if (m_truncateAtFaults())
{
if (containmentCells.count(globalCellIndex) > 0)
{
@ -176,21 +133,27 @@ void RimFractureContainment::setBaseKLayer(int baseKLayer)
//--------------------------------------------------------------------------------------------------
void RimFractureContainment::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_faultTruncation);
uiOrdering.add(&m_useContainment);
uiOrdering.add(&m_topKLayer);
uiOrdering.add(&m_baseKLayer);
if (m_faultTruncation() == CONTINUE_IN_CONTAINMENT_ZONE || m_faultTruncation() == TRUNCATE_AT_FAULT)
m_topKLayer.uiCapability()->setUiReadOnly(!m_useContainment());
m_baseKLayer.uiCapability()->setUiReadOnly(!m_useContainment());
uiOrdering.add(&m_truncateAtFaults);
uiOrdering.add(&m_useFaultThrow);
uiOrdering.add(&m_maximumFaultThrow);
m_useFaultThrow.uiCapability()->setUiReadOnly(!m_truncateAtFaults());
if (m_truncateAtFaults() && m_useFaultThrow())
{
uiOrdering.add(&m_topKLayer);
uiOrdering.add(&m_baseKLayer);
uiOrdering.add(&m_useFaultThrow);
if (m_useFaultThrow())
{
uiOrdering.add(&m_faultThrowValue);
}
m_maximumFaultThrow.uiCapability()->setUiReadOnly(false);
}
else
{
m_maximumFaultThrow.uiCapability()->setUiReadOnly(true);
}
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
@ -200,8 +163,6 @@ void RimFractureContainment::fieldChangedByUi(const caf::PdmFieldHandle* changed
const QVariant& oldValue,
const QVariant& newValue)
{
if (changedField == &m_faultTruncation || changedField == &m_topKLayer || changedField == &m_baseKLayer ||
changedField == &m_useFaultThrow || changedField == &m_faultThrowValue)
{
RimProject* proj;
this->firstAncestorOrThisOfType(proj);
@ -211,7 +172,7 @@ void RimFractureContainment::fieldChangedByUi(const caf::PdmFieldHandle* changed
}
}
if (changedField == &m_useFaultThrow || changedField == &m_faultTruncation)
if (changedField == &m_useFaultThrow || changedField == &m_useContainment || changedField == &m_truncateAtFaults)
{
RimFractureTemplate* fractureTemplate = nullptr;
this->firstAncestorOrThisOfType(fractureTemplate);

View File

@ -19,7 +19,6 @@
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafAppEnum.h"
class RigMainGrid;
@ -34,36 +33,24 @@ public:
RimFractureContainment();
~RimFractureContainment();
enum FaultTruncType
{
DISABLED,
TRUNCATE_AT_FAULT,
CONTINUE_IN_CONTAINMENT_ZONE
};
bool isEnabled() const;
bool isEclipseCellWithinContainment(const RigMainGrid* mainGrid, size_t anchorEclipseCell, size_t globalCellIndex, const std::set<size_t>& containmentCells) const;
void setTopKLayer(int topKLayer);
void setBaseKLayer(int baseKLayer);
double faultThrow() const; // Negative value means do not test for fault throw
double maximumFaultThrow() const; // Negative value means do not test for fault throw
private:
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
virtual void initAfterRead() override;
private:
friend caf::AppEnum< FaultTruncType >;
caf::PdmField< caf::AppEnum< FaultTruncType > > m_faultTruncation;
caf::PdmField<bool> m_useContainment;
caf::PdmField<int> m_topKLayer;
caf::PdmField<int> m_baseKLayer;
caf::PdmField<bool> m_truncateAtFaults;
caf::PdmField<bool> m_useFaultThrow;
caf::PdmField<float> m_faultThrowValue;
caf::PdmField<bool> m_isUsingFractureContainment_OBSOLETE;
caf::PdmField<float> m_maximumFaultThrow;
};

View File

@ -18,7 +18,6 @@
#include "RimFractureContainmentTools.h"
#include "RigActiveCellInfo.h"
#include "RigEclipseCaseData.h"
#include "RigFault.h"
#include "RigHexIntersectionTools.h"
@ -43,7 +42,7 @@ void RimFractureContainmentTools::appendNeighborCellForFace(const std::set<size_
size_t currentCell,
cvf::StructGridInterface::FaceType face,
std::set<size_t>& connectedCells,
double faultThrow)
double maximumFaultThrow)
{
// TODO: Remove when we know if LGR can have faults
@ -53,7 +52,7 @@ void RimFractureContainmentTools::appendNeighborCellForFace(const std::set<size_
size_t candidate;
if (mainGrid->cellIJKNeighbor(anchorI, anchorJ, anchorK, face, &candidate))
{
appendNeighborCells(allFracturedCells, mainGrid, candidate, connectedCells, faultThrow);
appendNeighborCells(allFracturedCells, mainGrid, candidate, connectedCells, maximumFaultThrow);
}
}
@ -65,12 +64,12 @@ void RimFractureContainmentTools::checkFaultAndAppendNeighborCell(const std::set
size_t globalReservoirCellIndex,
cvf::StructGridInterface::FaceType face,
std::set<size_t>& connectedCells,
double faultThrow)
double maximumFaultThrow)
{
const RigFault* fault = mainGrid->findFaultFromCellIndexAndCellFace(globalReservoirCellIndex, face);
if (fault)
{
if (faultThrow < 0.0)
if (maximumFaultThrow < 0.0)
{
return;
}
@ -87,7 +86,7 @@ void RimFractureContainmentTools::checkFaultAndAppendNeighborCell(const std::set
size_t i, j, k;
hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k);
size_t neighborGridLocalCellIndex;
bool foundCell = hostGrid->cellIJKNeighbor(i, j, k, face, &neighborGridLocalCellIndex);
@ -95,18 +94,19 @@ void RimFractureContainmentTools::checkFaultAndAppendNeighborCell(const std::set
size_t neighborGlobalReservoirCellIndex = hostGrid->reservoirCellIndex(neighborGridLocalCellIndex);
const RigCell& currentCell = mainGrid->globalCellArray()[globalReservoirCellIndex];
const RigCell& currentCell = mainGrid->globalCellArray()[globalReservoirCellIndex];
const RigCell& neightborCell = mainGrid->globalCellArray()[neighborGlobalReservoirCellIndex];
auto diffBetweenFaceCenters = currentCell.faceCenter(face) - neightborCell.faceCenter(cvf::StructGridInterface::oppositeFace(face));
if (diffBetweenFaceCenters.length() < faultThrow)
auto diffBetweenFaceCenters =
currentCell.faceCenter(face) - neightborCell.faceCenter(cvf::StructGridInterface::oppositeFace(face));
if (diffBetweenFaceCenters.length() > maximumFaultThrow)
{
return;
}
}
}
appendNeighborCellForFace(allFracturedCells, mainGrid, globalReservoirCellIndex, face, connectedCells, faultThrow);
appendNeighborCellForFace(allFracturedCells, mainGrid, globalReservoirCellIndex, face, connectedCells, maximumFaultThrow);
}
//--------------------------------------------------------------------------------------------------
@ -116,7 +116,7 @@ void RimFractureContainmentTools::appendNeighborCells(const std::set<size_t>& al
const RigMainGrid* mainGrid,
size_t currentCell,
std::set<size_t>& connectedCells,
double faultThrow)
double maximumFaultThrow)
{
if (std::find(connectedCells.begin(), connectedCells.end(), currentCell) != connectedCells.end())
{
@ -133,14 +133,20 @@ void RimFractureContainmentTools::appendNeighborCells(const std::set<size_t>& al
connectedCells.insert(currentCell);
// Check faults in IJ directions
checkFaultAndAppendNeighborCell(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_I, connectedCells, faultThrow);
checkFaultAndAppendNeighborCell(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_I, connectedCells, faultThrow);
checkFaultAndAppendNeighborCell(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_J, connectedCells, faultThrow);
checkFaultAndAppendNeighborCell(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_J, connectedCells, faultThrow);
checkFaultAndAppendNeighborCell(
allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_I, connectedCells, maximumFaultThrow);
checkFaultAndAppendNeighborCell(
allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_I, connectedCells, maximumFaultThrow);
checkFaultAndAppendNeighborCell(
allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_J, connectedCells, maximumFaultThrow);
checkFaultAndAppendNeighborCell(
allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_J, connectedCells, maximumFaultThrow);
// Append cells without fault check in K direction
appendNeighborCellForFace(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_K, connectedCells, faultThrow);
appendNeighborCellForFace(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_K, connectedCells, faultThrow);
appendNeighborCellForFace(
allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_K, connectedCells, maximumFaultThrow);
appendNeighborCellForFace(
allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_K, connectedCells, maximumFaultThrow);
}
//--------------------------------------------------------------------------------------------------
@ -156,25 +162,26 @@ std::set<size_t> RimFractureContainmentTools::fracturedCellsTruncatedByFaults(co
auto eclipseCaseData = eclipseCase->eclipseCaseData();
if (eclipseCaseData)
{
auto mainGrid = eclipseCaseData->mainGrid();
auto activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL);
auto mainGrid = eclipseCaseData->mainGrid();
if (mainGrid && activeCellInfo)
if (mainGrid)
{
std::set<size_t> cellsIntersectingFracturePlane =
getCellsIntersectingFracturePlane(mainGrid, activeCellInfo, fracture);
std::set<size_t> cellsIntersectingFracturePlane = getCellsIntersectingFracturePlane(mainGrid, fracture);
size_t anchorCellGlobalIndex = fracture->findAnchorEclipseCell(mainGrid);
// Negative faultThrow disables test on faultThrow
double faultThrow = -1.0;
double maximumFaultThrow = -1.0;
if (fracture && fracture->fractureTemplate())
{
faultThrow = fracture->fractureTemplate()->fractureContainment()->faultThrow();
maximumFaultThrow = fracture->fractureTemplate()->fractureContainment()->maximumFaultThrow();
}
appendNeighborCells(
cellsIntersectingFracturePlane, mainGrid, anchorCellGlobalIndex, fracturedCellsContainedByFaults, faultThrow);
appendNeighborCells(cellsIntersectingFracturePlane,
mainGrid,
anchorCellGlobalIndex,
fracturedCellsContainedByFaults,
maximumFaultThrow);
}
/*
@ -194,9 +201,8 @@ std::set<size_t> RimFractureContainmentTools::fracturedCellsTruncatedByFaults(co
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<size_t> RimFractureContainmentTools::getCellsIntersectingFracturePlane(const RigMainGrid* mainGrid,
const RigActiveCellInfo* activeCellInfo,
RimFracture* fracture)
std::set<size_t> RimFractureContainmentTools::getCellsIntersectingFracturePlane(const RigMainGrid* mainGrid,
RimFracture* fracture)
{
std::set<size_t> eclipseCellIndices;

View File

@ -24,7 +24,6 @@
#include <vector>
class RigMainGrid;
class RigActiveCellInfo;
class RimFracture;
class RimEclipseCase;
@ -35,26 +34,26 @@ public:
private:
// TODO: Try to change RimStimPlanFractureTemplate::fractureTriangleGeometry to be able to use const RimFracture
static std::set<size_t>
getCellsIntersectingFracturePlane(const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo, RimFracture* fracture);
static std::set<size_t> getCellsIntersectingFracturePlane(const RigMainGrid* mainGrid,
RimFracture* fracture);
static void appendNeighborCellForFace(const std::set<size_t>& allFracturedCells,
const RigMainGrid* mainGrid,
size_t currentCell,
cvf::StructGridInterface::FaceType face,
std::set<size_t>& connectedCells,
double faultThrow);
double maximumFaultThrow);
static void checkFaultAndAppendNeighborCell(const std::set<size_t>& allFracturedCells,
const RigMainGrid* mainGrid,
size_t currentCell,
cvf::StructGridInterface::FaceType face,
std::set<size_t>& connectedCells,
double faultThrow);
double maximumFaultThrow);
static void appendNeighborCells(const std::set<size_t>& allFracturedCells,
const RigMainGrid* mainGrid,
size_t currentCell,
std::set<size_t>& connectedCells,
double faultThrow);
double maximumFaultThrow);
};