#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)
{
@ -328,89 +319,7 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vector<cvf::Vec3f>* nodeCoords,
std::vector<cvf::uint>* triangleIndices,
RimUnitSystem::UnitSystem neededUnit)
{
if (m_stimPlanFractureDefinitionData.isNull())
{
loadDataAndUpdate();
}
std::vector<double> xCoords = m_stimPlanFractureDefinitionData->getNegAndPosXcoords();
cvf::uint lenXcoords = static_cast<cvf::uint>(xCoords.size());
std::vector<double> adjustedDepths = m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture());
if (neededUnit == fractureTemplateUnit())
{
RiaLogging::debug(QString("No conversion necessary for %1").arg(name));
}
else if (fractureTemplateUnit() == RimUnitSystem::UNITS_METRIC && neededUnit == RimUnitSystem::UNITS_FIELD)
{
RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(name));
for (double& value : adjustedDepths) value = RimUnitSystem::meterToFeet(value);
for (double& value : xCoords) value = RimUnitSystem::meterToFeet(value);
}
else if (fractureTemplateUnit() == RimUnitSystem::UNITS_FIELD && neededUnit == RimUnitSystem::UNITS_METRIC)
{
RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(name));
for (double& value : adjustedDepths) value = RimUnitSystem::feetToMeter(value);
for (double& value : xCoords) value = RimUnitSystem::feetToMeter(value);
}
else
{
//Should never get here...
RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(name));
return;
}
for (cvf::uint k = 0; k < adjustedDepths.size(); k++)
{
for (cvf::uint i = 0; i < lenXcoords; i++)
{
cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedDepths[k], 0);
nodeCoords->push_back(node);
if (i < lenXcoords - 1 && k < adjustedDepths.size() - 1)
{
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);
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimStimPlanFractureTemplate::getStimPlanTimeSteps()
std::vector<double> RimStimPlanFractureTemplate::timeSteps()
{
if (m_stimPlanFractureDefinitionData.isNull()) loadDataAndUpdate();
return m_stimPlanFractureDefinitionData->timeSteps;
@ -419,7 +328,7 @@ std::vector<double> RimStimPlanFractureTemplate::getStimPlanTimeSteps()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<QString, QString> > RimStimPlanFractureTemplate::getStimPlanResultNamesWithUnit() const
std::vector<std::pair<QString, QString> > RimStimPlanFractureTemplate::resultNamesWithUnit() const
{
std::vector<std::pair<QString, QString> > propertyNamesUnits;
if (m_stimPlanFractureDefinitionData.notNull())
@ -443,7 +352,23 @@ void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::setupStimPlanCells()
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;
@ -526,12 +451,87 @@ void RimStimPlanFractureTemplate::setupStimPlanCells()
m_fractureGrid->setJCellCount(m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture()).size() - 2);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigFractureGrid* RimStimPlanFractureTemplate::fractureGrid() const
void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vector<cvf::Vec3f>* nodeCoords,
std::vector<cvf::uint>* triangleIndices,
RimUnitSystem::UnitSystem neededUnit)
{
return m_fractureGrid.p();
if (m_stimPlanFractureDefinitionData.isNull())
{
loadDataAndUpdate();
}
std::vector<double> xCoords = m_stimPlanFractureDefinitionData->getNegAndPosXcoords();
cvf::uint lenXcoords = static_cast<cvf::uint>(xCoords.size());
std::vector<double> adjustedDepths = m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture());
if (neededUnit == fractureTemplateUnit())
{
RiaLogging::debug(QString("No conversion necessary for %1").arg(name));
}
else if (fractureTemplateUnit() == RimUnitSystem::UNITS_METRIC && neededUnit == RimUnitSystem::UNITS_FIELD)
{
RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(name));
for (double& value : adjustedDepths) value = RimUnitSystem::meterToFeet(value);
for (double& value : xCoords) value = RimUnitSystem::meterToFeet(value);
}
else if (fractureTemplateUnit() == RimUnitSystem::UNITS_FIELD && neededUnit == RimUnitSystem::UNITS_METRIC)
{
RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(name));
for (double& value : adjustedDepths) value = RimUnitSystem::feetToMeter(value);
for (double& value : xCoords) value = RimUnitSystem::feetToMeter(value);
}
else
{
//Should never get here...
RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(name));
return;
}
for (cvf::uint k = 0; k < adjustedDepths.size(); k++)
{
for (cvf::uint i = 0; i < lenXcoords; i++)
{
cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedDepths[k], 0);
nodeCoords->push_back(node);
if (i < lenXcoords - 1 && k < adjustedDepths.size() - 1)
{
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);
}
}
}
}
}
//--------------------------------------------------------------------------------------------------

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();
void fractureTriangleGeometry(std::vector<cvf::Vec3f>* nodeCoords,
// 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;
// Result Access
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;
void setDefaultsBasedOnXMLfile();
std::vector<std::vector<double>> getDataAtTimeIndex(const QString& resultName, const QString& unitName, size_t timeStepIndex) const;
void setupStimPlanCells();
const RigFractureGrid* fractureGrid() 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();
}