mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge branch 'dev' into fishbones
This commit is contained in:
@@ -348,7 +348,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
|
||||
// Open the project file and read the serialized data.
|
||||
// Will initialize itself.
|
||||
|
||||
if (!QFile::exists(projectFileName))
|
||||
if (!caf::Utils::fileExists(projectFileName))
|
||||
{
|
||||
RiaLogging::info(QString("File does not exist : '%1'").arg(projectFileName));
|
||||
return false;
|
||||
@@ -714,7 +714,7 @@ bool RiaApplication::saveProject()
|
||||
{
|
||||
CVF_ASSERT(m_project.notNull());
|
||||
|
||||
if (!QFile::exists(m_project->fileName()))
|
||||
if (!caf::Utils::fileExists(m_project->fileName()))
|
||||
{
|
||||
return saveProjectPromptForFileName();
|
||||
}
|
||||
@@ -940,7 +940,7 @@ QString RiaApplication::createAbsolutePathFromProjectRelativePath(QString projec
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::openEclipseCaseFromFile(const QString& fileName)
|
||||
{
|
||||
if (!QFile::exists(fileName)) return false;
|
||||
if (!caf::Utils::fileExists(fileName)) return false;
|
||||
|
||||
QFileInfo gridFileName(fileName);
|
||||
QString caseName = gridFileName.completeBaseName();
|
||||
@@ -1113,7 +1113,7 @@ bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNa
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::openOdbCaseFromFile(const QString& fileName)
|
||||
{
|
||||
if (!QFile::exists(fileName)) return false;
|
||||
if (!caf::Utils::fileExists(fileName)) return false;
|
||||
|
||||
QFileInfo gridFileName(fileName);
|
||||
QString caseName = gridFileName.completeBaseName();
|
||||
@@ -1479,14 +1479,14 @@ bool RiaApplication::parseArguments()
|
||||
foreach (QString caseName, caseNames)
|
||||
{
|
||||
QString caseFileNameWithExt = caseName + ".EGRID";
|
||||
if (QFile::exists(caseFileNameWithExt))
|
||||
if (!caf::Utils::fileExists(caseFileNameWithExt))
|
||||
{
|
||||
openEclipseCaseFromFile(caseFileNameWithExt);
|
||||
}
|
||||
else
|
||||
{
|
||||
caseFileNameWithExt = caseName + ".GRID";
|
||||
if (QFile::exists(caseFileNameWithExt))
|
||||
if (!caf::Utils::fileExists(caseFileNameWithExt))
|
||||
{
|
||||
openEclipseCaseFromFile(caseFileNameWithExt);
|
||||
}
|
||||
@@ -2135,7 +2135,7 @@ void RiaApplication::setLastUsedDialogDirectory(const QString& dialogName, const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::openFile(const QString& fileName)
|
||||
{
|
||||
if (!QFile::exists(fileName)) return false;
|
||||
if (!caf::Utils::fileExists(fileName)) return false;
|
||||
|
||||
bool loadingSucceded = false;
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
#include <QInputDialog>
|
||||
@@ -76,7 +78,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled.m";
|
||||
int num= 1;
|
||||
while (QFileInfo(fullPathFilenameNewScript).exists())
|
||||
while (caf::Utils::fileExists(fullPathFilenameNewScript))
|
||||
{
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".m";
|
||||
num++;
|
||||
|
||||
@@ -216,6 +216,15 @@ bool RicNewGridTimeHistoryCurveFeature::isCommandEnabled()
|
||||
|
||||
if (items.size() > 0)
|
||||
{
|
||||
const RiuEclipseSelectionItem* eclSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>(items[0]);
|
||||
if (eclSelectionItem)
|
||||
{
|
||||
if (eclSelectionItem->m_view->cellResult()->resultType() == RimDefines::FLOW_DIAGNOSTICS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuWellImportWizard.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@@ -47,7 +49,7 @@ bool RicWellPathsImportSsihubFeature::isCommandEnabled()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!QFile::exists(app->project()->fileName()))
|
||||
if (!caf::Utils::fileExists(app->project()->fileName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -66,7 +68,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QFile::exists(app->project()->fileName()))
|
||||
if (!caf::Utils::fileExists(app->project()->fileName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -969,8 +969,17 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa
|
||||
resultPoint.m_ertSegmentId = ertSegmentId;
|
||||
resultPoint.m_flowRate = volumeRate;
|
||||
resultPoint.m_oilRate = oilRate;
|
||||
resultPoint.m_gasRate = gasRate;
|
||||
resultPoint.m_waterRate = waterRate;
|
||||
|
||||
// If field unit, the Gas is in Mega ft^3 while the others are in [stb] (barrel)
|
||||
// we convert gas to stb as well. Based on
|
||||
// 1 [stb] = 0.15898729492800007 [m^3]
|
||||
// 1 [ft] = 0.3048 [m]
|
||||
// megaFt3ToStbFactor = 1.0 / (1.0e-6 * 0.15898729492800007 * ( 1.0 / 0.3048 )^3 )
|
||||
double megaFt3ToStbFactor = 178107.60668;
|
||||
if (m_eclipseCase->unitsType() == RigEclipseCaseData::UNITS_FIELD) gasRate = megaFt3ToStbFactor * gasRate;
|
||||
|
||||
resultPoint.m_gasRate = gasRate;
|
||||
}
|
||||
|
||||
return resultPoint;
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
|
||||
std::string ertGridName( size_t gridNr );
|
||||
|
||||
static RigWellResultPoint createWellResultPoint(const RigGridBase* grid, const well_conn_type* ert_connection, int ertBranchId, int ertSegmentId, const char* wellName);
|
||||
RigWellResultPoint createWellResultPoint(const RigGridBase* grid, const well_conn_type* ert_connection, int ertBranchId, int ertSegmentId, const char* wellName);
|
||||
|
||||
void importFaults(const QStringList& fileSet, cvf::Collection<RigFault>* faults);
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include "RiuFlowCharacteristicsPlot.h"
|
||||
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
|
||||
@@ -57,6 +59,8 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot()
|
||||
CAF_PDM_InitFieldNoDefault(&m_timeStepSelectionType, "TimeSelectionType", "Time Steps", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectedTimeSteps, "SelectedTimeSteps", "", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Legend", "", "", "");
|
||||
|
||||
this->m_showWindow = false;
|
||||
setAsPlotMdiWindow();
|
||||
}
|
||||
@@ -167,11 +171,11 @@ QList<caf::PdmOptionItemInfo> RimFlowCharacteristicsPlot::calculateValueOptions(
|
||||
RigFlowDiagResults* flowResult = m_flowDiagSolution->flowDiagResults();
|
||||
std::vector<int> calculatedTimesteps = flowResult->calculatedTimeSteps();
|
||||
|
||||
std::vector<QDateTime> timeStepDates = m_case->timeStepDates();
|
||||
QStringList timeStepDates = m_case->timeStepStrings();
|
||||
|
||||
for ( int tsIdx : calculatedTimesteps )
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(timeStepDates[tsIdx].toString(), tsIdx));
|
||||
options.push_back(caf::PdmOptionItemInfo(timeStepDates[tsIdx], tsIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,6 +195,8 @@ void RimFlowCharacteristicsPlot::defineUiOrdering(QString uiConfigName, caf::Pdm
|
||||
|
||||
if (m_timeStepSelectionType == SELECT_AVAILABLE) uiOrdering.add(&m_selectedTimeSteps);
|
||||
|
||||
uiOrdering.add(&m_showLegend);
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
@@ -210,7 +216,6 @@ void RimFlowCharacteristicsPlot::zoomAll()
|
||||
if (m_flowCharPlotWidget) m_flowCharPlotWidget->zoomAll();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -229,7 +234,6 @@ void RimFlowCharacteristicsPlot::fieldChangedByUi(const caf::PdmFieldHandle* cha
|
||||
this->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -246,8 +250,6 @@ QImage RimFlowCharacteristicsPlot::snapshotWindowContent()
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -277,6 +279,7 @@ void RimFlowCharacteristicsPlot::loadDataAndUpdate()
|
||||
m_currentlyPlottedTimeSteps = calculatedTimesteps;
|
||||
|
||||
std::vector<QDateTime> timeStepDates = m_case->timeStepDates();
|
||||
QStringList timeStepStrings = m_case->timeStepStrings();
|
||||
std::vector<double> lorenzVals(timeStepDates.size(), HUGE_VAL);
|
||||
|
||||
m_flowCharPlotWidget->removeAllCurves();
|
||||
@@ -285,7 +288,7 @@ void RimFlowCharacteristicsPlot::loadDataAndUpdate()
|
||||
{
|
||||
lorenzVals[timeStepIdx] = flowResult->flowCharacteristicsResults(timeStepIdx).m_lorenzCoefficient;
|
||||
}
|
||||
m_flowCharPlotWidget->setLorenzCurve(timeStepDates, lorenzVals);
|
||||
m_flowCharPlotWidget->setLorenzCurve(timeStepStrings, timeStepDates, lorenzVals);
|
||||
|
||||
for ( int timeStepIdx: calculatedTimesteps )
|
||||
{
|
||||
@@ -299,6 +302,7 @@ void RimFlowCharacteristicsPlot::loadDataAndUpdate()
|
||||
flowCharResults.m_sweepEfficiencyCurve.second);
|
||||
}
|
||||
|
||||
m_flowCharPlotWidget->showLegend(m_showLegend());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ private:
|
||||
caf::PdmPtrField<RimFlowDiagSolution*> m_flowDiagSolution;
|
||||
caf::PdmField<caf::AppEnum<TimeSelectionType> > m_timeStepSelectionType;
|
||||
caf::PdmField<std::vector<int> > m_selectedTimeSteps;
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
|
||||
std::vector<int> m_currentlyPlottedTimeSteps;
|
||||
|
||||
|
||||
@@ -374,7 +374,14 @@ void RimWellAllocationPlot::updateWellFlowPlotXAxisTitle(RimWellLogTrack* plotTr
|
||||
|
||||
}
|
||||
|
||||
plotTrack->setXAxisTitle("Flow Rate " + unitText);
|
||||
if (m_flowDiagSolution)
|
||||
{
|
||||
plotTrack->setXAxisTitle("Reservoir Flow Rate " + unitText);
|
||||
}
|
||||
else
|
||||
{
|
||||
plotTrack->setXAxisTitle("Surface Flow Rate " + unitText);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "cafPdmSettings.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafProgressInfo.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@@ -100,7 +101,7 @@ bool RimEclipseResultCase::openEclipseGridFile()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!QFile::exists(caseFileName()))
|
||||
if (!caf::Utils::fileExists(caseFileName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -174,7 +175,7 @@ bool RimEclipseResultCase::openAndReadActiveCellData(RigEclipseCaseData* mainEcl
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!QFile::exists(caseFileName()))
|
||||
if (!caf::Utils::fileExists(caseFileName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#include "RimGeoMechResultDefinition.h"
|
||||
#include "RimGeoMechPropertyFilter.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGeoMechCase, "ResInsightGeoMechCase");
|
||||
@@ -110,7 +112,7 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage)
|
||||
// If read already, return
|
||||
if (this->m_geoMechCaseData.notNull()) return true;
|
||||
|
||||
if (!QFile::exists(m_caseFileName()))
|
||||
if (!caf::Utils::fileExists(m_caseFileName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include "cvfGeometryTools.h"
|
||||
|
||||
@@ -1394,16 +1395,15 @@ void RimReservoirCellResultsStorage::setCellResults(RigCaseCellResultsData* cell
|
||||
// Get the name of the cache name relative to the current project file position
|
||||
QString newValidCacheFileName = getValidCacheFileName();
|
||||
|
||||
QFile storageFile(newValidCacheFileName);
|
||||
|
||||
// Warn if we thought we were to find some data on the storage file
|
||||
|
||||
if (!storageFile.exists() && m_resultCacheMetaData.size())
|
||||
if (!caf::Utils::fileExists(newValidCacheFileName) && m_resultCacheMetaData.size())
|
||||
{
|
||||
qWarning() << "Reading stored results: Missing the storage file : " + newValidCacheFileName;
|
||||
return;
|
||||
}
|
||||
|
||||
QFile storageFile(newValidCacheFileName);
|
||||
if (!storageFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
qWarning() << "Reading stored results: Can't open the file : " + newValidCacheFileName;
|
||||
|
||||
@@ -87,11 +87,12 @@ void RimScriptCollection::readContentFromDisc()
|
||||
{
|
||||
QString fileName = fileList.at(i);
|
||||
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.exists())
|
||||
if (caf::Utils::fileExists(fileName))
|
||||
{
|
||||
RimCalcScript* calcScript = new RimCalcScript;
|
||||
calcScript->absolutePath = fileName;
|
||||
|
||||
QFileInfo fi(fileName);
|
||||
calcScript->setUiName(fi.baseName());
|
||||
|
||||
calcScripts.push_back(calcScript);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "cafPdmUiItem.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
@@ -81,7 +82,7 @@ QString RimTools::relocateFile(const QString& orgFileName, const QString& orgNew
|
||||
bool isWindowsPath = false;
|
||||
if (orgFileName.count("/")) isWindowsPath = false; // "/" are not allowed in a windows path
|
||||
else if (orgFileName.count("\\")
|
||||
&& !QFile::exists(orgFileName)) // To make sure we do not convert single linux files containing "\"
|
||||
&& !caf::Utils::fileExists(orgFileName)) // To make sure we do not convert single linux files containing "\"
|
||||
{
|
||||
isWindowsPath = true;
|
||||
}
|
||||
@@ -93,7 +94,7 @@ QString RimTools::relocateFile(const QString& orgFileName, const QString& orgNew
|
||||
}
|
||||
|
||||
if (searchedPaths) searchedPaths->push_back(fileName);
|
||||
if (QFile::exists(fileName))
|
||||
if (caf::Utils::fileExists(fileName))
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
@@ -104,7 +105,7 @@ QString RimTools::relocateFile(const QString& orgFileName, const QString& orgNew
|
||||
QString candidate = QDir::fromNativeSeparators(newProjectPath + QDir::separator() + fileNameWithoutPath);
|
||||
if (searchedPaths) searchedPaths->push_back(candidate);
|
||||
|
||||
if (QFile::exists(candidate))
|
||||
if (caf::Utils::fileExists(candidate))
|
||||
{
|
||||
return candidate;
|
||||
}
|
||||
@@ -199,7 +200,7 @@ QString RimTools::relocateFile(const QString& orgFileName, const QString& orgNew
|
||||
|
||||
if (searchedPaths) searchedPaths->push_back(relocatedFileName);
|
||||
|
||||
if (QFile::exists(relocatedFileName))
|
||||
if (caf::Utils::fileExists(relocatedFileName))
|
||||
{
|
||||
return relocatedFileName;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
#include "RivWellPathPartMgr.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
#include <QDateTime>
|
||||
@@ -382,7 +384,7 @@ void RimWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath,
|
||||
{
|
||||
QString newCacheFileName = getCacheFileName();
|
||||
|
||||
if (QFile::exists(newCacheFileName))
|
||||
if (caf::Utils::fileExists(newCacheFileName))
|
||||
{
|
||||
filepath = newCacheFileName;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ size_t RigEclCellIndexCalculator::resultCellIndex(size_t gridIndex, size_t gridC
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
//#define USE_WELL_PHASE_RATES
|
||||
#define USE_WELL_PHASE_RATES
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -105,6 +105,9 @@ RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vecto
|
||||
|
||||
calculateAccumulatedFlowPrConnection(0, 1);
|
||||
calculateFlowPrPseudoLength(0, 0.0);
|
||||
#ifdef USE_WELL_PHASE_RATES
|
||||
sortTracers();
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -18,56 +18,83 @@
|
||||
|
||||
namespace RigFlowDiagInterfaceTools {
|
||||
|
||||
template <class FluxCalc>
|
||||
inline Opm::FlowDiagnostics::ConnectionValues
|
||||
extractFluxField(const Opm::ECLGraph& G, const bool compute_fluxes)
|
||||
extractFluxField(const Opm::ECLGraph& G,
|
||||
FluxCalc&& getFlux)
|
||||
{
|
||||
using ConnVals = Opm::FlowDiagnostics::ConnectionValues;
|
||||
|
||||
const auto actPh = G.activePhases();
|
||||
|
||||
auto flux = ConnVals(ConnVals::NumConnections{ G.numConnections() },
|
||||
ConnVals::NumPhases{ 3 });
|
||||
|
||||
ConnVals::NumPhases{ actPh.size() });
|
||||
|
||||
auto phas = ConnVals::PhaseID{ 0 };
|
||||
|
||||
Opm::ECLFluxCalc calc(G);
|
||||
|
||||
const auto phases = { Opm::ECLGraph::PhaseIndex::Aqua ,
|
||||
Opm::ECLGraph::PhaseIndex::Liquid ,
|
||||
Opm::ECLGraph::PhaseIndex::Vapour };
|
||||
|
||||
for ( const auto& p : phases )
|
||||
{
|
||||
const auto pflux = compute_fluxes ? calc.flux(p) : G.flux(p);
|
||||
if ( ! pflux.empty() )
|
||||
{
|
||||
assert (pflux.size() == flux.numConnections());
|
||||
|
||||
for (const auto& p : actPh) {
|
||||
const auto pflux = getFlux(p);
|
||||
|
||||
if (!pflux.empty()) {
|
||||
assert(pflux.size() == flux.numConnections());
|
||||
|
||||
auto conn = ConnVals::ConnID{ 0 };
|
||||
for ( const auto& v : pflux )
|
||||
{
|
||||
for (const auto& v : pflux) {
|
||||
flux(conn, phas) = v;
|
||||
conn.id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
phas.id += 1;
|
||||
}
|
||||
|
||||
|
||||
return flux;
|
||||
}
|
||||
|
||||
inline Opm::FlowDiagnostics::ConnectionValues
|
||||
extractFluxField(const Opm::ECLGraph& G,
|
||||
const Opm::ECLRestartData& rstrt,
|
||||
const bool compute_fluxes)
|
||||
{
|
||||
if (compute_fluxes) {
|
||||
Opm::ECLFluxCalc calc(G);
|
||||
|
||||
auto getFlux = [&calc, &rstrt]
|
||||
(const Opm::ECLGraph::PhaseIndex p)
|
||||
{
|
||||
return calc.flux(rstrt, p);
|
||||
};
|
||||
|
||||
return extractFluxField(G, getFlux);
|
||||
}
|
||||
|
||||
auto getFlux = [&G, &rstrt]
|
||||
(const Opm::ECLGraph::PhaseIndex p)
|
||||
{
|
||||
return G.flux(rstrt, p);
|
||||
};
|
||||
|
||||
return extractFluxField(G, getFlux);
|
||||
}
|
||||
|
||||
template <class WellFluxes>
|
||||
Opm::FlowDiagnostics::CellSetValues
|
||||
extractWellFlows(const Opm::ECLGraph& G,
|
||||
const WellFluxes& well_fluxes)
|
||||
extractWellFlows(const Opm::ECLGraph& G,
|
||||
const WellFluxes& well_fluxes)
|
||||
{
|
||||
Opm::FlowDiagnostics::CellSetValues inflow;
|
||||
for (const auto& well : well_fluxes) {
|
||||
for (const auto& completion : well.completions) {
|
||||
const int grid_index = completion.grid_index;
|
||||
const auto& gridName = completion.gridName;
|
||||
const auto& ijk = completion.ijk;
|
||||
const int cell_index = G.activeCell(ijk, grid_index);
|
||||
const int cell_index = G.activeCell(ijk, gridName);
|
||||
if (cell_index >= 0) {
|
||||
auto iterIsInsertedPair = inflow.emplace(cell_index, completion.reservoir_inflow_rate);
|
||||
if (!iterIsInsertedPair.second){ // Not inserted, We had something there already
|
||||
iterIsInsertedPair.first->second += completion.reservoir_inflow_rate; // Accumulate the flow at this connection
|
||||
}
|
||||
// Since inflow is a std::map, if the key was not
|
||||
// already present operator[] will insert a
|
||||
// value-initialized value (as in T() for a type
|
||||
// T), which is zero for built-in numerical types,
|
||||
// including double.
|
||||
inflow[cell_index] += completion.reservoir_inflow_rate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,7 +102,6 @@ namespace RigFlowDiagInterfaceTools {
|
||||
return inflow;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -104,19 +104,25 @@ void RigFlowDiagTimeStepResult::addResult(const RigFlowDiagResultAddress& resAdd
|
||||
}
|
||||
|
||||
|
||||
class RigOpmFldStaticData : public cvf::Object
|
||||
class RigOpmFlowDiagStaticData : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RigOpmFldStaticData(const std::string& grid, const std::string& init) : m_eclGraph(Opm::ECLGraph::load(grid, init)), m_hasUnifiedRestartFile(false)
|
||||
RigOpmFlowDiagStaticData(const std::string& grid, const std::string& init)
|
||||
{
|
||||
m_poreVolume = m_eclGraph.poreVolume();
|
||||
Opm::ECLInitFileData initData(init);
|
||||
|
||||
m_eclGraph.reset(new Opm::ECLGraph(Opm::ECLGraph::load(grid, initData)));
|
||||
|
||||
m_hasUnifiedRestartFile = false;
|
||||
m_poreVolume = m_eclGraph->poreVolume();
|
||||
}
|
||||
|
||||
Opm::ECLGraph m_eclGraph;
|
||||
std::unique_ptr<Opm::ECLGraph> m_eclGraph;
|
||||
std::vector<double> m_poreVolume;
|
||||
std::unique_ptr<Opm::FlowDiagnostics::Toolbox> m_fldToolbox;
|
||||
bool m_hasUnifiedRestartFile;
|
||||
QStringList m_restartFileNames;
|
||||
std::vector<Opm::ECLRestartData> m_singleRestartDataTimeSteps;
|
||||
std::unique_ptr<Opm::ECLRestartData> m_unifiedRestartData;
|
||||
};
|
||||
|
||||
|
||||
@@ -150,9 +156,8 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
RigFlowDiagTimeStepResult result(m_eclipseCase->eclipseCaseData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->reservoirActiveCellCount());
|
||||
|
||||
caf::ProgressInfo progressInfo(8, "Calculating Flow Diagnostics");
|
||||
|
||||
|
||||
if ( m_opmFldData.isNull() )
|
||||
if ( m_opmFlowDiagStaticData.isNull() )
|
||||
{
|
||||
progressInfo.setProgressDescription("Grid access");
|
||||
|
||||
@@ -165,66 +170,77 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
|
||||
QString initFileName = RifEclipseOutputFileTools::firstFileNameOfType(m_filesWithSameBaseName, ECL_INIT_FILE);
|
||||
|
||||
m_opmFldData = new RigOpmFldStaticData(gridFileName.toStdString(),
|
||||
m_opmFlowDiagStaticData = new RigOpmFlowDiagStaticData(gridFileName.toStdString(),
|
||||
initFileName.toStdString());
|
||||
|
||||
progressInfo.incrementProgress();
|
||||
progressInfo.setProgressDescription("Calculating Connectivities");
|
||||
|
||||
const Opm::FlowDiagnostics::ConnectivityGraph connGraph =
|
||||
Opm::FlowDiagnostics::ConnectivityGraph{ static_cast<int>(m_opmFldData->m_eclGraph.numCells()),
|
||||
m_opmFldData->m_eclGraph.neighbours() };
|
||||
Opm::FlowDiagnostics::ConnectivityGraph{ static_cast<int>(m_opmFlowDiagStaticData->m_eclGraph->numCells()),
|
||||
m_opmFlowDiagStaticData->m_eclGraph->neighbours() };
|
||||
|
||||
progressInfo.incrementProgress();
|
||||
progressInfo.setProgressDescription("Initialize Solver");
|
||||
|
||||
// Create the Toolbox.
|
||||
|
||||
m_opmFldData->m_fldToolbox.reset(new Opm::FlowDiagnostics::Toolbox{ connGraph });
|
||||
m_opmFldData->m_fldToolbox->assignPoreVolume( m_opmFldData->m_poreVolume);
|
||||
m_opmFlowDiagStaticData->m_fldToolbox.reset(new Opm::FlowDiagnostics::Toolbox{ connGraph });
|
||||
m_opmFlowDiagStaticData->m_fldToolbox->assignPoreVolume( m_opmFlowDiagStaticData->m_poreVolume);
|
||||
|
||||
// Look for unified restart file
|
||||
|
||||
QString restartFileName = RifEclipseOutputFileTools::firstFileNameOfType(m_filesWithSameBaseName, ECL_UNIFIED_RESTART_FILE);
|
||||
if ( !restartFileName.isEmpty() )
|
||||
{
|
||||
m_opmFldData->m_eclGraph.assignFluxDataSource(restartFileName.toStdString());
|
||||
m_opmFldData->m_hasUnifiedRestartFile = true;
|
||||
m_opmFlowDiagStaticData->m_unifiedRestartData.reset(new Opm::ECLRestartData(Opm::ECLRestartData(restartFileName.toStdString())));
|
||||
m_opmFlowDiagStaticData->m_hasUnifiedRestartFile = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList restartFileNames = RifEclipseOutputFileTools::filterFileNamesOfType(m_filesWithSameBaseName, ECL_RESTART_FILE);
|
||||
|
||||
m_opmFldData->m_restartFileNames = RifEclipseOutputFileTools::filterFileNamesOfType(m_filesWithSameBaseName, ECL_RESTART_FILE);
|
||||
|
||||
size_t restartFileCount = static_cast<size_t>(m_opmFldData->m_restartFileNames.size());
|
||||
size_t restartFileCount = static_cast<size_t>(restartFileNames.size());
|
||||
size_t maxTimeStepCount = m_eclipseCase->eclipseCaseData()->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount();
|
||||
|
||||
if (restartFileCount <= timeStepIndex && restartFileCount != maxTimeStepCount )
|
||||
if (restartFileCount <= timeStepIndex && restartFileCount != maxTimeStepCount )
|
||||
{
|
||||
QMessageBox::critical(nullptr, "ResInsight", "Flow Diagnostics: Could not find all the restart files. Results will not be loaded.");
|
||||
return result;
|
||||
}
|
||||
|
||||
m_opmFldData->m_restartFileNames.sort(); // To make sure they are sorted in increasing *.X000N order. Hack. Should probably be actual time stored on file.
|
||||
m_opmFldData->m_hasUnifiedRestartFile = false;
|
||||
restartFileNames.sort(); // To make sure they are sorted in increasing *.X000N order. Hack. Should probably be actual time stored on file.
|
||||
m_opmFlowDiagStaticData->m_hasUnifiedRestartFile = false;
|
||||
|
||||
for (auto restartFileName : restartFileNames)
|
||||
{
|
||||
m_opmFlowDiagStaticData->m_singleRestartDataTimeSteps.push_back(Opm::ECLRestartData(restartFileName.toStdString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
progressInfo.setProgress(3);
|
||||
progressInfo.setProgressDescription("Assigning Flux Field");
|
||||
|
||||
if ( ! m_opmFldData->m_hasUnifiedRestartFile )
|
||||
Opm::ECLRestartData* currentRestartData = nullptr;
|
||||
|
||||
if ( ! m_opmFlowDiagStaticData->m_hasUnifiedRestartFile )
|
||||
{
|
||||
QString restartFileName = m_opmFldData->m_restartFileNames[static_cast<int>(timeStepIndex)];
|
||||
m_opmFldData->m_eclGraph.assignFluxDataSource(restartFileName.toStdString());
|
||||
currentRestartData = &(m_opmFlowDiagStaticData->m_singleRestartDataTimeSteps[timeStepIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentRestartData = m_opmFlowDiagStaticData->m_unifiedRestartData.get();
|
||||
}
|
||||
|
||||
CVF_ASSERT(currentRestartData);
|
||||
|
||||
size_t resultIndexWithMaxTimeSteps = cvf::UNDEFINED_SIZE_T;
|
||||
m_eclipseCase->eclipseCaseData()->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(&resultIndexWithMaxTimeSteps);
|
||||
|
||||
int reportStepNumber = m_eclipseCase->eclipseCaseData()->results(RifReaderInterface::MATRIX_RESULTS)->reportStepNumber(resultIndexWithMaxTimeSteps, timeStepIndex);
|
||||
|
||||
if ( ! m_opmFldData->m_eclGraph.selectReportStep(reportStepNumber) )
|
||||
if ( !currentRestartData->selectReportStep(reportStepNumber) )
|
||||
{
|
||||
QMessageBox::critical(nullptr, "ResInsight", "Flow Diagnostics: Could not find the requested timestep in the result file. Results will not be loaded.");
|
||||
return result;
|
||||
@@ -235,22 +251,25 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
Opm::FlowDiagnostics::CellSetValues sumWellFluxPrCell;
|
||||
|
||||
{
|
||||
Opm::FlowDiagnostics::ConnectionValues connectionsVals = RigFlowDiagInterfaceTools::extractFluxField(m_opmFldData->m_eclGraph, false);
|
||||
Opm::FlowDiagnostics::ConnectionValues connectionsVals = RigFlowDiagInterfaceTools::extractFluxField(*(m_opmFlowDiagStaticData->m_eclGraph),
|
||||
*currentRestartData,
|
||||
false);
|
||||
|
||||
m_opmFldData->m_fldToolbox->assignConnectionFlux(connectionsVals);
|
||||
m_opmFlowDiagStaticData->m_fldToolbox->assignConnectionFlux(connectionsVals);
|
||||
|
||||
progressInfo.incrementProgress();
|
||||
|
||||
Opm::ECLWellSolution wsol = Opm::ECLWellSolution{-1.0 , false};
|
||||
|
||||
const std::vector<Opm::ECLWellSolution::WellData> well_fluxes =
|
||||
wsol.solution(m_opmFldData->m_eclGraph.rawResultData(), m_opmFldData->m_eclGraph.numGrids());
|
||||
std::vector<std::string> gridNames = m_opmFlowDiagStaticData->m_eclGraph->activeGrids();
|
||||
|
||||
sumWellFluxPrCell = RigFlowDiagInterfaceTools::extractWellFlows(m_opmFldData->m_eclGraph, well_fluxes);
|
||||
const std::vector<Opm::ECLWellSolution::WellData> well_fluxes = wsol.solution(*currentRestartData, gridNames);
|
||||
|
||||
m_opmFldData->m_fldToolbox->assignInflowFlux(sumWellFluxPrCell);
|
||||
sumWellFluxPrCell = RigFlowDiagInterfaceTools::extractWellFlows(*(m_opmFlowDiagStaticData->m_eclGraph), well_fluxes);
|
||||
|
||||
// Filter connection cells with inconsistent well in flow direction (Hack, we should do something better)
|
||||
m_opmFlowDiagStaticData->m_fldToolbox->assignInflowFlux(sumWellFluxPrCell);
|
||||
|
||||
// Start Hack: Filter connection cells with inconsistent well in flow direction (Hack, we should do something better)
|
||||
|
||||
for ( auto& tracerCellIdxsPair: injectorTracers )
|
||||
{
|
||||
@@ -259,6 +278,8 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
for (int activeCellIdx : tracerCellIdxsPair.second)
|
||||
{
|
||||
auto activeCellIdxFluxPair = sumWellFluxPrCell.find(activeCellIdx);
|
||||
CVF_TIGHT_ASSERT(activeCellIdxFluxPair != sumWellFluxPrCell.end());
|
||||
|
||||
if (activeCellIdxFluxPair->second > 0 )
|
||||
{
|
||||
filteredCellIndices.push_back(activeCellIdx);
|
||||
@@ -275,6 +296,8 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
for (int activeCellIdx : tracerCellIdxsPair.second)
|
||||
{
|
||||
auto activeCellIdxFluxPair = sumWellFluxPrCell.find(activeCellIdx);
|
||||
CVF_TIGHT_ASSERT(activeCellIdxFluxPair != sumWellFluxPrCell.end());
|
||||
|
||||
if (activeCellIdxFluxPair->second < 0 )
|
||||
{
|
||||
filteredCellIndices.push_back(activeCellIdx);
|
||||
@@ -282,6 +305,8 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
}
|
||||
if (tracerCellIdxsPair.second.size() != filteredCellIndices.size()) tracerCellIdxsPair.second = filteredCellIndices;
|
||||
}
|
||||
|
||||
// End Hack
|
||||
}
|
||||
|
||||
progressInfo.incrementProgress();
|
||||
@@ -299,7 +324,7 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
std::unique_ptr<Toolbox::Forward> injectorSolution;
|
||||
try
|
||||
{
|
||||
injectorSolution.reset(new Toolbox::Forward( m_opmFldData->m_fldToolbox->computeInjectionDiagnostics(injectorCellSets)));
|
||||
injectorSolution.reset(new Toolbox::Forward( m_opmFlowDiagStaticData->m_fldToolbox->computeInjectionDiagnostics(injectorCellSets)));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@@ -329,7 +354,7 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
std::unique_ptr<Toolbox::Reverse> producerSolution;
|
||||
try
|
||||
{
|
||||
producerSolution.reset(new Toolbox::Reverse(m_opmFldData->m_fldToolbox->computeProductionDiagnostics(prodjCellSets)));
|
||||
producerSolution.reset(new Toolbox::Reverse(m_opmFlowDiagStaticData->m_fldToolbox->computeProductionDiagnostics(prodjCellSets)));
|
||||
}
|
||||
catch ( const std::exception& e )
|
||||
{
|
||||
@@ -375,7 +400,7 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
|
||||
{
|
||||
Graph flowCapStorCapCurve = flowCapacityStorageCapacityCurve(*(injectorSolution.get()),
|
||||
*(producerSolution.get()),
|
||||
m_opmFldData->m_poreVolume);
|
||||
m_opmFlowDiagStaticData->m_poreVolume);
|
||||
|
||||
result.setFlowCapStorageCapCurve(flowCapStorCapCurve);
|
||||
result.setSweepEfficiencyCurve(sweepEfficiency(flowCapStorCapCurve));
|
||||
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
|
||||
|
||||
class RigEclipseCaseData;
|
||||
class RigOpmFldStaticData;
|
||||
class RigOpmFlowDiagStaticData;
|
||||
|
||||
class RigFlowDiagSolverInterface : public cvf::Object
|
||||
{
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
private:
|
||||
RimEclipseResultCase * m_eclipseCase;
|
||||
|
||||
cvf::ref<RigOpmFldStaticData> m_opmFldData;
|
||||
cvf::ref<RigOpmFlowDiagStaticData> m_opmFlowDiagStaticData;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "RimWellLogExtractionCurve.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include "laswell.hpp"
|
||||
@@ -390,7 +391,7 @@ bool RigLasFileExporter::writeToFolder(const QString& exportFolder)
|
||||
|
||||
QDir dir(exportFolder);
|
||||
QString fileName = dir.absoluteFilePath(QString::fromStdString(lasFileDescr.generateFilename()));
|
||||
if (QFile::exists(fileName))
|
||||
if (caf::Utils::fileExists(fileName))
|
||||
{
|
||||
QString txt = QString("File %1 exists.\n\nDo you want to overwrite the file?").arg(fileName);
|
||||
int ret = QMessageBox::question(NULL, "LAS File Export",
|
||||
|
||||
@@ -128,10 +128,10 @@ struct RigWellResultPoint
|
||||
int m_ertSegmentId;
|
||||
|
||||
cvf::Vec3d m_bottomPosition; //< The estimated bottom position of the well segment, when we have no grid cell connections for the segment.
|
||||
double m_flowRate;
|
||||
double m_oilRate;
|
||||
double m_gasRate;
|
||||
double m_waterRate;
|
||||
double m_flowRate; //< Total reservoir rate
|
||||
double m_oilRate; //< Surface oil rate
|
||||
double m_gasRate; //< Surface gas rate For Field-unit, converted to [stb/day] to allign with oil and water.
|
||||
double m_waterRate; //< Surface water rate
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const std::string casePath = "\\\\csfiles\\Store\\ProjectData\\StatoilReservoir\\ReferenceCases\\simple_FlowDiag_Model\\";
|
||||
|
||||
/*
|
||||
#include "exampleSetup.hpp"
|
||||
|
||||
TEST(opm_flowdiagnostics_test, basic_construction)
|
||||
@@ -9,12 +10,14 @@ TEST(opm_flowdiagnostics_test, basic_construction)
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Opm::ECLRestartData rstrt(casePath + "SIMPLE.UNRST");
|
||||
Opm::ECLInitFileData initData(casePath + "SIMPLE.INIT");
|
||||
|
||||
Opm::ECLGraph graph = Opm::ECLGraph::load(casePath + "SIMPLE.EGRID",
|
||||
casePath + "SIMPLE.INIT");
|
||||
graph.assignFluxDataSource(casePath + "SIMPLE.UNRST");
|
||||
initData);
|
||||
|
||||
int step = 2;
|
||||
if ( ! graph.selectReportStep(step) )
|
||||
if ( ! rstrt.selectReportStep(step) )
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
@@ -44,3 +47,4 @@ TEST(opm_flowdiagnostics_test, basic_construction)
|
||||
std::cerr << "Caught exception: " << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,27 +17,31 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuFlowCharacteristicsPlot.h"
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
#include "RiuResultQwtPlot.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotWheelZoomer.h"
|
||||
#include "RiuQwtPlotZoomer.h"
|
||||
#include "RiuResultQwtPlot.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfColor3.h"
|
||||
|
||||
#include "qwt_date.h"
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_plot_zoomer.h"
|
||||
#include "qwt_symbol.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QDateTime>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include <QDateTime>
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuQwtPlotWheelZoomer.h"
|
||||
#include "qwt_plot_zoomer.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "qwt_plot_zoneitem.h"
|
||||
#include "qwt_date.h"
|
||||
#include "RiuQwtPlotZoomer.h"
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -85,6 +89,9 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlo
|
||||
m_flowCapVsStorageCapPlot->setTitle("Flow Capacity vs Storage Capacity");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuFlowCharacteristicsPlot::addWindowZoom(QwtPlot* plot)
|
||||
{
|
||||
auto zoomer = new RiuQwtPlotZoomer(plot->canvas());
|
||||
@@ -107,50 +114,58 @@ RiuFlowCharacteristicsPlot::~RiuFlowCharacteristicsPlot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuFlowCharacteristicsPlot::setLorenzCurve(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
|
||||
void RiuFlowCharacteristicsPlot::setLorenzCurve(const QStringList& dateTimeStrings, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
|
||||
{
|
||||
initializeColors(dateTimes);
|
||||
|
||||
m_lorenzPlot->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
|
||||
auto curve = createEmptyCurve(m_lorenzPlot, "Lorenz Coefficient", QColor(0, 0, 0));
|
||||
curve->setSamplesFromDateAndValues(dateTimes, timeHistoryValues, false);
|
||||
//curve->setSymbol(QwtSymbol )
|
||||
|
||||
//size_t tsIdx = 0;
|
||||
//for ( const QDateTime& dateTime: dateTimes )
|
||||
//{
|
||||
// auto curve = createEmptyCurve(m_lorenzPlot, dateTime.toString(), m_dateToColorMap[dateTime]);
|
||||
// std::vector<QDateTime> timeStep;
|
||||
// timeStep.push_back(dateTime);
|
||||
// std::vector<double> lorCoeff;
|
||||
// lorCoeff.push_back(timeHistoryValues[tsIdx]);
|
||||
//
|
||||
// curve->setSamplesFromDateAndValues(timeStep, lorCoeff, false);
|
||||
//
|
||||
// ++tsIdx;
|
||||
//}
|
||||
//double milliSecSinceEpoch = QwtDate::toDouble(filteredDateTimes[i]);
|
||||
|
||||
for ( size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx )
|
||||
for (size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx)
|
||||
{
|
||||
double currentTsValue = QwtDate::toDouble(dateTimes[tsIdx]);
|
||||
if (timeHistoryValues[tsIdx] == HUGE_VAL) continue;
|
||||
|
||||
double minTsValue = currentTsValue;
|
||||
if ( tsIdx > 0 ) minTsValue = 0.5 * (currentTsValue + QwtDate::toDouble(dateTimes[tsIdx-1]));
|
||||
|
||||
double maxTsValue = currentTsValue;
|
||||
if ( tsIdx < dateTimes.size()-1 ) maxTsValue = 0.5 * (currentTsValue + QwtDate::toDouble(dateTimes[tsIdx+1]));
|
||||
QDateTime dateTime = dateTimes[tsIdx];
|
||||
double timeHistoryValue = timeHistoryValues[tsIdx];
|
||||
|
||||
auto plotZone = new QwtPlotZoneItem();
|
||||
plotZone->setOrientation(Qt::Vertical);
|
||||
plotZone->setInterval(minTsValue, maxTsValue);
|
||||
plotZone->setBrush(QBrush(m_dateToColorMap[dateTimes[tsIdx]]));
|
||||
plotZone->attach(m_lorenzPlot);
|
||||
QString curveName = dateTimeStrings[static_cast<int>(tsIdx)];
|
||||
|
||||
RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(m_lorenzPlot, curveName, m_dateToColorMap[dateTime], dateTime, timeHistoryValue);
|
||||
}
|
||||
|
||||
m_lorenzPlot->replot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(QwtPlot* plot, const QString& curveName, const QColor& color, const QDateTime& dateTime, double timeHistoryValue)
|
||||
{
|
||||
auto curve = createEmptyCurve(plot, curveName, color);
|
||||
|
||||
QwtSymbol::Style style = QwtSymbol::Diamond;
|
||||
QwtSymbol* symbol = new QwtSymbol(style);
|
||||
|
||||
symbol->setSize(15, 15);
|
||||
symbol->setColor(color);
|
||||
|
||||
curve->setSymbol(symbol);
|
||||
|
||||
// Add date and value twice to avoid a cross as symbol generated by RiuLineSegmentQwtPlotCurve
|
||||
|
||||
std::vector<QDateTime> dateTimes;
|
||||
dateTimes.push_back(dateTime);
|
||||
dateTimes.push_back(dateTime);
|
||||
|
||||
std::vector<double> timeHistoryValues;
|
||||
timeHistoryValues.push_back(timeHistoryValue);
|
||||
timeHistoryValues.push_back(timeHistoryValue);
|
||||
|
||||
curve->setSamplesFromDateAndValues(dateTimes, timeHistoryValues, false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuLineSegmentQwtPlotCurve* RiuFlowCharacteristicsPlot::createEmptyCurve(QwtPlot* plot, const QString& curveName, const QColor& curveColor )
|
||||
{
|
||||
RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve(curveName);
|
||||
@@ -200,6 +215,9 @@ void RiuFlowCharacteristicsPlot::removeAllCurves()
|
||||
m_dateToColorMap.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void zoomAllInPlot(QwtPlot * plot)
|
||||
{
|
||||
plot->setAxisAutoScale(QwtPlot::xBottom, true);
|
||||
@@ -217,6 +235,23 @@ void RiuFlowCharacteristicsPlot::zoomAll()
|
||||
zoomAllInPlot(m_flowCapVsStorageCapPlot);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuFlowCharacteristicsPlot::showLegend(bool show)
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
// Will be released in plot destructor or when a new legend is set
|
||||
QwtLegend* legend = new QwtLegend(m_lorenzPlot);
|
||||
m_lorenzPlot->insertLegend(legend, QwtPlot::BottomLegend);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lorenzPlot->insertLegend(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -225,7 +260,6 @@ RimFlowCharacteristicsPlot* RiuFlowCharacteristicsPlot::ownerPlotDefinition()
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -242,7 +276,6 @@ QSize RiuFlowCharacteristicsPlot::minimumSizeHint() const
|
||||
return QSize(0, 100);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qwt_plot.h"
|
||||
#include "RiuInterfaceToViewWindow.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include "qwt_plot.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include "RiuInterfaceToViewWindow.h"
|
||||
#include <QPointer>
|
||||
|
||||
class RimFlowCharacteristicsPlot;
|
||||
class RiuNightchartsWidget;
|
||||
@@ -49,13 +50,15 @@ public:
|
||||
RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent = NULL);
|
||||
virtual ~RiuFlowCharacteristicsPlot();
|
||||
|
||||
void setLorenzCurve(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues);
|
||||
void setLorenzCurve(const QStringList& dateTimeStrings, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues);
|
||||
void addFlowCapStorageCapCurve(const QDateTime& dateTime, const std::vector<double>& xVals, const std::vector<double>& yVals);
|
||||
void addSweepEfficiencyCurve(const QDateTime& dateTime, const std::vector<double>& xVals, const std::vector<double>& yVals);
|
||||
|
||||
void removeAllCurves();
|
||||
void zoomAll();
|
||||
|
||||
void showLegend(bool show);
|
||||
|
||||
RimFlowCharacteristicsPlot* ownerPlotDefinition();
|
||||
virtual RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
@@ -68,9 +71,9 @@ protected:
|
||||
|
||||
private:
|
||||
void setDefaults();
|
||||
|
||||
|
||||
void initializeColors(const std::vector<QDateTime>& dateTimes);
|
||||
void initializeColors(const std::vector<QDateTime>& dateTimes);
|
||||
|
||||
static void addCurveWithLargeSymbol(QwtPlot* plot, const QString& curveName, const QColor& color, const QDateTime& dateTime, double timeHistoryValue);
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimFlowCharacteristicsPlot> m_plotDefinition;
|
||||
@@ -78,7 +81,6 @@ private:
|
||||
QPointer<QwtPlot> m_flowCapVsStorageCapPlot;
|
||||
QPointer<QwtPlot> m_sweepEffPlot;
|
||||
|
||||
|
||||
std::map<QDateTime, QColor> m_dateToColorMap;
|
||||
};
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafPdmUiTreeView.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include "cvfTimer.h"
|
||||
|
||||
@@ -637,7 +638,7 @@ void RiuMainWindow::slotRefreshFileActions()
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
bool projectFileExists = QFile::exists(app->project()->fileName());
|
||||
bool projectFileExists = caf::Utils::fileExists(app->project()->fileName());
|
||||
|
||||
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
|
||||
CVF_ASSERT(cmdFeatureMgr);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "cafPdmUiPropertyView.h"
|
||||
#include "cafPdmUiTreeView.h"
|
||||
#include "cafPdmUiTreeViewEditor.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QtGui>
|
||||
@@ -99,7 +100,7 @@ QString RiuWellImportWizard::jsonWellsFilePath()
|
||||
void RiuWellImportWizard::downloadFields()
|
||||
{
|
||||
QString wellFileName = jsonWellsFilePath();
|
||||
if (QFile::exists(wellFileName))
|
||||
if (caf::Utils::fileExists(wellFileName))
|
||||
{
|
||||
QFile::remove(wellFileName);
|
||||
}
|
||||
@@ -355,7 +356,7 @@ void RiuWellImportWizard::updateFieldsModel()
|
||||
{
|
||||
QString fileName = jsonFieldsFilePath();
|
||||
|
||||
if (QFile::exists(fileName))
|
||||
if (caf::Utils::fileExists(fileName))
|
||||
{
|
||||
ResInsightInternalJson::JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(fileName);
|
||||
@@ -540,7 +541,7 @@ QStringList RiuWellImportWizard::absoluteFilePathsToWellPaths() const
|
||||
|
||||
for (size_t i = 0; i < downloadEntities.size(); i++)
|
||||
{
|
||||
if (QFile::exists(downloadEntities[i].responseFilename))
|
||||
if (caf::Utils::fileExists(downloadEntities[i].responseFilename))
|
||||
{
|
||||
filePaths.push_back(downloadEntities[i].responseFilename);
|
||||
}
|
||||
@@ -582,7 +583,7 @@ void RiuWellImportWizard::parseWellsResponse(RimOilFieldEntry* oilFieldEntry)
|
||||
QStringList surveyNames;
|
||||
QStringList planNames;
|
||||
|
||||
if (QFile::exists(oilFieldEntry->wellsFilePath))
|
||||
if (caf::Utils::fileExists(oilFieldEntry->wellsFilePath))
|
||||
{
|
||||
ResInsightInternalJson::JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(oilFieldEntry->wellsFilePath);
|
||||
@@ -1056,7 +1057,7 @@ void WellSummaryPage::updateSummaryPage()
|
||||
|
||||
for (size_t i = 0; i < downloadEntities.size(); i++)
|
||||
{
|
||||
if (QFile::exists(downloadEntities[i].responseFilename))
|
||||
if (caf::Utils::fileExists(downloadEntities[i].responseFilename))
|
||||
{
|
||||
wellPathCount++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user