Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
added faults
Browse files Browse the repository at this point in the history
  • Loading branch information
Pål Grønås Drange authored and Pål Grønås Drange committed Jan 13, 2017
1 parent 70a9ef1 commit 42fc9b2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/sunbeam/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def grid(self):
def cfg(self):
return EclipseConfig(self._cfg())

def faults(self):
"""Returns a map from fault names to list of (i,j,k,D) where D ~ 'X+'"""
fs = {}
for fn in self.faultNames():
fs[fn] = self.faultFaces(fn)
return fs


@delegate(lib.Eclipse3DProperties)
class Eclipse3DProperties(object):
Expand Down
42 changes: 42 additions & 0 deletions python/sunbeam/sunbeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
Expand All @@ -26,6 +30,42 @@ py::list getNNC( const EclipseState& state ) {
l.append( py::make_tuple( x.cell1, x.cell2, x.trans ) );
return l;
}
py::list faultNames( const EclipseState& state ) {
py::list l;
const auto& fc = state.getFaults();
for (size_t i = 0; i < fc.size(); i++) {
const auto& f = fc.getFault(i);
l.append(f.getName());
}
return l;
}

const std::string faceDir( FaceDir::DirEnum dir ) {
switch (dir) {
case FaceDir::DirEnum::XPlus: return "X+";
case FaceDir::DirEnum::XMinus: return "X-";
case FaceDir::DirEnum::YPlus: return "Y+";
case FaceDir::DirEnum::YMinus: return "Y-";
case FaceDir::DirEnum::ZPlus: return "Z+";
case FaceDir::DirEnum::ZMinus: return "Z-";
}
return "Unknown direction";
}
py::list faultFaces( const EclipseState& state, const std::string& name ) {
py::list l;
const auto& gr = state.getInputGrid(); // used for global -> IJK
const auto& fc = state.getFaults();
const Fault& f = fc.getFault(name);
for (const auto& ff : f) {
// for each fault face
for (size_t g : ff) {
// for global index g in ff
const auto ijk = gr.getIJK(g);
l.append(py::make_tuple(ijk[0], ijk[1], ijk[2], faceDir(ff.getDir())));
}
}
return l;
}
}

namespace cfg {
Expand Down Expand Up @@ -192,6 +232,8 @@ py::class_< EclipseState >( "EclipseState", py::no_init )
.def( "_cfg", &EclipseState::cfg, ref() )
.def( "has_input_nnc", &EclipseState::hasInputNNC )
.def( "input_nnc", state::getNNC )
.def( "faultNames", state::faultNames )
.def( "faultFaces", state::faultFaces )
;

py::class_< EclipseGrid >( "EclipseGrid", py::no_init )
Expand Down
4 changes: 4 additions & 0 deletions tests/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ def test_config(self):
self.assertFalse(sim.useCPR())
self.assertTrue(sim.hasDISGAS())
self.assertTrue(sim.hasVAPOIL())

def test_faults(self):
self.assertEquals([], self.spe3.faultNames())
self.assertEquals({}, self.spe3.faults())

0 comments on commit 42fc9b2

Please sign in to comment.