EclipseIO::writeInitial: added comments on int_data argument
This commit is contained in:
parent
73420104b5
commit
2dce52478c
@ -220,7 +220,6 @@ EclipseIO::Impl::Impl( const EclipseState& eclipseState,
|
||||
{}
|
||||
|
||||
|
||||
|
||||
void EclipseIO::Impl::writeINITFile( const data::Solution& simProps, std::map<std::string, std::vector<int> > int_data, const NNC& nnc) const {
|
||||
const auto& units = this->es.getUnits();
|
||||
const IOConfig& ioConfig = this->es.cfg().io();
|
||||
@ -339,19 +338,18 @@ void EclipseIO::Impl::writeINITFile( const data::Solution& simProps, std::map<st
|
||||
|
||||
//Write Integer Vector Map
|
||||
{
|
||||
std::map<std::string, std::vector<int> >::iterator it = int_data.begin();
|
||||
|
||||
while(it != int_data.end()) {
|
||||
std::string key = it->first;
|
||||
for( const auto& pair : int_data) {
|
||||
const std::string& key = pair.first;
|
||||
const std::vector<int>& int_data = pair.second;
|
||||
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++;
|
||||
if (int_data.size() == this->grid.getCartesianSize( ))
|
||||
writeKeyword( fortio , key , int_data );
|
||||
else {
|
||||
std::vector<int> global_copy = grid.scatterVector( int_data );
|
||||
writeKeyword( fortio , key , global_copy );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,8 +384,16 @@ void EclipseIO::Impl::writeEGRIDFile( const NNC& nnc ) const {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EclipseIO::writeInitial( data::Solution simProps, std::map<std::string, std::vector<int> > map, const NNC& nnc) {
|
||||
/*
|
||||
int_data: Writes key(string) and integers vector to INIT file as eclipse keywords
|
||||
- Key: Max 8 chars.
|
||||
- vector: Size number of grid cells (N_grid = nx*ny*nz) OR number of active cells.
|
||||
If vector size equals number of active cells, then vector is expanded to size N_grid.
|
||||
- expanded_vector[j] = vector[i], global cell j corresponds to active cell i.
|
||||
- expanded_vector[j] = default (-1), if j corresponds to an inactive cell.
|
||||
- Wrong input: invalid_argument exception.
|
||||
*/
|
||||
void EclipseIO::writeInitial( data::Solution simProps, std::map<std::string, std::vector<int> > int_data, const NNC& nnc) {
|
||||
if( !this->impl->output_enabled )
|
||||
return;
|
||||
|
||||
@ -397,7 +403,7 @@ void EclipseIO::writeInitial( data::Solution simProps, std::map<std::string, std
|
||||
|
||||
simProps.convertFromSI( es.getUnits() );
|
||||
if( ioConfig.getWriteINITFile() )
|
||||
this->impl->writeINITFile( simProps , map, nnc );
|
||||
this->impl->writeINITFile( simProps , int_data, nnc );
|
||||
|
||||
if( ioConfig.getWriteEGRIDFile( ) )
|
||||
this->impl->writeEGRIDFile( nnc );
|
||||
|
@ -317,16 +317,14 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) {
|
||||
{ "TRANZ", { measure::transmissibility, tranz, TargetType::INIT } },
|
||||
};
|
||||
|
||||
std::map<std::string, std::vector<int> > int_data;
|
||||
std::vector<int> u(27); u[2] = 67; u[5] = 89;
|
||||
int_data["STR_ULONGNAME"] = u;
|
||||
std::map<std::string, std::vector<int>> int_data = {{"STR_ULONGNAME" , {1,1,1,1,1,1,1,1} } };
|
||||
|
||||
std::vector<int> v(27); v[2] = 67; v[26] = 89;
|
||||
int_data["STR_V"] = v;
|
||||
|
||||
eclWriter.writeInitial( );
|
||||
|
||||
test_assert_throw( eclWriter.writeInitial( eGridProps , int_data) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( eclWriter.writeInitial( eGridProps , int_data) , std::invalid_argument);
|
||||
|
||||
int_data.erase("STR_ULONGNAME");
|
||||
eclWriter.writeInitial( eGridProps , int_data );
|
||||
@ -357,7 +355,7 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) {
|
||||
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") );
|
||||
BOOST_CHECK( 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));
|
||||
|
Loading…
Reference in New Issue
Block a user