void DocbookGenerator::writeKeywordSet(QTextStream &doc, ListViewInterface *item) { kdDebug(100200) << "DocTreeViewImpl::writeKeywordSet()" << endl; // read item's content QString whoAmI = (item->getValue(KSayItGlobal::XMLCONTEXTNAME)).toString(); if ( whoAmI != "KeywordSet" ) return; // add node to document doc << "<KeywordSet>" << endl; // process childs ListViewInterface *i = static_cast<ListViewInterface*>(item->firstChild()); QString itemType; while( i ){ itemType = ( i->getValue(KSayItGlobal::XMLCONTEXTNAME) ).toString(); if ( itemType == "Keyword" ){ writeKeyword( doc, i ); } // next child i = static_cast<ListViewInterface*>(i->nextSibling()); } doc << "</KeywordSet>" << endl; }
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(); std::string initFile( ERT::EclFilename( this->outputDir, this->baseName, ECL_INIT_FILE, ioConfig.getFMTOUT() )); ERT::FortIO fortio( initFile, std::ios_base::out, ioConfig.getFMTOUT(), ECL_ENDIAN_FLIP ); // Write INIT header. Observe that the PORV vector is treated // specially; that is because for this particulat vector we write // a total of nx*ny*nz values, where the PORV vector has been // explicitly set to zero for inactive cells. The convention is // that the active/inactive cell mapping can be inferred by // reading the PORV vector. { const auto& opm_data = this->es.get3DProperties().getDoubleGridProperty("PORV").getData(); auto ecl_data = opm_data; for (size_t global_index = 0; global_index < opm_data.size(); global_index++) if (!this->grid.cellActive( global_index )) ecl_data[global_index] = 0; ecl_init_file_fwrite_header( fortio.get(), this->grid.c_ptr(), NULL, units.getEclType(), this->es.runspec( ).eclPhaseMask( ), this->schedule.posixStartTime( )); units.from_si( UnitSystem::measure::volume, ecl_data ); writeKeyword( fortio, "PORV" , ecl_data ); } // Writing quantities which are calculated by the grid to the INIT file. ecl_grid_fwrite_depth( this->grid.c_ptr() , fortio.get() , units.getEclType( ) ); ecl_grid_fwrite_dims( this->grid.c_ptr() , fortio.get() , units.getEclType( ) ); // Write properties from the input deck. { const auto& properties = this->es.get3DProperties().getDoubleProperties(); using double_kw = std::pair<std::string, UnitSystem::measure>; /* This is a rather arbitrary hardcoded list of 3D keywords which are written to the INIT file, if they are in the current EclipseState. */ std::vector<double_kw> doubleKeywords = {{"PORO" , UnitSystem::measure::identity }, {"PERMX" , UnitSystem::measure::permeability }, {"PERMY" , UnitSystem::measure::permeability }, {"PERMZ" , UnitSystem::measure::permeability }, {"NTG" , UnitSystem::measure::identity }}; // The INIT file should always contain the NTG property, we // therefor invoke the auto create functionality to ensure // that "NTG" is included in the properties container. properties.assertKeyword("NTG"); for (const auto& kw_pair : doubleKeywords) { if (properties.hasKeyword( kw_pair.first)) { const auto& opm_property = properties.getKeyword(kw_pair.first); auto ecl_data = opm_property.compressedCopy( this->grid ); units.from_si( kw_pair.second, ecl_data ); writeKeyword( fortio, kw_pair.first, ecl_data ); } } } // Write properties which have been initialized by the simulator. { for (const auto& prop : simProps) { auto ecl_data = this->grid.compressedVector( prop.second.data ); writeKeyword( fortio, prop.first, ecl_data ); } } // Write tables { Tables tables( this->es.getUnits() ); tables.addPVTO( this->es.getTableManager().getPvtoTables() ); tables.addPVTG( this->es.getTableManager().getPvtgTables() ); tables.addPVTW( this->es.getTableManager().getPvtwTable() ); tables.addDensity( this->es.getTableManager().getDensityTable( ) ); tables.addSatFunc(this->es); fwrite(tables, fortio); } // Write all integer field properties from the input deck. { const auto& properties = this->es.get3DProperties().getIntProperties(); // It seems that the INIT file should always contain these // keywords, we therefor call getKeyword() here to invoke the // autocreation property, and ensure that the keywords exist // in the properties container. properties.assertKeyword("PVTNUM"); properties.assertKeyword("SATNUM"); properties.assertKeyword("EQLNUM"); properties.assertKeyword("FIPNUM"); for (const auto& property : properties) { auto ecl_data = property.compressedCopy( this->grid ); writeKeyword( fortio , property.getKeywordName() , ecl_data ); } } //Write Integer Vector Map { for( const auto& pair : int_data) { const std::string& key = pair.first; const std::vector<int>& int_vector = pair.second; if (key.size() > ECL_STRING8_LENGTH) throw std::invalid_argument("Keyword is too long."); writeKeyword( fortio , key , int_vector ); } } // Write NNC transmissibilities { std::vector<double> tran; for( const NNCdata& nd : nnc.nncdata() ) tran.push_back( nd.trans ); units.from_si( UnitSystem::measure::transmissibility , tran ); writeKeyword( fortio, "TRANNNC" , tran ); } }