3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_IO_GRID_CPGRIDMANAGER_HH
25#define DUMUX_IO_GRID_CPGRIDMANAGER_HH
26
27#if HAVE_OPM_GRID
28#include <dune/common/parallel/mpihelper.hh>
29
30#include <opm/grid/CpGrid.hpp>
31#include <opm/parser/eclipse/Parser/Parser.hpp>
32#include <opm/parser/eclipse/Parser/ParseContext.hpp>
33#include <opm/parser/eclipse/Deck/Deck.hpp>
34#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
35
37
38namespace Dumux {
39
44class CpGridManager
45{
46public:
47 using Grid = Dune::CpGrid;
48 using Deck = Opm::Deck;
49
53 void init(const std::string& paramGroup = "")
54 {
55 const auto fileName = getParamFromGroup<std::string>(paramGroup, "Grid.File");
56 deck_ = std::make_shared<Opm::Deck>(Opm::Parser().parseFile(fileName));
57 Opm::EclipseGrid eclGrid(*deck_);
58 Opm::EclipseState eclState(*deck_);
59 grid_ = std::make_shared<Grid>();
60 grid_->processEclipseFormat(&eclGrid, &eclState, false, false, false);
61 loadBalance();
62 }
63
67 Grid &grid()
68 {
69 return *grid_;
70 }
71
77 std::shared_ptr<Deck> getDeck() const
78 {
79 return deck_;
80 }
81
85 void loadBalance()
86 {
87 if (Dune::MPIHelper::getCommunication().size() > 1)
88 grid_->loadBalance();
89 }
90
91private:
92 std::shared_ptr<Deck> deck_;
93 std::shared_ptr<Grid> grid_;
94};
95
96} // end namespace Dumux
97
98#endif // HAVE_OPM_GRID
99
100#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Definition: adapt.hh:29