///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2023- Equinor ASA // // 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 "RigFemResultPosEnum.h" #include "RigFemTypes.h" #include #include #include #include #include class RigFemPartCollection; struct RifInpIncludeEntry { public: RifInpIncludeEntry( std::string propertyName, RigFemResultPosEnum resultType, int stepId, std::string fileName, int columnIndex ) { this->propertyName = propertyName; this->stepId = stepId; this->fileName = fileName; this->resultType = resultType; this->columnIndex = columnIndex; } public: std::string propertyName; int stepId; std::string fileName; RigFemResultPosEnum resultType; int columnIndex; }; //================================================================================================== // //================================================================================================== class RifInpReader : public RifGeoMechReaderInterface { public: RifInpReader(); ~RifInpReader() override; void enableIncludes( bool enable ); 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> scalarElementFieldAndComponentNames() 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 readElementField( 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; bool populateDerivedResultNames() const override; private: void close(); void readField( RigFemResultPosEnum resultType, const std::string& fieldName, int partIndex, int stepIndex, std::vector*>* resultValues ); void readScalarData( RigFemPartCollection* femParts, std::map& parts, std::vector& includeEntries ); std::map>>>* propertyDataMap( RigFemResultPosEnum resultType ); static void skipComments( std::istream& stream ); static std::string parseLabel( const std::string& line, const std::string& labelName ); static std::vector> readNodes( std::istream& stream ); static std::vector>> readElements( std::istream& stream ); static std::vector readElementSet( std::istream& stream ); static std::vector readElementSetGenerate( std::istream& stream ); static RigElementType read( std::istream& stream, std::map& parts, std::map>>& nodes, std::map>>>& elements, std::map>>>& elementSets, std::vector& stepNames, bool enableIncludes, std::vector& includeEntries ); private: bool m_enableIncludes; std::map> m_partElementSetNames; std::vector m_stepNames; std::vector m_includeEntries; std::ifstream m_stream; std::filesystem::path m_inputPath; std::map>>> m_propertyPartDataNodes; std::map>>> m_propertyPartDataElements; };