Added part index parameter to RifOdbReader::resultItemCount()

Made sure that RifOdbReader::resultItemCount() takes part index into
account.
This commit is contained in:
Stein Dale 2015-05-06 13:32:14 +02:00
parent 5a3603bf43
commit bd3758d026
2 changed files with 11 additions and 13 deletions

View File

@ -496,16 +496,14 @@ odb_Instance* RifOdbReader::instance(int instanceIndex)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Get the number of result items (== #nodes or #elements) /// Get the number of result items (== #nodes or #elements)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RifOdbReader::resultItemCount(const std::string& fieldName, int stepIndex, int frameIndex) const size_t RifOdbReader::resultItemCount(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex)
{ {
odb_Instance* partInstance = instance(partIndex);
CVF_ASSERT(partInstance != NULL);
const odb_Frame& frame = stepFrame(stepIndex, frameIndex); const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
const odb_FieldOutputRepository& fieldOutputRepo = frame.fieldOutputs(); const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance);
const odb_SequenceFieldBulkData& seqFieldBulkData = instanceFieldOutput.bulkDataBlocks();
odb_String fieldNameStr = fieldName.c_str();
CVF_ASSERT(fieldOutputRepo.isMember(fieldNameStr));
const odb_FieldOutput& fieldOutput = fieldOutputRepo[fieldNameStr];
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
size_t resultItemCount = 0; size_t resultItemCount = 0;
int numBlocks = seqFieldBulkData.size(); int numBlocks = seqFieldBulkData.size();
@ -519,7 +517,6 @@ size_t RifOdbReader::resultItemCount(const std::string& fieldName, int stepIndex
return resultItemCount; return resultItemCount;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -637,7 +634,8 @@ void RifOdbReader::readScalarElementNodeField(const std::string& fieldName, cons
auto elementIdToIdxMap = elementIdToIdxMapIt->second; auto elementIdToIdxMap = elementIdToIdxMapIt->second;
CVF_ASSERT(elementIdToIdxMap.size() > 0); CVF_ASSERT(elementIdToIdxMap.size() > 0);
size_t dataSize = resultItemCount(fieldName, stepIndex, frameIndex);
size_t dataSize = resultItemCount(fieldName, partIndex, stepIndex, frameIndex);
if (dataSize > 0) if (dataSize > 0)
{ {
resultValues->resize(dataSize); resultValues->resize(dataSize);
@ -696,7 +694,7 @@ void RifOdbReader::readScalarIntegrationPointField(const std::string& fieldName,
auto elementIdToIdxMap = elementIdToIdxMapIt->second; auto elementIdToIdxMap = elementIdToIdxMapIt->second;
CVF_ASSERT(elementIdToIdxMap.size() > 0); CVF_ASSERT(elementIdToIdxMap.size() > 0);
size_t dataSize = resultItemCount(fieldName, stepIndex, frameIndex); size_t dataSize = resultItemCount(fieldName, partIndex, stepIndex, frameIndex);
if (dataSize > 0) if (dataSize > 0)
{ {
resultValues->resize(dataSize); resultValues->resize(dataSize);
@ -749,7 +747,7 @@ void RifOdbReader::readDisplacements(int partIndex, int stepIndex, int frameInde
odb_Instance* partInstance = instance(partIndex); odb_Instance* partInstance = instance(partIndex);
CVF_ASSERT(partInstance != NULL); CVF_ASSERT(partInstance != NULL);
size_t dataSize = resultItemCount("U", stepIndex, frameIndex); size_t dataSize = resultItemCount("U", partIndex, stepIndex, frameIndex);
if (dataSize > 0) if (dataSize > 0)
{ {
displacements->resize(dataSize); displacements->resize(dataSize);

View File

@ -68,7 +68,7 @@ private:
bool buildMetaData(); bool buildMetaData();
void close(); void close();
size_t resultItemCount(const std::string& fieldName, int stepIndex, int frameIndex) const; size_t resultItemCount(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex);
odb_Frame stepFrame(int stepIndex, int frameIndex) const; odb_Frame stepFrame(int stepIndex, int frameIndex) const;
odb_Instance* instance(int instanceIndex); odb_Instance* instance(int instanceIndex);
int componentIndex(ResPos position, const std::string& fieldName, const std::string& componentName) const; int componentIndex(ResPos position, const std::string& fieldName, const std::string& componentName) const;