#1706 Ensure new fractures are created with unique names

This commit is contained in:
Bjørnar Grip Fjær
2017-08-04 15:47:23 +02:00
parent c222612ae0
commit 861aa292b2
5 changed files with 94 additions and 10 deletions

View File

@@ -46,6 +46,7 @@ ${CEE_CURRENT_LIST_DIR}RicSimWellFracturesDeleteAllFeature.h
${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.h
${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.h
${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.h
${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.h
@@ -101,6 +102,7 @@ ${CEE_CURRENT_LIST_DIR}RicSimWellFracturesDeleteAllFeature.cpp
${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.cpp
${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.cpp
${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.cpp
${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.cpp

View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicFractureNameGenerator.h"
#include "RiaApplication.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RimFracture.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicFractureNameGenerator::nameForNewFracture()
{
std::vector<RimFracture*> oldFractures;
RiaApplication::instance()->project()->activeOilField()->descendantsIncludingThisOfType(oldFractures);
size_t fractureNum = oldFractures.size();
bool found;
QString name;
do {
found = false;
name = QString("Fracture_%1").arg(fractureNum, 2, 10, QChar('0'));
for (RimFracture* fracture : oldFractures)
{
if (fracture->name() == name)
{
found = true;
break;
}
}
fractureNum++;
} while (found);
return name;
}

View File

@@ -0,0 +1,30 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
//==================================================================================================
///
//==================================================================================================
class RicFractureNameGenerator
{
public:
static QString nameForNewFracture();
};

View File

@@ -18,6 +18,8 @@
#include "RicNewSimWellFractureFeature.h"
#include "RicFractureNameGenerator.h"
#include "RiaApplication.h"
#include "RigEclipseCaseData.h"
@@ -64,11 +66,7 @@ void RicNewSimWellFractureFeature::onActionTriggered(bool isChecked)
objHandle->firstAncestorOrThisOfType(oilfield);
if (!oilfield) return;
std::vector<RimFracture* > oldFractures;
oilfield->descendantsIncludingThisOfType(oldFractures);
QString fracNum = QString("%1").arg(oldFractures.size(), 2, 10, QChar('0'));
fracture->setName(QString("Fracture_") + fracNum);
fracture->setName(RicFractureNameGenerator::nameForNewFracture());
{
RimEclipseResultCase* eclipseCase = nullptr;

View File

@@ -18,6 +18,8 @@
#include "RicNewWellPathFractureFeature.h"
#include "RicFractureNameGenerator.h"
#include "RiaApplication.h"
#include "RigWellPath.h"
@@ -70,11 +72,7 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me
fractureCollection->firstAncestorOrThisOfType(oilfield);
if (!oilfield) return;
std::vector<RimFracture* > oldFractures;
oilfield->descendantsIncludingThisOfType(oldFractures);
QString fracNum = QString("%1").arg(oldFractures.size(), 2, 10, QChar('0'));
fracture->setName(QString("Fracture_") + fracNum);
fracture->setName(RicFractureNameGenerator::nameForNewFracture());
if (oilfield->fractureDefinitionCollection->fractureDefinitions.size() > 0)
{