cpgridcreator.hh 3.34 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
 *   See the file COPYING for full copying permissions.                      *
 *                                                                           *
 *   This program is free software: you can redistribute it and/or modify    *
 *   it under the terms of the GNU General Public License as published by    *
 *   the Free Software Foundation, either version 2 of the License, or       *
 *   (at your option) any later version.                                     *
 *                                                                           *
 *   This program is distributed in the hope that it will be useful,         *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
 *   GNU General Public License for more details.                            *
 *                                                                           *
 *   You should have received a copy of the GNU General Public License       *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 *****************************************************************************/
/*!
 * \file
21
 * \ingroup InputOutput
22
23
24
25
26
 * \brief A grid creator that reads Petrel files and generates a CpGrid.
 */
#ifndef DUMUX_CPGRID_CREATOR_HH
#define DUMUX_CPGRID_CREATOR_HH

27
#if HAVE_OPM_GRID
28
29
#include <dune/grid/CpGrid.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
30
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
31
32
#include <opm/parser/eclipse/Deck/Deck.hpp>

33
34
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
35
36
37
38
39
40
41
42
43
44
45

namespace Dumux
{

namespace Properties
{
NEW_PROP_TAG(Scalar);
NEW_PROP_TAG(Grid);
}

/*!
46
 * \ingroup InputOutput
47
48
49
50
51
 * \brief A grid creator that reads Petrel files and generates a CpGrid.
 */
template <class TypeTag>
class CpGridCreator
{
Bernd Flemisch's avatar
Bernd Flemisch committed
52
53
54
55
    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
    using Grid = typename GET_PROP_TYPE(TypeTag, Grid);
    using GridPointer = std::shared_ptr<Grid>;
    using Deck = Opm::Deck;
56
57
58
59
60
61
62
63
64

public:
    /*!
     * \brief Create the Grid.
     */
    static void makeGrid()
    {
        std::string fileName = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, std::string, Grid, File);

65
66
        deck() = Opm::Parser().parseFile(fileName);
        Opm::EclipseGrid ecl_grid(deck());
67
68

        gridPtr() = std::make_shared<Grid>(*(new Grid()));
69
        gridPtr()->processEclipseFormat(ecl_grid, false, false);
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    }

    /*!
     * \brief Returns a reference to the grid.
     */
    static Grid &grid()
    {
        return *gridPtr();
    }

    /*!
     * \brief Returns a reference to the grid pointer.
     */
    static GridPointer &gridPtr()
    {
        static GridPointer cpGrid;
        return cpGrid;
    }

    /*!
     * \brief Returns a reference to the input deck.
91
     *
92
93
     * The input deck can be used to read parameters like porosity/permeability.
     */
94
    static Deck &deck()
95
    {
96
        static Deck deck_;
97
98
99
100
101
102
103
104
105
106
107
108
        return deck_;
    }

    /*!
     * \brief Distributes the grid over all processes for a parallel computation.
     */
    static void loadBalance()
    {
        gridPtr()->loadBalance();
    }
};
}
109
#endif // HAVE_OPM_GRID
110
111

#endif