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(
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 )") cfunc.in_coarse_group1 = cwrapper.prototype("bool ecl_grid_cell_in_coarse_group1( ecl_grid , int)") cfunc.exists = cwrapper.prototype("bool ecl_grid_exists( char* )") cfunc.free = cwrapper.prototype("void ecl_grid_free( ecl_grid )") cfunc.get_nx = cwrapper.prototype("int ecl_grid_get_nx( ecl_grid )")
fortio.close() """ cfunc.fwrite( self , fortio , 0 ) # 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_try_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("bool ecl_file_iselect_rstblock( ecl_file , int )") cfunc.select_global = cwrapper.prototype("void ecl_file_select_global( ecl_file )") cfunc.iget_kw = cwrapper.prototype("c_void_p ecl_file_iget_kw( ecl_file , int)") cfunc.iget_named_kw = cwrapper.prototype("c_void_p ecl_file_iget_named_kw( ecl_file , char* , int)") cfunc.close = cwrapper.prototype("void ecl_file_close( ecl_file )")
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(
from ert.cwrap import CClass, CWrapper, CWrapperNameSpace class Matrix(CClass): def __init__(self, rows, columns): c_ptr = cfunc.matrix_alloc(rows, columns) self.init_cobj(c_ptr, cfunc.free) def __getitem__(self, index_tuple ): # print index_tuple (i, j) = index_tuple return cfunc.iget(self, i, j) def __setitem__(self, index_tuple, value): (i, j) = index_tuple return cfunc.iset(self, i, j, value) ################################################################# CWrapper.registerType("matrix", Matrix) cwrapper = CWrapper(UTIL_LIB) cfunc = CWrapperNameSpace("matrix") cfunc.matrix_alloc = cwrapper.prototype("c_void_p matrix_alloc( int , int )") cfunc.free = cwrapper.prototype("void matrix_free( matrix )") cfunc.iget = cwrapper.prototype("double matrix_iget( matrix , int , int )") cfunc.iset = cwrapper.prototype("void matrix_iset( matrix , int , int , double)")
for (host, host_max) in rsh_host_list: options.append(("RSH_HOST", "%s:%d" % (host, host_max))) Driver.__init__(self, 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("c_void_p queue_driver_submit_job( driver , char* , int , char* , char* , int , char**)") cfunc.free_job = cwrapper.prototype("void queue_driver_free_job( driver , job )") cfunc.cget_status = cwrapper.prototype("int queue_driver_get_status( driver , job)") cfunc.kill_job = cwrapper.prototype("void queue_driver_kill_job( driver , job )") cfunc.set_max_running = cwrapper.prototype("void queue_driver_set_max_running( driver , int )") cfunc.get_max_running = cwrapper.prototype("int queue_driver_get_max_running( driver )") cfunc.set_str_option = cwrapper.prototype("bool queue_driver_set_option( driver , char* , char*) ")
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(
["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* )")
def close( self ): """ Close the filehandle. """ # Seems Python itself allows close() calls on already closed file handles, # so we take care to ensure that also the FortIO class supports that. if self.pyfile: self.pyfile.close() cfunc.free_wrapper( self ) self.pyfile = None self.c_ptr = None # 2. Creating a wrapper object around the libecl library, # registering the type map : fortio <-> FortIO cwrapper = CWrapper(ECL_LIB) cwrapper.registerType("fortio" , FortIO ) # 3. Installing the c-functions used to manipulate fortio instances. # These functions are used when implementing the FortIO class, not # used outside this scope. cfunc = CWrapperNameSpace("fortio") cfunc.fortio_wrap_FILE = cwrapper.prototype("c_void_p fortio_alloc_FILE_wrapper( char* , bool , bool , FILE )") cfunc.free_wrapper = cwrapper.prototype("void fortio_free_FILE_wrapper( fortio )")
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)" )
# 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 )")
>> print l ["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* )")
The new_std_density() and add_std_density() methods must be used before you use the add_survey_FIP() method to add a survey based on the FIP keyword. """ cfunc.add_std_density(self, phase_enum, pvtnum, density) # 2. Creating a wrapper object around the libecl library, cwrapper = CWrapper(ECL_LIB) cwrapper.registerType("ecl_grav", EclGrav) # 3. Installing the c-functions used to manipulate ecl_grav instances. # These functions are used when implementing the EclGrav class, not # used outside this scope. cfunc = CWrapperNameSpace("ecl_grav") cfunc.grav_alloc = cwrapper.prototype( "c_void_p ecl_grav_alloc( ecl_grid , ecl_file )") cfunc.free = cwrapper.prototype("void ecl_grav_free( ecl_grav )") # Return value ignored in the add_survey_xxx() functions: cfunc.add_survey_RPORV = cwrapper.prototype( "c_void_p ecl_grav_add_survey_RPORV( ecl_grav , char* , ecl_file )") cfunc.add_survey_PORMOD = cwrapper.prototype( "c_void_p ecl_grav_add_survey_PORMOD( ecl_grav , char* , ecl_file )") cfunc.add_survey_FIP = cwrapper.prototype( "c_void_p ecl_grav_add_survey_FIP( ecl_grav , char* , ecl_file )") cfunc.add_survey_RFIP = cwrapper.prototype( "c_void_p ecl_grav_add_survey_RFIP( ecl_grav , char* , ecl_file )")
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)") cfunc.select_less = cwrapper.prototype("void ecl_region_select_smaller( ecl_region , ecl_kw , float )") cfunc.deselect_less = cwrapper.prototype("void ecl_region_deselect_smaller( ecl_region , ecl_kw , float )") cfunc.select_more = cwrapper.prototype("void ecl_region_select_larger( ecl_region , ecl_kw , float )")
beta = Matrix( n , 1 ) res = cfunc.polyfit( beta , xm , ym , sm) if not res == LLSQResultEnum.LLSQ_SUCCESS: raise Exception("Linear Least Squares Estimator failed?") l = [] for i in range(n): l.append( beta[i,0] ) return tuple(l) 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 )") try: cfunc.polyfit = cwrapper.prototype("llsq_result_enum matrix_stat_polyfit(matrix , matrix , matrix , matrix)") except CWrapError: cfunc.polyfit = None
# 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 )")
def set_timeout(self, timeout): cfunc.set_timeout(self, timeout) 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("void latex_link_directory_content( latex , char*)") cfunc.link_path = cwrapper.prototype("void latex_link_path( latex , char*)")
if s: if isinstance(s, Matrix): sm = s else: sm = Matrix(len(s), 1) for i in range(len(s)): sm[i, 0] = s[i] else: sm = s beta = Matrix(n, 1) res = cfunc.polyfit(beta, xm, ym, sm) if not res == LLSQResultEnum.LLSQ_SUCCESS: raise Exception("Linear Least Squares Estimator failed?") l = [] for i in range(n): l.append(beta[i, 0]) return tuple(l) 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 )") cfunc.polyfit = cwrapper.prototype("llsq_result_enum matrix_stat_polyfit(matrix , matrix , matrix , matrix)")
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 )")
elif ecl_type == EclTypeEnum.ECL_DOUBLE_TYPE: 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("c_void_p ecl_kw_alloc_sub_copy( ecl_kw , char*, int , int)") cfunc.slice_copyc = cwrapper.prototype("c_void_p ecl_kw_alloc_slice_copy( ecl_kw , int , int , int )") cfunc.fread_alloc = cwrapper.prototype("c_void_p ecl_kw_fread_alloc( fortio )") cfunc.get_size = cwrapper.prototype("int ecl_kw_get_size( ecl_kw )") cfunc.get_fortio_size = cwrapper.prototype("size_t ecl_kw_fortio_size( ecl_kw )") cfunc.get_type = cwrapper.prototype("ecl_type_enum ecl_kw_get_type( ecl_kw )") cfunc.iget_char_ptr = cwrapper.prototype("char* ecl_kw_iget_char_ptr( ecl_kw , int )")
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.
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(
# 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)")
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. Will look for the "PARALLELL" keyword, and then read off the
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)")
# 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 )")
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)")
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)") cfunc_rft.get_type = cwrapper.prototype("int ecl_rft_node_get_type( ecl_rft )") cfunc_rft.get_well = cwrapper.prototype("char* ecl_rft_node_get_well_name( ecl_rft )") cfunc_rft.get_date = cwrapper.prototype("time_t ecl_rft_node_get_date( ecl_rft )") cfunc_rft.get_size = cwrapper.prototype("int ecl_rft_node_get_size( ecl_rft )") cfunc_rft.iget_cell = cwrapper.prototype("c_void_p ecl_rft_node_iget_cell( ecl_rft )")
The new_std_density() and add_std_density() methods must be used before you use the add_survey_FIP() method to add a survey based on the FIP keyword. """ cfunc.add_std_density(self, phase_enum, pvtnum, density) # 2. Creating a wrapper object around the libecl library, cwrapper = CWrapper(ECL_LIB) cwrapper.registerType("ecl_grav", EclGrav) # 3. Installing the c-functions used to manipulate ecl_grav instances. # These functions are used when implementing the EclGrav class, not # used outside this scope. cfunc = CWrapperNameSpace("ecl_grav") cfunc.grav_alloc = cwrapper.prototype("c_void_p ecl_grav_alloc( ecl_grid , ecl_file )") cfunc.free = cwrapper.prototype("void ecl_grav_free( ecl_grav )") # Return value ignored in the add_survey_xxx() functions: cfunc.add_survey_RPORV = cwrapper.prototype("c_void_p ecl_grav_add_survey_RPORV( ecl_grav , char* , ecl_file )") cfunc.add_survey_PORMOD = cwrapper.prototype("c_void_p ecl_grav_add_survey_PORMOD( ecl_grav , char* , ecl_file )") cfunc.add_survey_FIP = cwrapper.prototype("c_void_p ecl_grav_add_survey_FIP( ecl_grav , char* , ecl_file )") cfunc.add_survey_RFIP = cwrapper.prototype("c_void_p ecl_grav_add_survey_RFIP( ecl_grav , char* , ecl_file )") cfunc.new_std_density = cwrapper.prototype("void ecl_grav_new_std_density( ecl_grav , int , double)") cfunc.add_std_density = cwrapper.prototype("void ecl_grav_add_std_density( ecl_grav , int , int , double)") cfunc.eval = cwrapper.prototype("double ecl_grav_eval( ecl_grav , char* , char* , ecl_region , double , double , double, int)")
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 )")
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)" )