diff --git a/opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp b/opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp index a39bee0220..bebc0028c0 100644 --- a/opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp +++ b/opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp @@ -43,6 +43,15 @@ namespace Opm { +// Interface class to access the local Cartesian grid of each level grid (when refinement). +// Further documentation in opm/grid/common/LevelCartesianIndexMapper.hpp +// +// Adapter Design Pattern: In this case, LevelCartesianIndexMapper uses the Object Adapter variant, where it holds an instance +// (here, a std::unique_ptr) of CartesianIndexMapper, the wrapped type. The goal is to provide a standardized interface, allowing +// incompatible functionality (such as Cartesian indexing in the context of refinement that may not be supported - yet -for all +// grid types, like CpGrid) to integrate smoothly within the existing conventions. +// +// Specialization for AluGrid template<> class LevelCartesianIndexMapper> { @@ -56,12 +65,10 @@ class LevelCartesianIndexMapper& cartesianIndexMapper) - : grid_{&grid} - , cartesianIndexMapper_{std::make_unique>(cartesianIndexMapper)} + explicit LevelCartesianIndexMapper(const Dune::CartesianIndexMapper& cartesianIndexMapper) + : cartesianIndexMapper_{std::make_unique>(cartesianIndexMapper)} {} - + const std::array& cartesianDimensions(int level) const { throwIfLevelPositive(level); @@ -93,7 +100,6 @@ class LevelCartesianIndexMapper> cartesianIndexMapper_; void throwIfLevelPositive(int level) const diff --git a/opm/simulators/flow/AluGridVanguard.hpp b/opm/simulators/flow/AluGridVanguard.hpp index 2f65caf5f3..52b01ab0aa 100644 --- a/opm/simulators/flow/AluGridVanguard.hpp +++ b/opm/simulators/flow/AluGridVanguard.hpp @@ -238,9 +238,10 @@ class AluGridVanguard : public FlowBaseVanguard /*! * \brief Returns the object which maps a global element index of the simulation grid * to the corresponding element index of the level logically Cartesian index. + * No refinement is supported for AluGrid so it coincides with CartesianIndexMapper. */ const LevelCartesianIndexMapper levelCartesianIndexMapper() const - { return LevelCartesianIndexMapper(*grid_, *cartesianIndexMapper_); } + { return LevelCartesianIndexMapper(*cartesianIndexMapper_); } /*! * \brief Returns mapper from compressed to cartesian indices for the EQUIL grid diff --git a/opm/simulators/flow/PolyhedralGridVanguard.hpp b/opm/simulators/flow/PolyhedralGridVanguard.hpp index aea3cb0b77..c12e5441b2 100644 --- a/opm/simulators/flow/PolyhedralGridVanguard.hpp +++ b/opm/simulators/flow/PolyhedralGridVanguard.hpp @@ -174,9 +174,10 @@ class PolyhedralGridVanguard : public FlowBaseVanguard /*! * \brief Returns the object which maps a global element index of the simulation grid * to the corresponding element index of the level logically Cartesian index. + * No refinement is supported for AluGrid so it coincides with CartesianIndexMapper. */ const LevelCartesianIndexMapper levelCartesianIndexMapper() const - { return LevelCartesianIndexMapper(*grid_); } + { return LevelCartesianIndexMapper(*cartesianIndexMapper_); } /*! * \brief Returns mapper from compressed to cartesian indices for the EQUIL grid