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  Copyright (C) 2012-2013 by Andreas Lauser
5  Copyright (C) 2012 by Markus Wolff
6 
7  This file is part of the Open Porous Media project (OPM).
8 
9  OPM is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 2 of the License, or
12  (at your option) any later version.
13 
14  OPM is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OPM. If not, see <http://www.gnu.org/licenses/>.
21 */
26 #ifndef EWOMS_SIMPLEX_GRID_MANAGER_HH
27 #define EWOMS_SIMPLEX_GRID_MANAGER_HH
28 
32 
33 #include <dune/grid/utility/structuredgridfactory.hh>
34 #include <dune/common/fvector.hh>
35 
36 #include <memory>
37 
38 namespace Ewoms {
39 namespace Properties {
40 NEW_PROP_TAG(Scalar);
41 NEW_PROP_TAG(Grid);
42 
43 NEW_PROP_TAG(DomainSizeX);
44 NEW_PROP_TAG(DomainSizeY);
45 NEW_PROP_TAG(DomainSizeZ);
46 
47 NEW_PROP_TAG(CellsX);
48 NEW_PROP_TAG(CellsY);
49 NEW_PROP_TAG(CellsZ);
50 
51 NEW_PROP_TAG(GridGlobalRefinements);
52 } // namespace Properties
53 
58 template <class TypeTag>
60 {
62  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
63  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
64  typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
65 
66  typedef Dune::shared_ptr<Grid> GridPointer;
67  typedef typename Grid::ctype CoordScalar;
68  enum { dimWorld = Grid::dimensionworld };
69  typedef Dune::FieldVector<CoordScalar, dimWorld> GlobalPosition;
70 
71 public:
75  static void registerParameters()
76  {
77  EWOMS_REGISTER_PARAM(TypeTag, unsigned, GridGlobalRefinements,
78  "The number of global refinements of the grid "
79  "executed after it was loaded");
80  EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeX,
81  "The size of the domain in x direction");
82  EWOMS_REGISTER_PARAM(TypeTag, int, CellsX,
83  "The number of intervalls in x direction");
84  if (dimWorld > 1) {
85  EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeY,
86  "The size of the domain in y direction");
87  EWOMS_REGISTER_PARAM(TypeTag, int, CellsY,
88  "The number of intervalls in y direction");
89  }
90  if (dimWorld > 2) {
91  EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeZ,
92  "The size of the domain in z direction");
93  EWOMS_REGISTER_PARAM(TypeTag, int, CellsZ,
94  "The number of intervalls in z direction");
95  }
96  }
97 
101  SimplexGridManager(Simulator &simulator)
102  : ParentType(simulator)
103  {
104  Dune::array<unsigned, dimWorld> cellRes;
105  GlobalPosition upperRight;
106  GlobalPosition lowerLeft;
107 
108  lowerLeft[0] = 0.0;
109  upperRight[0] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeX);
110  cellRes[0] = EWOMS_GET_PARAM(TypeTag, int, CellsX);
111  if (dimWorld > 1) {
112  lowerLeft[1] = 0.0;
113  upperRight[1] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeY);
114  cellRes[1] = EWOMS_GET_PARAM(TypeTag, int, CellsY);
115  }
116  if (dimWorld > 2) {
117  lowerLeft[2] = 0.0;
118  upperRight[2] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeZ);
119  cellRes[2] = EWOMS_GET_PARAM(TypeTag, int, CellsZ);
120  }
121 
122  simplexGrid_ = Dune::StructuredGridFactory<Grid>::createSimplexGrid(lowerLeft,
123  upperRight,
124  cellRes);
125 
126  unsigned numRefinments = EWOMS_GET_PARAM(TypeTag, unsigned, GridGlobalRefinements);
127  simplexGrid_->globalRefine(numRefinments);
128 
129  this->finalizeInit_();
130  }
131 
135  Grid& grid()
136  { return simplexGrid_; }
137 
141  const Grid& grid() const
142  { return *simplexGrid_; }
143 
144 private:
145  GridPointer simplexGrid_;
146 };
147 } // namespace Ewoms
148 
149 #endif
static void registerParameters()
Register all run-time parameters for the grid manager.
Definition: simplexgridmanager.hh:75
Grid & grid()
Returns a reference to the grid.
Definition: simplexgridmanager.hh:135
Defines a type tags and some fundamental properties all models.
NEW_PROP_TAG(Grid)
The type of the DUNE grid.
This file provides the infrastructure to retrieve run-time parameters.
Provides the base class for most (all?) grid managers.
Definition: basegridmanager.hh:51
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:73
Definition: baseauxiliarymodule.hh:35
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:64
Provides the magic behind the eWoms property system.
const Grid & grid() const
Returns a reference to the grid.
Definition: simplexgridmanager.hh:141
SimplexGridManager(Simulator &simulator)
Create the Grid.
Definition: simplexgridmanager.hh:101
Provides a grid manager which a regular grid made of simplices.
Definition: simplexgridmanager.hh:59
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:95