basegridmanager.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-2014 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
25 #ifndef EWOMS_BASE_GRID_MANAGER_HH
26 #define EWOMS_BASE_GRID_MANAGER_HH
27 
30 
31 #include <dune/common/version.hh>
32 
33 #include <type_traits>
34 #include <memory>
35 
36 namespace Ewoms {
37 namespace Properties {
38 NEW_PROP_TAG(Grid);
39 NEW_PROP_TAG(GridManager);
40 NEW_PROP_TAG(GridView);
41 NEW_PROP_TAG(GridViewLevel);
42 NEW_PROP_TAG(GridFile);
43 NEW_PROP_TAG(GridGlobalRefinements);
44 NEW_PROP_TAG(Simulator);
45 } // namespace Properties
46 
50 template <class TypeTag>
52 {
53  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
54  typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
55  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
56  typedef typename GET_PROP_TYPE(TypeTag, GridManager) Implementation;
57 
58 public:
59  BaseGridManager(Simulator &simulator)
60  : simulator_(simulator)
61  {}
62 
66  GridView &gridView()
67  { return *gridView_; }
68 
72  const GridView &gridView() const
73  { return *gridView_; }
74 
79  void loadBalance()
80  { asImp_().grid().loadBalance(); }
81 
82 protected:
83  // this method should be called after the grid has been allocated
85  {
86 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2,3)
87  gridView_.reset(new GridView(asImp_().grid().leafGridView()));
88 #else
89  gridView_.reset(new GridView(asImp_().grid().leafView()));
90 #endif
91  }
92 
93 private:
94  Implementation &asImp_()
95  { return *static_cast<Implementation*>(this); }
96 
97  const Implementation &asImp_() const
98  { return *static_cast<const Implementation*>(this); }
99 
100  Simulator &simulator_;
101  std::unique_ptr<GridView> gridView_;
102 };
103 
104 } // namespace Ewoms
105 
106 #endif
void finalizeInit_()
Definition: basegridmanager.hh:84
const GridView & gridView() const
Returns a reference to the grid view to be used.
Definition: basegridmanager.hh:72
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
GridView & gridView()
Returns a reference to the grid view to be used.
Definition: basegridmanager.hh:66
Definition: baseauxiliarymodule.hh:35
void loadBalance()
Distribute the grid (and attached data) over all processes.
Definition: basegridmanager.hh:79
BaseGridManager(Simulator &simulator)
Definition: basegridmanager.hh:59
Provides the magic behind the eWoms property system.