3.2-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
36
37namespace Dumux {
38
43class CpGridManager
44{
45public:
46 using Grid = Dune::CpGrid;
47 using Deck = Opm::Deck;
48
52 void init(const std::string& paramGroup = "")
53 {
54 const auto fileName = getParamFromGroup<std::string>(paramGroup, "Grid.File");
55 deck_ = std::make_shared<Opm::Deck>(Opm::Parser().parseFile(fileName));
56 Opm::EclipseGrid eclGrid(*deck_);
57 grid_ = std::make_shared<Grid>();
58 grid_->processEclipseFormat(&eclGrid, false, false, false);
59 loadBalance();
60 }
61
65 Grid &grid()
66 {
67 return *grid_;
68 }
69
75 std::shared_ptr<Deck> getDeck() const
76 {
77 return deck_;
78 }
79
83 void loadBalance()
84 {
85 if (Dune::MPIHelper::getCollectiveCommunication().size() > 1)
86 grid_->loadBalance();
87 }
88
89private:
90 std::shared_ptr<Deck> deck_;
91 std::shared_ptr<Grid> grid_;
92};
93
94} // end namespace Dumux
95
96#endif // HAVE_OPM_GRID
97
98#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Definition: adapt.hh:29