cubegridvanguard.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_CUBE_GRID_VANGUARD_HH
28#define EWOMS_CUBE_GRID_VANGUARD_HH
29
35
36#include <dune/grid/utility/structuredgridfactory.hh>
37
38#include <dune/common/fvector.hh>
39
40#include <memory>
41
42namespace Opm {
43
51template <class TypeTag>
52class CubeGridVanguard : public BaseVanguard<TypeTag>
53{
58
59 using GridPointer = std::unique_ptr<Grid>;
60 using CoordScalar = typename Grid::ctype;
61 enum {
62 dim = Grid::dimension,
63 dimWorld = Grid::dimensionworld,
64 };
65 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
66
67public:
71 static void registerParameters()
72 {
73 Parameters::Register<Parameters::GridGlobalRefinements>
74 ("The number of global refinements of the grid "
75 "executed after it was loaded");
76 Parameters::Register<Parameters::DomainSizeX<Scalar>>
77 ("The size of the domain in x direction");
78 Parameters::Register<Parameters::CellsX>
79 ("The number of intervalls in x direction");
80
81 if constexpr (dim > 1) {
82 Parameters::Register<Parameters::DomainSizeY<Scalar>>
83 ("The size of the domain in y direction");
84 Parameters::Register<Parameters::CellsY>
85 ("The number of intervalls in y direction");
86 }
87 if constexpr (dim > 2) {
88 Parameters::Register<Parameters::DomainSizeZ<Scalar>>
89 ("The size of the domain in z direction");
90 Parameters::Register<Parameters::CellsZ>
91 ("The number of intervalls in z direction");
92 }
93 }
94
98 CubeGridVanguard(Simulator& simulator)
99 : ParentType(simulator)
100 {
101 std::array<unsigned int, dim> cellRes;
102 GlobalPosition upperRight(0.0);
103 GlobalPosition lowerLeft(0.0);
104
105 for (unsigned i = 0; i < dim; ++i)
106 cellRes[i] = 0;
107
108 upperRight[0] = Parameters::Get<Parameters::DomainSizeX<Scalar>>();
109 cellRes[0] = Parameters::Get<Parameters::CellsX>();
110
111 if constexpr (dim > 1) {
112 upperRight[1] = Parameters::Get<Parameters::DomainSizeY<Scalar>>();
113 cellRes[1] = Parameters::Get<Parameters::CellsY>();
114 }
115 if constexpr (dim > 2) {
116 upperRight[2] = Parameters::Get<Parameters::DomainSizeZ<Scalar>>();
117 cellRes[2] = Parameters::Get<Parameters::CellsZ>();
118 }
119
120 unsigned numRefinements = Parameters::Get<Parameters::GridGlobalRefinements>();
121 cubeGrid_ = Dune::StructuredGridFactory<Grid>::createCubeGrid(lowerLeft, upperRight, cellRes);
122 cubeGrid_->globalRefine(static_cast<int>(numRefinements));
123
124 this->finalizeInit_();
125 }
126
130 Grid& grid()
131 { return *cubeGrid_; }
132
136 const Grid& grid() const
137 { return *cubeGrid_; }
138
139protected:
140 GridPointer cubeGrid_;
141};
142
143} // namespace Opm
144
145#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
Provides a simulator vanguad which creates a regular grid made of quadrilaterals.
Definition: cubegridvanguard.hh:53
const Grid & grid() const
Returns a reference to the grid.
Definition: cubegridvanguard.hh:136
GridPointer cubeGrid_
Definition: cubegridvanguard.hh:140
Grid & grid()
Returns a reference to the grid.
Definition: cubegridvanguard.hh:130
CubeGridVanguard(Simulator &simulator)
Create the grid.
Definition: cubegridvanguard.hh:98
static void registerParameters()
Register all run-time parameters for the simulator vanguad.
Definition: cubegridvanguard.hh:71
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.