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
30#include <dune/common/fvector.hh>
31#include <dune/common/version.hh>
32
33#include <dune/grid/yaspgrid.hh>
34#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
35
37
42
43#if HAVE_DUNE_ALUGRID
44#include <dune/alugrid/grid.hh>
45#include <dune/alugrid/dgf.hh>
46#endif
47
48#include <memory>
49#include <sstream>
50
51namespace Opm {
52
53template <class TypeTag>
54class StructuredGridVanguard;
55
56} // namespace Opm
57
58namespace Opm::Properties {
59
60namespace TTag {
61
63
64} // namespace TTag
65
66// GRIDDIM is only set by the finger problem
67#ifndef GRIDDIM
68static constexpr int dim = 2;
69#else
70static constexpr int dim = GRIDDIM;
71#endif
72
73// set the Grid and Vanguard properties
74#if HAVE_DUNE_ALUGRID
75template<class TypeTag>
76struct Grid<TypeTag, TTag::StructuredGridVanguard>
77{ using type = Dune::ALUGrid< dim, dim, Dune::cube, Dune::nonconforming >; };
78#else
79template<class TypeTag>
80struct Grid<TypeTag, TTag::StructuredGridVanguard>
81{ using type = Dune::YaspGrid< dim >; };
82#endif
83
84template<class TypeTag>
85struct Vanguard<TypeTag, TTag::StructuredGridVanguard>
87
88} // namespace Opm::Properties
89
90namespace Opm {
91
97template <class TypeTag>
98class StructuredGridVanguard : public BaseVanguard<TypeTag>
99{
104
105 using GridPointer = std::unique_ptr<Grid>;
106
107 static constexpr int dim = Grid::dimension;
108
109public:
113 static void registerParameters()
114 {
115 Parameters::Register<Parameters::GridGlobalRefinements>
116 ("The number of global refinements of the grid "
117 "executed after it was loaded");
118 Parameters::Register<Parameters::DomainSizeX<Scalar>>
119 ("The size of the domain in x direction");
120 Parameters::Register<Parameters::CellsX>
121 ("The number of intervalls in x direction");
122 if constexpr (dim > 1) {
123 Parameters::Register<Parameters::DomainSizeY<Scalar>>
124 ("The size of the domain in y direction");
125 Parameters::Register<Parameters::CellsY>
126 ("The number of intervalls in y direction");
127 }
128 if constexpr (dim > 2) {
129 Parameters::Register<Parameters::DomainSizeZ<Scalar>>
130 ("The size of the domain in z direction");
131 Parameters::Register<Parameters::CellsZ>
132 ("The number of intervalls in z direction");
133 }
134 }
135
139 explicit StructuredGridVanguard(Simulator& simulator)
140 : ParentType(simulator)
141 {
142 Dune::FieldVector<int, dim> cellRes;
143
144 using GridScalar = double;
145 Dune::FieldVector<GridScalar, dim> upperRight;
146 Dune::FieldVector<GridScalar, dim> lowerLeft( 0 );
147
148 upperRight[0] = Parameters::Get<Parameters::DomainSizeX<Scalar>>();
149 upperRight[1] = Parameters::Get<Parameters::DomainSizeY<Scalar>>();
150
151 cellRes[0] = Parameters::Get<Parameters::CellsX>();
152 cellRes[1] = Parameters::Get<Parameters::CellsY>();
153 if constexpr (dim == 3) {
154 upperRight[2] = Parameters::Get<Parameters::DomainSizeZ<Scalar>>();
155 cellRes[2] = Parameters::Get<Parameters::CellsZ>();
156 }
157
158 std::stringstream dgffile;
159 dgffile << "DGF" << '\n'
160 << "INTERVAL" << '\n'
161 << lowerLeft << '\n'
162 << upperRight << '\n'
163 << cellRes << '\n'
164 << "#" << '\n'
165 << "GridParameter" << '\n'
166 << "overlap 1" << '\n'
167 << "#" << '\n'
168 << "Simplex" << '\n'
169 << "#" << '\n';
170
171 // use DGF parser to create a grid from interval block
172 gridPtr_.reset(Dune::GridPtr<Grid>(dgffile).release());
173
174 const int numRefinements = Parameters::Get<Parameters::GridGlobalRefinements>();
175 gridPtr_->globalRefine(numRefinements);
176
177 this->finalizeInit_();
178 }
179
183 Grid& grid()
184 { return *gridPtr_; }
185
189 const Grid& grid() const
190 { return *gridPtr_; }
191
192private:
193 GridPointer gridPtr_;
194};
195
196} // namespace Opm
197
198#endif
Defines some fundamental parameters for all models.
Defines a type tags and some fundamental properties all models.
Provides the base class for most (all?) simulator vanguards.
Definition: basevanguard.hh:50
void finalizeInit_()
Definition: basevanguard.hh:127
Helper class for grid instantiation of the lens problem.
Definition: structuredgridvanguard.hh:99
StructuredGridVanguard(Simulator &simulator)
Create the grid for the lens problem.
Definition: structuredgridvanguard.hh:139
static void registerParameters()
Register all run-time parameters for the structured grid simulator vanguard.
Definition: structuredgridvanguard.hh:113
const Grid & grid() const
Return a constant reference to the grid object.
Definition: structuredgridvanguard.hh:189
Grid & grid()
Return a reference to the grid object.
Definition: structuredgridvanguard.hh:183
Definition: blackoilmodel.hh:79
static constexpr int dim
Definition: structuredgridvanguard.hh:68
Definition: blackoilboundaryratevector.hh:39
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:233
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
Dune::YaspGrid< dim > type
Definition: structuredgridvanguard.hh:81
The type of the DUNE grid.
Definition: basicproperties.hh:100
UndefinedProperty type
Definition: basicproperties.hh:100
Definition: structuredgridvanguard.hh:62
Property which provides a Vanguard (manages grids)
Definition: basicproperties.hh:96