#1585 More rename and code reordering of StimPlanFractureTemplate

This commit is contained in:
Jacob Støren 2017-06-13 11:38:22 +02:00
parent f09374b12a
commit d8d2aaed5f
6 changed files with 119 additions and 116 deletions

View File

@ -177,7 +177,7 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor
textureCoords->resize(nodeCoords.size());
int timeStepIndex = m_rimFracture->stimPlanTimeIndexToPlot;
std::vector<std::vector<double> > dataToPlot = stimPlanFracTemplate->getDataAtTimeIndex(activeView->stimPlanColors->resultName(), activeView->stimPlanColors->unit(), timeStepIndex);
std::vector<std::vector<double> > dataToPlot = stimPlanFracTemplate->resultValues(activeView->stimPlanColors->resultName(), activeView->stimPlanColors->unit(), timeStepIndex);
int i = 0;
for (std::vector<double> depthData : dataToPlot)
@ -289,7 +289,7 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
{
//TODO: This is needed to avoid errors when loading project with stimPlan fractures with multipled timesteps.
//Should probably be moved, since it now is called twice in some cases...
stimPlanFracTemplate->setupStimPlanCells();
stimPlanFracTemplate->updateFractureGrid();
std::vector<RigFractureCell> stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells();
std::vector<cvf::Vec3f> stimPlanMeshVertices;

View File

@ -354,7 +354,7 @@ QList<caf::PdmOptionItemInfo> RimFracture::calculateValueOptions(const caf::PdmF
if (dynamic_cast<RimStimPlanFractureTemplate*>(fracTemplate))
{
RimStimPlanFractureTemplate* fracTemplateStimPlan = dynamic_cast<RimStimPlanFractureTemplate*>(fracTemplate);
std::vector<double> timeValues = fracTemplateStimPlan->getStimPlanTimeSteps();
std::vector<double> timeValues = fracTemplateStimPlan->timeSteps();
int index = 0;
for (double value : timeValues)
{

View File

@ -59,7 +59,7 @@ std::vector<std::pair<QString, QString> > RimFractureTemplateCollection::stimPla
auto stimPlanFracture = dynamic_cast<const RimStimPlanFractureTemplate*>(f);
if (stimPlanFracture)
{
std::vector<std::pair<QString, QString> > namesAndUnits = stimPlanFracture->getStimPlanResultNamesWithUnit();
std::vector<std::pair<QString, QString> > namesAndUnits = stimPlanFracture->resultNamesWithUnit();
for (auto nameAndUnit : namesAndUnits)
{

View File

@ -96,7 +96,7 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch
if (&m_activeTimeStepIndex == changedField)
{
setupStimPlanCells();
updateFractureGrid();
//Changes to this parameters should change all fractures with this fracture template attached.
RimProject* proj;
@ -198,7 +198,7 @@ void RimStimPlanFractureTemplate::setDefaultsBasedOnXMLfile()
bool RimStimPlanFractureTemplate::setBorderPolygonResultNameToDefault()
{
//first option: Width
for (std::pair<QString, QString> property : getStimPlanResultNamesWithUnit())
for (std::pair<QString, QString> property : resultNamesWithUnit())
{
if (property.first == "WIDTH")
{
@ -207,7 +207,7 @@ bool RimStimPlanFractureTemplate::setBorderPolygonResultNameToDefault()
}
}
//if width not found, use conductivity
for (std::pair<QString, QString> property : getStimPlanResultNamesWithUnit())
for (std::pair<QString, QString> property : resultNamesWithUnit())
{
if (property.first == "CONDUCTIVITY")
{
@ -236,7 +236,7 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate()
fractureTemplateUnit = RimUnitSystem::UNITS_UNKNOWN;
}
setupStimPlanCells();
updateFractureGrid();
// Todo: Must update all views using this fracture template
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
@ -245,15 +245,6 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate()
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<double>> RimStimPlanFractureTemplate::getDataAtTimeIndex(const QString& resultName, const QString& unitName, size_t timeStepIndex) const
{
return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(resultName, unitName, timeStepIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -263,7 +254,7 @@ QList<caf::PdmOptionItemInfo> RimStimPlanFractureTemplate::calculateValueOptions
if (fieldNeedingOptions == &m_borderPolygonResultName)
{
for (std::pair<QString, QString> nameUnit : getStimPlanResultNamesWithUnit())
for (std::pair<QString, QString> nameUnit : resultNamesWithUnit())
{
//options.push_back(caf::PdmOptionItemInfo(nameUnit.first + " [" + nameUnit.second + "]", nameUnit.first + " " + nameUnit.second));
options.push_back(caf::PdmOptionItemInfo(nameUnit.first, nameUnit.first));
@ -272,7 +263,7 @@ QList<caf::PdmOptionItemInfo> RimStimPlanFractureTemplate::calculateValueOptions
else if (fieldNeedingOptions == &m_activeTimeStepIndex)
{
std::vector<double> timeValues = getStimPlanTimeSteps();
std::vector<double> timeValues = timeSteps();
int index = 0;
for (double value : timeValues)
{
@ -309,7 +300,7 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet
bool found = false;
bool foundMultiple = false;
for (std::pair<QString, QString> nameUnit : getStimPlanResultNamesWithUnit())
for (std::pair<QString, QString> nameUnit : resultNamesWithUnit())
{
if (nameUnit.first == parameterName)
{
@ -325,6 +316,142 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimStimPlanFractureTemplate::timeSteps()
{
if (m_stimPlanFractureDefinitionData.isNull()) loadDataAndUpdate();
return m_stimPlanFractureDefinitionData->timeSteps;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<QString, QString> > RimStimPlanFractureTemplate::resultNamesWithUnit() const
{
std::vector<std::pair<QString, QString> > propertyNamesUnits;
if (m_stimPlanFractureDefinitionData.notNull())
{
propertyNamesUnits = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits();
}
return propertyNamesUnits;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue) const
{
if (m_stimPlanFractureDefinitionData.notNull())
{
m_stimPlanFractureDefinitionData->computeMinMax(resultName, unitName, minValue, maxValue);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<double>> RimStimPlanFractureTemplate::resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const
{
return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(resultName, unitName, timeStepIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigFractureGrid* RimStimPlanFractureTemplate::fractureGrid() const
{
return m_fractureGrid.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::updateFractureGrid()
{
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if (!activeView) return;
QString resultNameFromColors = activeView->stimPlanColors->resultName();
QString resultUnitFromColors = activeView->stimPlanColors->unit();
std::vector<RigFractureCell> stimPlanCells;
std::pair<size_t, size_t> wellCenterStimPlanCellIJ = std::make_pair(0,0);
bool wellCenterStimPlanCellFound = false;
std::vector<std::vector<double>> displayPropertyValuesAtTimeStep = m_stimPlanFractureDefinitionData->getMirroredDataAtTimeIndex(resultNameFromColors, resultUnitFromColors, m_activeTimeStepIndex);
QString condUnit;
if (fractureTemplateUnit == RimUnitSystem::UNITS_METRIC) condUnit = "md-m";
if (fractureTemplateUnit == RimUnitSystem::UNITS_FIELD) condUnit = "md-ft";
std::vector<std::vector<double>> conductivityValuesAtTimeStep = m_stimPlanFractureDefinitionData->getMirroredDataAtTimeIndex("CONDUCTIVITY", condUnit, m_activeTimeStepIndex);
std::vector<double> depthCoordsAtNodes = m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture());
std::vector<double> xCoordsAtNodes = m_stimPlanFractureDefinitionData->getNegAndPosXcoords();
std::vector<double> xCoords;
for (int i = 0; i < xCoordsAtNodes.size() - 1; i++) xCoords.push_back((xCoordsAtNodes[i] + xCoordsAtNodes[i + 1]) / 2);
std::vector<double> depthCoords;
for (int i = 0; i < depthCoordsAtNodes.size() - 1; i++) depthCoords.push_back((depthCoordsAtNodes[i] + depthCoordsAtNodes[i + 1]) / 2);
for (int i = 0; i < xCoords.size() - 1; i++)
{
for (int j = 0; j < depthCoords.size() - 1; j++)
{
std::vector<cvf::Vec3d> cellPolygon;
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j]), 0.0));
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j]), 0.0));
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j + 1]), 0.0));
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j + 1]), 0.0));
RigFractureCell stimPlanCell(cellPolygon, i, j);
if (conductivityValuesAtTimeStep.size() > 0) //Assuming vector to be of correct length, or no values
{
stimPlanCell.setConductivityValue(conductivityValuesAtTimeStep[j + 1][i + 1]);
}
else
{
stimPlanCell.setConductivityValue(cvf::UNDEFINED_DOUBLE);
}
if (displayPropertyValuesAtTimeStep.size() > 0)
{
stimPlanCell.setDisplayValue(displayPropertyValuesAtTimeStep[j + 1][i + 1]);
}
else
{
stimPlanCell.setDisplayValue(cvf::UNDEFINED_DOUBLE);
}
if (cellPolygon[0].x() < 0.0 && cellPolygon[1].x() > 0.0)
{
if (cellPolygon[1].y() > 0.0 && cellPolygon[2].y() < 0.0)
{
wellCenterStimPlanCellIJ = std::make_pair(stimPlanCell.getI(), stimPlanCell.getJ());
RiaLogging::debug(QString("Setting wellCenterStimPlanCell at cell %1, %2").
arg(QString::number(stimPlanCell.getI()), QString::number(stimPlanCell.getJ())));
wellCenterStimPlanCellFound = true;
}
}
stimPlanCells.push_back(stimPlanCell);
}
}
if (!wellCenterStimPlanCellFound)
{
RiaLogging::error("Did not find stim plan cell at well crossing!");
}
m_fractureGrid->setFractureCells(stimPlanCells);
m_fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ);
m_fractureGrid->setICellCount(m_stimPlanFractureDefinitionData->getNegAndPosXcoords().size() - 2);
m_fractureGrid->setJCellCount(m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture()).size() - 2);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -407,133 +534,6 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vector<cvf::Vec3
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimStimPlanFractureTemplate::getStimPlanTimeSteps()
{
if (m_stimPlanFractureDefinitionData.isNull()) loadDataAndUpdate();
return m_stimPlanFractureDefinitionData->timeSteps;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<QString, QString> > RimStimPlanFractureTemplate::getStimPlanResultNamesWithUnit() const
{
std::vector<std::pair<QString, QString> > propertyNamesUnits;
if (m_stimPlanFractureDefinitionData.notNull())
{
propertyNamesUnits = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits();
}
return propertyNamesUnits;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue) const
{
if (m_stimPlanFractureDefinitionData.notNull())
{
m_stimPlanFractureDefinitionData->computeMinMax(resultName, unitName, minValue, maxValue);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::setupStimPlanCells()
{
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if (!activeView) return;
QString resultNameFromColors = activeView->stimPlanColors->resultName();
QString resultUnitFromColors = activeView->stimPlanColors->unit();
std::vector<RigFractureCell> stimPlanCells;
std::pair<size_t, size_t> wellCenterStimPlanCellIJ = std::make_pair(0,0);
bool wellCenterStimPlanCellFound = false;
std::vector<std::vector<double>> displayPropertyValuesAtTimeStep = m_stimPlanFractureDefinitionData->getMirroredDataAtTimeIndex(resultNameFromColors, resultUnitFromColors, m_activeTimeStepIndex);
QString condUnit;
if (fractureTemplateUnit == RimUnitSystem::UNITS_METRIC) condUnit = "md-m";
if (fractureTemplateUnit == RimUnitSystem::UNITS_FIELD) condUnit = "md-ft";
std::vector<std::vector<double>> conductivityValuesAtTimeStep = m_stimPlanFractureDefinitionData->getMirroredDataAtTimeIndex("CONDUCTIVITY", condUnit, m_activeTimeStepIndex);
std::vector<double> depthCoordsAtNodes = m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture());
std::vector<double> xCoordsAtNodes = m_stimPlanFractureDefinitionData->getNegAndPosXcoords();
std::vector<double> xCoords;
for (int i = 0; i < xCoordsAtNodes.size() - 1; i++) xCoords.push_back((xCoordsAtNodes[i] + xCoordsAtNodes[i + 1]) / 2);
std::vector<double> depthCoords;
for (int i = 0; i < depthCoordsAtNodes.size() - 1; i++) depthCoords.push_back((depthCoordsAtNodes[i] + depthCoordsAtNodes[i + 1]) / 2);
for (int i = 0; i < xCoords.size() - 1; i++)
{
for (int j = 0; j < depthCoords.size() - 1; j++)
{
std::vector<cvf::Vec3d> cellPolygon;
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j]), 0.0));
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j]), 0.0));
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j + 1]), 0.0));
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j + 1]), 0.0));
RigFractureCell stimPlanCell(cellPolygon, i, j);
if (conductivityValuesAtTimeStep.size() > 0) //Assuming vector to be of correct length, or no values
{
stimPlanCell.setConductivityValue(conductivityValuesAtTimeStep[j + 1][i + 1]);
}
else
{
stimPlanCell.setConductivityValue(cvf::UNDEFINED_DOUBLE);
}
if (displayPropertyValuesAtTimeStep.size() > 0)
{
stimPlanCell.setDisplayValue(displayPropertyValuesAtTimeStep[j + 1][i + 1]);
}
else
{
stimPlanCell.setDisplayValue(cvf::UNDEFINED_DOUBLE);
}
if (cellPolygon[0].x() < 0.0 && cellPolygon[1].x() > 0.0)
{
if (cellPolygon[1].y() > 0.0 && cellPolygon[2].y() < 0.0)
{
wellCenterStimPlanCellIJ = std::make_pair(stimPlanCell.getI(), stimPlanCell.getJ());
RiaLogging::debug(QString("Setting wellCenterStimPlanCell at cell %1, %2").
arg(QString::number(stimPlanCell.getI()), QString::number(stimPlanCell.getJ())));
wellCenterStimPlanCellFound = true;
}
}
stimPlanCells.push_back(stimPlanCell);
}
}
if (!wellCenterStimPlanCellFound)
{
RiaLogging::error("Did not find stim plan cell at well crossing!");
}
m_fractureGrid->setFractureCells(stimPlanCells);
m_fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ);
m_fractureGrid->setICellCount(m_stimPlanFractureDefinitionData->getNegAndPosXcoords().size() - 2);
m_fractureGrid->setJCellCount(m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture()).size() - 2);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigFractureGrid* RimStimPlanFractureTemplate::fractureGrid() const
{
return m_fractureGrid.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -56,24 +56,27 @@ public:
bool showStimPlanMesh() { return m_showStimPlanMesh;}
void loadDataAndUpdate();
void setDefaultsBasedOnXMLfile();
void setFileName(const QString& fileName);
const QString& fileName();
QString fileNameWithOutPath();
// Fracture geometry
const RigFractureGrid* fractureGrid() const;
void updateFractureGrid();
void fractureTriangleGeometry(std::vector<cvf::Vec3f>* nodeCoords,
std::vector<cvf::uint>* triangleIndices,
RimUnitSystem::UnitSystem neededUnit) override;
std::vector<cvf::Vec3f> fractureBorderPolygon(RimUnitSystem::UnitSystem neededUnit);
std::vector<double> getStimPlanTimeSteps();
std::vector<std::pair<QString, QString> > getStimPlanResultNamesWithUnit() const;
void computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue) const;
void setDefaultsBasedOnXMLfile();
std::vector<std::vector<double>> getDataAtTimeIndex(const QString& resultName, const QString& unitName, size_t timeStepIndex) const;
// Result Access
void setupStimPlanCells();
const RigFractureGrid* fractureGrid() const;
std::vector<double> timeSteps();
std::vector<std::pair<QString, QString> > resultNamesWithUnit() const;
void computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue) const;
std::vector<std::vector<double>> resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const;
// OBSOLETE : Function used by upscaling only
void getStimPlanDataAsPolygonsAndValues(std::vector<std::vector<cvf::Vec3d> > &cellsAsPolygons, std::vector<double> &parameterValue, const QString& resultName, const QString& unitName, size_t timeStepIndex);

View File

@ -179,7 +179,7 @@ void RimStimPlanColors::fieldChangedByUi(const caf::PdmFieldHandle* changedField
proj->descendantsIncludingThisOfType(stimPlanFracTemplates);
for (RimStimPlanFractureTemplate* stimPlanFracTemplate : stimPlanFracTemplates)
{
stimPlanFracTemplate->setupStimPlanCells();
stimPlanFracTemplate->updateFractureGrid();
}
proj->createDisplayModelAndRedrawAllViews();
}