#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);
}
};

View File

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

View File

@ -61,11 +61,19 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void)
CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType" , "Result Position", "", "", "");
m_resultPositionType.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_resultFieldName, "ResultFieldName", QString(""), "Field Name", "", "", "");
m_resultFieldName.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", QString(""), "Component", "", "", "");
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", "", "", "");
m_resultPositionTypeUiField.xmlCapability()->setIOWritable(false);
m_resultPositionTypeUiField.xmlCapability()->setIOReadable(false);
@ -74,8 +82,19 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void)
m_resultVariableUiField.xmlCapability()->setIOWritable(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()->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]));
}
}
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;
@ -165,6 +216,8 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
// Complete string of selected formation is stored in m_resultFieldName
m_resultFieldName = m_resultVariableUiField();
m_resultComponentName = "";
m_isTimeLapseResult = false;
m_timeLapseBaseTimestep = 0;
}
else
{
@ -177,6 +230,9 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
{
m_resultComponentName = "";
}
m_isTimeLapseResult = m_isTimeLapseResultUiField();
m_timeLapseBaseTimestep = m_timeLapseBaseTimestepUiField();
}
if (m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress()))
@ -244,8 +300,9 @@ std::map<std::string, std::vector<std::string> > RimGeoMechResultDefinition::get
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition::getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames,
const std::map<std::string, std::vector<std::string> >& fieldCompNames)
void RimGeoMechResultDefinition::getUiAndResultVariableStringList(QStringList* uiNames,
QStringList* variableNames,
const std::map<std::string, std::vector<std::string> >& fieldCompNames)
{
CVF_ASSERT(uiNames && variableNames);
@ -290,7 +347,8 @@ void RimGeoMechResultDefinition::initAfterRead()
{
m_resultPositionTypeUiField = m_resultPositionType;
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_resultFieldName = QString::fromStdString(resultAddress.fieldName);
m_resultComponentName = QString::fromStdString(resultAddress.componentName);
m_isTimeLapseResult = resultAddress.isTimeLapse();
m_timeLapseBaseTimestep = m_isTimeLapseResult ? resultAddress.timeLapseBaseFrameIdx: 0;
m_resultPositionTypeUiField = m_resultPositionType;
m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName());
m_isTimeLapseResultUiField = m_isTimeLapseResult;
m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep;
}

View File

@ -39,57 +39,76 @@ class RimGeoMechCase;
class RimGeoMechResultDefinition : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimGeoMechResultDefinition(void);
virtual ~RimGeoMechResultDefinition(void);
void setGeoMechCase(RimGeoMechCase* geomCase);
void setGeoMechCase(RimGeoMechCase* geomCase);
RigGeoMechCaseData* ownerCaseData();
bool hasResult();
void loadResult();
RigGeoMechCaseData* ownerCaseData();
bool hasResult();
void loadResult();
RigFemResultAddress resultAddress() { return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString());}
RigFemResultAddress resultAddress();
RigFemResultPosEnum resultPositionType() { return m_resultPositionType();}
QString resultFieldName() { return m_resultFieldName();}
QString resultComponentName() { return m_resultComponentName();}
void setResultAddress(const RigFemResultAddress& resultAddress);
RigFemResultPosEnum resultPositionType() { return m_resultPositionType();}
QString resultFieldName() { return m_resultFieldName();}
QString resultComponentName() { return m_resultComponentName();}
void setResultAddress(const RigFemResultAddress& resultAddress);
QString resultFieldUiName();
QString resultComponentUiName();
QString resultFieldUiName();
QString resultComponentUiName();
bool hasCategoryResult() { return m_resultPositionType() == RIG_FORMATION_NAMES; }
bool hasCategoryResult() { return m_resultPositionType() == RIG_FORMATION_NAMES; }
protected:
virtual void updateLegendCategorySettings() {};
virtual void updateLegendCategorySettings() {};
private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool * useOptionsOnly);
std::map<std::string, std::vector<std::string> > getResultMetaDataForUIFieldSetting();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
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);
// Overridden PDM methods
virtual void initAfterRead();
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool * useOptionsOnly);
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue);
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<QString> m_resultFieldName;
caf::PdmField<QString> m_resultComponentName;
caf::PdmField<QString> m_resultFieldName;
caf::PdmField<QString> m_resultComponentName;
caf::PdmField<bool> m_isTimeLapseResult;
caf::PdmField<int> m_timeLapseBaseTimestep;
friend class RimGeoMechPropertyFilter; // Property filter needs the ui fields
// UI Fields only
friend class RimGeoMechPropertyFilter; // Property filter needs the ui fields
friend class RimWellLogExtractionCurve; // Curve needs the ui fields
friend class RimGeoMechCellColors; // Needs the ui fields
friend class RimGeoMechCellColors; // Needs the ui fields
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;
static QString convertToUiResultFieldName(QString resultFieldName);
static QString convertToUIComponentName(QString resultComponentName);
caf::PdmPointer<RimGeoMechCase> m_geomCase;
};