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
34
35#include <dune/grid/utility/structuredgridfactory.hh>
36
37#include <dune/common/fvector.hh>
38
39#include <memory>
40
41namespace Opm {
42
50template <class TypeTag>
51class CubeGridVanguard : public BaseVanguard<TypeTag>
52{
57
58 using GridPointer = std::unique_ptr<Grid>;
59 using CoordScalar = typename Grid::ctype;
60 enum { dimWorld = Grid::dimensionworld };
61 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
62
63public:
67 static void registerParameters()
68 {
69 Parameters::registerParam<TypeTag, Properties::GridGlobalRefinements>
70 ("The number of global refinements of the grid "
71 "executed after it was loaded");
72 Parameters::registerParam<TypeTag, Properties::DomainSizeX>
73 ("The size of the domain in x direction");
74 Parameters::registerParam<TypeTag, Properties::CellsX>
75 ("The number of intervalls in x direction");
76 if (dimWorld > 1) {
77 Parameters::registerParam<TypeTag, Properties::DomainSizeY>
78 ("The size of the domain in y direction");
79 Parameters::registerParam<TypeTag, Properties::CellsY>
80 ("The number of intervalls in y direction");
81 }
82 if (dimWorld > 2) {
83 Parameters::registerParam<TypeTag, Properties::DomainSizeZ>
84 ("The size of the domain in z direction");
85 Parameters::registerParam<TypeTag, Properties::CellsZ>
86 ("The number of intervalls in z direction");
87 }
88 }
89
93 CubeGridVanguard(Simulator& simulator)
94 : ParentType(simulator)
95 {
96 std::array<unsigned int, dimWorld> cellRes;
97 GlobalPosition upperRight(0.0);
98 GlobalPosition lowerLeft(0.0);
99
100 for (unsigned i = 0; i < dimWorld; ++i)
101 cellRes[i] = 0;
102
103 upperRight[0] = Parameters::get<TypeTag, Properties::DomainSizeX>();
104 cellRes[0] = Parameters::get<TypeTag, Properties::CellsX>();
105 if (dimWorld > 1) {
106 upperRight[1] = Parameters::get<TypeTag, Properties::DomainSizeY>();
107 cellRes[1] = Parameters::get<TypeTag, Properties::CellsY>();
108 }
109 if (dimWorld > 2) {
110 upperRight[2] = Parameters::get<TypeTag, Properties::DomainSizeZ>();
111 cellRes[2] = Parameters::get<TypeTag, Properties::CellsZ>();
112 }
113
114 unsigned numRefinements = Parameters::get<TypeTag, Properties::GridGlobalRefinements>();
115 cubeGrid_ = Dune::StructuredGridFactory<Grid>::createCubeGrid(lowerLeft, upperRight, cellRes);
116 cubeGrid_->globalRefine(static_cast<int>(numRefinements));
117
118 this->finalizeInit_();
119 }
120
124 Grid& grid()
125 { return *cubeGrid_; }
126
130 const Grid& grid() const
131 { return *cubeGrid_; }
132
133protected:
134 GridPointer cubeGrid_;
135};
136
137} // namespace Opm
138
139#endif
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:52
const Grid & grid() const
Returns a reference to the grid.
Definition: cubegridvanguard.hh:130
GridPointer cubeGrid_
Definition: cubegridvanguard.hh:134
Grid & grid()
Returns a reference to the grid.
Definition: cubegridvanguard.hh:124
CubeGridVanguard(Simulator &simulator)
Create the grid.
Definition: cubegridvanguard.hh:93
static void registerParameters()
Register all run-time parameters for the simulator vanguad.
Definition: cubegridvanguard.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:242
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.