#2042 Well import. Match wells, well paths and sim wells. Set 'master' well path name

This commit is contained in:
Bjørn Erik Jensen
2017-10-27 15:01:55 +02:00
parent 9f9fb21cbe
commit 1abc5e0e27
6 changed files with 192 additions and 50 deletions

View File

@@ -41,6 +41,7 @@
#include "RivWellPathPartMgr.h"
#include "RiaApplication.h"
#include "RiaWellNameComparer.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafUtils.h"
@@ -632,6 +633,7 @@ RiaEclipseUnitTools::UnitSystem RimWellPath::unitSystem() const
//--------------------------------------------------------------------------------------------------
void RimWellPath::addWellLogFile(RimWellLogFile* logFileInfo)
{
// Prevent the same file from being loaded more than once
auto itr = std::find_if(m_wellLogFiles.begin(), m_wellLogFiles.end(), [&](const RimWellLogFile* file)
{
return QString::compare(file->fileName(), logFileInfo->fileName(), Qt::CaseInsensitive) == 0;
@@ -702,27 +704,16 @@ int RimWellPath::associatedSimulationWellBranch() const
//--------------------------------------------------------------------------------------------------
bool RimWellPath::tryAssociateWithSimulationWell()
{
RimProject* proj = RiaApplication::instance()->project();
const std::vector<QString>& simWellNames = proj->simulationWellNames();
if (!m_simWellName().isEmpty()) return false;
if (simWellNames.empty()) return false;
QString wellPathName = QString(m_name);
// Try to remove prefix on the format 'xx xxxx/xx-'
std::regex pattern("^.*\\d*[/]\\d*[-_]");
wellPathName = QString::fromStdString(std::regex_replace(wellPathName.toStdString(), pattern, ""));
// Try exact name match
if (tryMatchName(wellPathName, simWellNames)) return true;
// Try matching ignoring spaces, dashes and underscores
return tryMatchName(wellPathName, simWellNames, [](const QString& str) {
QString s = str;
return s.remove(' ').remove('-').remove('_');
});
QString matchedSimWell = RiaWellNameComparer::tryFindMatchingSimWellName(m_name);
if (!matchedSimWell.isEmpty())
{
m_simWellName = matchedSimWell;
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
@@ -732,31 +723,3 @@ bool RimWellPath::isAssociatedWithSimulationWell() const
{
return !m_simWellName().isEmpty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellPath::tryMatchName(QString wellPathName, const std::vector<QString>& simWellNames, std::function<QString (QString)> stringFormatter)
{
if (wellPathName.isEmpty()) return false;
if (stringFormatter != nullptr)
{
wellPathName = stringFormatter(wellPathName);
}
for (const auto& simWellName : simWellNames)
{
QString simWn = simWellName;
if (stringFormatter != nullptr)
{
simWn = stringFormatter(simWn);
}
if (QString::compare(simWn, wellPathName, Qt::CaseInsensitive) == 0)
{
m_simWellName = simWellName;
return true;
}
}
return false;
}

View File

@@ -23,6 +23,7 @@
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RiaColorTables.h"
#include "RiaWellNameComparer.h"
#include "RigWellPath.h"
#include "RigEclipseCaseData.h"
@@ -250,13 +251,16 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name()));
// If a well path with this name exists already, make it read the well path file
RimWellPath* existingWellPath = wellPathByName(wellPath->name());
RimWellPath* existingWellPath = tryFindMatchingWellPath(wellPath->name());
if (existingWellPath)
{
existingWellPath->filepath = wellPath->filepath;
existingWellPath->wellPathIndexInFile = wellPath->wellPathIndexInFile;
existingWellPath->readWellPathFile(NULL, m_wellPathImporter);
// Let name from well path file override name from well log file
existingWellPath->setName(wellPath->name());
delete wellPath;
}
else
@@ -296,7 +300,7 @@ RimWellLogFile* RimWellPathCollection::addWellLogs(const QStringList& filePaths)
logFileInfo = RimWellLogFile::readWellLogFile(filePath);
if (logFileInfo)
{
RimWellPath* wellPath = wellPathByName(logFileInfo->wellName());
RimWellPath* wellPath = tryFindMatchingWellPath(logFileInfo->wellName());
if (!wellPath)
{
wellPath = new RimWellPath();
@@ -428,7 +432,17 @@ RimWellPath* RimWellPathCollection::wellPathByName(const QString& wellPathName)
}
}
return NULL;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimWellPathCollection::tryFindMatchingWellPath(const QString& wellName) const
{
QString matchedWellPath = RiaWellNameComparer::tryFindMatchingWellPath(wellName);
return !matchedWellPath.isEmpty() ? wellPathByName(matchedWellPath) : nullptr;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -94,6 +94,7 @@ public:
void deleteAllWellPaths();
RimWellPath* wellPathByName(const QString& wellPathName) const;
RimWellPath* tryFindMatchingWellPath(const QString& wellName) const;
void addWellPaths(const std::vector<RimWellPath*> wellPaths);
RimWellLogFile* addWellLogs(const QStringList& filePaths);