///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Ceetron Solutions AS // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "RifGeoMechReaderInterface.h" #include #include class RigFemPartCollection; class odb_Odb; class odb_Frame; class odb_Instance; class odb_SequenceFieldBulkData; //================================================================================================== // // Data interface base class // //================================================================================================== class RifOdbReader : public RifGeoMechReaderInterface { public: RifOdbReader(); ~RifOdbReader() override; bool openFile( const std::string& fileName, std::string* errorMessage ) override; bool isOpen() const override; bool readFemParts( RigFemPartCollection* geoMechCase ) override; std::vector allStepNames() const override; std::vector filteredStepNames() const override; std::vector frameTimes( int stepIndex ) const override; int frameCount( int stepIndex ) const override; std::vector elementSetNames( int partIndex, std::string partName ) override; std::vector elementSet( int partIndex, std::string partName, int setIndex ) override; std::map> scalarNodeFieldAndComponentNames() override; std::map> scalarElementNodeFieldAndComponentNames() override; std::map> scalarIntegrationPointFieldAndComponentNames() override; void readDisplacements( int partIndex, int stepIndex, int frameIndex, std::vector* displacements ) override; void readNodeField( const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues ) override; void readElementNodeField( const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues ) override; void readIntegrationPointField( const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues ) override; private: enum ResultPosition { NODAL, ELEMENT_NODAL, INTEGRATION_POINT }; class RifOdbResultKey { public: RifOdbResultKey( ResultPosition aResultPostion, const std::string& aFieldName ) : resultPostion( aResultPostion ) , fieldName( aFieldName ){}; ResultPosition resultPostion; std::string fieldName; bool operator<( const RifOdbResultKey& other ) const { if ( resultPostion != other.resultPostion ) { return ( resultPostion < other.resultPostion ); } return ( fieldName < other.fieldName ); } }; void assertMetaDataLoaded(); void close(); size_t resultItemCount( const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, ResultPosition resultPosition ); size_t componentsCount( const std::string& fieldName, ResultPosition position ); const odb_Frame& stepFrame( int stepIndex, int frameIndex ) const; odb_Instance* instance( int instanceIndex ); std::vector componentNames( const RifOdbResultKey& result ); std::map> fieldAndComponentNames( ResultPosition position ); std::map> readResultsMetaData( odb_Odb* odb ); private: odb_Odb* m_odb; std::map> m_resultsMetaData; std::map> m_partElementSetNames; std::vector> m_nodeIdToIdxMaps; std::vector> m_elementIdToIdxMaps; static size_t sm_instanceCount; };