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