mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added grid collection and reuse of MainGrid if the grids are equal
p4#: 20517
This commit is contained in:
@@ -94,8 +94,9 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames)
|
||||
{
|
||||
m_gridFileName = filenames[i];
|
||||
|
||||
registerEclipseCase();
|
||||
|
||||
m_rigEclipseCase->computeCachedData();
|
||||
m_rigEclipseCase->mainGrid()->computeCachedData();
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -175,6 +176,8 @@ bool RimInputReservoir::openEclipseGridFile()
|
||||
}
|
||||
|
||||
m_rigEclipseCase = eclipseCase;
|
||||
|
||||
registerEclipseCase();
|
||||
loadAndSyncronizeInputProperties();
|
||||
}
|
||||
|
||||
@@ -184,7 +187,6 @@ bool RimInputReservoir::openEclipseGridFile()
|
||||
m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
|
||||
m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
|
||||
m_rigEclipseCase->computeCachedData();
|
||||
m_rigEclipseCase->mainGrid()->computeCachedData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include "RIApplication.h"
|
||||
#include "RIVersionInfo.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RigGridCollection.h"
|
||||
#include "RigEclipseCase.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -38,6 +41,8 @@ RimProject::RimProject(void)
|
||||
scriptCollection = new RimScriptCollection();
|
||||
scriptCollection->directory.setUiHidden(true);
|
||||
|
||||
m_gridCollection = new RigGridCollection;
|
||||
|
||||
initAfterRead();
|
||||
}
|
||||
|
||||
@@ -46,6 +51,8 @@ RimProject::RimProject(void)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimProject::~RimProject(void)
|
||||
{
|
||||
close();
|
||||
|
||||
if (scriptCollection()) delete scriptCollection();
|
||||
|
||||
reservoirs.deleteAllChildObjects();
|
||||
@@ -56,6 +63,11 @@ RimProject::~RimProject(void)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::close()
|
||||
{
|
||||
for (size_t i = 0; i < reservoirs.size(); i++)
|
||||
{
|
||||
m_gridCollection->removeCase(reservoirs[i]->reservoirData());
|
||||
}
|
||||
|
||||
reservoirs.deleteAllChildObjects();
|
||||
|
||||
fileName = "";
|
||||
@@ -113,3 +125,35 @@ QString RimProject::projectFileVersionString() const
|
||||
{
|
||||
return m_projectFileVersionString;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::registerEclipseCase(RigEclipseCase* eclipseCase)
|
||||
{
|
||||
CVF_ASSERT(eclipseCase);
|
||||
|
||||
RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(eclipseCase->mainGrid());
|
||||
|
||||
if (equalGrid)
|
||||
{
|
||||
// Replace the grid with an already registered grid
|
||||
eclipseCase->setMainGrid(equalGrid);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is the first insertion of this grid, compute cached data
|
||||
eclipseCase->mainGrid()->computeCachedData();
|
||||
|
||||
std::vector<RigGridBase*> grids;
|
||||
eclipseCase->allGrids(&grids);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < grids.size(); i++)
|
||||
{
|
||||
grids[i]->computeFaults();
|
||||
}
|
||||
}
|
||||
|
||||
m_gridCollection->addCase(eclipseCase);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "RimScriptCollection.h"
|
||||
|
||||
class RimReservoir;
|
||||
class RigGridCollection;
|
||||
class RigEclipseCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -45,6 +47,8 @@ public:
|
||||
|
||||
void close();
|
||||
|
||||
void registerEclipseCase(RigEclipseCase* eclipseCase);
|
||||
|
||||
protected:
|
||||
// Overridden methods
|
||||
virtual void initAfterRead();
|
||||
@@ -52,4 +56,6 @@ protected:
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_projectFileVersionString;
|
||||
|
||||
cvf::ref<RigGridCollection> m_gridCollection;
|
||||
};
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
#include <QString>
|
||||
#include "RimProject.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -226,3 +227,27 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoir::registerEclipseCase()
|
||||
{
|
||||
std::vector<caf::PdmObject*> parentObjects;
|
||||
this->parentObjects(parentObjects);
|
||||
|
||||
RimProject* proj = NULL;
|
||||
for (size_t i = 0; i < parentObjects.size(); i++)
|
||||
{
|
||||
if (proj) continue;
|
||||
|
||||
caf::PdmObject* obj = parentObjects[i];
|
||||
proj = dynamic_cast<RimProject*>(obj);
|
||||
}
|
||||
|
||||
CVF_ASSERT(proj);
|
||||
if (proj)
|
||||
{
|
||||
proj->registerEclipseCase(m_rigEclipseCase.p());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ protected:
|
||||
|
||||
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
|
||||
|
||||
void registerEclipseCase();
|
||||
|
||||
protected:
|
||||
cvf::ref<RigEclipseCase> m_rigEclipseCase;
|
||||
};
|
||||
|
||||
@@ -84,12 +84,13 @@ bool RimResultReservoir::openEclipseGridFile()
|
||||
CVF_ASSERT(m_rigEclipseCase.notNull());
|
||||
CVF_ASSERT(readerInterface.notNull());
|
||||
|
||||
progInfo.setProgressDescription("Computing Faults");
|
||||
m_rigEclipseCase->computeCachedData();
|
||||
|
||||
progInfo.setProgressDescription("Registering Case and Grid");
|
||||
registerEclipseCase();
|
||||
|
||||
progInfo.incrementProgress();
|
||||
progInfo.setProgressDescription("Computing Cache");
|
||||
m_rigEclipseCase->mainGrid()->computeCachedData();
|
||||
progInfo.setProgressDescription("Computing Case Cache");
|
||||
m_rigEclipseCase->computeCachedData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user