opm-simulators
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 
30 #include <dune/common/fvector.hh>
31 #include <dune/grid/utility/structuredgridfactory.hh>
32 
38 
39 #include <array>
40 #include <memory>
41 
42 namespace Opm {
43 
51 template <class TypeTag>
52 class 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 
67 public:
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  explicit 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  upperRight[0] = Parameters::Get<Parameters::DomainSizeX<Scalar>>();
106  cellRes[0] = Parameters::Get<Parameters::CellsX>();
107 
108  if constexpr (dim > 1) {
109  upperRight[1] = Parameters::Get<Parameters::DomainSizeY<Scalar>>();
110  cellRes[1] = Parameters::Get<Parameters::CellsY>();
111  }
112  if constexpr (dim > 2) {
113  upperRight[2] = Parameters::Get<Parameters::DomainSizeZ<Scalar>>();
114  cellRes[2] = Parameters::Get<Parameters::CellsZ>();
115  }
116 
117  const unsigned numRefinements = Parameters::Get<Parameters::GridGlobalRefinements>();
118  cubeGrid_ = Dune::StructuredGridFactory<Grid>::createCubeGrid(lowerLeft, upperRight, cellRes);
119  cubeGrid_->globalRefine(static_cast<int>(numRefinements));
120 
121  this->finalizeInit_();
122  }
123 
127  Grid& grid()
128  { return *cubeGrid_; }
129 
133  const Grid& grid() const
134  { return *cubeGrid_; }
135 
136 protected:
137  GridPointer cubeGrid_;
138 };
139 
140 } // namespace Opm
141 
142 #endif
const Grid & grid() const
Returns a reference to the grid.
Definition: cubegridvanguard.hh:133
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
CubeGridVanguard(Simulator &simulator)
Create the grid.
Definition: cubegridvanguard.hh:98
Provides a simulator vanguad which creates a regular grid made of quadrilaterals. ...
Definition: cubegridvanguard.hh:52
This file provides the infrastructure to retrieve run-time parameters.
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
Defines some fundamental parameters for all models.
static void registerParameters()
Register all run-time parameters for the simulator vanguad.
Definition: cubegridvanguard.hh:71
The Opm property system, traits with inheritance.
Provides the base class for most (all?) simulator vanguards.
Definition: basevanguard.hh:49
Grid & grid()
Returns a reference to the grid.
Definition: cubegridvanguard.hh:127
Defines a type tags and some fundamental properties all models.