Skip to content

Commit

Permalink
#2388 fractures. Support for asymmetric stim plan
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjørn Erik Jensen committed Feb 8, 2018
1 parent 1370cfe commit 7ddfaeb
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 211 deletions.
80 changes: 45 additions & 35 deletions ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@

#include <cmath> // Needed for HUGE_VAL on Linux


//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
bool hasNegativeValues(std::vector<double> xs);

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigStimPlanFractureDefinition> RifStimPlanXmlReader::readStimPlanXMLFile(const QString& stimPlanFileName,
double conductivityScalingFactor,
MirrorMode mirrorMode,
QString * errorMessage)
{
RiaLogging::info(QString("Starting to open StimPlan XML file: '%1'").arg(stimPlanFileName));

cvf::ref<RigStimPlanFractureDefinition> stimPlanFileData = new RigStimPlanFractureDefinition;
size_t startingNegXsValues = 0;
{
QFile dataFile(stimPlanFileName);
if (!dataFile.open(QFile::ReadOnly))
Expand All @@ -50,7 +56,7 @@ cvf::ref<RigStimPlanFractureDefinition> RifStimPlanXmlReader::readStimPlanXMLFil
QXmlStreamReader xmlStream;
xmlStream.setDevice(&dataFile);
xmlStream.readNext();
startingNegXsValues = readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p());
readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), mirrorMode);

RiaEclipseUnitTools::UnitSystemType unitSystem = stimPlanFileData->unitSet();

Expand All @@ -69,9 +75,9 @@ cvf::ref<RigStimPlanFractureDefinition> RifStimPlanXmlReader::readStimPlanXMLFil
}


size_t numberOfDepthValues = stimPlanFileData->depthCount();
RiaLogging::debug(QString("Grid size X: %1, Y: %2").arg(QString::number(stimPlanFileData->gridXCount()),
QString::number(numberOfDepthValues)));
size_t numberOfYValues = stimPlanFileData->yCount();
RiaLogging::debug(QString("Grid size X: %1, Y: %2").arg(QString::number(stimPlanFileData->xCount()),
QString::number(numberOfYValues)));

size_t numberOfTimeSteps = stimPlanFileData->timeSteps().size();
RiaLogging::debug(QString("Number of time-steps: %1").arg(numberOfTimeSteps));
Expand Down Expand Up @@ -109,8 +115,9 @@ cvf::ref<RigStimPlanFractureDefinition> RifStimPlanXmlReader::readStimPlanXMLFil
{
double timeStepValue = getAttributeValueDouble(xmlStream2, "value");

std::vector<std::vector<double>> propertyValuesAtTimestep = getAllDepthDataAtTimeStep(xmlStream2, startingNegXsValues);

std::vector<std::vector<double>> propertyValuesAtTimestep =
stimPlanFileData->generateDataLayoutFromFileDataLayout(getAllDepthDataAtTimeStep(xmlStream2));

bool valuesOK = stimPlanFileData->numberOfParameterValuesOK(propertyValuesAtTimestep);
if (!valuesOK)
{
Expand Down Expand Up @@ -153,17 +160,16 @@ cvf::ref<RigStimPlanFractureDefinition> RifStimPlanXmlReader::readStimPlanXMLFil
RiaLogging::info(QString("Successfully read XML file: '%1'").arg(stimPlanFileName));
}


return stimPlanFileData;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData)
void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream,
RigStimPlanFractureDefinition* stimPlanFileData,
MirrorMode mirrorMode)
{

size_t startNegValuesXs = 0;
size_t startNegValuesYs = 0;
QString gridunit = "unknown";

Expand All @@ -180,9 +186,9 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS
{
gridunit = getAttributeValueString(xmlStream, "uom");

if (gridunit == "m") stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_METRIC);
else if (gridunit == "ft") stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_FIELD);
else stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_UNKNOWN);
if (gridunit == "m") stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_METRIC;
else if (gridunit == "ft") stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_FIELD;
else stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN;

double tvdToTopPerfFt = getAttributeValueDouble(xmlStream, "TVDToTopPerfFt");
double tvdToBottomPerfFt = getAttributeValueDouble(xmlStream, "TVDToBottomPerfFt");
Expand All @@ -193,18 +199,26 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS

if (xmlStream.name() == "xs")
{
size_t dummy;
std::vector<double> gridValues;
getGriddingValues(xmlStream, gridValues, startNegValuesXs);
stimPlanFileData->setGridXs(gridValues);
getGriddingValues(xmlStream, gridValues, dummy);
stimPlanFileData->m_fileXs = gridValues;

stimPlanFileData->generateXsFromFileXs(mirrorMode == MIRROR_AUTO ? !hasNegativeValues(gridValues) : (bool)mirrorMode);
}

else if (xmlStream.name() == "ys")
{
std::vector<double> gridValues;
getGriddingValues(xmlStream, gridValues, startNegValuesYs);
stimPlanFileData->setGridYs(gridValues);

stimPlanFileData->reorderYgridToDepths();
// Reorder and change sign
std::vector<double> ys;
for (double y : gridValues)
{
ys.insert(ys.begin(), -y);
}
stimPlanFileData->m_Ys = ys;
}

else if (xmlStream.name() == "time")
Expand All @@ -219,13 +233,12 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS
{
RiaLogging::error(QString("Negative depth values detected in XML file"));
}
return startNegValuesXs;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<double>> RifStimPlanXmlReader::getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream, size_t startingNegValuesXs)
std::vector<std::vector<double>> RifStimPlanXmlReader::getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream)
{
std::vector<std::vector<double>> propertyValuesAtTimestep;

Expand All @@ -245,14 +258,10 @@ std::vector<std::vector<double>> RifStimPlanXmlReader::getAllDepthDataAtTimeSte
QString depthDataStr = xmlStream.text().toString();
for (int i = 0; i < depthDataStr.split(' ').size(); i++)
{
if (i < static_cast<int>(startingNegValuesXs)) continue;
else
QString value = depthDataStr.split(' ')[i];
if ( value != "")
{
QString value = depthDataStr.split(' ')[i];
if ( value != "")
{
propertyValuesAtDepth.push_back(value.toDouble());
}
propertyValuesAtDepth.push_back(value.toDouble());
}
}
}
Expand All @@ -274,11 +283,8 @@ void RifStimPlanXmlReader::getGriddingValues(QXmlStreamReader &xmlStream, std::v
if (value.size() > 0)
{
double gridValue = value.toDouble();
if (gridValue > -1e-5) //tolerance of 1e-5
{
gridValues.push_back(gridValue);
}
else startNegValues++;
gridValues.push_back(gridValue);
if(gridValue < -RigStimPlanFractureDefinition::THRESHOLD_VALUE) startNegValues++;
}
}
}
Expand Down Expand Up @@ -315,6 +321,10 @@ QString RifStimPlanXmlReader::getAttributeValueString(QXmlStreamReader &xmlStrea
return parameterValue;
}




//--------------------------------------------------------------------------------------------------
/// Internal function
//--------------------------------------------------------------------------------------------------
bool hasNegativeValues(std::vector<double> xs)
{
return xs[0] < -RigStimPlanFractureDefinition::THRESHOLD_VALUE;
}
13 changes: 10 additions & 3 deletions ApplicationCode/FileInterface/RifStimPlanXmlReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,23 @@ class QXmlStreamReader;
class RifStimPlanXmlReader
{
public:
static cvf::ref<RigStimPlanFractureDefinition> readStimPlanXMLFile(const QString& stimPlanFileName, double conductivityScalingFactor, QString * errorMessage);
enum MirrorMode { MIRROR_OFF = 0, MIRROR_ON = 1, MIRROR_AUTO = 2};

static cvf::ref<RigStimPlanFractureDefinition> readStimPlanXMLFile(const QString& stimPlanFileName,
double conductivityScalingFactor,
MirrorMode mirrorMode,
QString * errorMessage);

private:
static size_t readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData);
static void readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream,
RigStimPlanFractureDefinition* stimPlanFileData,
MirrorMode mirrorMode);

static double getAttributeValueDouble(QXmlStreamReader &xmlStream, QString parameterName);
static QString getAttributeValueString(QXmlStreamReader &xmlStream, QString parameterName);
static void getGriddingValues(QXmlStreamReader &xmlStream, std::vector<double>& gridValues, size_t& startNegValues);

static std::vector<std::vector<double>> getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream, size_t startingNegValuesXs);
static std::vector<std::vector<double>> getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream);

};

Expand Down
24 changes: 3 additions & 21 deletions ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,23 +229,6 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
appendFracturePerforationLengthParts(eclView, model);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector<double> depthData)
{
std::vector<double> mirroredValuesAtGivenDepth;
mirroredValuesAtGivenDepth.push_back(depthData[0]);
for (size_t i = 1; i < (depthData.size()); i++) //starting at 1 since we don't want center value twice
{
double valueAtGivenX = depthData[i];
mirroredValuesAtGivenDepth.insert(mirroredValuesAtGivenDepth.begin(), valueAtGivenX);
mirroredValuesAtGivenDepth.push_back(valueAtGivenX);
}

return mirroredValuesAtGivenDepth;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -443,7 +426,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa
doubleCoord = displayCoordTransform->transformToDisplayCoord(doubleCoord);
nodeCoord = cvf::Vec3f(doubleCoord);
}

RimLegendConfig* legendConfig = nullptr;
if (activeView.fractureColors() && activeView.fractureColors()->isChecked())
{
Expand All @@ -459,10 +442,9 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa
{
size_t idx = 0;
const std::vector<std::vector<double> > dataToPlot = stimPlanFracTemplate->resultValues(activeView.fractureColors->uiResultName(), activeView.fractureColors->unit(), stimPlanFracTemplate->activeTimeStepIndex());
for (const std::vector<double>& unmirroredDataAtDepth : dataToPlot)
for (const std::vector<double>& dataAtY : dataToPlot)
{
const std::vector<double> mirroredValuesAtDepth = mirrorDataAtSingleDepth(unmirroredDataAtDepth);
for (double val : mirroredValuesAtDepth)
for (double val : dataAtY)
{
perNodeResultValues[idx++] = val;
}
Expand Down
2 changes: 0 additions & 2 deletions ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class RivWellFracturePartMgr : public cvf::Object

void appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView);

static std::vector<double> mirrorDataAtSingleDepth(std::vector<double> depthData);

const QString resultInfoText(const RimEclipseView& activeView, cvf::Vec3d domainIntersectionPoint) const;

const RigFractureCell* getFractureCellAtDomainCoord(cvf::Vec3d domainCoord) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate()

if (m_readError) return;

m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), m_conductivityScalingFactor(), &errorMessage);
m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(),
m_conductivityScalingFactor(),
RifStimPlanXmlReader::MIRROR_AUTO,
&errorMessage);
if (errorMessage.size() > 0) RiaLogging::error(errorMessage);

if (m_stimPlanFractureDefinitionData.notNull())
Expand Down Expand Up @@ -670,7 +673,7 @@ void RimStimPlanFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandl

if (field == &m_wellPathDepthAtFracture)
{
if ( !m_stimPlanFractureDefinitionData.isNull() && (m_stimPlanFractureDefinitionData->depthCount() > 0) )
if ( !m_stimPlanFractureDefinitionData.isNull() && (m_stimPlanFractureDefinitionData->yCount() > 0) )
{
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>(attribute);
if ( myAttr )
Expand Down
Loading

0 comments on commit 7ddfaeb

Please sign in to comment.