version 3.10-dev
cpgridmanager.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_IO_GRID_CPGRIDMANAGER_HH
13#define DUMUX_IO_GRID_CPGRIDMANAGER_HH
14
15#include <config.h>
16
17#if HAVE_OPM_GRID
18#include <dune/common/version.hh>
19#include <dune/common/parallel/mpihelper.hh>
20
21#include <opm/grid/CpGrid.hpp>
22
23#if DUNE_VERSION_GTE(OPM_GRID, 2022, 10)
24#include <opm/input/eclipse/Parser/Parser.hpp>
25#include <opm/input/eclipse/Parser/ParseContext.hpp>
26#include <opm/input/eclipse/Deck/Deck.hpp>
27#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
28#else
29#include <opm/parser/eclipse/Parser/Parser.hpp>
30#include <opm/parser/eclipse/Parser/ParseContext.hpp>
31#include <opm/parser/eclipse/Deck/Deck.hpp>
32#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
33#endif
34
36
37#if HAVE_ECL_INPUT
38
39namespace Dumux {
40
45class CpGridManager
46{
47public:
48 using Grid = Dune::CpGrid;
49 using Deck = Opm::Deck;
50
54 void init(const std::string& paramGroup = "")
55 {
56 const auto fileName = getParamFromGroup<std::string>(paramGroup, "Grid.File");
57 deck_ = std::make_shared<Opm::Deck>(Opm::Parser().parseFile(fileName));
58 Opm::EclipseGrid eclGrid(*deck_);
59 Opm::EclipseState eclState(*deck_);
60 grid_ = std::make_shared<Grid>();
61 grid_->processEclipseFormat(&eclGrid, &eclState, false, false, false);
62 loadBalance();
63 }
64
68 Grid &grid()
69 {
70 return *grid_;
71 }
72
78 std::shared_ptr<Deck> getDeck() const
79 {
80 return deck_;
81 }
82
86 void loadBalance()
87 {
88 if (Dune::MPIHelper::getCommunication().size() > 1)
89 grid_->loadBalance();
90 }
91
92private:
93 std::shared_ptr<Deck> deck_;
94 std::shared_ptr<Grid> grid_;
95};
96
97} // end namespace Dumux
98
99#else
100#warning "Eclipse input support in opm-common is required to use the cornerpoint grid manager"
101#endif // HAVE_ECL_INPUT
102
103#endif // HAVE_OPM_GRID
104
105#endif
Definition: adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.