Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
cac57ff314
@ -115,7 +115,9 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridManager::saveEGRID(const std::string& filename , const Opm::EclipseGridParser& deck) {
|
||||||
|
deck.saveEGRID( filename , ug_->number_of_cells , ug_->global_cell );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
@ -136,7 +138,6 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Construct corner-point grid from deck.
|
// Construct corner-point grid from deck.
|
||||||
void GridManager::initFromDeckCornerpoint(const Opm::EclipseGridParser& deck)
|
void GridManager::initFromDeckCornerpoint(const Opm::EclipseGridParser& deck)
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,8 @@ namespace Opm
|
|||||||
/// Destructor.
|
/// Destructor.
|
||||||
~GridManager();
|
~GridManager();
|
||||||
|
|
||||||
|
void saveEGRID(const std::string& filename , const Opm::EclipseGridParser& deck);
|
||||||
|
|
||||||
/// Access the managed UnstructuredGrid.
|
/// Access the managed UnstructuredGrid.
|
||||||
/// The method is named similarly to c_str() in std::string,
|
/// The method is named similarly to c_str() in std::string,
|
||||||
/// to make it clear that we are returning a C-compatible struct.
|
/// to make it clear that we are returning a C-compatible struct.
|
||||||
|
@ -966,49 +966,61 @@ ecl_grid_type * EclipseGridParser::newGrid( ) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void EclipseGridParser::saveEGRID( const std::string & filename) const {
|
void EclipseGridParser::saveEGRID( const std::string & filename , int num_cells , const int * global_cell) const {
|
||||||
bool endian_flip = true;//ECL_ENDIAN_FLIP;
|
bool endian_flip = true;//ECL_ENDIAN_FLIP;
|
||||||
bool fmt_file;
|
bool fmt_file;
|
||||||
struct grdecl grdecl = get_grdecl();
|
struct grdecl grdecl = get_grdecl();
|
||||||
fortio_type * fortio;
|
fortio_type * fortio;
|
||||||
|
|
||||||
|
if (!ecl_util_fmt_file( filename.c_str() , &fmt_file)) {
|
||||||
|
cerr << "Could not determine formatted/unformatted status of file:" << filename << " non-standard name?" << endl;
|
||||||
|
throw exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip );
|
||||||
|
{
|
||||||
|
float * mapaxes = NULL;
|
||||||
|
if (grdecl.mapaxes != NULL) {
|
||||||
|
mapaxes = new float[6];
|
||||||
|
for (int i=0; i < 6; i++)
|
||||||
|
mapaxes[i]= grdecl.mapaxes[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
ecl_grid_fwrite_EGRID_header( grdecl.dims , mapaxes , fortio );
|
||||||
|
|
||||||
|
if (grdecl.mapaxes != NULL)
|
||||||
|
delete[] mapaxes;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ecl_util_fmt_file( filename.c_str() , &fmt_file)) {
|
{
|
||||||
cerr << "Could not determine formatted/unformatted status of file:" << filename << " non-standard name?" << endl;
|
ecl_kw_type * coord_kw = newEclKW( COORD_KW , ECL_FLOAT_TYPE );
|
||||||
throw exception();
|
ecl_kw_type * zcorn_kw = newEclKW( ZCORN_KW , ECL_FLOAT_TYPE );
|
||||||
}
|
ecl_kw_type * endgrid_kw = ecl_kw_alloc( ENDGRID_KW , 0 , ECL_INT_TYPE );
|
||||||
|
|
||||||
|
|
||||||
|
ecl_kw_fwrite( coord_kw , fortio );
|
||||||
|
ecl_kw_fwrite( zcorn_kw , fortio );
|
||||||
|
if (global_cell) {
|
||||||
|
int global_size = grdecl.dims[0] * grdecl.dims[1] * grdecl.dims[2];
|
||||||
|
ecl_kw_type * actnum_kw = ecl_kw_alloc( ACTNUM_KW , global_size , ECL_INT_TYPE );
|
||||||
|
int * actnum_data = ecl_kw_get_int_ptr( actnum_kw );
|
||||||
|
|
||||||
|
ecl_kw_scalar_set_int( actnum_kw , 0 );
|
||||||
|
for (int c=0; c < num_cells; c++)
|
||||||
|
actnum_data[global_cell[c]] = 1;
|
||||||
|
|
||||||
fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip );
|
ecl_kw_fwrite( actnum_kw , fortio );
|
||||||
{
|
ecl_kw_free( actnum_kw );
|
||||||
float * mapaxes = NULL;
|
}
|
||||||
if (grdecl.mapaxes != NULL) {
|
ecl_kw_fwrite( endgrid_kw , fortio );
|
||||||
mapaxes = new float[6];
|
|
||||||
for (int i=0; i < 6; i++)
|
ecl_kw_free( coord_kw );
|
||||||
mapaxes[i]= grdecl.mapaxes[i];
|
ecl_kw_free( zcorn_kw );
|
||||||
|
ecl_kw_free( endgrid_kw );
|
||||||
|
}
|
||||||
|
fortio_fclose( fortio );
|
||||||
}
|
}
|
||||||
|
|
||||||
ecl_grid_fwrite_EGRID_header( grdecl.dims , mapaxes , fortio );
|
|
||||||
|
|
||||||
if (grdecl.mapaxes != NULL)
|
|
||||||
delete[] mapaxes;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
ecl_kw_type * coord_kw = newEclKW( COORD_KW , ECL_FLOAT_TYPE );
|
|
||||||
ecl_kw_type * zcorn_kw = newEclKW( ZCORN_KW , ECL_FLOAT_TYPE );
|
|
||||||
ecl_kw_type * actnum_kw = newEclKW( ACTNUM_KW , ECL_INT_TYPE );
|
|
||||||
ecl_kw_type * endgrid_kw = ecl_kw_alloc( ENDGRID_KW , 0 , ECL_INT_TYPE );
|
|
||||||
|
|
||||||
ecl_kw_fwrite( coord_kw , fortio );
|
|
||||||
ecl_kw_fwrite( zcorn_kw , fortio );
|
|
||||||
ecl_kw_fwrite( actnum_kw , fortio );
|
|
||||||
ecl_kw_fwrite( endgrid_kw , fortio );
|
|
||||||
|
|
||||||
ecl_kw_free( coord_kw );
|
|
||||||
ecl_kw_free( zcorn_kw );
|
|
||||||
ecl_kw_free( actnum_kw );
|
|
||||||
ecl_kw_free( endgrid_kw );
|
|
||||||
}
|
|
||||||
fortio_fclose( fortio );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Will query the deck for keyword @kw; and save it to the @fortio
|
Will query the deck for keyword @kw; and save it to the @fortio
|
||||||
@ -1092,12 +1104,14 @@ void EclipseGridParser::saveEGRID_INIT( const std::string& output_dir , const st
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void EclipseGridParser::saveEGRID( const std::string & filename) const
|
void EclipseGridParser::saveEGRID( const std::string & filename, int num_cells , const int * global_cell) const
|
||||||
{
|
{
|
||||||
static_cast<void>(filename); // Suppress "unused variable" warning.
|
static_cast<void>(filename); // Suppress "unused variable" warning.
|
||||||
|
static_cast<void>(num_cells); // Suppress "unused variable" warning.
|
||||||
|
static_cast<void>(global_cell); // Suppress "unused variable" warning.
|
||||||
THROW("Cannot write EGRID format without ERT library support. Reconfigure opm-core with ERT support and recompile.");
|
THROW("Cannot write EGRID format without ERT library support. Reconfigure opm-core with ERT support and recompile.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Read an imported fortio data file using Ert.
|
// Read an imported fortio data file using Ert.
|
||||||
|
@ -225,13 +225,14 @@ public:
|
|||||||
|
|
||||||
struct grdecl get_grdecl() const;
|
struct grdecl get_grdecl() const;
|
||||||
|
|
||||||
/// Save grid parts of deck in EGRID format.
|
/// Save grid parts of deck in EGRID format.
|
||||||
void saveEGRID(const std::string & filename) const;
|
void saveEGRID(const std::string & filename, int num_cells , const int * global_cell) const;
|
||||||
|
|
||||||
#ifdef HAVE_ERT
|
#ifdef HAVE_ERT
|
||||||
void saveEGRID_INIT( const std::string& output_dir , const std::string& basename, bool fmt_file = false);
|
//void saveEGRID_INIT( const std::string& output_dir , const std::string& basename, bool fmt_file = false);
|
||||||
void saveINIT( const std::string & filename , const ecl_grid_type * ecl_grid);
|
void saveINIT( const std::string & filename , const ecl_grid_type * ecl_grid);
|
||||||
ecl_grid_type * newGrid( );
|
void saveEGRID_INIT( const std::string& output_dir , const std::string& basename, bool fmt_file);
|
||||||
|
ecl_grid_type * newGrid( );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user