commit
f1d2a0db95
@ -18,21 +18,25 @@
|
|||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <opm/core/grid.h>
|
#include <opm/core/grid.h>
|
||||||
#include <opm/core/simulator/SimulatorTimer.hpp>
|
#include <opm/core/simulator/SimulatorTimer.hpp>
|
||||||
#include <opm/core/utility/writeECLData.hpp>
|
#include <opm/core/utility/writeECLData.hpp>
|
||||||
#include <opm/core/utility/Units.hpp>
|
#include <opm/core/utility/Units.hpp>
|
||||||
|
#include <opm/core/utility/ErrorMacros.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef HAVE_ERT // This one goes almost to the bottom of the file
|
||||||
|
|
||||||
#include <ecl_grid.h>
|
#include <ecl_grid.h>
|
||||||
#include <ecl_util.h>
|
#include <ecl_util.h>
|
||||||
#include <ecl_rst_file.h>
|
#include <ecl_rst_file.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -41,8 +45,12 @@ namespace Opm
|
|||||||
const std::vector<double> * data ,
|
const std::vector<double> * data ,
|
||||||
int offset ,
|
int offset ,
|
||||||
int stride ) {
|
int stride ) {
|
||||||
|
const int ecl_data_size = grid.cartdims[0]*grid.cartdims[1]*grid.cartdims[2];
|
||||||
ecl_kw_type * ecl_kw = ecl_kw_alloc( kw_name.c_str() , data->size() / stride , ECL_FLOAT_TYPE );
|
if (ecl_data_size < int(data->size()) / stride) {
|
||||||
|
THROW("Logical cartesian size claimed to be " << ecl_data_size << ", while active data size is " << data->size()
|
||||||
|
<< "\n --- check if the grid is really a corner-point grid or other logical cartesian grid.");
|
||||||
|
}
|
||||||
|
ecl_kw_type * ecl_kw = ecl_kw_alloc( kw_name.c_str() , ecl_data_size , ECL_FLOAT_TYPE );
|
||||||
if (grid.global_cell == NULL) {
|
if (grid.global_cell == NULL) {
|
||||||
for (int i=0; i < grid.number_of_cells; i++)
|
for (int i=0; i < grid.number_of_cells; i++)
|
||||||
ecl_kw_iset_float( ecl_kw , i , (*data)[i*stride + offset]);
|
ecl_kw_iset_float( ecl_kw , i , (*data)[i*stride + offset]);
|
||||||
@ -94,6 +102,9 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
DataMap::const_iterator i = data.find("saturation");
|
DataMap::const_iterator i = data.find("saturation");
|
||||||
if (i != data.end()) {
|
if (i != data.end()) {
|
||||||
|
if (int(i->second->size()) != 2 * grid.number_of_cells) {
|
||||||
|
THROW("writeECLData() requires saturation field to have two phases.");
|
||||||
|
}
|
||||||
ecl_kw_type * swat_kw = ecl_kw_wrapper( grid , "SWAT" , i->second , 0 , 2);
|
ecl_kw_type * swat_kw = ecl_kw_wrapper( grid , "SWAT" , i->second , 0 , 2);
|
||||||
ecl_rst_file_add_kw( rst_file , swat_kw );
|
ecl_rst_file_add_kw( rst_file , swat_kw );
|
||||||
ecl_kw_free( swat_kw );
|
ecl_kw_free( swat_kw );
|
||||||
@ -106,3 +117,18 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else // that is, we have not defined HAVE_ERT
|
||||||
|
|
||||||
|
namespace Opm
|
||||||
|
{
|
||||||
|
void writeECLData(const UnstructuredGrid&,
|
||||||
|
const DataMap&,
|
||||||
|
const SimulatorTimer&,
|
||||||
|
const std::string&,
|
||||||
|
const std::string&)
|
||||||
|
{
|
||||||
|
THROW("Cannot call writeECLData() without ert library support. Reconfigure opm-core with --with-ert and recompile.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user