#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; 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) RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr)
{ {
if (resVarAddr.isTimeLapse())
{
return calculateTimeLapseResult(partIndex, resVarAddr);
}
if (resVarAddr.fieldName == "S-Bar") if (resVarAddr.fieldName == "S-Bar")
{ {
return calculateBarConvertedResult(partIndex, resVarAddr, "S"); return calculateBarConvertedResult(partIndex, resVarAddr, "S");

View File

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

View File

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

View File

@ -134,8 +134,7 @@ void RimGeoMechPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUi
uiOrdering.add(&name); uiOrdering.add(&name);
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result"); caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result");
group1->add(&(resultDefinition->m_resultPositionTypeUiField)); resultDefinition->defineUiOrdering(uiConfigName, *group1);
group1->add(&(resultDefinition->m_resultVariableUiField));
uiOrdering.add(&isActive); uiOrdering.add(&isActive);
uiOrdering.add(&filterMode); uiOrdering.add(&filterMode);
@ -171,6 +170,8 @@ void RimGeoMechPropertyFilter::updateReadOnlyStateOfAllFields()
// Include fields declared in RimResultDefinition // Include fields declared in RimResultDefinition
objFields.push_back(&(resultDefinition->m_resultPositionTypeUiField)); objFields.push_back(&(resultDefinition->m_resultPositionTypeUiField));
objFields.push_back(&(resultDefinition->m_resultVariableUiField)); objFields.push_back(&(resultDefinition->m_resultVariableUiField));
objFields.push_back(&(resultDefinition->m_isTimeLapseResultUiField));
objFields.push_back(&(resultDefinition->m_timeLapseBaseTimestepUiField));
for (size_t i = 0; i < objFields.size(); i++) for (size_t i = 0; i < objFields.size(); i++)
{ {

View File

@ -61,11 +61,19 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void)
CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType" , "Result Position", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType" , "Result Position", "", "", "");
m_resultPositionType.uiCapability()->setUiHidden(true); m_resultPositionType.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_resultFieldName, "ResultFieldName", QString(""), "Field Name", "", "", ""); CAF_PDM_InitField(&m_resultFieldName, "ResultFieldName", QString(""), "Field Name", "", "", "");
m_resultFieldName.uiCapability()->setUiHidden(true); m_resultFieldName.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", QString(""), "Component", "", "", ""); CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", QString(""), "Component", "", "", "");
m_resultComponentName.uiCapability()->setUiHidden(true); m_resultComponentName.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_isTimeLapseResult, "IsTimeLapseResult", false, "TimeLapseResult", "", "", "");
m_isTimeLapseResult.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", 0, "Base Time Step", "", "", "");
m_timeLapseBaseTimestep.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", "");
m_resultPositionTypeUiField.xmlCapability()->setIOWritable(false); m_resultPositionTypeUiField.xmlCapability()->setIOWritable(false);
m_resultPositionTypeUiField.xmlCapability()->setIOReadable(false); m_resultPositionTypeUiField.xmlCapability()->setIOReadable(false);
@ -74,8 +82,19 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void)
m_resultVariableUiField.xmlCapability()->setIOWritable(false); m_resultVariableUiField.xmlCapability()->setIOWritable(false);
m_resultVariableUiField.xmlCapability()->setIOReadable(false); m_resultVariableUiField.xmlCapability()->setIOReadable(false);
CAF_PDM_InitField(&m_isTimeLapseResultUiField, "IsTimeLapseResultUI", false, "Type", "", "", "");
m_isTimeLapseResultUiField.xmlCapability()->setIOWritable(false);
m_isTimeLapseResultUiField.xmlCapability()->setIOReadable(false);
CAF_PDM_InitField(&m_timeLapseBaseTimestepUiField, "TimeLapseBaseTimeStepUI", 0, "Base Time Step", "", "", "");
m_timeLapseBaseTimestepUiField.xmlCapability()->setIOWritable(false);
m_timeLapseBaseTimestepUiField.xmlCapability()->setIOReadable(false);
m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -86,6 +105,20 @@ RimGeoMechResultDefinition::~RimGeoMechResultDefinition(void)
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_isTimeLapseResultUiField);
if (m_isTimeLapseResultUiField())
uiOrdering.add(&m_timeLapseBaseTimestepUiField);
uiOrdering.add(&m_resultPositionTypeUiField);
uiOrdering.add(&m_resultVariableUiField);
uiOrdering.setForgetRemainingFields(true);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -108,6 +141,24 @@ QList<caf::PdmOptionItemInfo> RimGeoMechResultDefinition::calculateValueOptions(
options.push_back(caf::PdmOptionItemInfo(uiVarNames[oIdx], varNames[oIdx])); options.push_back(caf::PdmOptionItemInfo(uiVarNames[oIdx], varNames[oIdx]));
} }
} }
else if (&m_isTimeLapseResultUiField == fieldNeedingOptions)
{
options.push_back(caf::PdmOptionItemInfo("Absolute", false));
options.push_back(caf::PdmOptionItemInfo("Time Lapse", true));
}
else if (&m_timeLapseBaseTimestepUiField == fieldNeedingOptions)
{
std::vector<std::string> stepNames;
if(m_geomCase->geoMechData())
{
stepNames = m_geomCase->geoMechData()->femPartResults()->stepNames();
}
for (size_t stepIdx = 0; stepIdx < stepNames.size(); ++stepIdx)
{
options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(stepNames[stepIdx]), stepIdx));
}
}
} }
return options; return options;
@ -165,6 +216,8 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
// Complete string of selected formation is stored in m_resultFieldName // Complete string of selected formation is stored in m_resultFieldName
m_resultFieldName = m_resultVariableUiField(); m_resultFieldName = m_resultVariableUiField();
m_resultComponentName = ""; m_resultComponentName = "";
m_isTimeLapseResult = false;
m_timeLapseBaseTimestep = 0;
} }
else else
{ {
@ -177,6 +230,9 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
{ {
m_resultComponentName = ""; m_resultComponentName = "";
} }
m_isTimeLapseResult = m_isTimeLapseResultUiField();
m_timeLapseBaseTimestep = m_timeLapseBaseTimestepUiField();
} }
if (m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) if (m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress()))
@ -244,7 +300,8 @@ std::map<std::string, std::vector<std::string> > RimGeoMechResultDefinition::get
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition::getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames, void RimGeoMechResultDefinition::getUiAndResultVariableStringList(QStringList* uiNames,
QStringList* variableNames,
const std::map<std::string, std::vector<std::string> >& fieldCompNames) const std::map<std::string, std::vector<std::string> >& fieldCompNames)
{ {
CVF_ASSERT(uiNames && variableNames); CVF_ASSERT(uiNames && variableNames);
@ -290,7 +347,8 @@ void RimGeoMechResultDefinition::initAfterRead()
{ {
m_resultPositionTypeUiField = m_resultPositionType; m_resultPositionTypeUiField = m_resultPositionType;
m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName()); m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName());
m_isTimeLapseResultUiField = m_isTimeLapseResult;
m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep;
} }
@ -305,6 +363,18 @@ void RimGeoMechResultDefinition::loadResult()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemResultAddress RimGeoMechResultDefinition::resultAddress()
{
if(m_isTimeLapseResult)
return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString(), m_timeLapseBaseTimestep);
else
return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString());
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -367,7 +437,12 @@ void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& re
m_resultPositionType = resultAddress.resultPosType; m_resultPositionType = resultAddress.resultPosType;
m_resultFieldName = QString::fromStdString(resultAddress.fieldName); m_resultFieldName = QString::fromStdString(resultAddress.fieldName);
m_resultComponentName = QString::fromStdString(resultAddress.componentName); m_resultComponentName = QString::fromStdString(resultAddress.componentName);
m_isTimeLapseResult = resultAddress.isTimeLapse();
m_timeLapseBaseTimestep = m_isTimeLapseResult ? resultAddress.timeLapseBaseFrameIdx: 0;
m_resultPositionTypeUiField = m_resultPositionType; m_resultPositionTypeUiField = m_resultPositionType;
m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName()); m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName());
m_isTimeLapseResultUiField = m_isTimeLapseResult;
m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep;
} }

View File

@ -39,7 +39,6 @@ class RimGeoMechCase;
class RimGeoMechResultDefinition : public caf::PdmObject class RimGeoMechResultDefinition : public caf::PdmObject
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public: public:
RimGeoMechResultDefinition(void); RimGeoMechResultDefinition(void);
virtual ~RimGeoMechResultDefinition(void); virtual ~RimGeoMechResultDefinition(void);
@ -50,7 +49,7 @@ public:
bool hasResult(); bool hasResult();
void loadResult(); void loadResult();
RigFemResultAddress resultAddress() { return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString());} RigFemResultAddress resultAddress();
RigFemResultPosEnum resultPositionType() { return m_resultPositionType();} RigFemResultPosEnum resultPositionType() { return m_resultPositionType();}
QString resultFieldName() { return m_resultFieldName();} QString resultFieldName() { return m_resultFieldName();}
@ -65,21 +64,41 @@ public:
protected: protected:
virtual void updateLegendCategorySettings() {}; virtual void updateLegendCategorySettings() {};
private: private:
// Overridden PDM methods
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool * useOptionsOnly); bool * useOptionsOnly);
std::map<std::string, std::vector<std::string> > getResultMetaDataForUIFieldSetting(); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField,
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); const QVariant& oldValue,
static void getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames, const QVariant& newValue);
const std::map<std::string, std::vector<std::string> >& fieldCompNames);
static QString composeFieldCompString(const QString& resultFieldName, const QString& resultComponentName);
virtual void initAfterRead(); virtual void initAfterRead();
// Metadata and option build tools
std::map<std::string, std::vector<std::string> > getResultMetaDataForUIFieldSetting();
static void getUiAndResultVariableStringList(QStringList* uiNames,
QStringList* variableNames,
const std::map<std::string, std::vector<std::string> >& fieldCompNames);
static QString composeFieldCompString(const QString& resultFieldName,
const QString& resultComponentName);
static QString convertToUiResultFieldName(QString resultFieldName);
static QString convertToUIComponentName(QString resultComponentName);
// Data Fields
caf::PdmField<caf::AppEnum<RigFemResultPosEnum> > m_resultPositionType; caf::PdmField<caf::AppEnum<RigFemResultPosEnum> > m_resultPositionType;
caf::PdmField<QString> m_resultFieldName; caf::PdmField<QString> m_resultFieldName;
caf::PdmField<QString> m_resultComponentName; caf::PdmField<QString> m_resultComponentName;
caf::PdmField<bool> m_isTimeLapseResult;
caf::PdmField<int> m_timeLapseBaseTimestep;
// UI Fields only
friend class RimGeoMechPropertyFilter; // Property filter needs the ui fields friend class RimGeoMechPropertyFilter; // Property filter needs the ui fields
friend class RimWellLogExtractionCurve; // Curve needs the ui fields friend class RimWellLogExtractionCurve; // Curve needs the ui fields
@ -87,9 +106,9 @@ private:
caf::PdmField<caf::AppEnum<RigFemResultPosEnum> > m_resultPositionTypeUiField; caf::PdmField<caf::AppEnum<RigFemResultPosEnum> > m_resultPositionTypeUiField;
caf::PdmField<QString> m_resultVariableUiField; caf::PdmField<QString> m_resultVariableUiField;
caf::PdmField<bool> m_isTimeLapseResultUiField;
caf::PdmField<int> m_timeLapseBaseTimestepUiField;
caf::PdmPointer<RimGeoMechCase> m_geomCase; caf::PdmPointer<RimGeoMechCase> m_geomCase;
static QString convertToUiResultFieldName(QString resultFieldName);
static QString convertToUIComponentName(QString resultComponentName);
}; };