Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LevelCartesianIndexMapper constructor for AluGrid taking only a grid as an argument #5715

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming>>
{
Expand All @@ -56,12 +65,10 @@ class LevelCartesianIndexMapper<Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconform
public:
static constexpr int dimension = 3 ;

LevelCartesianIndexMapper(const Grid& grid,
const Dune::CartesianIndexMapper<Grid>& cartesianIndexMapper)
: grid_{&grid}
, cartesianIndexMapper_{std::make_unique<Dune::CartesianIndexMapper<Grid>>(cartesianIndexMapper)}
explicit LevelCartesianIndexMapper(const Dune::CartesianIndexMapper<Grid>& cartesianIndexMapper)
: cartesianIndexMapper_{std::make_unique<Dune::CartesianIndexMapper<Grid>>(cartesianIndexMapper)}
{}

const std::array<int,3>& cartesianDimensions(int level) const
{
throwIfLevelPositive(level);
Expand Down Expand Up @@ -93,7 +100,6 @@ class LevelCartesianIndexMapper<Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconform
}

private:
[[maybe_unused]] const Grid* grid_;
std::unique_ptr<Dune::CartesianIndexMapper<Grid>> cartesianIndexMapper_;

void throwIfLevelPositive(int level) const
Expand Down
3 changes: 2 additions & 1 deletion opm/simulators/flow/AluGridVanguard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,10 @@ class AluGridVanguard : public FlowBaseVanguard<TypeTag>
/*!
* \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
Expand Down
3 changes: 2 additions & 1 deletion opm/simulators/flow/PolyhedralGridVanguard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ class PolyhedralGridVanguard : public FlowBaseVanguard<TypeTag>
/*!
* \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
Expand Down