#3043 Implement Time step filtering on import for Geomech

This commit is contained in:
Gaute Lindkvist
2018-06-11 13:47:21 +02:00
parent 62792b59c4
commit 280656ca26
23 changed files with 616 additions and 209 deletions

View File

@@ -36,3 +36,55 @@ RifGeoMechReaderInterface::~RifGeoMechReaderInterface()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifGeoMechReaderInterface::setTimeStepFilter(const std::vector<size_t>& fileTimeStepIndices)
{
m_fileTimeStepIndices.reserve(fileTimeStepIndices.size());
for (size_t stepIndex : fileTimeStepIndices)
{
m_fileTimeStepIndices.push_back(static_cast<int>(stepIndex));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifGeoMechReaderInterface::isTimeStepIncludedByFilter(int timeStepIndex) const
{
CVF_ASSERT(timeStepIndex >= 0);
if (m_fileTimeStepIndices.empty()) return true;
for (auto i : m_fileTimeStepIndices)
{
if (i == static_cast<size_t>(timeStepIndex))
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifGeoMechReaderInterface::timeStepIndexOnFile(int timeStepIndex) const
{
if (m_fileTimeStepIndices.empty())
{
return timeStepIndex;
}
CVF_ASSERT(timeStepIndex >= 0);
CVF_ASSERT(static_cast<size_t>(timeStepIndex) < m_fileTimeStepIndices.size());
if (static_cast<size_t>(timeStepIndex) < m_fileTimeStepIndices.size())
{
return static_cast<int>(m_fileTimeStepIndices[timeStepIndex]);
}
return timeStepIndex;
}

View File

@@ -42,9 +42,10 @@ public:
virtual ~RifGeoMechReaderInterface();
virtual bool openFile(const std::string& fileName, std::string* errorMessage) = 0;
virtual bool isOpen() const = 0;
virtual bool readFemParts(RigFemPartCollection* geoMechCase) = 0;
virtual std::vector<std::string> stepNames() const = 0;
virtual std::vector<std::string> allStepNames() const = 0;
virtual std::vector<std::string> filteredStepNames() const = 0;
virtual std::vector<double> frameTimes(int stepIndex) const = 0;
virtual std::vector<std::string> elementSetNames(int partIndex) = 0;
@@ -60,5 +61,9 @@ public:
virtual void readElementNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector<std::vector<float>*>* resultValues) = 0;
virtual void readIntegrationPointField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector<std::vector<float>*>* resultValues) = 0;
void setTimeStepFilter(const std::vector<size_t>& fileTimeStepIndices);
bool isTimeStepIncludedByFilter(int timeStepIndex) const;
int timeStepIndexOnFile(int timeStepIndex) const;
private:
std::vector<int> m_fileTimeStepIndices;
};

View File

@@ -234,6 +234,14 @@ bool RifOdbReader::openFile(const std::string& fileName, std::string* errorMessa
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifOdbReader::isOpen() const
{
return m_odb != NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -422,7 +430,7 @@ bool RifOdbReader::readFemParts(RigFemPartCollection* femParts)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifOdbReader::stepNames() const
std::vector<std::string> RifOdbReader::allStepNames() const
{
CVF_ASSERT(m_odb != NULL);
@@ -430,9 +438,34 @@ std::vector<std::string> RifOdbReader::stepNames() const
odb_StepRepository stepRepository = m_odb->steps();
odb_StepRepositoryIT sIter(stepRepository);
for (sIter.first(); !sIter.isDone(); sIter.next())
for (sIter.first(); !sIter.isDone(); sIter.next())
{
stepNames.push_back(stepRepository[sIter.currentKey()].name().CStr());
std::string stepName(sIter.currentValue().name().CStr());
stepNames.push_back(stepName);
}
return stepNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifOdbReader::filteredStepNames() const
{
CVF_ASSERT(m_odb != NULL);
std::vector<std::string> stepNames;
odb_StepRepository stepRepository = m_odb->steps();
odb_StepRepositoryIT sIter(stepRepository);
int stepIndex = 0;
for (sIter.first(); !sIter.isDone(); sIter.next())
{
std::string stepName(sIter.currentValue().name().CStr());
if (this->isTimeStepIncludedByFilter(stepIndex++))
{
stepNames.push_back(stepName);
}
}
return stepNames;
@@ -449,7 +482,10 @@ std::vector<double> RifOdbReader::frameTimes(int stepIndex) const
odb_StepRepository& stepRepository = m_odb->steps();
odb_StepList stepList = stepRepository.stepList();
odb_Step& step = stepList.Get(stepIndex);
int stepFileIndex = this->timeStepIndexOnFile(stepIndex);
odb_Step& step = stepList.Get(stepFileIndex);
odb_SequenceFrame& stepFrames = step.frames();
@@ -573,7 +609,10 @@ const odb_Frame& RifOdbReader::stepFrame(int stepIndex, int frameIndex) const
const odb_StepRepository& stepRepository = m_odb->steps();
const odb_StepList& stepList = stepRepository.stepList();
const odb_Step& step = stepList.ConstGet(stepIndex);
int stepFileIndex = this->timeStepIndexOnFile(stepIndex);
const odb_Step& step = stepList.ConstGet(stepFileIndex);
const odb_SequenceFrame& stepFrames = step.frames();
return stepFrames.constGet(frameIndex);

View File

@@ -42,9 +42,10 @@ public:
virtual ~RifOdbReader();
virtual bool openFile(const std::string& fileName, std::string* errorMessage);
virtual bool isOpen() const;
virtual bool readFemParts(RigFemPartCollection* geoMechCase);
virtual std::vector<std::string> stepNames() const override;
virtual std::vector<std::string> allStepNames() const override;
virtual std::vector<std::string> filteredStepNames() const override;
virtual std::vector<double> frameTimes(int stepIndex) const override;
virtual std::vector<std::string> elementSetNames(int partIndex);
@@ -93,7 +94,7 @@ private:
size_t resultItemCount(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex);
size_t componentsCount(const std::string& fieldName, ResultPosition position);
const odb_Frame& stepFrame(int stepIndex, int frameIndex) const;
odb_Instance* instance(int instanceIndex);
odb_Instance* instance(int instanceIndex);
int componentIndex(const RifOdbResultKey& result, const std::string& componentName);
std::vector<std::string> componentNames(const RifOdbResultKey& result);