///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2021- 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. // ///////////////////////////////////////////////////////////////////////////////// #include "RifEnsembleFractureStatisticsExporter.h" // #include "RiaEclipseUnitTools.h" // #include "RimStimPlanModel.h" #include "RiaDefines.h" #include "RigSlice2D.h" #include "cafAssert.h" #include #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RifEnsembleFractureStatisticsExporter::writeAsStimPlanXml( const std::vector>& statistics, const std::vector>& properties, const QString& filePath, const std::vector& gridXs, const std::vector& gridYs, double time, RiaDefines::EclipseUnitSystem unitSystem ) { QFile data( filePath ); if ( !data.open( QFile::WriteOnly | QFile::Truncate ) ) { return false; } QTextStream stream( &data ); appendHeaderToStream( stream ); appendGridDimensionsToStream( stream, gridXs, gridYs, unitSystem ); appendPropertiesToStream( stream, statistics, properties, gridYs, time ); appendFooterToStream( stream ); return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifEnsembleFractureStatisticsExporter::appendHeaderToStream( QTextStream& stream ) { stream << "" << endl << "" << endl; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifEnsembleFractureStatisticsExporter::appendPropertiesToStream( QTextStream& stream, const std::vector>& statistics, const std::vector>& properties, const std::vector& gridYs, double time ) { CAF_ASSERT( statistics.size() == properties.size() ); stream << "" << endl; for ( size_t s = 0; s < statistics.size(); s++ ) { QString propertyName = properties[s].first; QString propertyUnit = properties[s].second; stream << QString( "" ).arg( propertyName ).arg( propertyUnit ) << endl; stream << QString( "" << endl; stream << "" << endl; } stream << "" << endl; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifEnsembleFractureStatisticsExporter::appendGridDimensionsToStream( QTextStream& stream, const std::vector& gridXs, const std::vector& gridYs, RiaDefines::EclipseUnitSystem unitSystem ) { QString unitString = getStringForUnitSystem( unitSystem ); stream << QString( "" ).arg( gridXs.size() ).arg( gridYs.size() ).arg( unitString ) << endl; stream << "["; for ( auto x : gridXs ) stream << x << " "; stream << "]" << endl; stream << "["; for ( auto y : gridYs ) stream << y << " "; stream << "]" << endl; stream << "" << endl; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifEnsembleFractureStatisticsExporter::appendFooterToStream( QTextStream& stream ) { stream << "" << endl; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RifEnsembleFractureStatisticsExporter::getStringForUnitSystem( RiaDefines::EclipseUnitSystem unitSystem ) { if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC ) return "m"; else if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD ) return "ft"; else return ""; }