Merged in changes from dev

This commit is contained in:
Magne Sjaastad 2017-01-03 11:32:00 +01:00
commit dc970edf7e
35 changed files with 725 additions and 202 deletions

View File

@ -212,9 +212,14 @@ private:
private slots:
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotUpdateScheduledDisplayModels();
// Friend classes required to have access to slotUpdateScheduledDisplayModels
// As snapshots are produced fast in sequence, the feature must have access to force redraw
// of scheduled redraws
friend class RimView;
friend class RicExportMultipleSnapshotsFeature;
private:
caf::PdmPointer<RimView> m_activeReservoirView;
caf::PdmPointer<RimWellLogPlot> m_activeWellLogPlot;

View File

@ -75,7 +75,7 @@ void RicNewSimWellIntersectionFeature::setupActionLook(QAction* actionToSetup)
RicNewSimWellIntersectionCmd::RicNewSimWellIntersectionCmd(RimIntersectionCollection* intersectionCollection, RimEclipseWell* simWell)
: CmdExecuteCommand(NULL),
m_intersectionCollection(intersectionCollection),
m_wellPath(simWell)
m_simWell(simWell)
{
}
@ -100,12 +100,12 @@ QString RicNewSimWellIntersectionCmd::name()
void RicNewSimWellIntersectionCmd::redo()
{
CVF_ASSERT(m_intersectionCollection);
CVF_ASSERT(m_wellPath);
CVF_ASSERT(m_simWell);
RimIntersection* intersection = new RimIntersection();
intersection->name = m_wellPath->name;
intersection->name = m_simWell->name;
intersection->type = RimIntersection::CS_SIMULATION_WELL;
intersection->simulationWell = m_wellPath;
intersection->simulationWell = m_simWell;
m_intersectionCollection->appendIntersection(intersection);
}

View File

@ -42,7 +42,7 @@ public:
private:
caf::PdmPointer<RimIntersectionCollection> m_intersectionCollection;
caf::PdmPointer<RimEclipseWell> m_wellPath;
caf::PdmPointer<RimEclipseWell> m_simWell;
};

View File

@ -22,12 +22,17 @@
#include "RicSnapshotViewToClipboardFeature.h"
#include "RigFemResultPosEnum.h"
#include "RimCase.h"
#include "RimCellRangeFilter.h"
#include "RimCellRangeFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "RimMultiSnapshotDefinition.h"
#include "RimProject.h"
@ -71,6 +76,12 @@ void RicExportMultipleSnapshotsFeature::onActionTriggered(bool isChecked)
caf::CmdExecCommandSystemActivator activator;
RiuExportMultipleSnapshotsWidget dlg(nullptr, proj);
if (proj->multiSnapshotDefinitions.size() == 0)
{
dlg.addSnapshotItemFromActiveView();
}
dlg.exec();
}
}
@ -105,59 +116,51 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
int initialFramIndex = rimView->viewer()->currentFrameIndex();
exportViewVariationsToFolder(rimView, msd, folder);
exportResultVariations(rimView, msd, folder);
for (RimCase* rimCase : msd->additionalCases())
{
RimView* copyOfView = dynamic_cast<RimView*>(rimView->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
RimEclipseCase* eclCase = dynamic_cast<RimEclipseCase*>(rimCase);
if (eclCase)
RimEclipseView* sourceEclipseView = dynamic_cast<RimEclipseView*>(rimView);
if (eclCase && sourceEclipseView)
{
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(copyOfView);
CVF_ASSERT(eclView);
RimEclipseView* copyOfEclipseView = eclCase->createCopyAndAddView(sourceEclipseView);
CVF_ASSERT(copyOfEclipseView);
eclCase->reservoirViews().push_back(eclView);
copyOfEclipseView->loadDataAndUpdate();
eclView->setEclipseCase(eclCase);
exportResultVariations(copyOfEclipseView, msd, folder);
// Resolve references after reservoir view has been inserted into Rim structures
// Intersections referencing a well path/ simulation well requires this
// TODO: initAfterReadRecursively can probably be removed
eclView->initAfterReadRecursively();
eclView->resolveReferencesRecursively();
eclCase->reservoirViews().removeChildObject(copyOfEclipseView);
eclView->loadDataAndUpdate();
exportViewVariationsToFolder(eclView, msd, folder);
eclCase->reservoirViews().removeChildObject(eclView);
delete copyOfEclipseView;
}
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(rimCase);
if (geomCase)
RimGeoMechView* sourceGeoMechView = dynamic_cast<RimGeoMechView*>(rimView);
if (geomCase && sourceGeoMechView)
{
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(copyOfView);
CVF_ASSERT(geoMechView);
RimGeoMechView* copyOfGeoMechView = dynamic_cast<RimGeoMechView*>(sourceGeoMechView->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
CVF_ASSERT(copyOfGeoMechView);
geomCase->geoMechViews().push_back(geoMechView);
geomCase->geoMechViews().push_back(copyOfGeoMechView);
geoMechView->setGeoMechCase(geomCase);
copyOfGeoMechView->setGeoMechCase(geomCase);
// Resolve references after reservoir view has been inserted into Rim structures
// Intersections referencing a well path/ simulation well requires this
// TODO: initAfterReadRecursively can probably be removed
geoMechView->initAfterReadRecursively();
geoMechView->resolveReferencesRecursively();
copyOfGeoMechView->initAfterReadRecursively();
copyOfGeoMechView->resolveReferencesRecursively();
geoMechView->loadDataAndUpdate();
copyOfGeoMechView->loadDataAndUpdate();
exportViewVariationsToFolder(geoMechView, msd, folder);
exportResultVariations(copyOfGeoMechView, msd, folder);
geomCase->geoMechViews().removeChildObject(geoMechView);
geomCase->geoMechViews().removeChildObject(copyOfGeoMechView);
delete copyOfGeoMechView;
}
delete copyOfView;
}
// Set view back to initial state
@ -168,6 +171,36 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportMultipleSnapshotsFeature::exportResultVariations(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder)
{
exportViewVariationsToFolder(rimView, msd, folder);
if (msd->selectedEclipseResults().size() > 0)
{
RimEclipseCase* eclCase = dynamic_cast<RimEclipseCase*>(rimView->ownerCase());
RimEclipseView* copyOfView = eclCase->createCopyAndAddView(dynamic_cast<RimEclipseView*>(rimView));
copyOfView->cellResult()->setResultType(msd->eclipseResultType());
for (QString s : msd->selectedEclipseResults())
{
copyOfView->cellResult()->setResultVariable(s);
copyOfView->loadDataAndUpdate();
exportViewVariationsToFolder(copyOfView, msd, folder);
}
eclCase->reservoirViews().removeChildObject(copyOfView);
delete copyOfView;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -179,6 +212,9 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri
RiuViewer* viewer = rimView->viewer();
QStringList timeSteps = rimCase->timeStepStrings();
QString resName = resultName(rimView);
QString viewCaseResultString = rimCase->caseUserDescription() + "_" + rimView->name() + "_" + resName;
for (int i = msd->timeStepStart(); i <= msd->timeStepEnd(); i++)
{
QString timeStepIndexString = QString("%1").arg(i, 2, 10, QLatin1Char('0'));
@ -187,18 +223,21 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri
if (viewer)
{
// Force update of scheduled display models modifying the time step
// This is required due to visualization structures updated by the update functions,
// and this is not triggered by changing time step only
RiaApplication::instance()->slotUpdateScheduledDisplayModels();
viewer->setCurrentFrame(i);
viewer->animationControl()->setCurrentFrameOnly(i);
}
if (msd->sliceDirection == RimMultiSnapshotDefinition::NO_RANGEFILTER)
{
QString fileName = rimCase->caseUserDescription() + "_" + rimView->name() + "_" + timeStepString;
QString fileName = viewCaseResultString + "_" + timeStepString;
fileName.replace(" ", "-");
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
QCoreApplication::instance()->processEvents();
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, rimView);
}
else
@ -212,7 +251,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri
for (int i = msd->startSliceIndex(); i <= msd->endSliceIndex(); i++)
{
QString rangeFilterString = msd->sliceDirection().text() + "-" + QString::number(i);
QString fileName = rimCase->caseUserDescription() + "_" + rimView->name() + "_" + timeStepString + "_" + rangeFilterString;
QString fileName = viewCaseResultString + "_" + timeStepString + "_" + rangeFilterString;
fileName.replace(" ", "-");
rangeFilter->setDefaultValues();
@ -233,8 +272,6 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri
}
rimView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews(rangeFilter);
// Make sure the redraw is processed
QCoreApplication::instance()->processEvents();
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, rimView);
@ -248,3 +285,37 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportMultipleSnapshotsFeature::resultName(RimView* rimView)
{
if (dynamic_cast<RimEclipseView*>(rimView))
{
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(rimView);
return eclView->cellResult()->resultVariable();
}
else if (dynamic_cast<RimGeoMechView*>(rimView))
{
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(rimView);
RimGeoMechCellColors* cellResult = geoMechView->cellResult();
if (cellResult)
{
QString title = caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText() + "_"
+ cellResult->resultFieldUiName();
if (!cellResult->resultComponentUiName().isEmpty())
{
title += "_" + cellResult->resultComponentUiName();
}
return title;
}
}
return "";
}

View File

@ -39,7 +39,10 @@ protected:
public:
static void exportMultipleSnapshots(const QString& folder, RimProject* project);
static void exportViewVariationsToFolder(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder);
static void exportResultVariations(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder);
private:
static void exportViewVariationsToFolder(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder);
static QString resultName(RimView* rimView);
};

View File

@ -32,7 +32,7 @@
#include <QAction>
#include "RiuSelectionManager.h"
#include "RivWellPipeSourceInfo.h"
#include "RivSimWellPipeSourceInfo.h"
CAF_CMD_SOURCE_INIT(RicNewSimWellFractureAtPosFeature, "RicNewSimWellFractureAtPosFeature");
@ -56,7 +56,7 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked)
if (!simWellItem) return;
}
const RivEclipseWellSourceInfo* simwellSourceInfo = simWellItem->m_simwellSourceInfo;
const RivSimWellPipeSourceInfo* simwellSourceInfo = simWellItem->m_simwellSourceInfo;
RimEclipseWell* simWell = simwellSourceInfo->well();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(simWell);
if (!objHandle) return;

View File

@ -21,7 +21,7 @@ ${CEE_CURRENT_LIST_DIR}RivSourceInfo.h
${CEE_CURRENT_LIST_DIR}RivWellPathSourceInfo.h
${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.h
${CEE_CURRENT_LIST_DIR}RivWellPathCollectionPartMgr.h
${CEE_CURRENT_LIST_DIR}RivWellPipesPartMgr.h
${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.h
${CEE_CURRENT_LIST_DIR}RivReservoirWellSpheresPartMgr.h
${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.h
${CEE_CURRENT_LIST_DIR}RivResultToTextureMapper.h
@ -34,7 +34,7 @@ ${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.h
${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.h
${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.h
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.h
${CEE_CURRENT_LIST_DIR}RivWellPipeSourceInfo.h
${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.h
${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.h
)
@ -55,7 +55,7 @@ ${CEE_CURRENT_LIST_DIR}RivSourceInfo.cpp
${CEE_CURRENT_LIST_DIR}RivWellPathSourceInfo.cpp
${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellPathCollectionPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellPipesPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivReservoirWellSpheresPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.cpp
@ -66,7 +66,7 @@ ${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.cpp
${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.cpp
${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.cpp
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivWellPipeSourceInfo.cpp
${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.cpp
${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.cpp
)

View File

@ -30,7 +30,7 @@
#include "RimEclipseWellCollection.h"
#include "RivWellHeadPartMgr.h"
#include "RivWellPipesPartMgr.h"
#include "RivSimWellPipesPartMgr.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
@ -111,7 +111,7 @@ void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasic
for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i)
{
RivWellPipesPartMgr * wppmgr = new RivWellPipesPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]);
RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]);
m_wellPipesPartMgrs.push_back(wppmgr);
wppmgr->setScaleTransform(m_scaleTransform.p());

View File

@ -30,7 +30,7 @@ namespace cvf
}
class RimEclipseView;
class RivWellPipesPartMgr;
class RivSimWellPipesPartMgr;
class RivWellHeadPartMgr;
class RivReservoirPipesPartMgr : public cvf::Object
@ -53,6 +53,6 @@ private:
caf::PdmPointer<RimEclipseView> m_reservoirView;
cvf::ref<cvf::Transform> m_scaleTransform;
cvf::Collection< RivWellPipesPartMgr > m_wellPipesPartMgrs;
cvf::Collection< RivSimWellPipesPartMgr > m_wellPipesPartMgrs;
cvf::Collection< RivWellHeadPartMgr > m_wellHeadPartMgrs;
};

View File

@ -17,7 +17,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivWellPipeSourceInfo.h"
#include "RivSimWellPipeSourceInfo.h"
#include "RimEclipseWell.h"
@ -25,15 +25,16 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivEclipseWellSourceInfo::RivEclipseWellSourceInfo(RimEclipseWell* eclipseWell)
: m_eclipseWell(eclipseWell)
RivSimWellPipeSourceInfo::RivSimWellPipeSourceInfo(RimEclipseWell* eclipseWell, size_t branchIndex)
: m_eclipseWell(eclipseWell),
m_branchIndex(branchIndex)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseWell* RivEclipseWellSourceInfo::well() const
RimEclipseWell* RivSimWellPipeSourceInfo::well() const
{
return m_eclipseWell.p();
}

View File

@ -25,13 +25,14 @@
class RimEclipseWell;
class RivEclipseWellSourceInfo : public cvf::Object
class RivSimWellPipeSourceInfo : public cvf::Object
{
public:
RivEclipseWellSourceInfo(RimEclipseWell* eclipseWell);
RivSimWellPipeSourceInfo(RimEclipseWell* eclipseWell, size_t branchIndex);
RimEclipseWell* well() const;
private:
caf::PdmPointer<RimEclipseWell> m_eclipseWell;
size_t m_branchIndex;
};

View File

@ -18,7 +18,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivWellPipesPartMgr.h"
#include "RivSimWellPipesPartMgr.h"
#include "RigCaseData.h"
#include "RigCell.h"
@ -36,7 +36,7 @@
#include "RivPipeGeometryGenerator.h"
#include "RivWellPathSourceInfo.h"
#include "RivWellPipeSourceInfo.h"
#include "RivSimWellPipeSourceInfo.h"
#include "cafEffectGenerator.h"
#include "cafPdmFieldCvfColor.h"
@ -55,7 +55,7 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellPipesPartMgr::RivWellPipesPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well)
RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well)
{
m_rimReservoirView = reservoirView;
m_rimWell = well;
@ -85,7 +85,7 @@ RivWellPipesPartMgr::RivWellPipesPartMgr(RimEclipseView* reservoirView, RimEclip
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellPipesPartMgr::~RivWellPipesPartMgr()
RivSimWellPipesPartMgr::~RivSimWellPipesPartMgr()
{
}
@ -93,7 +93,7 @@ RivWellPipesPartMgr::~RivWellPipesPartMgr()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellPipesPartMgr::buildWellPipeParts()
void RivSimWellPipesPartMgr::buildWellPipeParts()
{
if (m_rimReservoirView.isNull()) return;
@ -107,10 +107,11 @@ void RivWellPipesPartMgr::buildWellPipeParts()
double characteristicCellSize = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize();
double pipeRadius = m_rimReservoirView->wellCollection()->pipeRadiusScaleFactor() *m_rimWell->pipeRadiusScaleFactor() * characteristicCellSize;
cvf::ref<RivEclipseWellSourceInfo> sourceInfo = new RivEclipseWellSourceInfo(m_rimWell);
for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx)
{
cvf::ref<RivSimWellPipeSourceInfo> sourceInfo = new RivSimWellPipeSourceInfo(m_rimWell, brIdx);
m_wellBranches.push_back(RivPipeBranchData());
RivPipeBranchData& pbd = m_wellBranches.back();
@ -171,7 +172,28 @@ void RivWellPipesPartMgr::buildWellPipeParts()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
RivSimWellPipesPartMgr::RivPipeBranchData* RivSimWellPipesPartMgr::pipeBranchData(size_t branchIndex)
{
if (branchIndex < m_wellBranches.size())
{
size_t i = 0;
auto brIt = m_wellBranches.begin();
while (i < branchIndex)
{
brIt++;
}
return &(*brIt);
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull()) return;
@ -196,7 +218,7 @@ void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
{
if (m_rimWell == NULL) return;
@ -305,3 +327,25 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivSimWellPipesPartMgr::findGridIndexAndCellIndex(size_t branchIndex, size_t triangleIndex, size_t* gridIndex, size_t* cellIndex)
{
CVF_ASSERT(branchIndex < m_wellBranches.size());
RivPipeBranchData* branchData = pipeBranchData(branchIndex);
if (branchData)
{
size_t segmentIndex = branchData->m_pipeGeomGenerator->segmentIndexFromTriangleIndex(triangleIndex);
*gridIndex = branchData->m_cellIds[segmentIndex].m_gridIndex;
*cellIndex = branchData->m_cellIds[segmentIndex].m_gridCellIndex;
}
else
{
*gridIndex = cvf::UNDEFINED_SIZE_T;
*cellIndex = cvf::UNDEFINED_SIZE_T;
}
}

View File

@ -40,11 +40,11 @@ class RivPipeGeometryGenerator;
class RimEclipseView;
class RimEclipseWell;
class RivWellPipesPartMgr : public cvf::Object
class RivSimWellPipesPartMgr : public cvf::Object
{
public:
RivWellPipesPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well);
~RivWellPipesPartMgr();
RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well);
~RivSimWellPipesPartMgr();
void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform; scheduleGeometryRegen();}
@ -55,6 +55,8 @@ public:
const std::vector< std::vector <cvf::Vec3d> >& centerLineOfWellBranches() { return m_pipeBranchesCLCoords;}
void findGridIndexAndCellIndex(size_t branchIndex, size_t triangleIndex, size_t* gridIndex, size_t* cellIndex);
private:
caf::PdmPointer<RimEclipseView> m_rimReservoirView;
caf::PdmPointer<RimEclipseWell> m_rimWell;
@ -64,7 +66,6 @@ private:
void buildWellPipeParts();
struct RivPipeBranchData
{
std::vector <RigWellResultPoint> m_cellIds;
@ -78,6 +79,8 @@ private:
};
RivPipeBranchData* pipeBranchData(size_t branchIndex);
std::list<RivPipeBranchData> m_wellBranches;
cvf::ref<cvf::ScalarMapper> m_scalarMapper;

View File

@ -40,7 +40,7 @@
#include "RimReservoirCellResultsStorage.h"
#include "RivPipeGeometryGenerator.h"
#include "RivWellPipesPartMgr.h"
#include "RivSimWellPipesPartMgr.h"
#include "cafEffectGenerator.h"
#include "cafPdmFieldCvfMat4d.h"

View File

@ -156,19 +156,44 @@ void RimEclipseCase::initAfterRead()
//--------------------------------------------------------------------------------------------------
RimEclipseView* RimEclipseCase::createAndAddReservoirView()
{
RimEclipseView* riv = new RimEclipseView();
riv->setEclipseCase(this);
riv->cellEdgeResult()->setResultVariable("MULT");
riv->cellEdgeResult()->enableCellEdgeColors = false;
RimEclipseView* rimEclipseView = new RimEclipseView();
rimEclipseView->setEclipseCase(this);
rimEclipseView->cellEdgeResult()->setResultVariable("MULT");
rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false;
caf::PdmDocument::updateUiIconStateRecursively(riv);
caf::PdmDocument::updateUiIconStateRecursively(rimEclipseView);
size_t i = reservoirViews().size();
riv->name = QString("View %1").arg(i + 1);
rimEclipseView->name = QString("View %1").arg(i + 1);
reservoirViews().push_back(riv);
reservoirViews().push_back(rimEclipseView);
return riv;
return rimEclipseView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseView* RimEclipseCase::createCopyAndAddView(const RimEclipseView* sourceView)
{
CVF_ASSERT(sourceView);
RimEclipseView* rimEclipseView = dynamic_cast<RimEclipseView*>(sourceView->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
CVF_ASSERT(rimEclipseView);
rimEclipseView->setEclipseCase(this);
caf::PdmDocument::updateUiIconStateRecursively(rimEclipseView);
reservoirViews().push_back(rimEclipseView);
// Resolve references after reservoir view has been inserted into Rim structures
// Intersections referencing a well path/ simulation well requires this
// TODO: initAfterReadRecursively can probably be removed
rimEclipseView->initAfterReadRecursively();
rimEclipseView->resolveReferencesRecursively();
return rimEclipseView;
}
//--------------------------------------------------------------------------------------------------

View File

@ -74,6 +74,7 @@ public:
RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel);
RimEclipseView* createAndAddReservoirView();
RimEclipseView* createCopyAndAddView(const RimEclipseView* sourceView);
void removeResult(const QString& resultName);

View File

@ -309,7 +309,7 @@ void RimEclipsePropertyFilter::computeResultValueRange()
if ( resultDefinition->hasCategoryResult() )
{
setCategoryValues(results->uniqueCellScalarValues(resAddr, timeStep));
setCategoryNames(resultDefinition->flowDiagSolution()->tracerNames());
}
}
}

View File

@ -311,7 +311,7 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
{
if ( fieldNeedingOptions == &m_resultVariableUiField )
{
optionItems.push_back(caf::PdmOptionItemInfo("Time Of Flight (Weighted Sum)", RIG_FLD_TOF_RESNAME));
optionItems.push_back(caf::PdmOptionItemInfo("Time Of Flight (Average)", RIG_FLD_TOF_RESNAME));
optionItems.push_back(caf::PdmOptionItemInfo("Tracer Cell Fraction (Sum)", RIG_FLD_CELL_FRACTION_RESNAME));
optionItems.push_back(caf::PdmOptionItemInfo("Max Fraction Tracer", RIG_FLD_MAX_FRACTION_TRACER_RESNAME));
optionItems.push_back(caf::PdmOptionItemInfo("Injector Producer Communication", RIG_FLD_COMMUNICATION_RESNAME));
@ -334,11 +334,11 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
RimFlowDiagSolution* flowSol = m_flowSolutionUiField();
if (flowSol)
{
std::set<QString> tracerNames = flowSol->tracerNames();
std::vector<QString> tracerNames = flowSol->tracerNames();
std::map<QString, QString> prefixedTracerNamesMap;
for ( const QString& tracerName : tracerNames )
{
RimFlowDiagSolution::TracerStatusType status = flowSol->tracerStatus(tracerName);
RimFlowDiagSolution::TracerStatusType status = flowSol->tracerStatusOverall(tracerName);
QString prefix;
switch (status)
{

View File

@ -1029,7 +1029,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R
if ( resultColors->hasCategoryResult() )
{
resultColors->legendConfig()->setIntegerCategories(cellResultsData->uniqueCellScalarValues(resAddr, m_currentTimeStep));
resultColors->legendConfig()->setNamedCategories(resultColors->flowDiagSolution()->tracerNames());
}
m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend());

View File

@ -75,12 +75,12 @@ RigFlowDiagResults* RimFlowDiagSolution::flowDiagResults()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<QString> RimFlowDiagSolution::tracerNames()
std::vector<QString> RimFlowDiagSolution::tracerNames()
{
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
std::set<QString> tracerNameSet;
std::vector<QString> tracerNameSet;
if (eclCase)
{
@ -88,7 +88,7 @@ std::set<QString> RimFlowDiagSolution::tracerNames()
for (size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx)
{
tracerNameSet.insert(wellResults[wIdx]->m_wellName);
tracerNameSet.push_back(wellResults[wIdx]->m_wellName);
}
}
@ -174,7 +174,7 @@ std::map<std::string, std::vector<int> > RimFlowDiagSolution::allTracerActiveCel
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatus(QString tracerName)
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall(QString tracerName)
{
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
@ -213,6 +213,49 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatus(QString
return tracerStatus;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex)
{
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
if ( eclCase )
{
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
{
if ( wellResults[wIdx]->m_wellName == tracerName )
{
size_t wellTimeStep = wellResults[wIdx]->m_resultTimeStepIndexToWellTimeStepIndex[timeStepIndex];
const RigWellResultFrame& wellResFrame = wellResults[wIdx]->m_wellCellsTimeSteps[wellTimeStep];
{
if ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR )
{
return INJECTOR;
}
else if ( wellResFrame.m_productionType == RigWellResultFrame::PRODUCER )
{
return PRODUCER;
}
else
{
return UNDEFINED;
}
}
}
}
}
CVF_ASSERT(false);
return UNDEFINED;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -41,7 +41,7 @@ public:
QString userDescription() { return m_userDescription();}
RigFlowDiagResults* flowDiagResults();
std::set<QString> tracerNames();
std::vector<QString> tracerNames();
std::map<std::string, std::vector<int> > allInjectorTracerActiveCellIndices(size_t timeStepIndex);
std::map<std::string, std::vector<int> > allProducerTracerActiveCellIndices(size_t timeStepIndex);
@ -54,7 +54,8 @@ public:
UNDEFINED
};
TracerStatusType tracerStatus(QString tracerName);
TracerStatusType tracerStatusOverall(QString tracerName);
TracerStatusType tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex);
protected:

View File

@ -747,6 +747,26 @@ void RimLegendConfig::setNamedCategoriesInverse(const std::vector<QString>& cate
updateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setNamedCategories(const std::vector<QString>& categoryNames)
{
std::vector<int> nameIndices;
std::vector<cvf::String> names;
for ( int i = 0; i < categoryNames.size(); ++i )
{
nameIndices.push_back(i);
names.push_back(cvfqt::Utils::toString(categoryNames[i]));
}
m_categories = nameIndices;
m_categoryNames = names;
updateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -106,6 +106,7 @@ public:
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
void setIntegerCategories(const std::vector<int>& categories);
void setNamedCategoriesInverse(const std::vector<QString>& categoryNames);
void setNamedCategories(const std::vector<QString>& categoryNames);
void setTitle(const cvf::String& title);

View File

@ -21,10 +21,13 @@
#include "RiaApplication.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RimCase.h"
#include "RimCellRangeFilterCollection.h"
#include "RimEclipseView.h"
#include "RimProject.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimView.h"
#include "cafPdmPointer.h"
@ -34,10 +37,10 @@ namespace caf
template<>
void caf::AppEnum< RimMultiSnapshotDefinition::SnapShotDirectionEnum >::setUp()
{
addItem(RimMultiSnapshotDefinition::RANGEFILTER_I, "I", "i-direction");
addItem(RimMultiSnapshotDefinition::RANGEFILTER_J, "J", "j-direction");
addItem(RimMultiSnapshotDefinition::RANGEFILTER_K, "K", "k-direction");
addItem(RimMultiSnapshotDefinition::NO_RANGEFILTER, "None", "None");
addItem(RimMultiSnapshotDefinition::RANGEFILTER_I, "I", "I");
addItem(RimMultiSnapshotDefinition::RANGEFILTER_J, "J", "J");
addItem(RimMultiSnapshotDefinition::RANGEFILTER_K, "K", "K");
setDefault(RimMultiSnapshotDefinition::RANGEFILTER_K);
}
@ -54,6 +57,10 @@ RimMultiSnapshotDefinition::RimMultiSnapshotDefinition()
CAF_PDM_InitObject("MultiSnapshotDefinition", "", "", "");
CAF_PDM_InitFieldNoDefault(&viewObject, "View", "View", "", "", "");
CAF_PDM_InitFieldNoDefault(&eclipseResultType, "EclipseResultType", "Result Type", "", "", "");
CAF_PDM_InitFieldNoDefault(&selectedEclipseResults, "SelectedEclipseResults", "Result Name", "", "", "");
CAF_PDM_InitField(&timeStepStart, "TimeStepStart", 0, "Timestep Start", "", "", "");
CAF_PDM_InitField(&timeStepEnd, "TimeStepEnd", 0, "Timestep End", "", "", "");
@ -61,7 +68,7 @@ RimMultiSnapshotDefinition::RimMultiSnapshotDefinition()
CAF_PDM_InitField(&startSliceIndex, "RangeFilterStart", 1, "RangeFilter Start", "", "", "");
CAF_PDM_InitField(&endSliceIndex, "RangeFilterEnd", 1, "RangeFilter End", "", "", "");
CAF_PDM_InitFieldNoDefault(&additionalCases, "AdditionalCases", "Additional Cases", "", "", "");
CAF_PDM_InitFieldNoDefault(&additionalCases, "AdditionalCases", "Case List", "", "", "");
}
@ -102,7 +109,23 @@ QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(
QString caseAndView = view->ownerCase()->caseUserDescription() + " - " + view->name();
options.push_back(caf::PdmOptionItemInfo(caseAndView, view));
}
options.push_back(caf::PdmOptionItemInfo("-- All views --", nullptr));
}
else if (fieldNeedingOptions == &eclipseResultType)
{
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<RimDefines::ResultCatType>(RimDefines::DYNAMIC_NATIVE).uiText(), RimDefines::DYNAMIC_NATIVE));
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<RimDefines::ResultCatType>(RimDefines::STATIC_NATIVE).uiText(), RimDefines::STATIC_NATIVE));
}
else if (fieldNeedingOptions == &selectedEclipseResults)
{
RimView* rimView = viewObject();
if (dynamic_cast<RimEclipseView*>(rimView))
{
RimEclipseView* rimEclipseView = dynamic_cast<RimEclipseView*>(rimView);
QStringList varList;
varList = rimEclipseView->currentGridCellResults()->cellResults()->resultNames(eclipseResultType());
options = toOptionList(varList);
}
}
else if (fieldNeedingOptions == &timeStepEnd)
{
@ -123,9 +146,10 @@ QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(
options.push_back(caf::PdmOptionItemInfo(rimCase->caseUserDescription(), rimCase));
}
if (useOptionsOnly) *useOptionsOnly = true;
}
if (useOptionsOnly) *useOptionsOnly = true;
return options;
}
@ -149,8 +173,11 @@ void RimMultiSnapshotDefinition::getTimeStepStrings(QList<caf::PdmOptionItemInfo
//--------------------------------------------------------------------------------------------------
void RimMultiSnapshotDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &sliceDirection)
if (changedField == &eclipseResultType)
{
selectedEclipseResults.v().clear();
}
else if (changedField == &sliceDirection)
{
const cvf::StructGridInterface* mainGrid = nullptr;
RigActiveCellInfo* actCellInfo = nullptr;
@ -203,3 +230,16 @@ void RimMultiSnapshotDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::toOptionList(const QStringList& varList)
{
QList<caf::PdmOptionItemInfo> optionList;
int i;
for (i = 0; i < varList.size(); ++i)
{
optionList.push_back(caf::PdmOptionItemInfo(varList[i], varList[i]));
}
return optionList;
}

View File

@ -18,6 +18,8 @@
#pragma once
#include "RimDefines.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@ -40,6 +42,9 @@ public:
caf::PdmPtrField<RimView*> viewObject;
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > eclipseResultType;
caf::PdmField< std::vector<QString> > selectedEclipseResults;
caf::PdmField<int> timeStepStart;
caf::PdmField<int> timeStepEnd;
@ -57,10 +62,12 @@ public:
caf::PdmPtrArrayField<RimCase*> additionalCases;
private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
void getTimeStepStrings(QList<caf::PdmOptionItemInfo> &options);
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
QList<caf::PdmOptionItemInfo> toOptionList(const QStringList& varList);
};

View File

@ -260,6 +260,9 @@ QImage RimView::snapshotWindowContent()
{
if (m_viewer)
{
// Force update of scheduled display models before snapshotting
RiaApplication::instance()->slotUpdateScheduledDisplayModels();
m_viewer->repaint();
return m_viewer->snapshotImage();

View File

@ -38,7 +38,7 @@ public:
selectedTracerNames.insert(tracerName);
}
bool isNativeResult() { return ( ( (variableName == RIG_FLD_TOF_RESNAME) || (variableName == RIG_FLD_CELL_FRACTION_RESNAME) ) && selectedTracerNames.size() <= 1); }
bool isNativeResult() const { return ( ( (variableName == RIG_FLD_TOF_RESNAME) || (variableName == RIG_FLD_CELL_FRACTION_RESNAME) ) && selectedTracerNames.size() <= 1); }
std::string variableName;
std::set<std::string> selectedTracerNames;

View File

@ -158,7 +158,215 @@ RigFlowDiagResultFrames* RigFlowDiagResults::findScalarResult(const RigFlowDiagR
//--------------------------------------------------------------------------------------------------
std::vector<double>* RigFlowDiagResults::calculateDerivedResult(const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex)
{
return nullptr; // Todo
if (resVarAddr.isNativeResult()) return nullptr;
size_t activeCellCount = this->activeCellInfo(resVarAddr)->reservoirActiveCellCount();
if (resVarAddr.variableName == RIG_FLD_TOF_RESNAME)
{
std::vector<const std::vector<double>* > injectorTOFs = findResultsForSelectedTracers(resVarAddr, frameIndex,
RIG_FLD_TOF_RESNAME, RimFlowDiagSolution::INJECTOR);
std::vector<const std::vector<double>* > injectorFractions = findResultsForSelectedTracers(resVarAddr, frameIndex,
RIG_FLD_CELL_FRACTION_RESNAME, RimFlowDiagSolution::INJECTOR);
std::vector<const std::vector<double>* > producerTOFs = findResultsForSelectedTracers(resVarAddr, frameIndex,
RIG_FLD_TOF_RESNAME, RimFlowDiagSolution::PRODUCER);
std::vector<const std::vector<double>* > producerFractions = findResultsForSelectedTracers(resVarAddr, frameIndex,
RIG_FLD_CELL_FRACTION_RESNAME, RimFlowDiagSolution::PRODUCER);
std::vector<double> injectorTotalFractions;
std::vector<double> injectorFractMultTof;
calculateSumOfFractionAndFractionMultTOF(activeCellCount, injectorFractions, injectorTOFs, &injectorTotalFractions, &injectorFractMultTof);
std::vector<double> producerTotalFractions;
std::vector<double> producerFractMultTof;
calculateSumOfFractionAndFractionMultTOF(activeCellCount, producerFractions, producerTOFs, &producerTotalFractions, &producerFractMultTof);
RigFlowDiagResultFrames* averageTofFrames = this->createScalarResult(resVarAddr);
std::vector<double>& averageTof = averageTofFrames->frameData(frameIndex);
averageTof.resize(activeCellCount, HUGE_VAL);
for (size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx)
{
if ( injectorTotalFractions[acIdx] == 0.0 && producerTotalFractions[acIdx] == 0.0 )
{
averageTof[acIdx] = HUGE_VAL;
}
else
{
double retVal = 0.0;
if (injectorTotalFractions[acIdx] != 0.0) retVal += (1.0/injectorTotalFractions[acIdx]) * injectorFractMultTof[acIdx];
if (producerTotalFractions[acIdx] != 0.0) retVal += (1.0/producerTotalFractions[acIdx]) * producerFractMultTof[acIdx];
averageTof[acIdx] = retVal;
}
}
return &averageTof;
}
else if (resVarAddr.variableName == RIG_FLD_CELL_FRACTION_RESNAME)
{
std::vector<const std::vector<double>* > fractions = findResultsForSelectedTracers(resVarAddr,
frameIndex,
RIG_FLD_CELL_FRACTION_RESNAME,
RimFlowDiagSolution::UNDEFINED);
RigFlowDiagResultFrames* sumOfFractionsFrames = this->createScalarResult(resVarAddr);
std::vector<double>& sumOfFractions = sumOfFractionsFrames->frameData(frameIndex);
calculateSumOfFractions(fractions, activeCellCount, &sumOfFractions);
return &sumOfFractions;
}
else if ( resVarAddr.variableName == RIG_FLD_COMMUNICATION_RESNAME )
{
std::vector<const std::vector<double>* > injectorFractions = findResultsForSelectedTracers(resVarAddr,
frameIndex,
RIG_FLD_CELL_FRACTION_RESNAME,
RimFlowDiagSolution::INJECTOR);
std::vector<const std::vector<double>* > producerFractions = findResultsForSelectedTracers(resVarAddr,
frameIndex,
RIG_FLD_CELL_FRACTION_RESNAME,
RimFlowDiagSolution::PRODUCER);
std::vector<double> sumOfInjectorFractions;
calculateSumOfFractions(injectorFractions, activeCellCount, &sumOfInjectorFractions);
std::vector<double> sumOfProducerFractions;
calculateSumOfFractions(producerFractions, activeCellCount, &sumOfProducerFractions);
RigFlowDiagResultFrames* commFrames = this->createScalarResult(resVarAddr);
std::vector<double>& commPI = commFrames->frameData(frameIndex);
commPI.resize(activeCellCount, HUGE_VAL);
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
{
if ( (sumOfInjectorFractions)[acIdx] == HUGE_VAL ) continue;
if ( (sumOfProducerFractions)[acIdx] == HUGE_VAL ) continue;
(commPI)[acIdx] = (sumOfInjectorFractions)[acIdx] * (sumOfProducerFractions)[acIdx];
}
return &commPI;
}
else if ( resVarAddr.variableName == RIG_FLD_MAX_FRACTION_TRACER_RESNAME )
{
std::vector<int> selectedTracerIdxToGlobalTracerIdx;
{
selectedTracerIdxToGlobalTracerIdx.resize(resVarAddr.selectedTracerNames.size(), -1);
std::vector<QString> allTracerNames = m_flowDiagSolution->tracerNames();
int selTracerIdx = 0;
for ( const std::string& tracerName: resVarAddr.selectedTracerNames )
{
for ( int globIdx = 0; globIdx < allTracerNames.size(); ++globIdx )
{
if ( allTracerNames[globIdx].toStdString() == tracerName )
{
selectedTracerIdxToGlobalTracerIdx[selTracerIdx] = globIdx;
break;
}
}
++selTracerIdx;
}
}
RigFlowDiagResultFrames* maxFractionTracerIdxFrames = this->createScalarResult(resVarAddr);
std::vector<double>& maxFractionTracerIdx = maxFractionTracerIdxFrames->frameData(frameIndex);
{
std::vector<const std::vector<double>* > fractions = findResultsForSelectedTracers(resVarAddr,
frameIndex,
RIG_FLD_CELL_FRACTION_RESNAME,
RimFlowDiagSolution::UNDEFINED);
maxFractionTracerIdx.resize(activeCellCount, HUGE_VAL);
std::vector<double> maxFraction;
maxFraction.resize(activeCellCount, -HUGE_VAL);
for ( size_t frIdx = 0; frIdx < fractions.size(); ++frIdx )
{
const std::vector<double> * fr = fractions[frIdx];
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
{
if ( (*fr)[acIdx] == HUGE_VAL) continue;
if ( maxFraction[acIdx] < (*fr)[acIdx] )
{
maxFraction[acIdx] = (*fr)[acIdx];
maxFractionTracerIdx[acIdx] = frIdx;
}
}
}
}
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
{
if (maxFractionTracerIdx[acIdx] == HUGE_VAL) continue;
double selectedTracerIdx = static_cast<int>( maxFractionTracerIdx[acIdx]);
maxFractionTracerIdx[acIdx] = selectedTracerIdxToGlobalTracerIdx[selectedTracerIdx];
}
return &maxFractionTracerIdx;
}
return nullptr;
}
std::vector<const std::vector<double>* > RigFlowDiagResults::findResultsForSelectedTracers(const RigFlowDiagResultAddress& resVarAddr,
size_t frameIndex,
const std::string& nativeResultName,
RimFlowDiagSolution::TracerStatusType wantedTracerType)
{
std::vector<const std::vector<double>* > selectedTracersResults;
for ( const std::string& tracerName: resVarAddr.selectedTracerNames )
{
RimFlowDiagSolution::TracerStatusType tracerType = m_flowDiagSolution->tracerStatusInTimeStep(QString::fromStdString(tracerName), frameIndex);
if ( tracerType == wantedTracerType || wantedTracerType == RimFlowDiagSolution::UNDEFINED )
{
selectedTracersResults.push_back(findOrCalculateResult(RigFlowDiagResultAddress(nativeResultName, tracerName), frameIndex));
}
}
return selectedTracersResults;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagResults::calculateSumOfFractionAndFractionMultTOF(size_t activeCellCount,
const std::vector<const std::vector<double> *> & fractions,
const std::vector<const std::vector<double> *> & TOFs,
std::vector<double> *sumOfFractions,
std::vector<double> *fractionMultTOF)
{
sumOfFractions->resize(activeCellCount, 0.0);
fractionMultTOF->resize(activeCellCount, 0.0);
for ( size_t iIdx = 0; iIdx < fractions.size() ; ++iIdx )
{
const std::vector<double> * frInj = fractions[iIdx];
const std::vector<double> * tofInj = TOFs[iIdx];
if ( ! (frInj && tofInj) ) continue;
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
{
if ( (*frInj)[acIdx] == HUGE_VAL ) continue;
(*sumOfFractions)[acIdx] += (*frInj)[acIdx];
(*fractionMultTOF)[acIdx] += (*frInj)[acIdx] * (*tofInj)[acIdx];
}
}
}
//--------------------------------------------------------------------------------------------------
@ -177,6 +385,32 @@ RigStatisticsDataCache* RigFlowDiagResults::statistics(const RigFlowDiagResultAd
return statCache;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagResults::calculateSumOfFractions(const std::vector<const std::vector<double> *> &fractions,
size_t activeCellCount,
std::vector<double>* sumOfFractions)
{
sumOfFractions->resize(activeCellCount, HUGE_VAL);
for ( size_t iIdx = 0; iIdx < fractions.size() ; ++iIdx )
{
const std::vector<double> * fraction = fractions[iIdx];
if ( ! (fraction) ) continue;
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
{
if ( (*fraction)[acIdx] == HUGE_VAL ) continue;
if ( (*sumOfFractions)[acIdx] == HUGE_VAL ) (*sumOfFractions)[acIdx] = 0.0;
(*sumOfFractions)[acIdx] += (*fraction)[acIdx];
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -29,9 +29,9 @@
#include "RigFlowDiagResultFrames.h"
#include "RigStatisticsDataCache.h"
#include "cafPdmPointer.h"
#include "RimFlowDiagSolution.h"
class RigFlowDiagSolverInterface;
class RimFlowDiagSolution;
class RigActiveCellInfo;
class RigFlowDiagResults: public cvf::Object
@ -44,7 +44,6 @@ public:
size_t timeStepCount() { return m_timeStepCount; }
const RigActiveCellInfo * activeCellInfo(const RigFlowDiagResultAddress& resVarAddr);
void minMaxScalarValues (const RigFlowDiagResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax);
void minMaxScalarValues (const RigFlowDiagResultAddress& resVarAddr, double* globalMin, double* globalMax);
void posNegClosestToZero(const RigFlowDiagResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero);
@ -63,12 +62,23 @@ public:
private:
const std::vector<double>* findOrCalculateResult (const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
std::vector<double>* calculateDerivedResult(const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
RigStatisticsDataCache* statistics(const RigFlowDiagResultAddress& resVarAddr);
void calculateFractionWeightedTOF (size_t timeStepIdx, std::set<std::string> selectedTracerNames);
void calculateSumOfFractions ( size_t timeStepIdx, std::set<std::string> selectedTracerNames);
void calculateTracerWithMaxFraction( size_t timeStepIdx, std::set<std::string> selectedTracerNames); // Needs a tracer index
void calculateCommunication ( size_t timeStepIdx, std::set<std::string> selectedTracerNames);
std::vector<const std::vector<double>* > findResultsForSelectedTracers(const RigFlowDiagResultAddress& resVarAddr,
size_t frameIndex,
const std::string& nativeResultName,
RimFlowDiagSolution::TracerStatusType wantedTracerType);
void calculateSumOfFractionAndFractionMultTOF(size_t activeCellCount,
const std::vector<const std::vector<double> *>& injectorFractions,
const std::vector<const std::vector<double> *>& injectorTOFs,
std::vector<double> *injectorTotalFractions,
std::vector<double> *injectorFractMultTof);
void calculateSumOfFractions(const std::vector<const std::vector<double> *> &fractions,
size_t activeCellCount,
std::vector<double>* sumOfFractions);
RigStatisticsDataCache* statistics(const RigFlowDiagResultAddress& resVarAddr);
RigFlowDiagResultFrames* createScalarResult(const RigFlowDiagResultAddress& resVarAddr);
RigFlowDiagResultFrames* findScalarResult (const RigFlowDiagResultAddress& resVarAddr) ;
@ -76,16 +86,16 @@ private:
//void deleteScalarResult(const RigFlowDiagResultAddress& resVarAddr);
RigFlowDiagSolverInterface* solverInterface();
size_t m_timeStepCount;
caf::PdmPointer<RimFlowDiagSolution> m_flowDiagSolution;
std::vector<bool> m_hasAtemptedNativeResults;
std::map< RigFlowDiagResultAddress, cvf::ref<RigFlowDiagResultFrames> > m_resultSets;
std::map< RigFlowDiagResultAddress, cvf::ref<RigStatisticsDataCache> > m_resultStatistics;
RigFlowDiagSolverInterface* solverInterface();
caf::PdmPointer<RimFlowDiagSolution> m_flowDiagSolution;
std::vector<bool> m_hasAtemptedNativeResults;
};

View File

@ -54,7 +54,7 @@ RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* pare
{
setWindowTitle("Export Multiple Snapshots");
int nWidth = 800;
int nWidth = 1000;
int nHeight = 300;
resize(nWidth, nHeight);
@ -72,6 +72,8 @@ RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* pare
QHeaderView* verticalHeader = m_pdmTableView->tableView()->verticalHeader();
verticalHeader->setResizeMode(QHeaderView::Interactive);
m_pdmTableView->tableView()->resizeColumnsToContents();
// Set active child array to be able to use generic delete
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&(project->multiSnapshotDefinitions()));
@ -124,6 +126,26 @@ RiuExportMultipleSnapshotsWidget::~RiuExportMultipleSnapshotsWidget()
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(nullptr);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuExportMultipleSnapshotsWidget::addSnapshotItemFromActiveView()
{
if (!m_rimProject) return;
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (activeView)
{
RimMultiSnapshotDefinition* multiSnapshot = new RimMultiSnapshotDefinition();
multiSnapshot->viewObject = activeView;
multiSnapshot->timeStepStart = activeView->currentTimeStep();
multiSnapshot->timeStepEnd = activeView->currentTimeStep();
m_rimProject->multiSnapshotDefinitions.push_back(multiSnapshot);
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -194,40 +216,22 @@ void RiuExportMultipleSnapshotsWidget::addSnapshotItem()
{
if (!m_rimProject) return;
RimMultiSnapshotDefinition* multiSnapshot = new RimMultiSnapshotDefinition();
if (m_rimProject->multiSnapshotDefinitions.size() > 0)
if (m_rimProject->multiSnapshotDefinitions.size() == 0)
{
addSnapshotItemFromActiveView();
}
else
{
//Getting default value from last entered line:
RimMultiSnapshotDefinition* other = m_rimProject->multiSnapshotDefinitions[m_rimProject->multiSnapshotDefinitions.size() - 1];
RimMultiSnapshotDefinition* multiSnapshot = new RimMultiSnapshotDefinition();
multiSnapshot->viewObject = other->viewObject();
multiSnapshot->timeStepStart = other->timeStepStart();
multiSnapshot->timeStepEnd = other->timeStepEnd();
}
else
{
RimProject* proj = RiaApplication::instance()->project();
std::vector<RimCase*> cases;
proj->allCases(cases);
if (cases.size() > 0)
{
RimCase* caseExample = cases.at(0);
std::vector<RimView*> viewExamples;
viewExamples = caseExample->views();
if (viewExamples.size() > 0)
{
RimView* viewExample = viewExamples.at(0);
multiSnapshot->viewObject = viewExample;
multiSnapshot->timeStepStart = viewExample->currentTimeStep();
multiSnapshot->timeStepEnd = viewExample->currentTimeStep();
}
}
}
m_rimProject->multiSnapshotDefinitions.push_back(multiSnapshot);
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
}
}

View File

@ -36,6 +36,8 @@ public:
RiuExportMultipleSnapshotsWidget(QWidget* parent, RimProject* project);
~RiuExportMultipleSnapshotsWidget();
void addSnapshotItemFromActiveView();
private slots:
void customMenuRequested(QPoint pos);
void addSnapshotItem();

View File

@ -219,7 +219,7 @@ RiuWellPathSelectionItem::RiuWellPathSelectionItem(const RivWellPathSourceInfo*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuSimWellSelectionItem::RiuSimWellSelectionItem(const RivEclipseWellSourceInfo* simwellSourceInfo,
RiuSimWellSelectionItem::RiuSimWellSelectionItem(const RivSimWellPipeSourceInfo* simwellSourceInfo,
size_t i,
size_t j,
size_t k)

View File

@ -37,7 +37,7 @@ class RiuSelectionItem;
class RimGeoMechView;
class RimWellPath;
class RivWellPathSourceInfo;
class RivEclipseWellSourceInfo;
class RivSimWellPipeSourceInfo;
//==================================================================================================
//
@ -221,7 +221,7 @@ public:
class RiuSimWellSelectionItem : public RiuSelectionItem
{
public:
explicit RiuSimWellSelectionItem(const RivEclipseWellSourceInfo* simwellSourceInfo,
explicit RiuSimWellSelectionItem(const RivSimWellPipeSourceInfo* simwellSourceInfo,
size_t i, size_t j, size_t k);
@ -234,7 +234,7 @@ public:
public:
caf::PdmPointer<RimEclipseView> m_view;
const RivEclipseWellSourceInfo* m_simwellSourceInfo;
const RivSimWellPipeSourceInfo* m_simwellSourceInfo;
size_t i;
size_t j;
size_t k;

View File

@ -65,7 +65,7 @@
#include "RivSourceInfo.h"
#include "RivTernarySaturationOverlayItem.h"
#include "RivWellPathSourceInfo.h"
#include "RivWellPipeSourceInfo.h"
#include "RivSimWellPipeSourceInfo.h"
#include "cafCmdExecCommandManager.h"
#include "cafCmdFeatureManager.h"
@ -307,7 +307,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
}
}
const RivEclipseWellSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivEclipseWellSourceInfo*>(firstHitPart->sourceInfo());
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(firstHitPart->sourceInfo());
if (eclipseWellSourceInfo)
{
RimEclipseWell* well = eclipseWellSourceInfo->well();
@ -526,7 +526,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionSourceInfo* crossSectionSourceInfo = dynamic_cast<const RivIntersectionSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo = dynamic_cast<const RivIntersectionBoxSourceInfo*>(firstHitPart->sourceInfo());
const RivEclipseWellSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivEclipseWellSourceInfo*>(firstHitPart->sourceInfo());
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(firstHitPart->sourceInfo());
if (rivSourceInfo)
{

View File

@ -192,35 +192,39 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
PdmFieldHandle* fieldHandle = getField(index);
if (dynamic_cast<PdmPtrArrayFieldHandle*>(fieldHandle))
{
PdmPtrArrayFieldHandle* ptrArrayFieldHandle = dynamic_cast<PdmPtrArrayFieldHandle*>(fieldHandle);
QString displayText;
for (size_t i = 0; i < ptrArrayFieldHandle->size(); i++)
{
PdmObjectHandle* objHandle = ptrArrayFieldHandle->at(i);
if (objHandle && objHandle->uiCapability())
{
PdmUiObjectHandle* uiObjHandle = objHandle->uiCapability();
if (!displayText.isEmpty()) displayText += ", ";
caf::PdmUiFieldHandle* uiFieldHandle = uiObjHandle->userDescriptionField()->uiCapability();
PdmUiFieldHandle* uiFieldHandle = fieldHandle->uiCapability();
if (uiFieldHandle)
{
displayText += uiFieldHandle->uiValue().toString();
QVariant fieldValue = uiFieldHandle->uiValue();
if (fieldValue.type() == QVariant::List)
{
QString displayText;
QList<QVariant> valuesSelectedInField = fieldValue.toList();
if (valuesSelectedInField.size() > 0)
{
QList<PdmOptionItemInfo> options;
bool useOptionsOnly = true;
options = uiFieldHandle->valueOptions(&useOptionsOnly);
for (QVariant v : valuesSelectedInField)
{
int index = v.toInt();
if (index != -1)
{
if (!displayText.isEmpty()) displayText += ", ";
displayText += options.at(index).optionUiText;
}
}
}
return displayText;
}
PdmUiFieldHandle* uiFieldHandle = fieldHandle->uiCapability();
if (uiFieldHandle)
{
bool fromMenuOnly = false;
QList<PdmOptionItemInfo> valueOptions = uiFieldHandle->valueOptions(&fromMenuOnly);
bool useOptionsOnly = false;
QList<PdmOptionItemInfo> valueOptions = uiFieldHandle->valueOptions(&useOptionsOnly);
if (!valueOptions.isEmpty())
{
int listIndex = uiFieldHandle->uiValue().toInt();