mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1105 Created new folder for flow project files
This commit is contained in:
23
ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake
Normal file
23
ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
source_group( "ProjectDataModel\\Flow" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )
|
||||
280
ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp
Normal file
280
ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp
Normal file
@@ -0,0 +1,280 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimFlowDiagSolution.h"
|
||||
|
||||
#include "RimEclipseResultCase.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigFlowDiagResults.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigSingleWellResultsData.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimFlowDiagSolution, "FlowDiagSolution");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowDiagSolution::RimFlowDiagSolution(void)
|
||||
{
|
||||
CAF_PDM_InitObject("Flow Diagnostics Solution", "", "", "");
|
||||
|
||||
//CAF_PDM_InitFieldNoDefault(&m_selectedWells, "SelectedWells", "Selected Wells","","");
|
||||
|
||||
CAF_PDM_InitField(&m_userDescription, "UserDescription", QString("All Wells") ,"Description", "", "","");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowDiagSolution::~RimFlowDiagSolution(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigFlowDiagResults* RimFlowDiagSolution::flowDiagResults()
|
||||
{
|
||||
if ( m_flowDiagResults.isNull() )
|
||||
{
|
||||
size_t timeStepCount;
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType(eclCase);
|
||||
|
||||
CVF_ASSERT(eclCase && eclCase->reservoirData() && eclCase->reservoirData() );
|
||||
|
||||
timeStepCount = eclCase->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount();
|
||||
|
||||
}
|
||||
|
||||
m_flowDiagResults = new RigFlowDiagResults(this, timeStepCount);
|
||||
}
|
||||
|
||||
return m_flowDiagResults.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RimFlowDiagSolution::tracerNames()
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType(eclCase);
|
||||
|
||||
std::vector<QString> tracerNameSet;
|
||||
|
||||
if (eclCase)
|
||||
{
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx)
|
||||
{
|
||||
tracerNameSet.push_back(wellResults[wIdx]->m_wellName);
|
||||
}
|
||||
}
|
||||
|
||||
return tracerNameSet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<int> > RimFlowDiagSolution::allInjectorTracerActiveCellIndices(size_t timeStepIndex)
|
||||
{
|
||||
return allTracerActiveCellIndices(timeStepIndex, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<int> > RimFlowDiagSolution::allProducerTracerActiveCellIndices(size_t timeStepIndex)
|
||||
{
|
||||
return allTracerActiveCellIndices(timeStepIndex, false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<int> > RimFlowDiagSolution::allTracerActiveCellIndices(size_t timeStepIndex, bool useInjectors)
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType(eclCase);
|
||||
|
||||
std::map<std::string, std::vector<int> > tracersWithCells;
|
||||
|
||||
if ( eclCase )
|
||||
{
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
|
||||
RigMainGrid* mainGrid = eclCase->reservoirData()->mainGrid();
|
||||
RigActiveCellInfo* activeCellInfo = eclCase->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS); //Todo: Must come from the results definition
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
|
||||
{
|
||||
if (!wellResults[wIdx]->hasWellResult(timeStepIndex) ) continue;
|
||||
|
||||
size_t wellTimeStep = wellResults[wIdx]->m_resultTimeStepIndexToWellTimeStepIndex[timeStepIndex];
|
||||
|
||||
if (wellTimeStep == cvf::UNDEFINED_SIZE_T) continue;
|
||||
|
||||
const RigWellResultFrame& wellResFrame = wellResults[wIdx]->m_wellCellsTimeSteps[wellTimeStep];
|
||||
|
||||
if ( !wellResFrame.m_isOpen ) continue;
|
||||
|
||||
bool useWell = ( useInjectors && ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR) )
|
||||
|| (!useInjectors && wellResFrame.m_productionType == RigWellResultFrame::PRODUCER);
|
||||
|
||||
|
||||
if (useWell)
|
||||
{
|
||||
std::string wellname = wellResults[wIdx]->m_wellName.toStdString();
|
||||
std::vector<int>& tracerCells = tracersWithCells[wellname];
|
||||
|
||||
for (const RigWellResultBranch& wBr: wellResFrame.m_wellResultBranches)
|
||||
{
|
||||
for (const RigWellResultPoint& wrp: wBr.m_branchResultPoints)
|
||||
{
|
||||
if (wrp.isValid() && wrp.m_isOpen)
|
||||
{
|
||||
RigGridBase * grid = mainGrid->gridByIndex(wrp.m_gridIndex);
|
||||
size_t reservoirCellIndex = grid->reservoirCellIndex(wrp.m_gridCellIndex);
|
||||
|
||||
int cellActiveIndex = static_cast<int>(activeCellInfo->cellResultIndex(reservoirCellIndex));
|
||||
tracerCells.push_back(cellActiveIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tracersWithCells;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall(QString tracerName)
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType(eclCase);
|
||||
TracerStatusType tracerStatus = UNDEFINED;
|
||||
if ( eclCase )
|
||||
{
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
|
||||
{
|
||||
if ( wellResults[wIdx]->m_wellName == tracerName )
|
||||
{
|
||||
tracerStatus = CLOSED;
|
||||
for ( const RigWellResultFrame& wellResFrame : wellResults[wIdx]->m_wellCellsTimeSteps )
|
||||
{
|
||||
if (wellResFrame.m_isOpen)
|
||||
{
|
||||
if ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR )
|
||||
{
|
||||
if ( tracerStatus == PRODUCER ) tracerStatus = VARYING;
|
||||
else tracerStatus = INJECTOR;
|
||||
}
|
||||
else if ( wellResFrame.m_productionType == RigWellResultFrame::PRODUCER )
|
||||
{
|
||||
if ( tracerStatus == INJECTOR ) tracerStatus = VARYING;
|
||||
else tracerStatus = PRODUCER;
|
||||
}
|
||||
}
|
||||
if ( tracerStatus == VARYING ) break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tracerStatus;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex)
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType(eclCase);
|
||||
|
||||
if ( eclCase )
|
||||
{
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
|
||||
{
|
||||
if ( wellResults[wIdx]->m_wellName == tracerName )
|
||||
{
|
||||
size_t wellTimeStep = wellResults[wIdx]->m_resultTimeStepIndexToWellTimeStepIndex[timeStepIndex];
|
||||
|
||||
if (wellTimeStep == cvf::UNDEFINED_SIZE_T) return CLOSED;
|
||||
|
||||
const RigWellResultFrame& wellResFrame = wellResults[wIdx]->m_wellCellsTimeSteps[wellTimeStep];
|
||||
{
|
||||
if (!wellResFrame.m_isOpen) return CLOSED;
|
||||
|
||||
if ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR )
|
||||
{
|
||||
return INJECTOR;
|
||||
}
|
||||
else if ( wellResFrame.m_productionType == RigWellResultFrame::PRODUCER )
|
||||
{
|
||||
return PRODUCER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return UNDEFINED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(false);
|
||||
|
||||
return UNDEFINED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimFlowDiagSolution::userDescriptionField()
|
||||
{
|
||||
return &m_userDescription;
|
||||
}
|
||||
|
||||
74
ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.h
Normal file
74
ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
class RimEclipseWell;
|
||||
class RigFlowDiagResults;
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimFlowDiagSolution : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimFlowDiagSolution();
|
||||
virtual ~RimFlowDiagSolution();
|
||||
|
||||
QString userDescription() { return m_userDescription();}
|
||||
RigFlowDiagResults* flowDiagResults();
|
||||
std::vector<QString> tracerNames();
|
||||
|
||||
std::map<std::string, std::vector<int> > allInjectorTracerActiveCellIndices(size_t timeStepIndex);
|
||||
std::map<std::string, std::vector<int> > allProducerTracerActiveCellIndices(size_t timeStepIndex);
|
||||
|
||||
enum TracerStatusType
|
||||
{
|
||||
CLOSED,
|
||||
PRODUCER,
|
||||
INJECTOR,
|
||||
VARYING,
|
||||
UNDEFINED
|
||||
};
|
||||
|
||||
TracerStatusType tracerStatusOverall(QString tracerName);
|
||||
TracerStatusType tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex);
|
||||
|
||||
|
||||
protected:
|
||||
//virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::vector<int> > allTracerActiveCellIndices(size_t timeStepIndex, bool useInjectors);
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() override;
|
||||
caf::PdmField<QString> m_userDescription;
|
||||
|
||||
cvf::ref<RigFlowDiagResults> m_flowDiagResults;
|
||||
|
||||
//caf::PdmPtrArrayField<RimEclipseWell*> m_selectedWells;
|
||||
};
|
||||
Reference in New Issue
Block a user