diff --git a/opm/models/discretization/ecfv/ecfvstencil.hh b/opm/models/discretization/ecfv/ecfvstencil.hh index d100bd4b8a..27dab07b8e 100644 --- a/opm/models/discretization/ecfv/ecfvstencil.hh +++ b/opm/models/discretization/ecfv/ecfvstencil.hh @@ -258,6 +258,13 @@ public: , elementMapper_(mapper) { // try to ensure that the mapper passed indeed maps elements + // gridView.grid().switchToGlobalView(); // I would like to switch here (only relevant for CpGrid with LGRs) + // What we actually want is data_[0] + // which can be done with: + // gridView.grid().switchToGlobalView(); + // gridView.grid().currentData().front(); This works only for CpGrid ... + std::cout<< "gridView size: " << gridView.size(/*codim=*/0) << " vs elemMapper_ size: " << + elementMapper_.size()<< std::endl; assert(int(gridView.size(/*codim=*/0)) == int(elementMapper_.size())); } diff --git a/opm/models/io/basevanguard.hh b/opm/models/io/basevanguard.hh index c0fbf8d99e..378197114f 100644 --- a/opm/models/io/basevanguard.hh +++ b/opm/models/io/basevanguard.hh @@ -110,6 +110,17 @@ public: updateGridView_(); } + /*! + * \brief Add LGRs to the grid, if any. Only supported for CpGrid - for now. + */ + void addLgrs() + { + if(&asImp_() != this) { + asImp_().addLgrs(); + //updateGridView_(); + } + } + protected: // this method should be called after the grid has been allocated void finalizeInit_() diff --git a/opm/models/utils/simulator.hh b/opm/models/utils/simulator.hh index 1fb9852be0..6c3172178c 100644 --- a/opm/models/utils/simulator.hh +++ b/opm/models/utils/simulator.hh @@ -228,6 +228,10 @@ public: checkParallelException("Could not initialize the problem: ", exceptionThrown, what); + // Only relevant for CpGrid + std::cout << "Adding LGRs, if any\n" << std::flush; + vanguard_->addLgrs(); + setupTimer_.stop(); if (verbose_) diff --git a/opm/simulators/flow/AluGridVanguard.hpp b/opm/simulators/flow/AluGridVanguard.hpp index d2f590da00..73ec669e79 100644 --- a/opm/simulators/flow/AluGridVanguard.hpp +++ b/opm/simulators/flow/AluGridVanguard.hpp @@ -196,7 +196,12 @@ class AluGridVanguard : public FlowBaseVanguard globalTrans_->update(false, TransmissibilityType::TransUpdateQuantities::Trans, [&](unsigned int i) { return gridEquilIdxToGridIdx(i);}); } - + + } + + void addLgrs() + { + // do nothing: AluGrid with LGRs not supported yet! } template diff --git a/opm/simulators/flow/CpGridVanguard.hpp b/opm/simulators/flow/CpGridVanguard.hpp index c147014c06..3b48348d0a 100644 --- a/opm/simulators/flow/CpGridVanguard.hpp +++ b/opm/simulators/flow/CpGridVanguard.hpp @@ -246,9 +246,25 @@ class CpGridVanguard : public FlowBaseVanguard #endif } + /*! + * \brief Add LGRs in the simulation grid. + */ + void addLgrs() + { + // Check if input file contains Lgrs. + const auto& lgrs = this-> eclState().getLgrs(); + const auto& lgrsSize = lgrs.size(); + // If there are lgrs, create the grid with them, and update the leaf grid view. + if (lgrsSize) + { + OpmLog::info("\nAdding LGRs to the grid and updating its leaf grid view"); + this->addLgrsUpdateLeafView(lgrs, lgrsSize, *(this->grid_)); + } + } + unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const { - return elemIndex; - } + return elemIndex; + } unsigned int gridIdxToEquilGridIdx(unsigned int elemIndex) const { return elemIndex; diff --git a/opm/simulators/flow/GenericCpGridVanguard.cpp b/opm/simulators/flow/GenericCpGridVanguard.cpp index 90ef3e05e3..06565599da 100644 --- a/opm/simulators/flow/GenericCpGridVanguard.cpp +++ b/opm/simulators/flow/GenericCpGridVanguard.cpp @@ -463,17 +463,6 @@ void GenericCpGridVanguard::doCreateGrids_(Eclips cartesianIndexMapper_ = std::make_unique(*grid_); - // --- Add LGRs and update Leaf Grid View --- - // Check if input file contains Lgrs. - const auto& lgrs = eclState.getLgrs(); - const auto lgrsSize = lgrs.size(); - // If there are lgrs, create the grid with them, and update the leaf grid view. - if (lgrsSize) - { - OpmLog::info("\nAdding LGRs to the grid and updating its leaf grid view"); - this->addLgrsUpdateLeafView(lgrs, lgrsSize, *(this->grid_)); - } - #if HAVE_MPI { const bool has_numerical_aquifer = eclState.aquifer().hasNumericalAquifer(); @@ -509,7 +498,7 @@ void GenericCpGridVanguard::doCreateGrids_(Eclips } #endif - // --- Copy grid with LGRs to equilGrid_ --- + // --- Copy grid to equilGrid_ --- // We use separate grid objects: one for the calculation of the initial // condition via EQUIL and one for the actual simulation. The reason is // that the EQUIL code is allergic to distributed grids and the @@ -569,6 +558,7 @@ void GenericCpGridVanguard::addLgrsUpdateLeafView grid.addLgrsUpdateLeafView(cells_per_dim_vec, startIJK_vec, endIJK_vec, lgrName_vec); }; + template void GenericCpGridVanguard:: doFilterConnections_(Schedule& schedule) diff --git a/opm/simulators/flow/PolyhedralGridVanguard.hpp b/opm/simulators/flow/PolyhedralGridVanguard.hpp index 98d0493e36..7e168424c1 100644 --- a/opm/simulators/flow/PolyhedralGridVanguard.hpp +++ b/opm/simulators/flow/PolyhedralGridVanguard.hpp @@ -164,6 +164,10 @@ class PolyhedralGridVanguard : public FlowBaseVanguard { /* do nothing: PolyhedralGrid is not parallel! */ } + void addLgrs() + { /* do nothing: PolyhedralGrid with LGRs not supported yet! */ + } + /*! * \brief Returns the object which maps a global element index of the simulation grid * to the corresponding element index of the logically Cartesian index.