simplexgridmanager.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_MANAGER_HH
28 #define EWOMS_SIMPLEX_GRID_MANAGER_HH
29 
33 
34 #include <dune/grid/utility/structuredgridfactory.hh>
35 #include <dune/common/fvector.hh>
36 
37 #include <memory>
38 
39 namespace Ewoms {
40 namespace Properties {
41 NEW_PROP_TAG(Scalar);
42 NEW_PROP_TAG(Grid);
43 
44 NEW_PROP_TAG(DomainSizeX);
45 NEW_PROP_TAG(DomainSizeY);
46 NEW_PROP_TAG(DomainSizeZ);
47 
48 NEW_PROP_TAG(CellsX);
49 NEW_PROP_TAG(CellsY);
50 NEW_PROP_TAG(CellsZ);
51 
52 NEW_PROP_TAG(GridGlobalRefinements);
53 } // namespace Properties
54 
59 template <class TypeTag>
61 {
63  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
64  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
65  typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
66 
67  typedef Dune::shared_ptr<Grid> GridPointer;
68  typedef typename Grid::ctype CoordScalar;
69  enum { dimWorld = Grid::dimensionworld };
70  typedef Dune::FieldVector<CoordScalar, dimWorld> GlobalPosition;
71 
72 public:
76  static void registerParameters()
77  {
78  EWOMS_REGISTER_PARAM(TypeTag, unsigned, GridGlobalRefinements,
79  "The number of global refinements of the grid "
80  "executed after it was loaded");
81  EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeX,
82  "The size of the domain in x direction");
83  EWOMS_REGISTER_PARAM(TypeTag, unsigned, CellsX,
84  "The number of intervalls in x direction");
85  if (dimWorld > 1) {
86  EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeY,
87  "The size of the domain in y direction");
88  EWOMS_REGISTER_PARAM(TypeTag, unsigned, CellsY,
89  "The number of intervalls in y direction");
90  }
91  if (dimWorld > 2) {
92  EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeZ,
93  "The size of the domain in z direction");
94  EWOMS_REGISTER_PARAM(TypeTag, unsigned, CellsZ,
95  "The number of intervalls in z direction");
96  }
97  }
98 
103  : ParentType(simulator)
104  {
105  Dune::array<unsigned, dimWorld> cellRes;
106  GlobalPosition upperRight;
107  GlobalPosition lowerLeft;
108 
109  lowerLeft[0] = 0.0;
110  upperRight[0] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeX);
111  cellRes[0] = EWOMS_GET_PARAM(TypeTag, unsigned, CellsX);
112  if (dimWorld > 1) {
113  lowerLeft[1] = 0.0;
114  upperRight[1] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeY);
115  cellRes[1] = EWOMS_GET_PARAM(TypeTag, unsigned, CellsY);
116  }
117  if (dimWorld > 2) {
118  lowerLeft[2] = 0.0;
119  upperRight[2] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeZ);
120  cellRes[2] = EWOMS_GET_PARAM(TypeTag, unsigned, CellsZ);
121  }
122 
123  simplexGrid_ = Dune::StructuredGridFactory<Grid>::createSimplexGrid(lowerLeft,
124  upperRight,
125  cellRes);
126 
127  unsigned numRefinments = EWOMS_GET_PARAM(TypeTag, unsigned, GridGlobalRefinements);
128  simplexGrid_->globalRefine(numRefinments);
129 
130  this->finalizeInit_();
131  }
132 
136  Grid& grid()
137  { return simplexGrid_; }
138 
142  const Grid& grid() const
143  { return *simplexGrid_; }
144 
145 private:
146  GridPointer simplexGrid_;
147 };
148 } // namespace Ewoms
149 
150 #endif
Definition: baseauxiliarymodule.hh:37
Provides the base class for most (all?) grid managers.
Definition: basegridmanager.hh:58
static void registerParameters()
Register all run-time parameters for the grid manager.
Definition: simplexgridmanager.hh:76
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
This file provides the infrastructure to retrieve run-time parameters.
Provides a grid manager which a regular grid made of simplices.
Definition: simplexgridmanager.hh:60
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
Grid & grid()
Returns a reference to the grid.
Definition: simplexgridmanager.hh:136
Provides the magic behind the eWoms property system.
const Grid & grid() const
Returns a reference to the grid.
Definition: simplexgridmanager.hh:142
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
Defines a type tags and some fundamental properties all models.
SimplexGridManager(Simulator &simulator)
Create the Grid.
Definition: simplexgridmanager.hh:102