diff --git a/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h b/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h index 54d8c90afa..ac3b2fadf0 100644 --- a/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h +++ b/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h @@ -54,11 +54,8 @@ public: virtual std::map > scalarElementNodeFieldAndComponentNames() = 0; virtual std::map > scalarIntegrationPointFieldAndComponentNames() = 0; - virtual void readScalarNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector* resultValues) = 0; - virtual void readScalarElementNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector* resultValues) = 0; - virtual void readScalarIntegrationPointField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector* resultValues) = 0; virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector* displacements) = 0; - + virtual void readNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues) = 0; virtual void readElementNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues) = 0; virtual void readIntegrationPointField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues) = 0; diff --git a/ApplicationCode/GeoMech/OdbReader/RifOdbReader.cpp b/ApplicationCode/GeoMech/OdbReader/RifOdbReader.cpp index efec20060b..67384d4ba1 100644 --- a/ApplicationCode/GeoMech/OdbReader/RifOdbReader.cpp +++ b/ApplicationCode/GeoMech/OdbReader/RifOdbReader.cpp @@ -607,48 +607,6 @@ odb_Instance* RifOdbReader::instance(int instanceIndex) } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const odb_SequenceFieldBulkData& RifOdbReader::fieldBulkData(const std::string& fieldName, ResultPosition position, odb_Instance* instance, const odb_Frame& frame) -{ -<<<<<<< HEAD - - const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*instance); - CVF_ASSERT(false); // This stuff must be fixed for linux -#if 0 -======= - const odb_FieldOutput& mainFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*instance); - ->>>>>>> Results are now loaded pr field, and not pr component - switch (position) - { - case NODAL: - return mainFieldOutput.getSubset(odb_Enum::NODAL).bulkDataBlocks(); - break; - - case ELEMENT_NODAL: - return mainFieldOutput.getSubset(odb_Enum::ELEMENT_NODAL).bulkDataBlocks(); - break; - - case INTEGRATION_POINT: - return mainFieldOutput.getSubset(odb_Enum::INTEGRATION_POINT).bulkDataBlocks(); - break; - - default: - CVF_ASSERT(false); - return mainFieldOutput.getSubset(odb_Enum::NODAL).bulkDataBlocks(); - break; - } -<<<<<<< HEAD -#endif - return fieldOutput.bulkDataBlocks(); -======= - ->>>>>>> Results are now loaded pr field, and not pr component -} - - //-------------------------------------------------------------------------------------------------- /// Get the number of result items (== #nodes or #elements) //-------------------------------------------------------------------------------------------------- @@ -749,180 +707,6 @@ std::map > RifOdbReader::fieldAndComponent } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifOdbReader::readScalarNodeField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector* resultValues) -{ - CVF_ASSERT(resultValues); - - odb_Instance* partInstance = instance(partIndex); - CVF_ASSERT(partInstance != NULL); - - std::map& nodeIdToIdxMap = m_nodeIdToIdxMaps[partIndex]; - size_t dataSize = nodeIdToIdxMap.size(); - CVF_ASSERT(dataSize > 0); - - int compIndex = componentIndex(RifOdbResultKey(NODAL, fieldName), componentName); - - if (compIndex < 0) return; - - resultValues->resize(dataSize); - resultValues->assign(dataSize, std::numeric_limits::infinity()); - - const odb_Frame& frame = stepFrame(stepIndex, frameIndex); - const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance); - const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::NODAL); - const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks(); - - size_t dataIndex = 0; - int numBlocks = seqFieldBulkData.size(); - for (int block = 0; block < numBlocks; block++) - { - const odb_FieldBulkData& bulkData = seqFieldBulkData[block]; - RifOdbBulkDataGetter bulkDataGetter(bulkData); - - int numNodes = bulkData.length(); - int numComp = bulkData.width(); - int* nodeLabels = bulkData.nodeLabels(); - float* data = bulkDataGetter.data(); - - for (int i = 0; i < numNodes; i++) - { - (*resultValues)[nodeIdToIdxMap[nodeLabels[i]]] = data[i*numComp + compIndex]; - } - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifOdbReader::readScalarElementNodeField(const std::string& fieldName, const std::string& componentName, - int partIndex, int stepIndex, int frameIndex, - std::vector* resultValues) -{ - CVF_ASSERT(resultValues); - - odb_Instance* partInstance = instance(partIndex); - CVF_ASSERT(partInstance != NULL); - - std::map& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex]; - CVF_ASSERT(elementIdToIdxMap.size() > 0); - - int compIndex = componentIndex(RifOdbResultKey(ELEMENT_NODAL, fieldName), componentName); - if (compIndex < 0) return; - - size_t dataSize = resultItemCount(fieldName, partIndex, stepIndex, frameIndex); - if (dataSize > 0) - { - resultValues->resize(dataSize); - resultValues->assign(dataSize, std::numeric_limits::infinity()); - } - - const odb_Frame& frame = stepFrame(stepIndex, frameIndex); - const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance); - const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::ELEMENT_NODAL); - const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks(); - - size_t dataIndex = 0; - int numBlocks = seqFieldBulkData.size(); - for (int block = 0; block < numBlocks; block++) - { - const odb_FieldBulkData& bulkData = seqFieldBulkData[block]; - RifOdbBulkDataGetter bulkDataGetter(bulkData); - - int numValues = bulkData.length(); - int numComp = bulkData.width(); - int elemCount = bulkData.numberOfElements(); - int elemNodeCount = numValues/elemCount; - int* elementLabels = bulkData.elementLabels(); - float* data = bulkDataGetter.data(); - - for (int elem = 0; elem < elemCount; elem++) - { - int elementIdx = elementIdToIdxMap[elementLabels[elem*elemNodeCount]]; - int elementResultStartDestIdx = elementIdx*elemNodeCount; // Ikke generellt riktig ! - int elementResultStartSourceIdx = elem*elemNodeCount*numComp; - - for (int elemNode = 0; elemNode < elemNodeCount; elemNode++) - { - int destIdx = elementResultStartDestIdx + elemNode; - int srcIdx = elementResultStartSourceIdx + elemNode*numComp + compIndex; - (*resultValues)[destIdx] = data[srcIdx]; - } - } - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifOdbReader::readScalarIntegrationPointField( const std::string& fieldName, const std::string& componentName, - int partIndex, int stepIndex, int frameIndex, - std::vector* resultValues) -{ - CVF_ASSERT(resultValues); - - odb_Instance* partInstance = instance(partIndex); - CVF_ASSERT(partInstance != NULL); - - std::map& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex]; - CVF_ASSERT(elementIdToIdxMap.size() > 0); - - int compIndex = componentIndex(RifOdbResultKey(INTEGRATION_POINT, fieldName), componentName); - if (compIndex < 0) return; - - size_t dataSize = resultItemCount(fieldName, partIndex, stepIndex, frameIndex); - if (dataSize > 0) - { - resultValues->resize(dataSize); - resultValues->assign(dataSize, std::numeric_limits::infinity()); - } - - const odb_Frame& frame = stepFrame(stepIndex, frameIndex); - const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance); - const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::INTEGRATION_POINT); - const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks(); - - size_t dataIndex = 0; - int numBlocks = seqFieldBulkData.size(); - for (int block = 0; block < numBlocks; block++) - { - const odb_FieldBulkData& bulkData = seqFieldBulkData[block]; - RifOdbBulkDataGetter bulkDataGetter(bulkData); - - int numValues = bulkData.length(); - int numComp = bulkData.width(); - int elemCount = bulkData.numberOfElements(); - int ipCount = numValues/elemCount; - int* elementLabels = bulkData.elementLabels(); - float* data = bulkDataGetter.data(); - - RigElementType eType = toRigElementType(bulkData.baseElementType()); - const int* elmNodeToIpResultMapping = localElmNodeToIntegrationPointMapping(eType); - if (!elmNodeToIpResultMapping) continue; - - for (int elem = 0; elem < elemCount; elem++) - { - int elementIdx = elementIdToIdxMap[elementLabels[elem*ipCount]]; - int elementResultStartDestIdx = elementIdx*ipCount; // Ikke generellt riktig ! - int elementResultStartSourceIdx = elem*ipCount*numComp; - - for (int ipIdx = 0; ipIdx < ipCount; ipIdx++) - { - int resultIpIdx = elmNodeToIpResultMapping[ipIdx]; - int destIdx = elementResultStartDestIdx + ipIdx; - int srcIdx = elementResultStartSourceIdx + resultIpIdx*numComp + compIndex; - - (*resultValues)[destIdx] = data[srcIdx]; - } - } - } -} - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/OdbReader/RifOdbReader.h b/ApplicationCode/GeoMech/OdbReader/RifOdbReader.h index 300de3ae0e..d0b777d4f3 100644 --- a/ApplicationCode/GeoMech/OdbReader/RifOdbReader.h +++ b/ApplicationCode/GeoMech/OdbReader/RifOdbReader.h @@ -53,10 +53,7 @@ public: virtual std::map > scalarNodeFieldAndComponentNames(); virtual std::map > scalarElementNodeFieldAndComponentNames(); virtual std::map > scalarIntegrationPointFieldAndComponentNames(); - - virtual void readScalarNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector* resultValues); - virtual void readScalarElementNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector* resultValues); - virtual void readScalarIntegrationPointField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector* resultValues); + virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector* displacements); virtual void readNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues); @@ -97,7 +94,7 @@ private: size_t componentsCount(const std::string& fieldName, ResultPosition position); const odb_Frame& stepFrame(int stepIndex, int frameIndex) const; odb_Instance* instance(int instanceIndex); - const odb_SequenceFieldBulkData& fieldBulkData(const std::string& fieldName, ResultPosition position, odb_Instance*, const odb_Frame& frame); + int componentIndex(const RifOdbResultKey& result, const std::string& componentName); std::vector componentNames(const RifOdbResultKey& result); std::map< std::string, std::vector > fieldAndComponentNames(ResultPosition position); @@ -105,9 +102,11 @@ private: private: odb_Odb* m_odb; + std::map< RifOdbResultKey, std::vector > m_resultsMetaData; std::map< int, std::vector > m_partElementSetNames; std::vector< std::map > m_nodeIdToIdxMaps; std::vector< std::map > m_elementIdToIdxMaps; - static size_t sm_instanceCount; + + static size_t sm_instanceCount; };