#885 Time lapse derived results. Works, but needs polish and testing

This commit is contained in:
Jacob Støren
2016-10-10 16:09:54 +02:00
parent fd71ea3aa6
commit d0c70f1653
6 changed files with 192 additions and 37 deletions

View File

@@ -330,11 +330,48 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateEnIpPorBarResult
return dstDataFrames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResultsCollection::calculateTimeLapseResult(int partIndex, const RigFemResultAddress& resVarAddr)
{
CVF_ASSERT(resVarAddr.isTimeLapse());
RigFemResultAddress resVarNative(resVarAddr.resultPosType, resVarAddr.fieldName, resVarAddr.componentName);
RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, resVarNative);
RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
int frameCount = srcDataFrames->frameCount();
int baseFrameIdx = resVarAddr.timeLapseBaseFrameIdx;
if (baseFrameIdx >= frameCount) return dstDataFrames;
const std::vector<float>& baseFrameData = srcDataFrames->frameData(baseFrameIdx);
for(int fIdx = 0; fIdx < frameCount; ++fIdx)
{
const std::vector<float>& srcFrameData = srcDataFrames->frameData(fIdx);
std::vector<float>& dstFrameData = dstDataFrames->frameData(fIdx);
size_t valCount = srcFrameData.size();
dstFrameData.resize(valCount);
for(size_t vIdx = 0; vIdx < valCount; ++vIdx)
{
dstFrameData[vIdx] = srcFrameData[vIdx] - baseFrameData[vIdx];
}
}
return dstDataFrames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr)
{
if (resVarAddr.isTimeLapse())
{
return calculateTimeLapseResult(partIndex, resVarAddr);
}
if (resVarAddr.fieldName == "S-Bar")
{
return calculateBarConvertedResult(partIndex, resVarAddr, "S");

View File

@@ -72,6 +72,7 @@ private:
RigFemScalarResultFrames* calculateBarConvertedResult(int partIndex, const RigFemResultAddress &convertedResultAddr, const std::string fieldNameToConvert);
RigFemScalarResultFrames* calculateEnIpPorBarResult(int partIndex, const RigFemResultAddress &convertedResultAddr);
RigFemScalarResultFrames* calculateTimeLapseResult(int partIndex, const RigFemResultAddress& resVarAddr);
cvf::Collection<RigFemPartResults> m_femPartResults;
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;

View File

@@ -32,12 +32,28 @@ public:
RigFemResultAddress(RigFemResultPosEnum resPosType,
const std::string& aFieldName,
const std::string& aComponentName)
: resultPosType(resPosType), fieldName(aFieldName), componentName(aComponentName)
: resultPosType(resPosType),
fieldName(aFieldName),
componentName(aComponentName),
timeLapseBaseFrameIdx(-1)
{}
RigFemResultAddress(RigFemResultPosEnum resPosType,
const std::string& aFieldName,
const std::string& aComponentName,
int aTimeLapseBaseFrame)
: resultPosType(resPosType),
fieldName(aFieldName),
componentName(aComponentName),
timeLapseBaseFrameIdx(aTimeLapseBaseFrame)
{}
RigFemResultPosEnum resultPosType;
std::string fieldName;
std::string componentName;
int timeLapseBaseFrameIdx;
bool isTimeLapse() const { return timeLapseBaseFrameIdx >= 0;}
bool isValid() const
{
@@ -46,11 +62,17 @@ RigFemResultAddress(RigFemResultPosEnum resPosType,
|| resultPosType == RIG_INTEGRATION_POINT
|| resultPosType == RIG_FORMATION_NAMES;
bool isFieldValid = fieldName != "";
return isTypeValid && isFieldValid;
}
bool operator< (const RigFemResultAddress& other ) const
{
if (timeLapseBaseFrameIdx != other.timeLapseBaseFrameIdx)
{
return (timeLapseBaseFrameIdx < other.timeLapseBaseFrameIdx);
}
if (resultPosType != other.resultPosType)
{
return (resultPosType < other.resultPosType);
@@ -60,7 +82,7 @@ RigFemResultAddress(RigFemResultPosEnum resPosType,
{
return (fieldName < other.fieldName);
}
return (componentName < other.componentName);
}
};