diff --git a/ebos/eclequilinitializer.hh b/ebos/eclequilinitializer.hh index 3eb43acbb..d3a7156f9 100644 --- a/ebos/eclequilinitializer.hh +++ b/ebos/eclequilinitializer.hh @@ -100,12 +100,21 @@ public: const auto& eclState = vanguard.eclState(); unsigned numElems = vanguard.grid().size(0); + using ElementMapper = GetPropType; + using Grid = GetPropType; + using CartesianIndexMapper = Dune::CartesianIndexMapper; + using Initializer = EQUIL::DeckDependent::InitialStateComputer; - EQUIL::DeckDependent::InitialStateComputer initialState(materialLawManager, - eclState, - vanguard, - vanguard.cartesianMapper(), - simulator.problem().gravity()[dimWorld - 1]); + Initializer initialState(materialLawManager, + eclState, + vanguard.grid(), + vanguard.gridView(), + vanguard.cartesianMapper(), + simulator.problem().gravity()[dimWorld - 1]); // copy the result into the array of initial fluid states initialFluidStates_.resize(numElems); diff --git a/ebos/equil/initstateequil.hh b/ebos/equil/initstateequil.hh index 489b23087..0ab54cc54 100644 --- a/ebos/equil/initstateequil.hh +++ b/ebos/equil/initstateequil.hh @@ -1581,34 +1581,32 @@ equilnum(const EclipseState& eclipseState, return eqlnum; } -template +template class InitialStateComputer { - using FluidSystem = GetPropType; - using GridView = GetPropType; using Element = typename GridView::template Codim<0>::Entity; - using ElementMapper = GetPropType; - using Vanguard = GetPropType; - using Grid = GetPropType; - using CartesianIndexMapper = Dune::CartesianIndexMapper; - public: template InitialStateComputer(MaterialLawManager& materialLawManager, const Opm::EclipseState& eclipseState, - const Vanguard& vanguard, + const Grid& grid, + const GridView& gridView, const CartesianIndexMapper& cartMapper, const double grav = Opm::unit::gravity, const bool applySwatInit = true) - : temperature_(vanguard.grid().size(/*codim=*/0)), - saltConcentration_(vanguard.grid().size(/*codim=*/0)), - saltSaturation_(vanguard.grid().size(/*codim=*/0)), + : temperature_(grid.size(/*codim=*/0)), + saltConcentration_(grid.size(/*codim=*/0)), + saltSaturation_(grid.size(/*codim=*/0)), pp_(FluidSystem::numPhases, - std::vector(vanguard.grid().size(/*codim=*/0))), + std::vector(grid.size(/*codim=*/0))), sat_(FluidSystem::numPhases, - std::vector(vanguard.grid().size(/*codim=*/0))), - rs_(vanguard.grid().size(/*codim=*/0)), - rv_(vanguard.grid().size(/*codim=*/0)), + std::vector(grid.size(/*codim=*/0))), + rs_(grid.size(/*codim=*/0)), + rv_(grid.size(/*codim=*/0)), cartesianIndexMapper_(cartMapper) { //Check for presence of kw SWATINIT @@ -1621,8 +1619,7 @@ public: // Querry cell depth, cell top-bottom. // numerical aquifer cells might be specified with different depths. const auto& num_aquifers = eclipseState.aquifer().numericalAquifers(); - updateCellProps_(vanguard, num_aquifers); - const Grid& grid = vanguard.grid(); + updateCellProps_(gridView, num_aquifers); // Get the equilibration records. const std::vector rec = getEquil(eclipseState); @@ -1743,7 +1740,7 @@ public: calcPressSatRsRv(eqlmap, rec, materialLawManager, comm, grav); // modify the pressure and saturation for numerical aquifer cells - applyNumericalAquifers_(vanguard, num_aquifers, eclipseState.runspec().co2Storage()); + applyNumericalAquifers_(gridView, num_aquifers, eclipseState.runspec().co2Storage()); // Modify oil pressure in no-oil regions so that the pressures of present phases can // be recovered from the oil pressure and capillary relations. @@ -1837,10 +1834,9 @@ private: std::vector> cellZSpan_; std::vector> cellZMinMax_; - void updateCellProps_(const Vanguard& vanguard, + void updateCellProps_(const GridView& gridView, const NumericalAquifers& aquifer) { - const auto& gridView = vanguard.gridView(); ElementMapper elemMapper(gridView, Dune::mcmgElementLayout()); //const auto& elemMapper = gridView.elementMapper(); int numElements = gridView.size(/*codim=*/0); @@ -1873,13 +1869,12 @@ private: } } - void applyNumericalAquifers_(const Vanguard& vanguard, + void applyNumericalAquifers_(const GridView& gridView, const NumericalAquifers& aquifer, const bool co2store) { const auto num_aqu_cells = aquifer.allAquiferCells(); if (num_aqu_cells.empty()) return; - const auto& gridView = vanguard.gridView(); ElementMapper elemMapper(gridView, Dune::mcmgElementLayout()); //const auto& elemMapper = vanguard.gridView().elementMapper();; auto elemIt = gridView.template begin(); diff --git a/tests/test_equil.cc b/tests/test_equil.cc index d050a9f3f..749667886 100644 --- a/tests/test_equil.cc +++ b/tests/test_equil.cc @@ -220,7 +220,6 @@ struct EquilFixture { Dune::MPIHelper::instance(argc, argv); #endif Opm::EclGenericVanguard::setCommunication(std::make_unique()); - using TypeTag = Opm::Properties::TTag::TestEquilTypeTag; Opm::BlackoilModelParametersEbos::registerParameters(); Opm::Parameters::registerParam("EnableTerminalOutput", "EnableTerminalOutput", @@ -228,6 +227,18 @@ struct EquilFixture { "Dummy added for the well model to compile."); Opm::registerAllParameters_(); } + + using TypeTag = Opm::Properties::TTag::TestEquilTypeTag; + using FluidSystem = Opm::GetPropType; + using Grid = Opm::GetPropType; + using GridView = Opm::GetPropType; + using ElementMapper = Opm::GetPropType; + using CartesianIndexMapper = Dune::CartesianIndexMapper; + using Initializer = Opm::EQUIL::DeckDependent::InitialStateComputer; }; } @@ -501,10 +512,11 @@ BOOST_AUTO_TEST_CASE(DeckAllDead) const auto& eclipseState = simulator->vanguard().eclState(); Opm::GridManager gm(eclipseState.getInputGrid()); const UnstructuredGrid& grid = *(gm.c_grid()); - - Opm::EQUIL::DeckDependent::InitialStateComputer comp(*simulator->problem().materialLawManager(), - eclipseState, simulator->vanguard(), - simulator->vanguard().cartesianMapper(), 10.0); + EquilFixture::Initializer comp(*simulator->problem().materialLawManager(), + eclipseState, + simulator->vanguard().grid(), + simulator->vanguard().gridView(), + simulator->vanguard().cartesianMapper(), 10.0); const auto& pressures = comp.press(); BOOST_REQUIRE_EQUAL(pressures.size(), 3U); BOOST_REQUIRE_EQUAL(int(pressures[0].size()), grid.number_of_cells); @@ -581,9 +593,11 @@ BOOST_AUTO_TEST_CASE(DeckWithCapillary) Opm::GridManager gm(eclipseState.getInputGrid()); const UnstructuredGrid& grid = *(gm.c_grid()); - Opm::EQUIL::DeckDependent::InitialStateComputer comp(*simulator->problem().materialLawManager(), - eclipseState, simulator->vanguard(), - simulator->vanguard().cartesianMapper(), 10.0); + EquilFixture::Initializer comp(*simulator->problem().materialLawManager(), + eclipseState, + simulator->vanguard().grid(), + simulator->vanguard().gridView(), + simulator->vanguard().cartesianMapper(), 10.0); const auto& pressures = comp.press(); BOOST_REQUIRE_EQUAL(pressures.size(), 3U); @@ -621,9 +635,11 @@ BOOST_AUTO_TEST_CASE(DeckWithCapillaryOverlap) Opm::GridManager gm(eclipseState.getInputGrid()); const UnstructuredGrid& grid = *(gm.c_grid()); - Opm::EQUIL::DeckDependent::InitialStateComputer comp(*simulator->problem().materialLawManager(), - eclipseState, simulator->vanguard(), - simulator->vanguard().cartesianMapper(), 9.80665); + EquilFixture::Initializer comp(*simulator->problem().materialLawManager(), + eclipseState, + simulator->vanguard().grid(), + simulator->vanguard().gridView(), + simulator->vanguard().cartesianMapper(), 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE_EQUAL(pressures.size(), 3U); BOOST_REQUIRE_EQUAL(int(pressures[0].size()), grid.number_of_cells); @@ -682,9 +698,11 @@ BOOST_AUTO_TEST_CASE(DeckWithLiveOil) const UnstructuredGrid& grid = *(gm.c_grid()); // Initialize the fluid system - Opm::EQUIL::DeckDependent::InitialStateComputer comp(*simulator->problem().materialLawManager(), - eclipseState, simulator->vanguard(), - simulator->vanguard().cartesianMapper(), 9.80665); + EquilFixture::Initializer comp(*simulator->problem().materialLawManager(), + eclipseState, + simulator->vanguard().grid(), + simulator->vanguard().gridView(), + simulator->vanguard().cartesianMapper(), 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE_EQUAL(pressures.size(), 3U); BOOST_REQUIRE_EQUAL(int(pressures[0].size()), grid.number_of_cells); @@ -759,9 +777,11 @@ BOOST_AUTO_TEST_CASE(DeckWithLiveGas) Opm::GridManager gm(eclipseState.getInputGrid()); const UnstructuredGrid& grid = *(gm.c_grid()); - Opm::EQUIL::DeckDependent::InitialStateComputer comp(*simulator->problem().materialLawManager(), - eclipseState, simulator->vanguard(), - simulator->vanguard().cartesianMapper(), 9.80665); + EquilFixture::Initializer comp(*simulator->problem().materialLawManager(), + eclipseState, + simulator->vanguard().grid(), + simulator->vanguard().gridView(), + simulator->vanguard().cartesianMapper(), 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE_EQUAL(pressures.size(), 3U); BOOST_REQUIRE_EQUAL(int(pressures[0].size()), grid.number_of_cells); @@ -839,9 +859,11 @@ BOOST_AUTO_TEST_CASE(DeckWithRSVDAndRVVD) Opm::GridManager gm(eclipseState.getInputGrid()); const UnstructuredGrid& grid = *(gm.c_grid()); - Opm::EQUIL::DeckDependent::InitialStateComputer comp(*simulator->problem().materialLawManager(), - eclipseState, simulator->vanguard(), - simulator->vanguard().cartesianMapper(), 9.80665); + EquilFixture::Initializer comp(*simulator->problem().materialLawManager(), + eclipseState, + simulator->vanguard().grid(), + simulator->vanguard().gridView(), + simulator->vanguard().cartesianMapper(), 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE_EQUAL(pressures.size(), 3U); BOOST_REQUIRE_EQUAL(int(pressures[0].size()), grid.number_of_cells); @@ -939,9 +961,11 @@ BOOST_AUTO_TEST_CASE(DeckWithPBVDAndPDVD) Opm::GridManager gm(eclipseState.getInputGrid()); const UnstructuredGrid& grid = *(gm.c_grid()); - Opm::EQUIL::DeckDependent::InitialStateComputer comp(*simulator->problem().materialLawManager(), - eclipseState, simulator->vanguard(), - simulator->vanguard().cartesianMapper(), 9.80665); + EquilFixture::Initializer comp(*simulator->problem().materialLawManager(), + eclipseState, + simulator->vanguard().grid(), + simulator->vanguard().gridView(), + simulator->vanguard().cartesianMapper(), 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE_EQUAL(pressures.size(), 3U); BOOST_REQUIRE_EQUAL(int(pressures[0].size()), grid.number_of_cells);