structuredgridvanguard.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 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 2 of the License, or
9 (at your option) any later version.
10
11 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef EWOMS_STRUCTURED_GRID_VANGUARD_HH
28#define EWOMS_STRUCTURED_GRID_VANGUARD_HH
29
33
34#include <dune/grid/yaspgrid.hh>
35#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
36
37#if HAVE_DUNE_ALUGRID
38#include <dune/alugrid/grid.hh>
39#include <dune/alugrid/dgf.hh>
40#endif
41
42#include <dune/common/fvector.hh>
43#include <dune/common/version.hh>
44
45#include <vector>
46#include <memory>
47
48namespace Opm {
49
50template <class TypeTag>
51class StructuredGridVanguard;
52
53} // namespace Opm
54
55namespace Opm::Properties {
56
57namespace TTag {
58
60
61} // namespace TTag
62
63// GRIDDIM is only set by the finger problem
64#ifndef GRIDDIM
65static const int dim = 2;
66#else
67static const int dim = GRIDDIM;
68#endif
69
70// set the Grid and Vanguard properties
71#if HAVE_DUNE_ALUGRID
72template<class TypeTag>
73struct Grid<TypeTag, TTag::StructuredGridVanguard> { using type = Dune::ALUGrid< dim, dim, Dune::cube, Dune::nonconforming >; };
74#else
75template<class TypeTag>
76struct Grid<TypeTag, TTag::StructuredGridVanguard> { using type = Dune::YaspGrid< dim >; };
77#endif
78
79template<class TypeTag>
81
82} // namespace Opm::Properties
83
84namespace Opm {
85
91template <class TypeTag>
92class StructuredGridVanguard : public BaseVanguard<TypeTag>
93{
98
99 using GridPointer = std::unique_ptr<Grid>;
100
101 static const int dim = Grid::dimension;
102
103public:
107 static void registerParameters()
108 {
109 Parameters::registerParam<TypeTag, Properties::GridGlobalRefinements>
110 ("The number of global refinements of the grid "
111 "executed after it was loaded");
112 Parameters::registerParam<TypeTag, Properties::DomainSizeX>
113 ("The size of the domain in x direction");
114 Parameters::registerParam<TypeTag, Properties::CellsX>
115 ("The number of intervalls in x direction");
116 if (dim > 1) {
117 Parameters::registerParam<TypeTag, Properties::DomainSizeY>
118 ("The size of the domain in y direction");
119 Parameters::registerParam<TypeTag, Properties::CellsY>
120 ("The number of intervalls in y direction");
121 }
122 if (dim > 2) {
123 Parameters::registerParam<TypeTag, Properties::DomainSizeZ>
124 ("The size of the domain in z direction");
125 Parameters::registerParam<TypeTag, Properties::CellsZ>
126 ("The number of intervalls in z direction");
127 }
128 }
129
133 StructuredGridVanguard(Simulator& simulator)
134 : ParentType(simulator)
135 {
136 Dune::FieldVector<int, dim> cellRes;
137
138 using GridScalar = double;
139 Dune::FieldVector<GridScalar, dim> upperRight;
140 Dune::FieldVector<GridScalar, dim> lowerLeft( 0 );
141
142 upperRight[0] = Parameters::get<TypeTag, Properties::DomainSizeX>();
143 upperRight[1] = Parameters::get<TypeTag, Properties::DomainSizeY>();
144
145 cellRes[0] = Parameters::get<TypeTag, Properties::CellsX>();
146 cellRes[1] = Parameters::get<TypeTag, Properties::CellsY>();
147 if (dim == 3) {
148 upperRight[2] = Parameters::get<TypeTag, Properties::DomainSizeZ>();
149 cellRes[2] = Parameters::get<TypeTag, Properties::CellsZ>();
150 }
151
152 std::stringstream dgffile;
153 dgffile << "DGF" << std::endl;
154 dgffile << "INTERVAL" << std::endl;
155 dgffile << lowerLeft << std::endl;
156 dgffile << upperRight << std::endl;
157 dgffile << cellRes << std::endl;
158 dgffile << "#" << std::endl;
159 dgffile << "GridParameter" << std::endl;
160 dgffile << "overlap 1" << std::endl;
161 dgffile << "#" << std::endl;
162 dgffile << "Simplex" << std::endl;
163 dgffile << "#" << std::endl;
164
165 // use DGF parser to create a grid from interval block
166 gridPtr_.reset( Dune::GridPtr< Grid >( dgffile ).release() );
167
168 unsigned numRefinements = Parameters::get<TypeTag, Properties::GridGlobalRefinements>();
169 gridPtr_->globalRefine(static_cast<int>(numRefinements));
170
171 this->finalizeInit_();
172 }
173
177 Grid& grid()
178 { return *gridPtr_; }
179
183 const Grid& grid() const
184 { return *gridPtr_; }
185
186private:
187 GridPointer gridPtr_;
188};
189
190} // namespace Opm
191
192#endif
Provides the base class for most (all?) simulator vanguards.
Definition: basevanguard.hh:49
void finalizeInit_()
Definition: basevanguard.hh:115
Helper class for grid instantiation of the lens problem.
Definition: structuredgridvanguard.hh:93
StructuredGridVanguard(Simulator &simulator)
Create the grid for the lens problem.
Definition: structuredgridvanguard.hh:133
static void registerParameters()
Register all run-time parameters for the structured grid simulator vanguard.
Definition: structuredgridvanguard.hh:107
const Grid & grid() const
Return a constant reference to the grid object.
Definition: structuredgridvanguard.hh:183
Grid & grid()
Return a reference to the grid object.
Definition: structuredgridvanguard.hh:177
Definition: blackoilmodel.hh:72
static const int dim
Definition: structuredgridvanguard.hh:65
Definition: blackoilboundaryratevector.hh:37
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:242
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
Dune::YaspGrid< dim > type
Definition: structuredgridvanguard.hh:76
The type of the DUNE grid.
Definition: basicproperties.hh:93
UndefinedProperty type
Definition: basicproperties.hh:93
Definition: structuredgridvanguard.hh:59
Property which provides a Vanguard (manages grids)
Definition: basicproperties.hh:89