Exemplo n.º 1
0
    def exportACTNUMKw(self):
        actnum = EclKW.create("ACTNUM", self.getGlobalSize(),
                              EclTypeEnum.ECL_INT_TYPE)
        cfunc.init_actnum(self, actnum.getDataPtr())
        return actnum


# 2. Creating a wrapper object around the libecl library,
#    registering the type map : ecl_kw <-> EclKW
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_grid", EclGrid)

# 3. Installing the c-functions used to manipulate ecl_kw instances.
#    These functions are used when implementing the EclKW class, not
#    used outside this scope.
cfunc = CWrapperNameSpace("ecl_grid")

cfunc.fread_alloc = cwrapper.prototype("c_void_p ecl_grid_load_case( char* )")
cfunc.grdecl_create = cwrapper.prototype(
    "c_void_p ecl_grid_alloc_GRDECL_kw( int , int , int , ecl_kw , ecl_kw , ecl_kw , ecl_kw)"
)
cfunc.get_lgr = cwrapper.prototype(
    "c_void_p ecl_grid_get_lgr( ecl_grid , char* )")
cfunc.get_cell_lgr = cwrapper.prototype(
    "c_void_p ecl_grid_get_cell_lgr1( ecl_grid , int )")
cfunc.alloc_rectangular = cwrapper.prototype(
    "c_void_p ecl_grid_alloc_rectangular( int , int , int , double , double , double , int*)"
)

cfunc.num_coarse_groups = cwrapper.prototype(
    "int  ecl_grid_get_num_coarse_groups( ecl_grid )")
Exemplo n.º 2
0
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
"""
Create a polygon
"""
from ert.cwrap import CClass, CWrapper, CWrapperNameSpace
from ert.geo import ERT_GEOMETRY_LIB


class GeoPolygon(CClass):
    def __init__(self, points):
        c_ptr = cfunc.alloc_new()
        self.init_cobj(c_ptr, cfunc.free)
        for (xc, yc) in points:
            self.add_point(xc, yc)

    def add_point(self, xc, yc):
        cfunc.add_point(self, xc, yc)


#################################################################

cwrapper = CWrapper(ERT_GEOMETRY_LIB)
cwrapper.registerType("geo_polygon", GeoPolygon)

cfunc = CWrapperNameSpace("geo_polygon")
cfunc.alloc_new = cwrapper.prototype("c_void_p geo_polygon_alloc( )")
cfunc.add_point = cwrapper.prototype(
    "void     geo_polygon_add_point( geo_polygon , double , double )")
cfunc.free = cwrapper.prototype("void     geo_polygon_free( geo_polygon )")
Exemplo n.º 3
0
            return cfunc.double_ptr(self)
        else:
            raise ValueError("Only numeric types can export data pointer")


#################################################################

# 2. Creating a wrapper object around the libecl library,
#    registering the type map : ecl_kw <-> EclKW
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_kw", EclKW)

# 3. Installing the c-functions used to manipulate ecl_kw instances.
#    These functions are used when implementing the EclKW class, not
#    used outside this scope.
cfunc = CWrapperNameSpace("ecl_kw")

cfunc.load_grdecl = cwrapper.prototype(
    "c_void_p ecl_kw_fscanf_alloc_grdecl_dynamic__( FILE , char* , bool , int )"
)
cfunc.fseek_grdecl = cwrapper.prototype(
    "bool     ecl_kw_grdecl_fseek_kw(char* , bool , FILE )")
cfunc.fprintf_grdecl = cwrapper.prototype(
    "void     ecl_kw_fprintf_grdecl( ecl_kw , FILE )")
cfunc.fprintf_data = cwrapper.prototype(
    "void     ecl_kw_fprintf_data( ecl_kw , char* , FILE )")

cfunc.alloc_new = cwrapper.prototype(
    "c_void_p ecl_kw_alloc( char* , int , ecl_type_enum )")
cfunc.copyc = cwrapper.prototype("c_void_p ecl_kw_alloc_copy( ecl_kw )")
cfunc.sub_copy = cwrapper.prototype(
Exemplo n.º 4
0
                        QueueDriverEnum.RSH_DRIVER,
                        max_running,
                        options=options)


#Legacy enum support for ecl_local.py
LSF_DRIVER = QueueDriverEnum.LSF_DRIVER
RSH_DRIVER = QueueDriverEnum.RSH_DRIVER
LOCAL_DRIVER = QueueDriverEnum.LOCAL_DRIVER

#################################################################
cwrapper = CWrapper(JOB_QUEUE_LIB)
cwrapper.registerType("driver", Driver)
cwrapper.registerType("job", Job)

cfunc = CWrapperNameSpace("driver")

cfunc.alloc_driver_lsf = cwrapper.prototype(
    "c_void_p    queue_driver_alloc_LSF( char* , char* , char* )")
cfunc.alloc_driver_local = cwrapper.prototype(
    "c_void_p    queue_driver_alloc_local( )")
cfunc.alloc_driver_rsh = cwrapper.prototype(
    "c_void_p    queue_driver_alloc_RSH( char* , c_void_p )")
cfunc.alloc_driver = cwrapper.prototype(
    "c_void_p    queue_driver_alloc( int )")
cfunc.set_driver_option = cwrapper.prototype(
    "void        queue_driver_set_option(driver , char* , char*)")

cfunc.free_driver = cwrapper.prototype(
    "void        queue_driver_free( driver )")
cfunc.submit = cwrapper.prototype(
Exemplo n.º 5
0
        self.__ecl_file.close()
        return False


def openEclFile(file_name, flags=0):
    return EclFileContextManager(EclFile(file_name, flags))


# 2. Creating a wrapper object around the libecl library,
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_file", EclFile)

# 3. Installing the c-functions used to manipulate ecl_file instances.
#    These functions are used when implementing the EclFile class, not
#    used outside this scope.
cfunc = CWrapperNameSpace("ecl_file")

cfunc.open = cwrapper.prototype("c_void_p    ecl_file_open( char* , int )")
cfunc.writable = cwrapper.prototype(
    "bool        ecl_file_writable( ecl_file )")
cfunc.new = cwrapper.prototype("c_void_p    ecl_file_alloc_empty(  )")
cfunc.save_kw = cwrapper.prototype(
    "void        ecl_file_save_kw( ecl_file , ecl_kw )")

cfunc.select_block = cwrapper.prototype(
    "bool        ecl_file_select_block( ecl_file , char* , int )")
cfunc.restart_block_time = cwrapper.prototype(
    "bool        ecl_file_select_rstblock_sim_time( ecl_file , time_t )")
cfunc.restart_block_step = cwrapper.prototype(
    "bool        ecl_file_select_rstblock_report_step( ecl_file , int )")
cfunc.restart_block_iselect = cwrapper.prototype(
Exemplo n.º 6
0
#  ERT 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. 
#   
#  ERT 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. 


from ert.util import UTIL_LIB
from ert.cwrap import CWrapper, CWrapperNameSpace


def quantile( data, q ):
    return cfunc.quantile(data, q)


def quantile_sorted( data, q ):
    return cfunc.quantile_sorted(data, q)


cwrapper = CWrapper(UTIL_LIB)
cfunc = CWrapperNameSpace("stat")

cfunc.quantile = cwrapper.prototype("double statistics_empirical_quantile( double_vector , double )")
cfunc.quantile_sorted = cwrapper.prototype("double statistics_empirical_quantile( double_vector , double )")
Exemplo n.º 7
0
          ["CASE-10" , "CASE-9"]
       >> l.sort( strcmp_int )
       >> print l
          ["CASE-9" , "CASE-10"]   

    When the standard strcmp() function is used for comparing strings
    the '1' will compare as less than the '9' and the order will be
    the reverse. Observe that the '-' is not interpreted as a sign
    prefix. The strcmp_int function will interpret '.' as separating
    character, wheras the strcmp_float() function will interpret '.'
    as a descimal point.
    """
    return cfunc.strcmp_int(s1, s2)


def strcmp_float(s1, s2):
    """
    Function to compare strings with embedded numbers.

    See documentation of strcmp_int() for further details.
    """
    return cfunc.strcmp_float(s1, s2)


cwrapper = CWrapper(UTIL_LIB)
cfunc = CWrapperNameSpace("util_func")

cfunc.strcmp_int = cwrapper.prototype("int util_strcmp_int( char* , char* )")
cfunc.strcmp_float = cwrapper.prototype(
    "int util_strcmp_float( char* , char* )")
Exemplo n.º 8
0
    def set_name(self, name):
        cfunc.set_name(self, name)

    def get_name(self):
        return cfunc.get_name(self)

    name = property(get_name, set_name)


# 2. Creating a wrapper object around the libecl library.
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_region", EclRegion)

# 3. Installing the c-functions used to manipulate.
cfunc = CWrapperNameSpace("ecl_region")

cfunc.alloc = cwrapper.prototype(
    "c_void_p ecl_region_alloc( ecl_grid , bool )")
cfunc.free = cwrapper.prototype("void ecl_region_free( ecl_region )")
cfunc.reset = cwrapper.prototype("void ecl_region_reset( ecl_region )")

cfunc.select_all = cwrapper.prototype(
    "void ecl_region_select_all( ecl_region )")
cfunc.deselect_all = cwrapper.prototype(
    "void ecl_region_deselect_all( ecl_region )")

cfunc.select_equal = cwrapper.prototype(
    "void ecl_region_select_equal( ecl_region , ecl_kw , int )")
cfunc.deselect_equal = cwrapper.prototype(
    "void ecl_region_deselect_equal( ecl_region , ecl_kw , int)")
Exemplo n.º 9
0
        i.e. you must subtract 1 from the (i,j,k) values given in the ECLIPSE input.
        """
        cell_ptr = cfunc_rft.lookup_ijk(self, ijk[0], ijk[1], ijk[2])
        if cell_ptr:
            return self.__cell_ref(cell_ptr)
        else:
            return None


# 2. Creating a wrapper object around the libecl library,
#    registering the type map : ecl_kw <-> EclKW
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_rft_file", EclRFTFile)
cwrapper.registerType("ecl_rft", EclRFT)

cfunc_file = CWrapperNameSpace("ecl_rft_file")
cfunc_rft = CWrapperNameSpace("ecl_rft")

cfunc_file.load = cwrapper.prototype(
    "c_void_p ecl_rft_file_alloc_case( char* )")
cfunc_file.has_rft = cwrapper.prototype(
    "bool ecl_rft_file_case_has_rft( char* )")
cfunc_file.free = cwrapper.prototype("void ecl_rft_file_free( ecl_rft_file )")
cfunc_file.get_size = cwrapper.prototype(
    "int ecl_rft_file_get_size__( ecl_rft_file , char* , time_t)")
cfunc_file.iget = cwrapper.prototype(
    "c_void_p ecl_rft_file_iget_node( ecl_rft_file , int )")
cfunc_file.get_num_wells = cwrapper.prototype(
    "int  ecl_rft_file_get_num_wells( ecl_rft_file )")
cfunc_file.get_rft = cwrapper.prototype(
    "c_void_p ecl_rft_file_get_well_time_rft( ecl_rft_file , char* , time_t)")
Exemplo n.º 10
0
            # Oil / Water system
            soil1 = 1 - swat1
            soil2 = 1 - swat2
            soil1.name = "SOIL"
            soil2.name = "SOIL"
            phase_list += [(soil1, soil2)]
        else:
            # Gas / Water system
            sgas1 = 1 - swat1
            sgas2 = 1 - swat2
            sgas1.name = "SGAS"
            sgas2.name = "SGAS"
            phase_list += [(sgas1, sgas2)]

    porv1 = restart_file1.iget_named_kw("RPORV", 0)
    porv2 = restart_file2.iget_named_kw("RPORV", 0)

    deltag = 0
    for (sat1, sat2) in phase_list:
        rho_name = "%s_DEN" % sat1.name[1:]
        rho1 = restart_file1.iget_named_kw(rho_name, 0)
        rho2 = restart_file2.iget_named_kw(rho_name, 0)
        deltag += phase_deltag(xyz, grid, init_file, sat1, rho1, porv1, sat2, rho2, porv2)
    return deltag


cwrapper = CWrapper(ECL_LIB)
cfunc = CWrapperNameSpace("ecl_grav")
cfunc.phase_deltag = cwrapper.prototype("double ecl_grav_phase_deltag( double, double ,double , c_void_p , c_void_p , c_void_p , c_void_p , c_void_p , c_void_p , c_void_p , c_void_p)")

Exemplo n.º 11
0

class EclFileFlagEnum(BaseCEnum):
    ECL_FILE_CLOSE_STREAM = None
    ECL_FILE_WRITABLE = None


EclFileFlagEnum.addEnum("ECL_FILE_CLOSE_STREAM", 1)
EclFileFlagEnum.addEnum("ECL_FILE_WRITABLE", 2)

EclFileFlagEnum.registerEnum(ECL_LIB, "ecl_file_flag_enum")

#-----------------------------------------------------------------

cwrapper = CWrapper(ECL_LIB)
cfunc = CWrapperNameSpace("ecl_util")

cfunc.get_num_cpu = cwrapper.prototype("int ecl_util_get_num_cpu( char* )")
cfunc.get_file_type = cwrapper.prototype(
    "ecl_file_enum ecl_util_get_file_type( char* , bool* , int*)")
cfunc.get_type_name = cwrapper.prototype("char* ecl_util_get_type_name( int )")
cfunc.get_start_date = cwrapper.prototype(
    "time_t ecl_util_get_start_date( char* )")


class EclUtil(object):
    @staticmethod
    def get_num_cpu(datafile):
        """
        Parse ECLIPSE datafile and determine how many CPUs are needed.
Exemplo n.º 12
0
        return cfunc.get_gas_flowrate( self )

    @property
    def water_flowrate(self):
        return cfunc.get_water_flowrate( self )


#################################################################


cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType( "rft_cell"     , RFTCell)
cwrapper.registerType( "ecl_rft_cell" , EclRFTCell )
cwrapper.registerType( "ecl_plt_cell" , EclPLTCell )

cfunc = CWrapperNameSpace("ecl_rft_cell")

cfunc.alloc_RFT    = cwrapper.prototype("c_void_p ecl_rft_cell_alloc_RFT( int, int , int , double , double , double , double)")
cfunc.alloc_PLT    = cwrapper.prototype("c_void_p ecl_rft_cell_alloc_PLT( int, int , int , double , double , double, double , double, double , double , double , double , double , double )")
cfunc.free         = cwrapper.prototype("void ecl_rft_cell_free( rft_cell )")

cfunc.get_pressure = cwrapper.prototype("double ecl_rft_cell_get_pressure( rft_cell )")
cfunc.get_depth    = cwrapper.prototype("double ecl_rft_cell_get_depth( rft_cell )")
cfunc.get_i        = cwrapper.prototype("int ecl_rft_cell_get_i( rft_cell )")
cfunc.get_j        = cwrapper.prototype("int ecl_rft_cell_get_j( rft_cell )")
cfunc.get_k        = cwrapper.prototype("int ecl_rft_cell_get_k( rft_cell )")

cfunc.get_swat = cwrapper.prototype("double ecl_rft_cell_get_swat( ecl_rft_cell )")
cfunc.get_soil = cwrapper.prototype("double ecl_rft_cell_get_soil( ecl_rft_cell )")
cfunc.get_sgas = cwrapper.prototype("double ecl_rft_cell_get_sgas( ecl_rft_cell )")
Exemplo n.º 13
0
    timeout = property(get_timeout, set_timeout)

    #-----------------------------------------------------------------

    def link_content(self, directory):
        cfunc.link_directory_content(self, directory)

    def link_path(self, path):
        cfunc.link_path(self, path)


cwrapper = CWrapper(UTIL_LIB)
cwrapper.registerType("latex", LaTeX)

# 3. Installing the c-functions used to manipulate.
cfunc = CWrapperNameSpace("latex")
cfunc.alloc = cwrapper.prototype("c_void_p  latex_alloc( char* , bool )")
cfunc.free = cwrapper.prototype("void      latex_free( latex )")
cfunc.compile = cwrapper.prototype(
    "bool      latex_compile(latex , bool , bool , bool)")
cfunc.get_runpath = cwrapper.prototype("char*     latex_get_runpath( latex )")
cfunc.get_target = cwrapper.prototype(
    "char*     latex_get_target_file( latex )")
cfunc.set_target = cwrapper.prototype(
    "void      latex_set_target_file( latex , char* )")
cfunc.set_timeout = cwrapper.prototype(
    "void      latex_set_timeout( latex , int )")
cfunc.get_timeout = cwrapper.prototype("int       latex_get_timeout( latex )")
cfunc.compile_in_place = cwrapper.prototype(
    "bool      latex_compile_in_place( latex )")
cfunc.link_directory_content = cwrapper.prototype(
Exemplo n.º 14
0
        If supplied the optional argument @region should be an
        EclRegion() instance; this region will be used to limit the
        part of the reserviour included in the subsidence calculations.

        The argument @compressibility is the total reservoir compressibility.
        """
        return cfunc.eval(self, base_survey, monitor_survey, region, pos[0],
                          pos[1], pos[2], compressibility, poisson_ratio)


# 2. Creating a wrapper object around the libecl library,
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_subsidence", EclSubsidence)

# 3. Installing the c-functions used to manipulate ecl_subsidence instances.
#    These functions are used when implementing the EclSubsidence class, not
#    used outside this scope.
cfunc = CWrapperNameSpace("ecl_subsidence")

cfunc.subsidence_alloc = cwrapper.prototype(
    "c_void_p ecl_subsidence_alloc( ecl_grid , ecl_file )")
cfunc.free = cwrapper.prototype("void ecl_subsidence_free( ecl_subsidence )")

# Return value ignored in the add_survey_xxx() functions:
cfunc.add_survey_PRESSURE = cwrapper.prototype(
    "c_void_p  ecl_subsidence_add_survey_PRESSURE( ecl_subsidence , char* , ecl_file )"
)
cfunc.eval = cwrapper.prototype(
    "double ecl_subsidence_eval( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double)"
)