Created RigFemPartResultsCollection

Refactored the results stuff from GeoMechCaseData into the new class
preparing to extend the statistics calculation
This commit is contained in:
Jacob Støren 2015-06-04 11:54:21 +02:00
parent 60c9b72671
commit a3fa27d2ec
7 changed files with 85 additions and 41 deletions

View File

@ -38,7 +38,6 @@
RigGeoMechCaseData::RigGeoMechCaseData(const std::string& fileName)
{
m_geoMechCaseFileName = fileName;
m_femParts = new RigFemPartCollection();
}
//--------------------------------------------------------------------------------------------------
@ -65,6 +64,14 @@ const RigFemPartCollection* RigGeoMechCaseData::femParts() const
return m_femParts.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigFemPartResultsCollection* RigGeoMechCaseData::femPartResults() const
{
return m_femPartResultsColl.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -87,13 +94,7 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage)
progress.setProgressDescription("Calculating element neighbors");
// Initialize results containers
m_femPartResults.resize(m_femParts->partCount());
std::vector<std::string> stepNames = m_readerInterface->stepNames();
for (int pIdx = 0; pIdx < static_cast<int>(m_femPartResults.size()); ++pIdx)
{
m_femPartResults[pIdx] = new RigFemPartResults;
m_femPartResults[pIdx]->initResultSteps(stepNames);
}
m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_femParts->partCount());
// Calculate derived Fem data
for (int pIdx = 0; pIdx < m_femParts->partCount(); ++pIdx)
@ -110,7 +111,32 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > RigGeoMechCaseData::scalarFieldAndComponentNames(RigFemResultPosEnum resPos)
RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, int partCount)
{
CVF_ASSERT(readerInterface);
m_readerInterface = readerInterface;
m_femPartResults.resize(partCount);
std::vector<std::string> stepNames = m_readerInterface->stepNames();
for (int pIdx = 0; pIdx < static_cast<int>(m_femPartResults.size()); ++pIdx)
{
m_femPartResults[pIdx] = new RigFemPartResults;
m_femPartResults[pIdx]->initResultSteps(stepNames);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartResultsCollection::~RigFemPartResultsCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > RigFemPartResultsCollection::scalarFieldAndComponentNames(RigFemResultPosEnum resPos)
{
std::map<std::string, std::vector<std::string> > fieldCompNames;
@ -136,10 +162,10 @@ std::map<std::string, std::vector<std::string> > RigGeoMechCaseData::scalarField
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partIndex,
RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(int partIndex,
const RigFemResultAddress& resVarAddr)
{
CVF_ASSERT(partIndex < m_femParts->partCount());
CVF_ASSERT(partIndex < m_femPartResults.size());
CVF_ASSERT(m_readerInterface.notNull());
RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr);
@ -175,7 +201,7 @@ RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partInd
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RigGeoMechCaseData::stepNames()
std::vector<std::string> RigFemPartResultsCollection::stepNames()
{
CVF_ASSERT(m_readerInterface.notNull());
return m_readerInterface->stepNames();
@ -184,7 +210,7 @@ std::vector<std::string> RigGeoMechCaseData::stepNames()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex,
void RigFemPartResultsCollection::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex,
double* localMin, double* localMax)
{
minMaxScalarValuesInternal(resVarAddr, frameIndex, localMin, localMax);
@ -193,7 +219,7 @@ void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAdd
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr,
void RigFemPartResultsCollection::minMaxScalarValues(const RigFemResultAddress& resVarAddr,
double* globalMin, double* globalMax)
{
minMaxScalarValuesInternal(resVarAddr, -1, globalMin, globalMax);
@ -202,7 +228,7 @@ void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAdd
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex, double* overallMin, double* overallMax)
void RigFemPartResultsCollection::minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex, double* overallMin, double* overallMax)
{
CVF_ASSERT(overallMax && overallMin);
@ -241,7 +267,7 @@ void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& r
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero)
void RigFemPartResultsCollection::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero)
{
posNegClosestToZeroInternal(resVarAddr, frameIndex, localPosClosestToZero, localNegClosestToZero);
}
@ -249,7 +275,7 @@ void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAd
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero)
void RigFemPartResultsCollection::posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero)
{
posNegClosestToZeroInternal(resVarAddr, -1, globalPosClosestToZero, globalNegClosestToZero);
}
@ -257,7 +283,7 @@ void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAd
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
void RigFemPartResultsCollection::posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
double* overallPosClosestToZero, double* overallNegClosestToZero)
{
CVF_ASSERT(overallPosClosestToZero && overallNegClosestToZero);
@ -298,7 +324,7 @@ void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::meanCellScalarValues(const RigFemResultAddress& resVarAddr, double* meanValue)
void RigFemPartResultsCollection::meanCellScalarValues(const RigFemResultAddress& resVarAddr, double* meanValue)
{
CVF_ASSERT(meanValue);
@ -329,7 +355,7 @@ void RigGeoMechCaseData::meanCellScalarValues(const RigFemResultAddress& resVarA
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigGeoMechCaseData::frameCount()
int RigFemPartResultsCollection::frameCount()
{
return static_cast<int>(stepNames().size());
}
@ -337,7 +363,7 @@ int RigGeoMechCaseData::frameCount()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::assertResultsLoaded( const RigFemResultAddress& resVarAddr)
void RigFemPartResultsCollection::assertResultsLoaded( const RigFemResultAddress& resVarAddr)
{
for (int pIdx = 0; pIdx < static_cast<int>(m_femPartResults.size()); ++pIdx)
{
@ -351,7 +377,7 @@ void RigGeoMechCaseData::assertResultsLoaded( const RigFemResultAddress& resVarA
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<float>& RigGeoMechCaseData::resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex)
const std::vector<float>& RigFemPartResultsCollection::resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex)
{
RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult(partIndex, resVarAddr);
return scalarResults->frameData(frameIndex);

View File

@ -30,6 +30,7 @@
class RifGeoMechReaderInterface;
class RigFemPartCollection;
class RigFemScalarResultFrames;
class RigFemPartResultsCollection;
class RigGeoMechCaseData: public cvf::Object
{
@ -42,6 +43,22 @@ public:
RigFemPartCollection* femParts();
const RigFemPartCollection* femParts() const;
RigFemPartResultsCollection* femPartResults();
const RigFemPartResultsCollection* femPartResults() const;
private:
std::string m_geoMechCaseFileName;
cvf::ref<RigFemPartCollection> m_femParts;
cvf::ref<RigFemPartResultsCollection> m_femPartResultsColl;
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
};
class RigFemPartResultsCollection: public cvf::Object
{
public:
RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, int partCount);
~RigFemPartResultsCollection();
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(RigFemResultPosEnum resPos);
std::vector<std::string> stepNames();
void assertResultsLoaded(const RigFemResultAddress& resVarAddr);
@ -49,6 +66,7 @@ public:
int frameCount();
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero);
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax);
@ -59,14 +77,14 @@ private:
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
const RigFemResultAddress& resVarAddr);
void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
double* overallMin, double* overallMax);
void posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
double* localPosClosestToZero, double* localNegClosestToZero);
std::string m_geoMechCaseFileName;
cvf::ref<RigFemPartCollection> m_femParts;
cvf::Collection<RigFemPartResults> m_femPartResults;
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
};

View File

@ -236,7 +236,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechRe
RigFemResultAddress resVarAddress(resPosType, fieldName.toStdString(), compName.toStdString());
const std::vector<float>& resultValues = caseData->resultValues(resVarAddress, m_gridIdx, timeStepIndex);
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, timeStepIndex);
const std::vector<size_t>* vxToResultMapping = NULL;

View File

@ -330,8 +330,8 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView)
double mean = 0;
RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress();
caseData->meanCellScalarValues(resAddress, &mean);
caseData->minMaxScalarValues(resAddress,&min, &max);
caseData->femPartResults()->meanCellScalarValues(resAddress, &mean);
caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max);
// ToDo: Implement statistics for geomech data
@ -346,7 +346,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView)
}
int currentTimeStep = geoMechView->currentTimeStep();
QString stepName = QString::fromStdString(caseData->stepNames()[currentTimeStep]);
QString stepName = QString::fromStdString(caseData->femPartResults()->stepNames()[currentTimeStep]);
infoText += QString("<b>Time Step:</b> %1 <b>Time:</b> %2").arg(currentTimeStep).arg(stepName);
}
}
@ -378,13 +378,13 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView)
double mean = 0;
RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress();
caseData->meanCellScalarValues(resAddress, &mean);
caseData->minMaxScalarValues(resAddress,&min, &max);
caseData->femPartResults()->meanCellScalarValues(resAddress, &mean);
caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max);
// ToDo: Implement statistics for geomech data
//caseData->p10p90CellScalarValues(resAddress, p10, p90);
caseData->minMaxScalarValues(resAddress, &min, &max);
caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max);
//geoMechView->viewer()->setHistogram(min, max, caseData->scalarValuesHistogram(resAddress));
geoMechView->viewer()->setHistogramPercentiles(p10, p90, mean);
}

View File

@ -173,7 +173,7 @@ void RimGeoMechResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedFi
m_resultComponentName = "";
}
m_reservoirView->geoMechCase()->geoMechData()->assertResultsLoaded(this->resultAddress());
m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress());
if (m_reservoirView)
{
@ -192,7 +192,7 @@ std::map<std::string, std::vector<std::string> > RimGeoMechResultSlot::getResult
RimGeoMechCase* gmCase = m_reservoirView->geoMechCase();
if (gmCase && gmCase->geoMechData())
{
return gmCase->geoMechData()->scalarFieldAndComponentNames(m_resultPositionTypeUiField());
return gmCase->geoMechData()->femPartResults()->scalarFieldAndComponentNames(m_resultPositionTypeUiField());
}
else
{

View File

@ -140,7 +140,7 @@ void RimGeoMechView::loadDataAndUpdate()
progress.setProgressDescription("Reading Current Result");
CVF_ASSERT(this->cellResult() != NULL);
m_geomechCase->geoMechData()->assertResultsLoaded(this->cellResult()->resultAddress());
m_geomechCase->geoMechData()->femPartResults()->assertResultsLoaded(this->cellResult()->resultAddress());
progress.incrementProgress();
progress.setProgressDescription("Create Display model");
@ -203,7 +203,7 @@ void RimGeoMechView::createDisplayModel()
if (isTimeStepDependentDataVisible())
{
int i;
for (i = 0; i < geoMechCase()->geoMechData()->frameCount(); ++i)
for (i = 0; i < geoMechCase()->geoMechData()->femPartResults()->frameCount(); ++i)
{
timeStepIndices.push_back(i);
}
@ -383,11 +383,11 @@ void RimGeoMechView::updateLegends()
RigFemResultAddress resVarAddress = cellResult->resultAddress();
if (resVarAddress.fieldName != "")
{
gmCase->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax);
gmCase->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax);
gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
gmCase->minMaxScalarValues(resVarAddress, &globalMin, &globalMax);
gmCase->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero);
gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax);
gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero);
cellResult->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
@ -424,7 +424,7 @@ void RimGeoMechView::clampCurrentTimestep()
int maxFrameCount = 0;
if (m_geomechCase){
maxFrameCount = m_geomechCase->geoMechData()->frameCount();
maxFrameCount = m_geomechCase->geoMechData()->femPartResults()->frameCount();
}
if (m_currentTimeStep >= maxFrameCount ) m_currentTimeStep = maxFrameCount -1;

View File

@ -764,7 +764,7 @@ void RiuMainWindow::refreshAnimationActions()
{
if (activeGmv->isTimeStepDependentDataVisible())
{
std::vector<std::string> stepNames = activeGmv->geoMechCase()->geoMechData()->stepNames();
std::vector<std::string> stepNames = activeGmv->geoMechCase()->geoMechData()->femPartResults()->stepNames();
for (size_t i = 0; i < stepNames.size(); i++)
{
timeStepStrings += QString::fromStdString(stepNames[i]);