diff --git a/opm/simulators/aquifers/AquiferConstantFlux.hpp b/opm/simulators/aquifers/AquiferConstantFlux.hpp index e9c9aa020..9940841b9 100644 --- a/opm/simulators/aquifers/AquiferConstantFlux.hpp +++ b/opm/simulators/aquifers/AquiferConstantFlux.hpp @@ -91,12 +91,18 @@ public: aquifer_data_ = aquifer; } - void initFromRestart(const data::Aquifers& /* aquiferSoln */) override { - } - - void initialSolutionApplied() override { + void initFromRestart(const data::Aquifers& aquiferSoln) override + { + auto xaqPos = aquiferSoln.find(this->aquiferID()); + if (xaqPos == aquiferSoln.end()) { + return; + } + + this->cumulative_flux_ = this->area_fraction_ * xaqPos->second.volume; } + void initialSolutionApplied() override + {} void beginTimeStep() override {} diff --git a/opm/simulators/aquifers/BlackoilAquiferModel.hpp b/opm/simulators/aquifers/BlackoilAquiferModel.hpp index 0388045ce..37b99ae43 100644 --- a/opm/simulators/aquifers/BlackoilAquiferModel.hpp +++ b/opm/simulators/aquifers/BlackoilAquiferModel.hpp @@ -134,6 +134,9 @@ private: void createDynamicAquifers(const int episode_index); void initializeStaticAquifers(); + void initializeRestartDynamicAquifers(); + + bool needRestartDynamicAquifers() const; template std::unique_ptr diff --git a/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp b/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp index 41f9badfa..98713b27b 100644 --- a/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp +++ b/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp @@ -165,6 +165,9 @@ void BlackoilAquiferModel::init() this->initializeStaticAquifers(); } + if (this->needRestartDynamicAquifers()) { + this->initializeRestartDynamicAquifers(); + } } template @@ -202,6 +205,15 @@ serializeOp(Serializer& serializer) } } +template +void BlackoilAquiferModel::initializeRestartDynamicAquifers() +{ + const auto rstStep = this->simulator_.vanguard().eclState() + .getInitConfig().getRestartStep() - 1; + + this->createDynamicAquifers(rstStep); +} + template void BlackoilAquiferModel::initializeStaticAquifers() { @@ -248,6 +260,20 @@ void BlackoilAquiferModel::initializeStaticAquifers() } } +template +bool BlackoilAquiferModel::needRestartDynamicAquifers() const +{ + const auto& initconfig = + this->simulator_.vanguard().eclState().getInitConfig(); + + if (! initconfig.restartRequested()) { + return false; + } + + return this->simulator_.vanguard() + .schedule()[initconfig.getRestartStep() - 1].hasAnalyticalAquifers(); +} + template template std::unique_ptr diff --git a/parallelRestartTests.cmake b/parallelRestartTests.cmake index 710b5b433..5d5e09d91 100644 --- a/parallelRestartTests.cmake +++ b/parallelRestartTests.cmake @@ -44,6 +44,24 @@ add_test_compare_parallel_restarted_simulation(CASENAME numerical_aquifer_3d_1aq DIR aquifer-num TEST_ARGS --enable-tuning=true --tolerance-cnv=0.00003 --time-step-control=pid --linear-solver=cpr_trueimpes) +add_test_compare_parallel_restarted_simulation(CASENAME aquflux_01 + FILENAME AQUFLUX-01 + SIMULATOR flow + ABS_TOL ${abs_tol_restart} + REL_TOL 5.0e-2 + RESTART_STEP 3 + DIR aquifers + TEST_ARGS --solver-max-time-step-in-days=1) + +add_test_compare_parallel_restarted_simulation(CASENAME aquflux_02 + FILENAME AQUFLUX-02 + SIMULATOR flow + ABS_TOL ${abs_tol_restart} + REL_TOL 5.0e-2 + RESTART_STEP 50 + DIR aquifers + TEST_ARGS --solver-max-time-step-in-days=1) + # Serialized restart tests if(HDF5_FOUND) opm_set_test_driver(${PROJECT_SOURCE_DIR}/tests/run-serialization-regressionTest.sh "") diff --git a/parallelTests.cmake b/parallelTests.cmake index f256c6b5d..8652e48e5 100644 --- a/parallelTests.cmake +++ b/parallelTests.cmake @@ -141,6 +141,14 @@ add_test_compare_parallel_simulation(CASENAME aquflux_01 DIR aquifers TEST_ARGS --enable-tuning=true) +add_test_compare_parallel_simulation(CASENAME aquflux_02 + FILENAME AQUFLUX-02 + SIMULATOR flow + ABS_TOL ${abs_tol} + REL_TOL ${coarse_rel_tol_parallel} + DIR aquifers + TEST_ARGS --enable-tuning=true) + add_test_compare_parallel_simulation(CASENAME network_balance_01 FILENAME NETWORK-01 SIMULATOR flow diff --git a/regressionTests.cmake b/regressionTests.cmake index 2b56cabeb..aaa0e3330 100644 --- a/regressionTests.cmake +++ b/regressionTests.cmake @@ -199,7 +199,14 @@ add_test_compareECLFiles(CASENAME aquflux_01 SIMULATOR flow ABS_TOL ${abs_tol} REL_TOL ${rel_tol} - DIR aquifers) + DIR aquifers --solver-max-time-step-in-days=1) + +add_test_compareECLFiles(CASENAME aquflux_02 + FILENAME AQUFLUX-02 + SIMULATOR flow + ABS_TOL ${abs_tol} + REL_TOL ${rel_tol} + DIR aquifers --solver-max-time-step-in-days=1) add_test_compareECLFiles(CASENAME spe3 FILENAME SPE3CASE1 diff --git a/restartTests.cmake b/restartTests.cmake index 204a0338f..c6711f76b 100644 --- a/restartTests.cmake +++ b/restartTests.cmake @@ -56,6 +56,24 @@ add_test_compare_restarted_simulation(CASENAME numerical_aquifer_3d_2aqu DIR aquifer-num TEST_ARGS --sched-restart=true --enable-tuning=true) +add_test_compare_restarted_simulation(CASENAME aquflux_01 + FILENAME AQUFLUX-01 + SIMULATOR flow + ABS_TOL ${abs_tol_restart} + REL_TOL 3.0e-3 + RESTART_STEP 3 + DIR aquifers + TEST_ARGS --enable-tuning=true) + +add_test_compare_restarted_simulation(CASENAME aquflux_02 + FILENAME AQUFLUX-02 + SIMULATOR flow + ABS_TOL ${abs_tol_restart} + REL_TOL ${rel_tol_restart} + RESTART_STEP 50 + DIR aquifers + TEST_ARGS --enable-tuning=true) + # The dynamic MSW data is not written to /read from the restart file # We therefore accept significant deviation in the results. # Note also that we use --sched-restart=true since some necessary diff --git a/tests/update_reference_data.sh b/tests/update_reference_data.sh index 4d01064c2..e0f3fd21c 100755 --- a/tests/update_reference_data.sh +++ b/tests/update_reference_data.sh @@ -85,6 +85,7 @@ tests[fetkovich_2d]="flow aquifer-fetkovich 2D_FETKOVICHAQUIFER" tests[numerical_aquifer_3d_1aqu]="flow aquifer-num 3D_1AQU_3CELLS" tests[numerical_aquifer_3d_2aqu]="flow aquifer-num 3D_2AQU_NUM" tests[aquflux_01]="flow aquifers AQUFLUX-01" +tests[aquflux_02]="flow aquifers AQUFLUX-02" tests[msw_2d_h]="flow msw_2d_h 2D_H__" tests[msw_3d_hfa]="flow msw_3d_hfa 3D_MSW" tests[polymer_oilwater]="flow polymer_oilwater 2D_OILWATER_POLYMER"