simplexvanguard.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_SIMPLEX_GRID_VANGUARD_HH
28#define EWOMS_SIMPLEX_GRID_VANGUARD_HH
29
30#include <dune/common/fvector.hh>
31
32#include <dune/grid/utility/structuredgridfactory.hh>
33
35
39
40#include <memory>
41
42namespace Opm {
46template <class TypeTag>
48{
53
54 using GridPointer = std::unique_ptr<Grid>;
55 using CoordScalar = typename Grid::ctype;
56 enum {
57 dim = Grid::dimension,
58 dimWorld = Grid::dimensionworld,
59 };
60 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
61
62public:
66 static void registerParameters()
67 {
68 Parameters::Register<Parameters::GridGlobalRefinements>
69 ("The number of global refinements of the grid "
70 "executed after it was loaded");
71 Parameters::Register<Parameters::DomainSizeX>
72 ("The size of the domain in x direction");
73 Parameters::Register<Parameters::CellsX>
74 ("The number of intervalls in x direction");
75 if (dimWorld > 1) {
76 Parameters::Register<Parameters::DomainSizeY>
77 ("The size of the domain in y direction");
78 Parameters::Register<Parameters::CellsY>
79 ("The number of intervalls in y direction");
80 }
81 if constexpr (dim > 2) {
82 Parameters::Register<Parameters::DomainSizeZ>
83 ("The size of the domain in z direction");
84 Parameters::Register<Parameters::CellsZ>
85 ("The number of intervalls in z direction");
86 }
87 }
88
92 SimplexGridVanguard(Simulator& simulator)
93 : ParentType(simulator)
94 {
95 Dune::array<unsigned, dim> cellRes;
96 GlobalPosition upperRight;
97 GlobalPosition lowerLeft;
98
99 lowerLeft[0] = 0.0;
100 upperRight[0] = Parameters::Get<Parameters::DomainSizeX>();
101 cellRes[0] = Parameters::Get<Parameters::CellsX>();
102 if constexpr (dim > 1) {
103 lowerLeft[1] = 0.0;
104 upperRight[1] = Parameters::Get<Parameters::DomainSizeY>();
105 cellRes[1] = Parameters::Get<Parameters::CellsY>();
106 }
107 if constexpr (dim > 2) {
108 lowerLeft[2] = 0.0;
109 upperRight[2] = Parameters::Get<Parameters::DomainSizeZ>();
110 cellRes[2] = Parameters::Get<Parameters::CellsZ>();
111 }
112
113 simplexGrid_ = Dune::StructuredGridFactory<Grid>::createSimplexGrid(lowerLeft,
114 upperRight,
115 cellRes);
116
117 unsigned numRefinments = Parameters::Get<Parameters::GridGlobalRefinements>();
118 simplexGrid_->globalRefine(numRefinments);
119
120 this->finalizeInit_();
121 }
122
126 Grid& grid()
127 { return simplexGrid_; }
128
132 const Grid& grid() const
133 { return *simplexGrid_; }
134
135private:
136 GridPointer simplexGrid_;
137};
138} // namespace Opm
139
140#endif
Defines a type tags and some fundamental properties all models.
Provides the base class for most (all?) simulator vanguards.
Definition: basevanguard.hh:49
Provides a simulator vanguard which a creates regular grid made of simplices.
Definition: simplexvanguard.hh:48
static void registerParameters()
Register all run-time parameters for the grid manager.
Definition: simplexvanguard.hh:66
SimplexGridVanguard(Simulator &simulator)
Create the Grid.
Definition: simplexvanguard.hh:92
const Grid & grid() const
Returns a reference to the grid.
Definition: simplexvanguard.hh:132
Grid & grid()
Returns a reference to the grid.
Definition: simplexvanguard.hh:126
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.