opm-simulators
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 <array>
41 #include <memory>
42 
43 namespace Opm {
44 
48 template <class TypeTag>
50 {
55 
56  using GridPointer = std::unique_ptr<Grid>;
57  using CoordScalar = typename Grid::ctype;
58  enum {
59  dim = Grid::dimension,
60  dimWorld = Grid::dimensionworld,
61  };
62  using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
63 
64 public:
68  static void registerParameters()
69  {
70  Parameters::Register<Parameters::GridGlobalRefinements>
71  ("The number of global refinements of the grid "
72  "executed after it was loaded");
73  Parameters::Register<Parameters::DomainSizeX<Scalar>>
74  ("The size of the domain in x direction");
75  Parameters::Register<Parameters::CellsX>
76  ("The number of intervalls in x direction");
77  if (dimWorld > 1) {
78  Parameters::Register<Parameters::DomainSizeY<Scalar>>
79  ("The size of the domain in y direction");
80  Parameters::Register<Parameters::CellsY>
81  ("The number of intervalls in y direction");
82  }
83  if constexpr (dim > 2) {
84  Parameters::Register<Parameters::DomainSizeZ<Scalar>>
85  ("The size of the domain in z direction");
86  Parameters::Register<Parameters::CellsZ>
87  ("The number of intervalls in z direction");
88  }
89  }
90 
94  explicit SimplexGridVanguard(Simulator& simulator)
95  : ParentType(simulator)
96  {
97  std::array<unsigned, dim> cellRes{};
98  GlobalPosition upperRight;
99  GlobalPosition lowerLeft;
100 
101  lowerLeft[0] = 0.0;
102  upperRight[0] = Parameters::Get<Parameters::DomainSizeX<Scalar>>();
103  cellRes[0] = Parameters::Get<Parameters::CellsX>();
104  if constexpr (dim > 1) {
105  lowerLeft[1] = 0.0;
106  upperRight[1] = Parameters::Get<Parameters::DomainSizeY<Scalar>>();
107  cellRes[1] = Parameters::Get<Parameters::CellsY>();
108  }
109  if constexpr (dim > 2) {
110  lowerLeft[2] = 0.0;
111  upperRight[2] = Parameters::Get<Parameters::DomainSizeZ<Scalar>>();
112  cellRes[2] = Parameters::Get<Parameters::CellsZ>();
113  }
114 
115  simplexGrid_ = Dune::StructuredGridFactory<Grid>::createSimplexGrid(lowerLeft,
116  upperRight,
117  cellRes);
118 
119  const unsigned numRefinments = Parameters::Get<Parameters::GridGlobalRefinements>();
120  simplexGrid_->globalRefine(numRefinments);
121 
122  this->finalizeInit_();
123  }
124 
128  Grid& grid()
129  { return simplexGrid_; }
130 
134  const Grid& grid() const
135  { return *simplexGrid_; }
136 
137 private:
138  GridPointer simplexGrid_;
139 };
140 
141 } // namespace Opm
142 
143 #endif
Provides a simulator vanguard which a creates regular grid made of simplices.
Definition: simplexvanguard.hh:49
const Grid & grid() const
Returns a reference to the grid.
Definition: simplexvanguard.hh:134
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.
Grid & grid()
Returns a reference to the grid.
Definition: simplexvanguard.hh:128
static void registerParameters()
Register all run-time parameters for the grid manager.
Definition: simplexvanguard.hh:68
Provides the base class for most (all?) simulator vanguards.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
SimplexGridVanguard(Simulator &simulator)
Create the Grid.
Definition: simplexvanguard.hh:94
The Opm property system, traits with inheritance.
Provides the base class for most (all?) simulator vanguards.
Definition: basevanguard.hh:49
Defines a type tags and some fundamental properties all models.