2017-02-07 02:09:00 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 - Statoil ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimStimPlanFractureTemplate.h"
|
|
|
|
|
2017-02-20 08:39:15 -06:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2017-02-07 04:08:56 -06:00
|
|
|
#include "RigStimPlanFractureDefinition.h"
|
2017-02-07 02:09:00 -06:00
|
|
|
|
2017-02-20 08:39:15 -06:00
|
|
|
#include "RimEclipseView.h"
|
2017-02-10 08:29:15 -06:00
|
|
|
#include "RimFracture.h"
|
|
|
|
#include "RimProject.h"
|
2017-02-20 08:39:15 -06:00
|
|
|
#include "RimStimPlanColors.h"
|
2017-02-17 02:29:46 -06:00
|
|
|
#include "RimStimPlanLegendConfig.h"
|
2017-02-10 08:29:15 -06:00
|
|
|
|
2017-02-07 02:09:00 -06:00
|
|
|
#include "cafPdmObject.h"
|
2017-02-17 08:10:04 -06:00
|
|
|
#include "cafPdmUiDoubleSliderEditor.h"
|
2017-02-09 03:52:05 -06:00
|
|
|
#include "cafPdmUiFilePathEditor.h"
|
2017-02-07 02:09:00 -06:00
|
|
|
|
|
|
|
#include "cvfVector3.h"
|
2017-02-09 03:52:05 -06:00
|
|
|
|
|
|
|
#include <QDebug>
|
2017-02-07 04:08:56 -06:00
|
|
|
#include <QFileInfo>
|
2017-02-09 03:52:05 -06:00
|
|
|
#include <QMessageBox>
|
2017-02-07 02:09:00 -06:00
|
|
|
|
2017-02-17 04:03:20 -06:00
|
|
|
#include <algorithm>
|
|
|
|
|
2017-02-07 02:09:00 -06:00
|
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimStimPlanFractureTemplate, "RimStimPlanFractureTemplate");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimStimPlanFractureTemplate::RimStimPlanFractureTemplate(void)
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", "");
|
|
|
|
|
2017-02-22 04:52:06 -06:00
|
|
|
CAF_PDM_InitField(&m_stimPlanFileName, "StimPlanFileName", QString(""), "File Name", "", "", "");
|
2017-02-10 08:29:15 -06:00
|
|
|
m_stimPlanFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
|
|
|
|
2017-02-22 04:52:06 -06:00
|
|
|
CAF_PDM_InitField(&wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Well/Fracture Intersection Depth", "", "", "");
|
2017-02-17 08:10:04 -06:00
|
|
|
wellPathDepthAtFracture.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
2017-02-07 02:09:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimStimPlanFractureTemplate::~RimStimPlanFractureTemplate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
2017-02-07 04:08:56 -06:00
|
|
|
|
2017-02-10 08:29:15 -06:00
|
|
|
if (&m_stimPlanFileName == changedField)
|
2017-02-07 04:08:56 -06:00
|
|
|
{
|
|
|
|
updateUiTreeName();
|
2017-02-17 02:29:46 -06:00
|
|
|
loadDataAndUpdate();
|
|
|
|
/*
|
2017-02-07 04:08:56 -06:00
|
|
|
QString errorMessage;
|
|
|
|
readStimPlanXMLFile(&errorMessage);
|
|
|
|
if (!errorMessage.isEmpty())
|
|
|
|
{
|
|
|
|
QMessageBox::warning(nullptr, "StimPlanFile", errorMessage);
|
|
|
|
}
|
2017-02-17 02:29:46 -06:00
|
|
|
*/
|
2017-02-07 04:08:56 -06:00
|
|
|
}
|
2017-02-10 08:29:15 -06:00
|
|
|
|
|
|
|
if (&wellPathDepthAtFracture == changedField)
|
|
|
|
{
|
|
|
|
RimProject* proj;
|
|
|
|
this->firstAncestorOrThisOfType(proj);
|
|
|
|
if (proj)
|
|
|
|
{
|
|
|
|
//Regenerate geometry
|
|
|
|
std::vector<RimFracture*> fractures;
|
|
|
|
proj->descendantsIncludingThisOfType(fractures);
|
|
|
|
|
|
|
|
for (RimFracture* fracture : fractures)
|
|
|
|
{
|
|
|
|
if (fracture->attachedFractureDefinition() == this)
|
|
|
|
{
|
|
|
|
fracture->setRecomputeGeometryFlag();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proj->createDisplayModelAndRedrawAllViews();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-07 02:09:00 -06:00
|
|
|
}
|
|
|
|
|
2017-02-07 04:08:56 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStimPlanFractureTemplate::updateUiTreeName()
|
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
this->uiCapability()->setUiName(fileNameWithOutPath());
|
2017-02-07 04:08:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStimPlanFractureTemplate::setFileName(const QString& fileName)
|
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
m_stimPlanFileName = fileName;
|
2017-02-07 04:08:56 -06:00
|
|
|
|
|
|
|
updateUiTreeName();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const QString& RimStimPlanFractureTemplate::fileName()
|
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
return m_stimPlanFileName();
|
2017-02-07 04:08:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-02-10 08:29:15 -06:00
|
|
|
QString RimStimPlanFractureTemplate::fileNameWithOutPath()
|
2017-02-07 04:08:56 -06:00
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
QFileInfo stimplanfileFileInfo(m_stimPlanFileName());
|
2017-02-07 04:08:56 -06:00
|
|
|
return stimplanfileFileInfo.fileName();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStimPlanFractureTemplate::readStimPlanXMLFile(QString * errorMessage)
|
|
|
|
{
|
2017-02-15 03:32:34 -06:00
|
|
|
m_stimPlanFractureDefinitionData = new RigStimPlanFractureDefinition;
|
|
|
|
{
|
|
|
|
QFile dataFile(m_stimPlanFileName());
|
|
|
|
if (!dataFile.open(QFile::ReadOnly))
|
|
|
|
{
|
|
|
|
if (errorMessage) (*errorMessage) += "Could not open the File: " + (m_stimPlanFileName()) + "\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QXmlStreamReader xmlStream;
|
|
|
|
xmlStream.setDevice(&dataFile);
|
|
|
|
xmlStream.readNext();
|
|
|
|
readStimplanGridAndTimesteps(xmlStream);
|
|
|
|
if (xmlStream.hasError())
|
|
|
|
{
|
|
|
|
qDebug() << "Error: Failed to parse file " << dataFile.fileName();
|
|
|
|
qDebug() << xmlStream.errorString();
|
|
|
|
}
|
|
|
|
dataFile.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t numberOfDepthValues;
|
|
|
|
numberOfDepthValues = m_stimPlanFractureDefinitionData->depths.size();
|
|
|
|
size_t numberOfTimeSteps;
|
|
|
|
numberOfTimeSteps = m_stimPlanFractureDefinitionData->timeSteps.size();
|
|
|
|
|
|
|
|
//Start reading from top:
|
2017-02-10 08:29:15 -06:00
|
|
|
QFile dataFile(m_stimPlanFileName());
|
2017-02-09 03:52:05 -06:00
|
|
|
|
|
|
|
if (!dataFile.open(QFile::ReadOnly))
|
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
if (errorMessage) (*errorMessage) += "Could not open the File: " + (m_stimPlanFileName()) + "\n";
|
2017-02-09 03:52:05 -06:00
|
|
|
return;
|
|
|
|
}
|
2017-02-15 03:32:34 -06:00
|
|
|
|
|
|
|
QXmlStreamReader xmlStream2;
|
|
|
|
xmlStream2.setDevice(&dataFile);
|
2017-02-09 03:52:05 -06:00
|
|
|
QString parameter;
|
2017-02-17 03:10:06 -06:00
|
|
|
QString unit;
|
2017-02-09 03:52:05 -06:00
|
|
|
|
2017-02-15 03:32:34 -06:00
|
|
|
while (!xmlStream2.atEnd())
|
2017-02-09 03:52:05 -06:00
|
|
|
{
|
2017-02-15 03:32:34 -06:00
|
|
|
xmlStream2.readNext();
|
2017-02-09 03:52:05 -06:00
|
|
|
|
2017-02-15 03:32:34 -06:00
|
|
|
if (xmlStream2.isStartElement())
|
2017-02-09 03:52:05 -06:00
|
|
|
{
|
2017-02-15 03:32:34 -06:00
|
|
|
if (xmlStream2.name() == "property")
|
|
|
|
{
|
2017-02-17 03:10:06 -06:00
|
|
|
unit = getAttributeValueString(xmlStream2, "uom");
|
2017-02-15 03:32:34 -06:00
|
|
|
parameter = getAttributeValueString(xmlStream2, "name");
|
2017-02-17 03:10:06 -06:00
|
|
|
//Width - convert to cm from mm?
|
|
|
|
|
2017-02-09 03:52:05 -06:00
|
|
|
}
|
2017-02-15 03:32:34 -06:00
|
|
|
else if (xmlStream2.name() == "time")
|
2017-02-09 03:52:05 -06:00
|
|
|
{
|
2017-02-15 03:32:34 -06:00
|
|
|
double timeStepValue = getAttributeValueDouble(xmlStream2, "value");
|
|
|
|
std::vector<std::vector<double>> propertyValuesAtTimestep = getAllDepthDataAtTimeStep(xmlStream2);
|
|
|
|
|
|
|
|
bool valuesOK = numberOfParameterValuesOK(propertyValuesAtTimestep);
|
|
|
|
if (!valuesOK)
|
|
|
|
{
|
|
|
|
qDebug() << "Inconsistency detected in reading XML file!";
|
|
|
|
return;
|
|
|
|
}
|
2017-02-09 03:52:05 -06:00
|
|
|
|
2017-02-17 05:17:57 -06:00
|
|
|
m_stimPlanFractureDefinitionData->setDataAtTimeValue(parameter, unit, propertyValuesAtTimestep, timeStepValue);
|
|
|
|
|
2017-02-09 03:52:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dataFile.close();
|
|
|
|
|
2017-02-15 03:32:34 -06:00
|
|
|
if (xmlStream2.hasError())
|
2017-02-09 03:52:05 -06:00
|
|
|
{
|
|
|
|
qDebug() << "Error: Failed to parse file " << dataFile.fileName();
|
2017-02-15 03:32:34 -06:00
|
|
|
qDebug() << xmlStream2.errorString();
|
2017-02-09 03:52:05 -06:00
|
|
|
}
|
|
|
|
else if (dataFile.error() != QFile::NoError)
|
|
|
|
{
|
|
|
|
qDebug() << "Error: Cannot read file " << dataFile.fileName();
|
|
|
|
qDebug() << dataFile.errorString();
|
|
|
|
}
|
2017-02-17 03:10:06 -06:00
|
|
|
|
2017-02-17 08:10:04 -06:00
|
|
|
setDepthOfWellPathAtFracture();
|
2017-02-20 08:39:15 -06:00
|
|
|
|
|
|
|
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
|
|
|
if (!activeView) return;
|
|
|
|
activeView->stimPlanColors->loadDataAndUpdate();
|
2017-02-09 03:52:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-15 08:49:53 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStimPlanFractureTemplate::loadDataAndUpdate()
|
|
|
|
{
|
|
|
|
QString errorMessage;
|
|
|
|
readStimPlanXMLFile(&errorMessage);
|
|
|
|
qDebug() << errorMessage;
|
2017-02-17 02:29:46 -06:00
|
|
|
|
|
|
|
updateConnectedEditors();
|
2017-02-15 08:49:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-17 07:11:47 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-02-20 02:31:24 -06:00
|
|
|
std::vector<std::vector<double>> RimStimPlanFractureTemplate::getDataAtTimeIndex(const QString& resultName, const QString& unitName, size_t timeStepIndex) const
|
2017-02-17 07:11:47 -06:00
|
|
|
{
|
2017-02-20 02:31:24 -06:00
|
|
|
return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(resultName, unitName, timeStepIndex);
|
2017-02-17 07:11:47 -06:00
|
|
|
}
|
|
|
|
|
2017-02-09 03:52:05 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-02-15 03:32:34 -06:00
|
|
|
void RimStimPlanFractureTemplate::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream)
|
|
|
|
{
|
|
|
|
|
|
|
|
xmlStream.readNext();
|
|
|
|
|
|
|
|
//First, read time steps and grid to establish data structures for putting data into later.
|
|
|
|
while (!xmlStream.atEnd())
|
|
|
|
{
|
|
|
|
xmlStream.readNext();
|
|
|
|
|
|
|
|
if (xmlStream.isStartElement())
|
|
|
|
{
|
|
|
|
|
|
|
|
if (xmlStream.name() == "xs")
|
|
|
|
{
|
2017-02-22 04:52:06 -06:00
|
|
|
// if (getGriddingValues(xmlStream)[0] < 0.0)
|
|
|
|
// {
|
|
|
|
// qDebug() << getGriddingValues(xmlStream)[0];
|
|
|
|
// }
|
2017-02-15 03:32:34 -06:00
|
|
|
m_stimPlanFractureDefinitionData->gridXs = getGriddingValues(xmlStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (xmlStream.name() == "ys")
|
|
|
|
{
|
|
|
|
m_stimPlanFractureDefinitionData->gridYs = getGriddingValues(xmlStream);
|
|
|
|
m_stimPlanFractureDefinitionData->reorderYgridToDepths();
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (xmlStream.name() == "time")
|
|
|
|
{
|
|
|
|
double timeStepValue = getAttributeValueDouble(xmlStream, "value");
|
|
|
|
if (!m_stimPlanFractureDefinitionData->timeStepExisist(timeStepValue))
|
|
|
|
{
|
|
|
|
m_stimPlanFractureDefinitionData->timeSteps.push_back(timeStepValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<std::vector<double>> RimStimPlanFractureTemplate::getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream)
|
2017-02-09 03:52:05 -06:00
|
|
|
{
|
|
|
|
std::vector<std::vector<double>> propertyValuesAtTimestep;
|
|
|
|
|
|
|
|
while (!(xmlStream.isEndElement() && xmlStream.name() == "time"))
|
|
|
|
{
|
|
|
|
xmlStream.readNext();
|
2017-02-15 03:32:34 -06:00
|
|
|
|
2017-02-09 03:52:05 -06:00
|
|
|
if (xmlStream.name() == "depth")
|
|
|
|
{
|
|
|
|
double depth = xmlStream.readElementText().toDouble();
|
|
|
|
std::vector<double> propertyValuesAtDepth;
|
|
|
|
|
|
|
|
xmlStream.readNext(); //read end depth token
|
|
|
|
xmlStream.readNext(); //read cdata section with values
|
|
|
|
if (xmlStream.isCDATA())
|
|
|
|
{
|
|
|
|
QString depthDataStr = xmlStream.text().toString();
|
|
|
|
for (QString value : depthDataStr.split(' '))
|
|
|
|
{
|
2017-02-15 03:32:34 -06:00
|
|
|
if (value != "")
|
|
|
|
{
|
|
|
|
propertyValuesAtDepth.push_back(value.toDouble());
|
|
|
|
}
|
2017-02-09 03:52:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
propertyValuesAtTimestep.push_back(propertyValuesAtDepth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return propertyValuesAtTimestep;
|
|
|
|
}
|
|
|
|
|
2017-02-15 03:32:34 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimStimPlanFractureTemplate::numberOfParameterValuesOK(std::vector<std::vector<double>> propertyValuesAtTimestep)
|
|
|
|
{
|
|
|
|
size_t depths = m_stimPlanFractureDefinitionData->depths.size();
|
|
|
|
size_t gridXvalues = m_stimPlanFractureDefinitionData->gridXs.size();
|
|
|
|
|
|
|
|
if (propertyValuesAtTimestep.size() != depths) return false;
|
|
|
|
for (std::vector<double> valuesAtDepthVector : propertyValuesAtTimestep)
|
|
|
|
{
|
|
|
|
if (valuesAtDepthVector.size() != gridXvalues) return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-02-17 08:10:04 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStimPlanFractureTemplate::setDepthOfWellPathAtFracture()
|
|
|
|
{
|
|
|
|
if (!m_stimPlanFractureDefinitionData.isNull())
|
|
|
|
{
|
|
|
|
double firstDepth = m_stimPlanFractureDefinitionData->depths[0];
|
|
|
|
double lastDepth = m_stimPlanFractureDefinitionData->depths[m_stimPlanFractureDefinitionData->depths.size()-1];
|
|
|
|
double averageDepth = (firstDepth + lastDepth) / 2;
|
|
|
|
wellPathDepthAtFracture = averageDepth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-09 03:52:05 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<double> RimStimPlanFractureTemplate::getGriddingValues(QXmlStreamReader &xmlStream)
|
|
|
|
{
|
|
|
|
std::vector<double> gridValues;
|
|
|
|
QString gridValuesString = xmlStream.readElementText().replace('\n', ' ');
|
|
|
|
for (QString value : gridValuesString.split(' '))
|
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
if (value.size()>0) gridValues.push_back(value.toDouble());
|
2017-02-09 03:52:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return gridValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RimStimPlanFractureTemplate::getAttributeValueDouble(QXmlStreamReader &xmlStream, QString parameterName)
|
|
|
|
{
|
|
|
|
double value = cvf::UNDEFINED_DOUBLE;
|
|
|
|
for (const QXmlStreamAttribute &attr : xmlStream.attributes())
|
|
|
|
{
|
|
|
|
if (attr.name() == parameterName)
|
|
|
|
{
|
|
|
|
value = attr.value().toString().toDouble();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimStimPlanFractureTemplate::getAttributeValueString(QXmlStreamReader &xmlStream, QString parameterName)
|
|
|
|
{
|
|
|
|
QString parameterValue;
|
|
|
|
for (const QXmlStreamAttribute &attr : xmlStream.attributes())
|
|
|
|
{
|
|
|
|
if (attr.name() == parameterName)
|
|
|
|
{
|
|
|
|
parameterValue = attr.value().toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return parameterValue;
|
2017-02-07 04:08:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-07 02:09:00 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-02-10 04:32:18 -06:00
|
|
|
void RimStimPlanFractureTemplate::fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices)
|
2017-02-07 02:09:00 -06:00
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
|
|
|
|
if (m_stimPlanFractureDefinitionData.isNull())
|
|
|
|
{
|
2017-02-15 08:49:53 -06:00
|
|
|
loadDataAndUpdate();
|
2017-02-10 08:29:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-13 06:46:49 -06:00
|
|
|
std::vector<double> xCoords = getNegAndPosXcoords();
|
2017-02-15 08:14:16 -06:00
|
|
|
//std::vector<double> xCoords = m_stimPlanFractureDefinitionData->gridXs;
|
2017-02-13 06:46:49 -06:00
|
|
|
cvf::uint lenXcoords = static_cast<cvf::uint>(xCoords.size());
|
2017-02-10 08:29:15 -06:00
|
|
|
|
2017-02-13 06:46:49 -06:00
|
|
|
std::vector<double> adjustedDepths = adjustedDepthCoordsAroundWellPathPosition();
|
2017-02-10 08:29:15 -06:00
|
|
|
|
2017-02-13 06:46:49 -06:00
|
|
|
for (cvf::uint k = 0; k < adjustedDepths.size(); k++)
|
2017-02-10 08:29:15 -06:00
|
|
|
{
|
2017-02-13 06:46:49 -06:00
|
|
|
for (cvf::uint i = 0; i < lenXcoords; i++)
|
2017-02-10 08:29:15 -06:00
|
|
|
{
|
2017-02-13 06:46:49 -06:00
|
|
|
cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedDepths[k], 0);
|
|
|
|
nodeCoords->push_back(node);
|
2017-02-10 08:29:15 -06:00
|
|
|
|
2017-02-13 06:46:49 -06:00
|
|
|
if (i < lenXcoords - 1 && k < adjustedDepths.size() - 1)
|
|
|
|
{
|
2017-02-16 06:05:40 -06:00
|
|
|
if (xCoords[i] < 1e-5)
|
|
|
|
{
|
|
|
|
//Upper triangle
|
|
|
|
triangleIndices->push_back(i + k*lenXcoords);
|
|
|
|
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
|
|
|
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
|
|
|
//Lower triangle
|
|
|
|
triangleIndices->push_back(i + k*lenXcoords);
|
|
|
|
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
|
|
|
triangleIndices->push_back((i)+(k + 1)*lenXcoords);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Upper triangle
|
|
|
|
triangleIndices->push_back(i + k*lenXcoords);
|
|
|
|
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
|
|
|
triangleIndices->push_back((i)+(k + 1)*lenXcoords);
|
|
|
|
//Lower triangle
|
|
|
|
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
|
|
|
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
|
|
|
triangleIndices->push_back((i) + (k + 1)*lenXcoords);
|
|
|
|
}
|
|
|
|
|
2017-02-13 06:46:49 -06:00
|
|
|
}
|
2017-02-10 08:29:15 -06:00
|
|
|
}
|
|
|
|
}
|
2017-02-13 06:46:49 -06:00
|
|
|
|
2017-02-10 08:29:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<double> RimStimPlanFractureTemplate::getNegAndPosXcoords()
|
|
|
|
{
|
|
|
|
std::vector<double> allXcoords;
|
|
|
|
for (const double& xCoord : m_stimPlanFractureDefinitionData->gridXs)
|
|
|
|
{
|
|
|
|
if (xCoord > 1e-5)
|
|
|
|
{
|
|
|
|
double negXcoord = -xCoord;
|
|
|
|
allXcoords.insert(allXcoords.begin(), negXcoord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const double& xCoord : m_stimPlanFractureDefinitionData->gridXs)
|
|
|
|
{
|
|
|
|
allXcoords.push_back(xCoord);
|
|
|
|
}
|
|
|
|
|
|
|
|
return allXcoords;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<double> RimStimPlanFractureTemplate::adjustedDepthCoordsAroundWellPathPosition()
|
|
|
|
{
|
|
|
|
std::vector<double> depthRelativeToWellPath;
|
|
|
|
|
|
|
|
for (const double& depth : m_stimPlanFractureDefinitionData->depths)
|
|
|
|
{
|
|
|
|
double adjustedDepth = depth - wellPathDepthAtFracture();
|
|
|
|
depthRelativeToWellPath.push_back(adjustedDepth);
|
|
|
|
}
|
|
|
|
return depthRelativeToWellPath;
|
2017-02-07 02:09:00 -06:00
|
|
|
}
|
|
|
|
|
2017-02-15 05:16:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<double> RimStimPlanFractureTemplate::getStimPlanTimeValues()
|
|
|
|
{
|
2017-02-15 08:49:53 -06:00
|
|
|
if (m_stimPlanFractureDefinitionData.isNull()) loadDataAndUpdate();
|
2017-02-15 05:16:01 -06:00
|
|
|
return m_stimPlanFractureDefinitionData->timeSteps;
|
|
|
|
}
|
|
|
|
|
2017-02-17 07:11:47 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-02-20 02:31:24 -06:00
|
|
|
std::vector<std::pair<QString, QString> > RimStimPlanFractureTemplate::getStimPlanPropertyNamesUnits() const
|
2017-02-17 07:11:47 -06:00
|
|
|
{
|
|
|
|
std::vector<RigStimPlanData > allStimPlanData = m_stimPlanFractureDefinitionData->stimPlanData;
|
|
|
|
std::vector<std::pair<QString, QString> > propertyNamesUnits;
|
|
|
|
for (RigStimPlanData stimPlanDataEntry : allStimPlanData)
|
|
|
|
{
|
|
|
|
propertyNamesUnits.push_back(std::make_pair(stimPlanDataEntry.resultName, stimPlanDataEntry.unit));
|
|
|
|
}
|
|
|
|
return propertyNamesUnits;
|
|
|
|
}
|
|
|
|
|
2017-02-20 02:31:24 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:14:16 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-02-17 08:10:04 -06:00
|
|
|
std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fracturePolygon()
|
2017-02-15 08:14:16 -06:00
|
|
|
{
|
2017-02-17 08:10:04 -06:00
|
|
|
std::vector<cvf::Vec3f> polygon;
|
2017-02-15 08:14:16 -06:00
|
|
|
|
2017-02-17 08:10:04 -06:00
|
|
|
//TODO: Handle multiple time-step and properties
|
2017-02-20 02:31:24 -06:00
|
|
|
std::vector<std::vector<double>> dataAtTimeStep = m_stimPlanFractureDefinitionData->getDataAtTimeIndex(getStimPlanPropertyNamesUnits()[0].first, getStimPlanPropertyNamesUnits()[0].second, 0);
|
2017-02-15 08:14:16 -06:00
|
|
|
|
2017-02-17 08:10:04 -06:00
|
|
|
for (int k = 0; k < dataAtTimeStep.size(); k++)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < dataAtTimeStep[k].size(); i++)
|
|
|
|
{
|
|
|
|
if ((dataAtTimeStep[k])[i] > 1e-7)
|
|
|
|
{
|
|
|
|
if ((i < dataAtTimeStep[k].size() - 1))
|
|
|
|
{
|
|
|
|
if ((dataAtTimeStep[k])[(i + 1)] < 1e-7)
|
|
|
|
{
|
|
|
|
polygon.push_back(cvf::Vec3f(static_cast<float>(m_stimPlanFractureDefinitionData->gridXs[i]),
|
|
|
|
static_cast<float>(m_stimPlanFractureDefinitionData->depths[k]), 0.0f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
polygon.push_back(cvf::Vec3f(static_cast<float>(m_stimPlanFractureDefinitionData->gridXs[i]),
|
|
|
|
static_cast<float>(m_stimPlanFractureDefinitionData->depths[k]), 0.0f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-02-15 08:14:16 -06:00
|
|
|
|
2017-02-17 08:10:04 -06:00
|
|
|
std::vector<cvf::Vec3f> negPolygon;
|
|
|
|
|
|
|
|
for (const auto& node : polygon)
|
|
|
|
{
|
|
|
|
cvf::Vec3f negNode = node;
|
|
|
|
negNode.x() = -negNode.x();
|
|
|
|
negPolygon.insert(negPolygon.begin(), negNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto& negNode : negPolygon)
|
|
|
|
{
|
|
|
|
polygon.push_back(negNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return polygon;
|
2017-02-07 02:09:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
2017-02-10 03:33:07 -06:00
|
|
|
RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering);
|
2017-02-07 02:09:00 -06:00
|
|
|
|
2017-02-10 03:33:07 -06:00
|
|
|
uiOrdering.add(&name);
|
|
|
|
|
|
|
|
caf::PdmUiGroup* fileGroup = uiOrdering.addNewGroup("File");
|
2017-02-10 08:29:15 -06:00
|
|
|
fileGroup->add(&m_stimPlanFileName);
|
2017-02-17 08:10:04 -06:00
|
|
|
fileGroup->add(&wellPathDepthAtFracture);
|
2017-02-10 03:33:07 -06:00
|
|
|
|
2017-02-22 04:52:06 -06:00
|
|
|
caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Geometry");
|
2017-02-10 03:33:07 -06:00
|
|
|
geometryGroup->add(&orientation);
|
|
|
|
geometryGroup->add(&azimuthAngle);
|
|
|
|
|
2017-02-22 04:52:06 -06:00
|
|
|
caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties");
|
2017-02-10 08:29:15 -06:00
|
|
|
propertyGroup->add(&fractureConductivity);
|
2017-02-10 03:33:07 -06:00
|
|
|
propertyGroup->add(&skinFactor);
|
2017-02-07 02:09:00 -06:00
|
|
|
}
|
2017-02-07 04:08:56 -06:00
|
|
|
|
2017-02-17 08:10:04 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStimPlanFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
|
|
|
|
{
|
2017-02-22 07:46:28 -06:00
|
|
|
if (field == &m_stimPlanFileName)
|
|
|
|
{
|
|
|
|
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
|
|
|
if (myAttr)
|
|
|
|
{
|
|
|
|
myAttr->m_fileSelectionFilter = "StimPlan Xml Files(*.xml);;All Files (*.*)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-17 08:10:04 -06:00
|
|
|
if (field == &wellPathDepthAtFracture)
|
|
|
|
{
|
2017-02-22 04:52:06 -06:00
|
|
|
if (!m_stimPlanFractureDefinitionData.isNull() && (m_stimPlanFractureDefinitionData->depths.size()>0))
|
2017-02-17 08:10:04 -06:00
|
|
|
{
|
|
|
|
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>(attribute);
|
|
|
|
if (myAttr)
|
|
|
|
{
|
|
|
|
myAttr->m_minimum = m_stimPlanFractureDefinitionData->depths[0];
|
2017-02-22 04:52:06 -06:00
|
|
|
myAttr->m_maximum = m_stimPlanFractureDefinitionData->depths[m_stimPlanFractureDefinitionData->depths.size() - 1];
|
2017-02-17 08:10:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|