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-07 04:08:56 -06:00
|
|
|
#include "RigStimPlanFractureDefinition.h"
|
2017-02-07 02:09:00 -06:00
|
|
|
|
2017-02-10 08:29:15 -06:00
|
|
|
#include "RimFracture.h"
|
|
|
|
#include "RimProject.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-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-10 08:29:15 -06:00
|
|
|
CAF_PDM_InitField(&m_stimPlanFileName, "StimPlanFileName", QString(""), "StimPlan File Name", "", "", "");
|
|
|
|
m_stimPlanFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Depth of Well Path at Fracture", "", "", "");
|
2017-02-07 04:08:56 -06:00
|
|
|
|
2017-02-17 02:29:46 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_legendConfigurations, "LegendConfigurations", "", "", "", "");
|
|
|
|
m_legendConfigurations.uiCapability()->setUiTreeHidden(true);
|
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();
|
|
|
|
|
2017-02-17 05:17:57 -06:00
|
|
|
|
|
|
|
// std::vector<std::vector<std::vector<double>>> condValues(numberOfTimeSteps);
|
|
|
|
// m_stimPlanFractureDefinitionData->conductivities = condValues;
|
|
|
|
// std::vector<std::vector<std::vector<double>>> widthValues(numberOfTimeSteps);
|
|
|
|
// m_stimPlanFractureDefinitionData->widths = widthValues;
|
|
|
|
// std::vector<std::vector<std::vector<double>>> permValues(numberOfTimeSteps);
|
|
|
|
// m_stimPlanFractureDefinitionData->permeabilities = permValues;
|
2017-02-15 03:32:34 -06:00
|
|
|
|
|
|
|
//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-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
|
|
|
|
|
|
|
std::vector<QString> resultNames = m_stimPlanFractureDefinitionData->resultNames();
|
|
|
|
|
|
|
|
// Delete legends referencing results not present on file
|
|
|
|
{
|
|
|
|
std::vector<RimStimPlanLegendConfig*> toBeDeleted;
|
|
|
|
for (RimStimPlanLegendConfig* legend : m_legendConfigurations)
|
|
|
|
{
|
|
|
|
QString legendName = legend->name();
|
|
|
|
if (std::find(resultNames.begin(), resultNames.end(), legendName) == resultNames.end())
|
|
|
|
{
|
|
|
|
toBeDeleted.push_back(legend);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto legend : toBeDeleted)
|
|
|
|
{
|
|
|
|
m_legendConfigurations.removeChildObject(legend);
|
|
|
|
|
|
|
|
delete legend;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create legend for result if not already present
|
|
|
|
for (auto resultName : resultNames)
|
|
|
|
{
|
|
|
|
bool foundResult = false;
|
|
|
|
|
|
|
|
for (RimStimPlanLegendConfig* legend : m_legendConfigurations)
|
|
|
|
{
|
|
|
|
if (legend->name().compare(resultName) == 0)
|
|
|
|
{
|
|
|
|
foundResult = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!foundResult)
|
|
|
|
{
|
|
|
|
RimStimPlanLegendConfig* legendConfig = new RimStimPlanLegendConfig();
|
|
|
|
legendConfig->setName(resultName);
|
|
|
|
|
|
|
|
m_legendConfigurations.push_back(legendConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateConnectedEditors();
|
2017-02-15 08:49:53 -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")
|
|
|
|
{
|
|
|
|
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-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-15 08:14:16 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<std::vector<double>> RimStimPlanFractureTemplate::getConductivitiesAtTimeStep(size_t timStep)
|
|
|
|
{
|
2017-02-17 05:17:57 -06:00
|
|
|
return m_stimPlanFractureDefinitionData->getDataAtTimeIndex("CONDUCTIVITY", timStep);
|
2017-02-15 08:14:16 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<std::vector<double>> RimStimPlanFractureTemplate::getPermeabilitiesAtTimeStep(size_t timStep)
|
|
|
|
{
|
2017-02-17 05:17:57 -06:00
|
|
|
return m_stimPlanFractureDefinitionData->getDataAtTimeIndex("PERMEABILITY", timStep);
|
2017-02-15 08:14:16 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<std::vector<double>> RimStimPlanFractureTemplate::getWidthsAtTimeStep(size_t timStep)
|
|
|
|
{
|
2017-02-17 05:17:57 -06:00
|
|
|
return m_stimPlanFractureDefinitionData->getDataAtTimeIndex("WIDTH", timStep);
|
2017-02-15 08:14:16 -06:00
|
|
|
}
|
|
|
|
|
2017-02-07 02:09:00 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fracturePolygon()
|
|
|
|
{
|
|
|
|
std::vector<cvf::Vec3f> polygon;
|
2017-02-09 03:52:05 -06:00
|
|
|
|
|
|
|
//TODO: Handle multiple time-step and properties
|
2017-02-10 08:29:15 -06:00
|
|
|
std::vector<std::vector<double>> ConductivitiesAtTimeStep = m_stimPlanFractureDefinitionData->conductivities[0];
|
2017-02-09 03:52:05 -06:00
|
|
|
|
|
|
|
for (int k = 0; k < ConductivitiesAtTimeStep.size(); k++)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < ConductivitiesAtTimeStep[k].size(); i++)
|
|
|
|
{
|
|
|
|
if ((ConductivitiesAtTimeStep[k])[i] > 1e-7)
|
|
|
|
{
|
|
|
|
if ((i < ConductivitiesAtTimeStep[k].size() - 1))
|
|
|
|
{
|
|
|
|
if ((ConductivitiesAtTimeStep[k])[(i + 1)] < 1e-7)
|
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
polygon.push_back(cvf::Vec3f(static_cast<float>(m_stimPlanFractureDefinitionData->gridXs[i]),
|
|
|
|
static_cast<float>(m_stimPlanFractureDefinitionData->depths[k]), 0.0f));
|
2017-02-09 03:52:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-10 08:29:15 -06:00
|
|
|
polygon.push_back(cvf::Vec3f(static_cast<float>(m_stimPlanFractureDefinitionData->gridXs[i]),
|
|
|
|
static_cast<float>(m_stimPlanFractureDefinitionData->depths[k]), 0.0f));
|
2017-02-09 03:52:05 -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);
|
|
|
|
}
|
|
|
|
|
2017-02-07 02:09:00 -06:00
|
|
|
return polygon;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
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-10 03:33:07 -06:00
|
|
|
|
|
|
|
caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Fracture geometry");
|
|
|
|
geometryGroup->add(&orientation);
|
|
|
|
geometryGroup->add(&azimuthAngle);
|
|
|
|
|
|
|
|
caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Fracture 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
|
|
|
|