#1670 Move grid functions from RimCellRangeFilterCollection to RigReservoirGridTools

This commit is contained in:
Magne Sjaastad
2017-06-28 13:46:19 +02:00
parent 7cc95c3fa8
commit 468d5134cb
7 changed files with 243 additions and 167 deletions

View File

@@ -11,6 +11,7 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RigCaseToCaseRangeFilterMapper.h
${CEE_CURRENT_LIST_DIR}RigSimulationWellCenterLineCalculator.h
${CEE_CURRENT_LIST_DIR}RigWellLogFile.h
${CEE_CURRENT_LIST_DIR}RigReservoirGridTools.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -20,6 +21,7 @@ set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RigCaseToCaseRangeFilterMapper.cpp
${CEE_CURRENT_LIST_DIR}RigSimulationWellCenterLineCalculator.cpp
${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp
${CEE_CURRENT_LIST_DIR}RigReservoirGridTools.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,143 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RigReservoirGridTools.h"
#include "RigActiveCellInfo.h"
#include "RigEclipseCaseData.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigGeoMechCaseData.h"
#include "RigMainGrid.h"
#include "RimEclipseCase.h"
#include "RimGeoMechCase.h"
#include "RimEclipseView.h"
#include <QString>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigReservoirGridTools::gridCount(RimCase* rimCase)
{
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid(rimCase);
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection(rimCase);
if (eclipseMainGrid)
{
return eclipseMainGrid->gridCount();
}
else if (geoMechPartCollection)
{
return geoMechPartCollection->partCount();
}
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RigReservoirGridTools::mainGrid(RimCase* rimCase)
{
return gridByIndex(rimCase, 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RigReservoirGridTools::gridByIndex(RimCase* rimCase, int gridIndex)
{
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid(rimCase);
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection(rimCase);
if (eclipseMainGrid)
{
return eclipseMainGrid->gridByIndex(gridIndex);
}
else if (geoMechPartCollection)
{
return geoMechPartCollection->part(gridIndex)->structGrid();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigReservoirGridTools::gridName(RimCase* rimCase, int gridIndex)
{
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid(rimCase);
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection(rimCase);
if (eclipseMainGrid)
{
return eclipseMainGrid->gridByIndex(gridIndex)->gridName().c_str();
}
else if (geoMechPartCollection)
{
return QString::number(gridIndex);
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RigReservoirGridTools::activeCellInfo(RimView* rimView)
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(rimView);
if (eclipseView)
{
return eclipseView->currentActiveCellInfo();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigMainGrid* RigReservoirGridTools::eclipseMainGrid(RimCase* rimCase)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(rimCase);
if (eclipseCase && eclipseCase->eclipseCaseData())
{
return eclipseCase->eclipseCaseData()->mainGrid();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartCollection* RigReservoirGridTools::geoMechPartCollection(RimCase* rimCase)
{
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>(rimCase);
if (geoMechCase && geoMechCase->geoMechData())
{
return geoMechCase->geoMechData()->femParts();
}
return nullptr;
}

View File

@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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
class RigActiveCellInfo;
class RigFemPartCollection;
class RigMainGrid;
class RimCase;
class RimView;
namespace cvf
{
class StructGridInterface;
}
class QString;
//==================================================================================================
///
///
//==================================================================================================
class RigReservoirGridTools
{
public:
static int gridCount(RimCase* rimCase);
static const cvf::StructGridInterface* mainGrid(RimCase* rimCase);
static const cvf::StructGridInterface* gridByIndex(RimCase* rimCase, int gridIndex);
static QString gridName(RimCase* rimCase, int gridIndex);
static RigActiveCellInfo* activeCellInfo(RimView* rimView);
private:
static RigMainGrid* eclipseMainGrid(RimCase* rimCase);
static RigFemPartCollection* geoMechPartCollection(RimCase* rimCase);
};