Added possiblity: writing integer fields to INIT files.
added std::map argument to EclipseIO::Impl::writeINITFile writing EclipseIO::Impl::writeINITFile argument to INIT file ... ...
This commit is contained in:
parent
3fffeda7d7
commit
045e355720
@ -107,7 +107,7 @@ public:
|
||||
* are not yet written to disk.
|
||||
*/
|
||||
|
||||
void writeInitial( data::Solution simProps = data::Solution(), const NNC& nnc = NNC());
|
||||
void writeInitial( data::Solution simProps = data::Solution(), std::map<std::string, std::vector<int> > map = {}, const NNC& nnc = NNC());
|
||||
|
||||
/**
|
||||
* \brief Overwrite the initial OIP values.
|
||||
|
@ -192,7 +192,7 @@ inline std::string uppercase( std::string x ) {
|
||||
class EclipseIO::Impl {
|
||||
public:
|
||||
Impl( const EclipseState&, EclipseGrid, const Schedule&, const SummaryConfig& );
|
||||
void writeINITFile( const data::Solution& simProps, const NNC& nnc) const;
|
||||
void writeINITFile( const data::Solution& simProps, std::map<std::string, std::vector<int> > map, const NNC& nnc) const;
|
||||
void writeEGRIDFile( const NNC& nnc ) const;
|
||||
|
||||
const EclipseState& es;
|
||||
@ -221,7 +221,7 @@ EclipseIO::Impl::Impl( const EclipseState& eclipseState,
|
||||
|
||||
|
||||
|
||||
void EclipseIO::Impl::writeINITFile( const data::Solution& simProps, const NNC& nnc) const {
|
||||
void EclipseIO::Impl::writeINITFile( const data::Solution& simProps, std::map<std::string, std::vector<int> > map, const NNC& nnc) const {
|
||||
const auto& units = this->es.getUnits();
|
||||
const IOConfig& ioConfig = this->es.cfg().io();
|
||||
|
||||
@ -337,6 +337,25 @@ void EclipseIO::Impl::writeINITFile( const data::Solution& simProps, const NNC&
|
||||
}
|
||||
|
||||
|
||||
//Write Integer Vector Map
|
||||
{
|
||||
std::map<std::string, std::vector<int> >::iterator it = map.begin();
|
||||
|
||||
while(it != map.end()) {
|
||||
std::string key = it->first;
|
||||
if (key.size() > ECL_STRING8_LENGTH)
|
||||
throw std::invalid_argument("Keyword is too long.");
|
||||
|
||||
std::vector<int> int_field = it->second;
|
||||
if (int_field.size() < this->grid.getCartesianSize())
|
||||
int_field = grid.scatterVector( int_field );
|
||||
writeKeyword( fortio, key, int_field);
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write NNC transmissibilities
|
||||
{
|
||||
std::vector<double> tran;
|
||||
@ -368,7 +387,7 @@ void EclipseIO::Impl::writeEGRIDFile( const NNC& nnc ) const {
|
||||
}
|
||||
|
||||
|
||||
void EclipseIO::writeInitial( data::Solution simProps, const NNC& nnc) {
|
||||
void EclipseIO::writeInitial( data::Solution simProps, std::map<std::string, std::vector<int> > map, const NNC& nnc) {
|
||||
if( !this->impl->output_enabled )
|
||||
return;
|
||||
|
||||
@ -378,7 +397,7 @@ void EclipseIO::writeInitial( data::Solution simProps, const NNC& nnc) {
|
||||
|
||||
simProps.convertFromSI( es.getUnits() );
|
||||
if( ioConfig.getWriteINITFile() )
|
||||
this->impl->writeINITFile( simProps , nnc );
|
||||
this->impl->writeINITFile( simProps , map, nnc );
|
||||
|
||||
if( ioConfig.getWriteEGRIDFile( ) )
|
||||
this->impl->writeEGRIDFile( nnc );
|
||||
|
@ -43,6 +43,7 @@
|
||||
// ERT stuff
|
||||
#include <ert/util/ert_unique_ptr.hpp>
|
||||
#include <ert/util/TestArea.hpp>
|
||||
#include <ert/util/test_util.hpp>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
@ -50,9 +51,11 @@
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
#include <ert/ecl_well/well_info.h>
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
@ -314,9 +317,19 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) {
|
||||
{ "TRANZ", { measure::transmissibility, tranz, TargetType::INIT } },
|
||||
};
|
||||
|
||||
std::map<std::string, std::vector<int> > map;
|
||||
std::vector<int> u(27); u[2] = 67; u[5] = 89;
|
||||
map["STR_ULONGNAME"] = u;
|
||||
|
||||
std::vector<int> v(27); v[2] = 67; v[26] = 89;
|
||||
map["STR_V"] = v;
|
||||
|
||||
eclWriter.writeInitial( );
|
||||
eclWriter.writeInitial( eGridProps );
|
||||
|
||||
test_assert_throw( eclWriter.writeInitial( eGridProps , map) , std::invalid_argument);
|
||||
|
||||
map.erase("STR_ULONGNAME");
|
||||
eclWriter.writeInitial( eGridProps , map );
|
||||
|
||||
data::Wells wells;
|
||||
|
||||
@ -343,6 +356,13 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) {
|
||||
checkEgridFile( eclGrid );
|
||||
loadWells( "FOO.EGRID", "FOO.UNRST" );
|
||||
|
||||
ecl_file_type * ecl_file = ecl_file_open("./FOO.INIT", 0);
|
||||
test_assert_true( ecl_file_has_kw(ecl_file, "STR_V") );
|
||||
ecl_kw_type * kw = ecl_file_iget_named_kw(ecl_file, "STR_V", 0);
|
||||
test_assert_double_equal(67, ecl_kw_iget_as_double(kw, 2));
|
||||
test_assert_double_equal(89, ecl_kw_iget_as_double(kw, 26));
|
||||
|
||||
|
||||
std::ifstream file( "FOO.UNRST", std::ios::binary );
|
||||
std::streampos file_size = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user