Adds hysteresis output and input (for restarting)

This commit is contained in:
babrodtk 2017-02-24 17:10:25 +01:00
parent 431abb0012
commit 8340d26890
4 changed files with 108 additions and 13 deletions

View File

@ -1250,6 +1250,20 @@ namespace Opm {
simData.registerCellData( "SOMAX", 1 );
VectorType& somax = simData.getCellData( "SOMAX" );
// Two components for hysteresis parameters
// pcSwMdc/krnSwMdc, one for oil-water and one for gas-oil
simData.registerCellData( "PCSWMDC_GO", 1 );
simData.registerCellData( "KRNSWMDC_GO", 1 );
simData.registerCellData( "PCSWMDC_OW", 1 );
simData.registerCellData( "KRNSWMDC_OW", 1 );
VectorType& pcSwMdc_go = simData.getCellData( "PCSWMDC_GO" );
VectorType& krnSwMdc_go = simData.getCellData( "KRNSWMDC_GO" );
VectorType& pcSwMdc_ow = simData.getCellData( "PCSWMDC_OW" );
VectorType& krnSwMdc_ow = simData.getCellData( "KRNSWMDC_OW" );
std::vector<int> failed_cells_pb;
std::vector<int> failed_cells_pd;
const auto& gridView = ebosSimulator().gridView();
@ -1276,6 +1290,16 @@ namespace Opm {
somax[cellIdx] = ebosSimulator().model().maxOilSaturation(cellIdx);
const auto matLawManager = ebosSimulator().problem().materialLawManager();
matLawManager->oilWaterHysteresisParams(
pcSwMdc_ow[cellIdx],
krnSwMdc_ow[cellIdx],
cellIdx);
matLawManager->gasOilHysteresisParams(
pcSwMdc_go[cellIdx],
krnSwMdc_go[cellIdx],
cellIdx);
if (aqua_active) {
saturation[ satIdx + aqua_pos ] = fs.saturation(FluidSystem::waterPhaseIdx).value();
bWater[cellIdx] = fs.invB(FluidSystem::waterPhaseIdx).value();

View File

@ -170,7 +170,7 @@ void solutionToSim( const data::Solution& sol,
state.getCellData( "RV" ) = sol.data( "RV" );
}
if (sol.has( "SSOL" ) ) {
if ( sol.has( "SSOL" ) ) {
state.getCellData("SSOL") = sol.data("SSOL");
}
@ -178,6 +178,26 @@ void solutionToSim( const data::Solution& sol,
state.registerCellData("SOMAX", 1);
state.getCellData("SOMAX") = sol.data("SOMAX");
}
if ( sol.has( "PCSWM_OW" ) ) {
state.registerCellData("PCSWMDC_OW", 1);
state.getCellData("PCSWMDC_OW") = sol.data("PCSWM_OW");
}
if ( sol.has( "KRNSW_OW" ) ) {
state.registerCellData("KRNSWMDC_OW", 1);
state.getCellData("KRNSWMDC_OW") = sol.data("KRNSW_OW");
}
if ( sol.has( "PCSWM_GO" ) ) {
state.registerCellData("PCSWMDC_GO", 1);
state.getCellData("PCSWMDC_GO") = sol.data("PCSWM_GO");
}
if ( sol.has( "KRNSW_GO" ) ) {
state.registerCellData("KRNSWMDC_GO", 1);
state.getCellData("KRNSWMDC_GO") = sol.data("KRNSW_GO");
}
}

View File

@ -149,17 +149,7 @@ public:
// This is a restart, populate WellState and ReservoirState state objects from restart file
output_writer_.initFromRestartFile(props_.phaseUsage(), grid(), state, prev_well_state, extra);
initHydroCarbonState(state, props_.phaseUsage(), Opm::UgGridHelpers::numCells(grid()), has_disgas_, has_vapoil_);
{
const int num_cells = Opm::UgGridHelpers::numCells(grid());
typedef std::vector<double> VectorType;
const VectorType& somax = state.getCellData( "SOMAX" );
for (int cellIdx = 0; cellIdx < num_cells; ++cellIdx) {
ebosSimulator_.model().setMaxOilSaturation(somax[cellIdx], cellIdx);
}
}
initHysteresisParams(state);
}
// Create timers and file for writing timing info.
@ -796,6 +786,37 @@ protected:
}
}
void initHysteresisParams(ReservoirState& state) {
const int num_cells = Opm::UgGridHelpers::numCells(grid());
typedef std::vector<double> VectorType;
const VectorType& somax = state.getCellData( "SOMAX" );
for (int cellIdx = 0; cellIdx < num_cells; ++cellIdx) {
ebosSimulator_.model().setMaxOilSaturation(somax[cellIdx], cellIdx);
}
VectorType& pcSwMdc_ow = state.getCellData( "PCSWMDC_OW" );
VectorType& krnSwMdc_ow = state.getCellData( "KRNSWMDC_OW" );
VectorType& pcSwMdc_go = state.getCellData( "PCSWMDC_GO" );
VectorType& krnSwMdc_go = state.getCellData( "KRNSWMDC_GO" );
for (int cellIdx = 0; cellIdx < num_cells; ++cellIdx) {
auto matLawManager = ebosSimulator_.problem().materialLawManager();
matLawManager->setOilWaterHysteresisParams(
pcSwMdc_ow[cellIdx],
krnSwMdc_ow[cellIdx],
cellIdx);
matLawManager->setGasOilHysteresisParams(
pcSwMdc_go[cellIdx],
krnSwMdc_go[cellIdx],
cellIdx);
}
}
// Data.
Simulator& ebosSimulator_;

View File

@ -425,7 +425,11 @@ namespace Opm
{"TEMP" , UnitSystem::measure::temperature},
{"RS" , UnitSystem::measure::gas_oil_ratio},
{"RV" , UnitSystem::measure::oil_gas_ratio},
{"SOMAX", UnitSystem::measure::identity}};
{"SOMAX", UnitSystem::measure::identity},
{"PCSWM_OW", UnitSystem::measure::identity},
{"KRNSW_OW", UnitSystem::measure::identity},
{"PCSWM_GO", UnitSystem::measure::identity},
{"KRNSW_GO", UnitSystem::measure::identity}};
std::map<std::string, bool> extra_keys {{"OPMEXTRA" , false}};
if (restart_double_si_) {
@ -784,6 +788,32 @@ namespace Opm
data::TargetType::RESTART_AUXILIARY);
}
if (sd.hasCellData("PCSWMDC_OW")) {
output.insert("PCSWM_OW", //FIXME: Eight-long variable name
Opm::UnitSystem::measure::identity,
std::move( sd.getCellData("PCSWMDC_OW") ),
data::TargetType::RESTART_AUXILIARY);
}
if (sd.hasCellData("KRNSWMDC_OW")) {
output.insert("KRNSW_OW",
Opm::UnitSystem::measure::identity,
std::move( sd.getCellData("KRNSWMDC_OW") ),
data::TargetType::RESTART_AUXILIARY);
}
if (sd.hasCellData("PCSWMDC_GO")) {
output.insert("PCSWM_GO", //FIXME: Eight-long variable name
Opm::UnitSystem::measure::identity,
std::move( sd.getCellData("PCSWMDC_GO") ),
data::TargetType::RESTART_AUXILIARY);
}
if (sd.hasCellData("KRNSWMDC_GO")) {
output.insert("KRNSW_GO",
Opm::UnitSystem::measure::identity,
std::move( sd.getCellData("KRNSWMDC_GO") ),
data::TargetType::RESTART_AUXILIARY);
}
//Warn for any unhandled keyword
if (log) {
for (auto& keyValue : rstKeywords) {