mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
NNC import started
This commit is contained in:
parent
81176258bc
commit
04ccadd2f1
@ -33,6 +33,7 @@
|
||||
#include "ecl_grid.h"
|
||||
#include "well_state.h"
|
||||
#include "ecl_kw_magic.h"
|
||||
#include "ecl_nnc_export.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
#include <map>
|
||||
@ -397,7 +398,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseC
|
||||
// Build results meta data
|
||||
buildMetaData();
|
||||
|
||||
|
||||
transferNNCData(mainEclGrid, m_ecl_init_file, eclipseCase->mainGrid());
|
||||
|
||||
progInfo.incrementProgress();
|
||||
progInfo.setNextProgressIncrement(8);
|
||||
@ -411,6 +412,35 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseC
|
||||
return true;
|
||||
}
|
||||
|
||||
void RifReaderEclipseOutput::transferNNCData( const ecl_grid_type * mainEclGrid , const ecl_file_type * init_file, RigMainGrid * mainGrid)
|
||||
{
|
||||
if (!m_ecl_init_file ) return;
|
||||
|
||||
CVF_ASSERT(mainEclGrid && mainGrid);
|
||||
|
||||
// Get the data from ERT
|
||||
|
||||
int numNNC = ecl_nnc_export_get_size( mainEclGrid );
|
||||
ecl_nnc_type * eclNNCData= new ecl_nnc_type[numNNC];
|
||||
|
||||
ecl_nnc_export( mainEclGrid , init_file , eclNNCData);
|
||||
|
||||
// Transform to our own datastructures
|
||||
|
||||
mainGrid->nncData()->connections().resize(numNNC);
|
||||
for (int nIdx = 0; nIdx < numNNC; ++nIdx)
|
||||
{
|
||||
RigGridBase* grid1 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr1);
|
||||
mainGrid->nncData()->connections()[nIdx].m_c1GlobIdx = grid1->globalGridCellIndex(eclNNCData[nIdx].global_index1);
|
||||
RigGridBase* grid2 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr2);
|
||||
mainGrid->nncData()->connections()[nIdx].m_c2GlobIdx = grid2->globalGridCellIndex(eclNNCData[nIdx].global_index2);
|
||||
mainGrid->nncData()->connections()[nIdx].m_transmissibility = eclNNCData[nIdx].trans;
|
||||
}
|
||||
|
||||
|
||||
delete[] eclNNCData;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -70,6 +70,8 @@ private:
|
||||
bool openDynamicAccess();
|
||||
|
||||
void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector<double>* values, const std::vector<double>& fileValues);
|
||||
void transferNNCData( const ecl_grid_type * mainEclGrid , const ecl_file_type * init_file,
|
||||
RigMainGrid * mainGrid);
|
||||
|
||||
RifEclipseRestartDataAccess* createDynamicResultsAccess();
|
||||
|
||||
|
@ -19,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.h
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsMath.h
|
||||
${CEE_CURRENT_LIST_DIR}RigWellPath.h
|
||||
${CEE_CURRENT_LIST_DIR}RigFault.h
|
||||
${CEE_CURRENT_LIST_DIR}RigNNCData.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -36,6 +37,7 @@ ${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsMath.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigWellPath.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigFault.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigNNCData.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -179,3 +179,16 @@ RigGridBase* RigMainGrid::gridById(int localGridId)
|
||||
return this->gridByIndex(m_gridIdToIndexMapping[localGridId]);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigNNCData* RigMainGrid::nncData()
|
||||
{
|
||||
if (m_nncData.isNull())
|
||||
{
|
||||
m_nncData = new RigNNCData;
|
||||
}
|
||||
|
||||
return m_nncData.p();
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include "RigNNCData.h"
|
||||
|
||||
class RigMainGrid : public RigGridBase
|
||||
{
|
||||
@ -46,6 +47,8 @@ public:
|
||||
const RigGridBase* gridByIndex(size_t localGridIndex) const;
|
||||
RigGridBase* gridById(int localGridId);
|
||||
|
||||
RigNNCData* nncData();
|
||||
|
||||
void computeCachedData();
|
||||
|
||||
// Overrides
|
||||
@ -65,6 +68,8 @@ private:
|
||||
cvf::Collection<RigLocalGrid> m_localGrids; ///< List of all the LGR's in this reservoir
|
||||
std::vector<size_t> m_gridIdToIndexMapping; ///< Mapping from LGR Id to index.
|
||||
|
||||
cvf::ref<RigNNCData> m_nncData;
|
||||
|
||||
cvf::Vec3d m_displayModelOffset;
|
||||
|
||||
bool m_flipXAxis;
|
||||
|
140
ApplicationCode/ReservoirDataModel/RigNNCData.cpp
Normal file
140
ApplicationCode/ReservoirDataModel/RigNNCData.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, Ceetron Solutions AS
|
||||
//
|
||||
// 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 "RigNNCData.h"
|
||||
#include "RigMainGrid.h"
|
||||
//#include "../ModelVisualization/cvfGeometryTools.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigNNCData::RigNNCData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigNNCData::processConnections(const RigMainGrid& mainGrid)
|
||||
{
|
||||
/*
|
||||
for (size_t cnIdx = 0; cnIdx < 0; ++cnIdx)
|
||||
{
|
||||
const RigCell& c1 = mainGrid.cells()[m_connections[cnIdx].m_c1GlobIdx];
|
||||
const RigCell& c2 = mainGrid.cells()[m_connections[cnIdx].m_c2GlobIdx];
|
||||
|
||||
// Try to find the shared face
|
||||
char hasNeighbourInAnyDirection = 0;
|
||||
|
||||
if (c1.hostGrid() == c2.hostGrid())
|
||||
{
|
||||
size_t i1, j1, k1;
|
||||
c1.hostGrid()->ijkFromCellIndex(c1.cellIndex(), &i1, &j1, &k1);
|
||||
size_t i2, j2, k2;
|
||||
c2.hostGrid()->ijkFromCellIndex(c2.cellIndex(), &i2, &j2, &k2);
|
||||
|
||||
bool isPossibleNeighborInDirection[6]= {false, false, false, false, false, false};
|
||||
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_I] = ((i1 + 1) == i2);
|
||||
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_I] = ((i2 + 1) == i1);
|
||||
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_J] = ((j1 + 1) == j2);
|
||||
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_J] = ((j2 + 1) == j1);
|
||||
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_K] = ((k1 + 1) == k2);
|
||||
isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_K] = ((k2 + 1) == k1);
|
||||
|
||||
hasNeighbourInAnyDirection =
|
||||
isPossibleNeighborInDirection[cvf::StructGridInterface::POS_I]
|
||||
+ isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_I]
|
||||
+ isPossibleNeighborInDirection[cvf::StructGridInterface::POS_J]
|
||||
+ isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_J]
|
||||
+ isPossibleNeighborInDirection[cvf::StructGridInterface::POS_K]
|
||||
+ isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_K];
|
||||
|
||||
|
||||
// If cell 2 is not adjancent with respect to any of the six ijk directions,
|
||||
// assume that we have no overlapping area.
|
||||
|
||||
if (!hasNeighbourInAnyDirection)
|
||||
{
|
||||
m_connections[cnIdx].m_hasNoSharedArea = true;
|
||||
continue; // to next connection
|
||||
}
|
||||
|
||||
if (hasNeighbourInAnyDirection == 1)
|
||||
{
|
||||
for (char fIdx = 0; fIdx < 6; ++fIdx)
|
||||
{
|
||||
if (isPossibleNeighborInDirection[fIdx])
|
||||
{
|
||||
m_connections[cnIdx].m_c1Face = (cvf::StructGridInterface::FaceType)fIdx;
|
||||
break; // the face loop
|
||||
}
|
||||
}
|
||||
|
||||
// calculate polygon for this face
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cvf::Vec3d normal;
|
||||
for (char fIdx = 0; fIdx < 6; ++fIdx)
|
||||
{
|
||||
if (isPossibleNeighborInDirection[fIdx])
|
||||
{
|
||||
cvf::Vec3d fc1 = c1.faceCenter((cvf::StructGridInterface::FaceType)(fIdx));
|
||||
cvf::Vec3d fc2 = c2.faceCenter(cvf::StructGridInterface::oppositeFace((cvf::StructGridInterface::FaceType)(fIdx)));
|
||||
cvf::Vec3d fc1ToFc2 = fc2 - fc1;
|
||||
normal = c1.faceNormal((cvf::StructGridInterface::FaceType)(fIdx));
|
||||
normal.normalize();
|
||||
// Check that face centers are approx in the face plane
|
||||
if (normal.dot(fc1ToFc2) < 0.01*fc1ToFc2.length())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Calculate connection polygon
|
||||
|
||||
std::vector<size_t> polygon;
|
||||
std::vector<cvf::Vec3d> intersections;
|
||||
bool isOk = false;
|
||||
caf::SizeTArray4 face1;
|
||||
caf::SizeTArray4 face2;
|
||||
c1.faceIndices((cvf::StructGridInterface::FaceType)(fIdx), &face1);
|
||||
c2.faceIndices(cvf::StructGridInterface::oppositeFace((cvf::StructGridInterface::FaceType)(fIdx)), &face2);
|
||||
|
||||
isOk = cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads(
|
||||
&polygon,
|
||||
&intersections,
|
||||
(cvf::EdgeIntersectStorage<size_t>*)NULL,
|
||||
cvf::wrapArrayConst(&mainGrid.nodes()),
|
||||
face1.data(),
|
||||
face2.data(),
|
||||
1e-6);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
75
ApplicationCode/ReservoirDataModel/RigNNCData.h
Normal file
75
ApplicationCode/ReservoirDataModel/RigNNCData.h
Normal file
@ -0,0 +1,75 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, Ceetron Solutions AS
|
||||
//
|
||||
// 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 "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cafFixedArray.h"
|
||||
|
||||
class RigMainGrid;
|
||||
|
||||
|
||||
class RigConnection
|
||||
{
|
||||
public:
|
||||
RigConnection( )
|
||||
: m_c1GlobIdx(cvf::UNDEFINED_SIZE_T),
|
||||
m_c1Face(cvf::StructGridInterface::POS_I),
|
||||
m_c2GlobIdx(cvf::UNDEFINED_SIZE_T),
|
||||
m_c2Face(cvf::StructGridInterface::NEG_I),
|
||||
m_hasNoSharedArea(false),
|
||||
m_transmissibility(0.0)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
bool m_hasNoSharedArea;
|
||||
size_t m_c1GlobIdx;
|
||||
cvf::StructGridInterface::FaceType m_c1Face;
|
||||
size_t m_c2GlobIdx;
|
||||
cvf::StructGridInterface::FaceType m_c2Face; //7 Probably Unused. Remove
|
||||
|
||||
double m_transmissibility;
|
||||
/* enum NNCType
|
||||
{
|
||||
|
||||
};*/
|
||||
};
|
||||
|
||||
|
||||
class RigNNCData : public cvf::Object
|
||||
{
|
||||
|
||||
public:
|
||||
RigNNCData();
|
||||
|
||||
void processConnections(const RigMainGrid& mainGrid);
|
||||
|
||||
std::vector<RigConnection>& connections() { return m_connections; }
|
||||
const std::vector<RigConnection>& connections() const { return m_connections; };
|
||||
|
||||
private:
|
||||
|
||||
std::vector<RigConnection> m_connections;
|
||||
};
|
Loading…
Reference in New Issue
Block a user