mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#542) Fixed several project-open crashes related to missing files.
Added errormessage on missing wellpath file
This commit is contained in:
@@ -454,15 +454,21 @@ QString RimWellLogExtractionCurve::createCurveName()
|
|||||||
if (eclipseCase)
|
if (eclipseCase)
|
||||||
{
|
{
|
||||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel());
|
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel());
|
||||||
maxTimeStep = eclipseCase->reservoirData()->results(porosityModel)->maxTimeStepCount();
|
if(eclipseCase->reservoirData())
|
||||||
|
{
|
||||||
|
maxTimeStep = eclipseCase->reservoirData()->results(porosityModel)->maxTimeStepCount();
|
||||||
|
timeStepNames = eclipseCase->timeStepStrings();
|
||||||
|
}
|
||||||
|
|
||||||
timeStepNames = eclipseCase->timeStepStrings();
|
|
||||||
}
|
}
|
||||||
else if (geomCase)
|
else if (geomCase)
|
||||||
{
|
{
|
||||||
maxTimeStep = geomCase->geoMechData()->femPartResults()->frameCount();
|
if (geomCase->geoMechData())
|
||||||
|
{
|
||||||
|
maxTimeStep = geomCase->geoMechData()->femPartResults()->frameCount();
|
||||||
|
timeStepNames = geomCase->timeStepStrings();
|
||||||
|
}
|
||||||
|
|
||||||
timeStepNames = geomCase->timeStepStrings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_addDateToCurveName && m_timeStep < timeStepNames.size())
|
if (m_addDateToCurveName && m_timeStep < timeStepNames.size())
|
||||||
|
|||||||
@@ -77,17 +77,19 @@ void RimWellLogFileCurve::updatePlotData()
|
|||||||
if (logFileInfo)
|
if (logFileInfo)
|
||||||
{
|
{
|
||||||
RigWellLogFile* wellLogFile = logFileInfo->wellLogFile();
|
RigWellLogFile* wellLogFile = logFileInfo->wellLogFile();
|
||||||
|
if (wellLogFile)
|
||||||
std::vector<double> values = wellLogFile->values(m_wellLogChannnelName);
|
|
||||||
std::vector<double> depthValues = wellLogFile->depthValues();
|
|
||||||
|
|
||||||
if (values.size() > 0 && depthValues.size() > 0)
|
|
||||||
{
|
{
|
||||||
m_plotCurve->setSamples(values.data(), depthValues.data(), (int)depthValues.size());
|
std::vector<double> values = wellLogFile->values(m_wellLogChannnelName);
|
||||||
}
|
std::vector<double> depthValues = wellLogFile->depthValues();
|
||||||
else
|
|
||||||
{
|
if (values.size() > 0 && depthValues.size() > 0)
|
||||||
m_plotCurve->setSamples(NULL, NULL, 0);
|
{
|
||||||
|
m_plotCurve->setSamples(values.data(), depthValues.data(), (int)depthValues.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_plotCurve->setSamples(NULL, NULL, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_autoName)
|
if (m_autoName)
|
||||||
|
|||||||
@@ -158,21 +158,31 @@ caf::PdmFieldHandle* RimWellPath::objectToggleField()
|
|||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Read JSON file containing well path data
|
/// Read JSON or ascii file containing well path data
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimWellPath::readWellPathFile()
|
bool RimWellPath::readWellPathFile(QString* errorMessage)
|
||||||
{
|
{
|
||||||
QFileInfo fi(filepath());
|
QFileInfo fileInf(filepath());
|
||||||
|
|
||||||
if (fi.suffix().compare("json") == 0)
|
if (fileInf.isFile() && fileInf.exists())
|
||||||
{
|
{
|
||||||
this->readJsonWellPathFile();
|
if (fileInf.suffix().compare("json") == 0)
|
||||||
|
{
|
||||||
|
this->readJsonWellPathFile();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->readAsciiWellPathFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->readAsciiWellPathFile();
|
if (errorMessage) (*errorMessage) = "Could not find the well path file: " + filepath();
|
||||||
}
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -273,12 +283,18 @@ QString RimWellPath::getCacheDirectoryPath()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimWellPath::getCacheFileName()
|
QString RimWellPath::getCacheFileName()
|
||||||
{
|
{
|
||||||
|
if (filepath().isEmpty())
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
QString cacheFileName;
|
QString cacheFileName;
|
||||||
|
|
||||||
// Make the path correct related to the possibly new project filename
|
// Make the path correct related to the possibly new project filename
|
||||||
QString newCacheDirPath = getCacheDirectoryPath();
|
QString newCacheDirPath = getCacheDirectoryPath();
|
||||||
QFileInfo oldCacheFile(filepath);
|
QFileInfo oldCacheFile(filepath);
|
||||||
|
|
||||||
|
|
||||||
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
|
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
|
||||||
|
|
||||||
return cacheFileName;
|
return cacheFileName;
|
||||||
@@ -295,6 +311,11 @@ void RimWellPath::setupBeforeSave()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filepath().isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QDir::root().mkpath(getCacheDirectoryPath());
|
QDir::root().mkpath(getCacheDirectoryPath());
|
||||||
|
|
||||||
QString newCacheFileName = getCacheFileName();
|
QString newCacheFileName = getCacheFileName();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
RigWellPath* wellPathGeometry() { return m_wellPath.p(); }
|
RigWellPath* wellPathGeometry() { return m_wellPath.p(); }
|
||||||
RivWellPathPartMgr* partMgr();
|
RivWellPathPartMgr* partMgr();
|
||||||
|
|
||||||
void readWellPathFile();
|
bool readWellPathFile(QString * errorMessage);
|
||||||
void updateFilePathsFromProjectPath();
|
void updateFilePathsFromProjectPath();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,13 @@ void RimWellPathCollection::readWellPathFiles()
|
|||||||
{
|
{
|
||||||
if (!wellPaths[wpIdx]->filepath().isEmpty())
|
if (!wellPaths[wpIdx]->filepath().isEmpty())
|
||||||
{
|
{
|
||||||
wellPaths[wpIdx]->readWellPathFile();
|
QString errorMessage;
|
||||||
|
if (!wellPaths[wpIdx]->readWellPathFile(&errorMessage))
|
||||||
|
{
|
||||||
|
QMessageBox::warning(RiuMainWindow::instance(),
|
||||||
|
"File open error",
|
||||||
|
errorMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RimWellLogFile* wellLogFile = wellPaths[wpIdx]->m_wellLogFile;
|
RimWellLogFile* wellLogFile = wellPaths[wpIdx]->m_wellLogFile;
|
||||||
@@ -231,7 +237,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
|
|||||||
for (size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++)
|
for (size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++)
|
||||||
{
|
{
|
||||||
RimWellPath* wellPath = wellPathArray[wpIdx];
|
RimWellPath* wellPath = wellPathArray[wpIdx];
|
||||||
wellPath->readWellPathFile();
|
wellPath->readWellPathFile(NULL);
|
||||||
|
|
||||||
progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name));
|
progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name));
|
||||||
|
|
||||||
@@ -241,7 +247,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
|
|||||||
{
|
{
|
||||||
existingWellPath->filepath = wellPath->filepath;
|
existingWellPath->filepath = wellPath->filepath;
|
||||||
existingWellPath->wellPathIndexInFile = wellPath->wellPathIndexInFile;
|
existingWellPath->wellPathIndexInFile = wellPath->wellPathIndexInFile;
|
||||||
existingWellPath->readWellPathFile();
|
existingWellPath->readWellPathFile(NULL);
|
||||||
|
|
||||||
delete wellPath;
|
delete wellPath;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user