version 3.11-dev
Loading...
Searching...
No Matches
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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_IO_GRID_CPGRIDMANAGER_HH
14#define DUMUX_IO_GRID_CPGRIDMANAGER_HH
15
16#include <config.h>
17
18#if HAVE_OPM_GRID
19#include <dune/common/version.hh>
20#include <dune/common/parallel/mpihelper.hh>
21
22#include <opm/grid/CpGrid.hpp>
23
24#if DUNE_VERSION_GTE(OPM_GRID, 2022, 10)
25#include <opm/input/eclipse/Parser/Parser.hpp>
26#include <opm/input/eclipse/Parser/ParseContext.hpp>
27#include <opm/input/eclipse/Deck/Deck.hpp>
28#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
29#else
30#include <opm/parser/eclipse/Parser/Parser.hpp>
31#include <opm/parser/eclipse/Parser/ParseContext.hpp>
32#include <opm/parser/eclipse/Deck/Deck.hpp>
33#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
34#endif
35
37
38#if HAVE_ECL_INPUT
39
40namespace Dumux {
41
52{
53public:
54 using Grid = Dune::CpGrid;
55 using Deck = Opm::Deck;
56
60 void init(const std::string& paramGroup = "")
61 {
62 const auto fileName = getParamFromGroup<std::string>(paramGroup, "Grid.File");
63 deck_ = std::make_shared<Opm::Deck>(Opm::Parser().parseFile(fileName));
64 Opm::EclipseGrid eclGrid(*deck_);
65 Opm::EclipseState eclState(*deck_);
66 grid_ = std::make_shared<Grid>();
67 grid_->processEclipseFormat(&eclGrid, &eclState, false, false, false);
69 }
70
75 {
76 return *grid_;
77 }
78
84 std::shared_ptr<Deck> getDeck() const
85 {
86 return deck_;
87 }
88
93 {
94 if (Dune::MPIHelper::getCommunication().size() > 1)
95 grid_->loadBalance();
96 }
97
98private:
99 std::shared_ptr<Deck> deck_;
100 std::shared_ptr<Grid> grid_;
101};
102
103} // end namespace Dumux
104
105#else
106#warning "Eclipse input support in opm-common is required to use the cornerpoint grid manager"
107#endif // HAVE_ECL_INPUT
108
109#endif // HAVE_OPM_GRID
110
111#endif
A grid creator that reads Petrel files and generates a CpGrid.
Definition cpgridmanager.hh:52
Dune::CpGrid Grid
Definition cpgridmanager.hh:54
Opm::Deck Deck
Definition cpgridmanager.hh:55
Grid & grid()
Returns a reference to the grid.
Definition cpgridmanager.hh:74
std::shared_ptr< Deck > getDeck() const
Returns a reference to the input deck.
Definition cpgridmanager.hh:84
void loadBalance()
Distributes the grid over all processes for a parallel computation.
Definition cpgridmanager.hh:92
void init(const std::string &paramGroup="")
Create the Grid.
Definition cpgridmanager.hh:60
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:149
Definition adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.