///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil 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 "RigFlowDiagResultAddress.h" #include "RigFlowDiagSolverInterface.h" #include "RimFlowDiagSolution.h" #include "cafAppEnum.h" #include "cafPdmPointer.h" #include "cvfArray.h" #include "cvfObject.h" #include #include #include class RigFlowDiagResultFrames; class RigStatisticsDataCache; class RigActiveCellInfo; class RigFlowDiagResults : public cvf::Object { public: enum CellFilter { CELLS_ACTIVE, CELLS_VISIBLE, CELLS_COMMUNICATION, CELLS_FLOODED, CELLS_DRAINED, }; using CellFilterEnum = caf::AppEnum; public: RigFlowDiagResults( RimFlowDiagSolution* flowSolution, size_t timeStepCount ); ~RigFlowDiagResults() override; const std::vector* resultValues( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex ); size_t timeStepCount() { return m_timeStepCount; } const RigActiveCellInfo* activeCellInfo( const RigFlowDiagResultAddress& resVarAddr ); void minMaxScalarValues( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* localMin, double* localMax ); void minMaxScalarValues( const RigFlowDiagResultAddress& resVarAddr, double* globalMin, double* globalMax ); void posNegClosestToZero( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* localPosClosestToZero, double* localNegClosestToZero ); void posNegClosestToZero( const RigFlowDiagResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero ); void meanScalarValue( const RigFlowDiagResultAddress& resVarAddr, double* meanValue ); void meanScalarValue( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* meanValue ); void p10p90ScalarValues( const RigFlowDiagResultAddress& resVarAddr, double* p10, double* p90 ); void p10p90ScalarValues( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* p10, double* p90 ); void sumScalarValue( const RigFlowDiagResultAddress& resVarAddr, double* sum ); void sumScalarValue( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* sum ); const std::vector& scalarValuesHistogram( const RigFlowDiagResultAddress& resVarAddr ); const std::vector& scalarValuesHistogram( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex ); const std::vector& uniqueCellScalarValues( const RigFlowDiagResultAddress& resVarAddr ); const std::vector& uniqueCellScalarValues( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex ); void mobileVolumeWeightedMean( const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* mean ); void mobileVolumeWeightedMean( const RigFlowDiagResultAddress& resVarAddr, double* mean ); std::pair injectorProducerPairFluxes( const std::string& injTracername, const std::string& prodTracerName, int timeStepIndex ); double maxAbsPairFlux( int timeStepIndex ); std::vector calculatedTimeSteps( RigFlowDiagResultAddress::PhaseSelection phaseSelection ); RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame flowCharacteristicsResults( int timeStepIndex, CellFilter cellSelection, const std::vector& tracerNames, double max_pv_fraction, double minCommunication, int maxTof ); RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame flowCharacteristicsResults( int timeStepIndex, const std::vector& visibleActiveCells, double max_pv_fraction ); RimFlowDiagSolution* flowDiagSolution(); void setStatisticsDataCacheNumBins( const RigFlowDiagResultAddress& resVarAddr, size_t numBins ); private: const std::vector* findOrCalculateResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex ); void calculateNativeResultsIfNotPreviouslyAttempted( size_t timeStepIndex, RigFlowDiagResultAddress::PhaseSelection phaseSelection ); std::vector* calculateDerivedResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex ); std::vector* calculateAverageTOFResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex ); std::vector* calculateSumOfFractionsResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex ); std::vector* calculateTracerWithMaxFractionResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex ); std::vector* calculateCommunicationResult( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex ); void calculateNumFloodedPV( const RigFlowDiagResultAddress& resVarAddr ); std::vector*> findResultsForSelectedTracers( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex, const std::string& nativeResultName, RimFlowDiagSolution::TracerStatusType wantedTracerType ); std::vector*>> findNamedResultsForSelectedTracers( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex, const std::string& nativeResultName, RimFlowDiagSolution::TracerStatusType wantedTracerType ); void calculateSumOfFractionAndFractionMultTOF( size_t activeCellCount, const std::vector*>& injectorFractions, const std::vector*>& injectorTOFs, std::vector* injectorTotalFractions, std::vector* injectorFractMultTof ); void calculateSumOfFractions( const std::vector*>& fractions, size_t activeCellCount, std::vector* sumOfFractions ); RigStatisticsDataCache* statistics( const RigFlowDiagResultAddress& resVarAddr ); RigFlowDiagResultFrames* createScalarResult( const RigFlowDiagResultAddress& resVarAddr ); RigFlowDiagResultFrames* findScalarResult( const RigFlowDiagResultAddress& resVarAddr ); std::vector* findScalarResultFrame( const RigFlowDiagResultAddress& resVarAddr, size_t timeStepIndex ); // void deleteScalarResult(const RigFlowDiagResultAddress& resVarAddr); RigFlowDiagSolverInterface* solverInterface(); size_t m_timeStepCount; caf::PdmPointer m_flowDiagSolution; std::vector> m_hasAtemptedNativeResults; std::map> m_resultSets; std::map> m_resultStatistics; using InjectorProducerCommunicationMap = std::map, std::pair>; std::vector> m_injProdPairFluxCommunicationTimesteps; };