opm-simulators
PolyhedralGridVanguard.hpp
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 OPM_POLYHEDRAL_GRID_VANGUARD_HPP
28 #define OPM_POLYHEDRAL_GRID_VANGUARD_HPP
29 
30 #include <opm/grid/polyhedralgrid.hh>
31 #include <opm/grid/polyhedralgrid/levelcartesianindexmapper.hh>
32 
34 
37 
38 #include <array>
39 #include <functional>
40 #include <string>
41 #include <tuple>
42 #include <unordered_set>
43 
44 namespace Opm {
45 template <class TypeTag>
47 }
48 
49 namespace Opm::Properties {
50 
51 namespace TTag {
53  using InheritsFrom = std::tuple<FlowBaseVanguard>;
54 };
55 }
56 
57 // declare the properties
58 template<class TypeTag>
59 struct Vanguard<TypeTag, TTag::PolyhedralGridVanguard> {
61 };
62 template<class TypeTag>
63 struct Grid<TypeTag, TTag::PolyhedralGridVanguard> {
64  using type = Dune::PolyhedralGrid<3, 3>;
65 };
66 template<class TypeTag>
67 struct EquilGrid<TypeTag, TTag::PolyhedralGridVanguard> {
69 };
70 
71 } // namespace Opm::Properties
72 
73 namespace Opm {
74 
82 template <class TypeTag>
83 class PolyhedralGridVanguard : public FlowBaseVanguard<TypeTag>
84 {
85  friend class FlowBaseVanguard<TypeTag>;
86  using ParentType = FlowBaseVanguard<TypeTag>;
87 
91 
92 public:
96  using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
98  using EquilCartesianIndexMapper = Dune::CartesianIndexMapper<EquilGrid>;
99  static constexpr int dimension = Grid::dimension;
100  static constexpr int dimensionworld = Grid::dimensionworld;
101 
102 private:
103  using GridPointer = Grid*;
104  using EquilGridPointer = EquilGrid*;
105 
106 public:
107  using TransmissibilityType = Transmissibility<Grid, GridView, ElementMapper,
108  CartesianIndexMapper, Scalar>;
109 
110  explicit PolyhedralGridVanguard(Simulator& simulator)
111  : FlowBaseVanguard<TypeTag>(simulator)
112  , simulator_(simulator)
113  {
114  this->callImplementationInit();
115  // add a copy in standard vector format to fullfill new interface
116  const int* globalcellorg = this->grid().globalCell();
117  int num_cells = this->gridView().size(0);
118  globalcell_.resize(num_cells);
119  for(int i=0; i < num_cells; ++i){
120  globalcell_[i] = globalcellorg[i];
121  }
122  }
123 
127  Grid& grid()
128  { return *grid_; }
129 
133  const Grid& grid() const
134  { return *grid_; }
135 
145  const EquilGrid& equilGrid() const
146  { return *grid_; }
147 
156  { /* do nothing: The EQUIL grid is the simulation grid! */ }
157 
163  void loadBalance()
164  { /* do nothing: PolyhedralGrid is not parallel! */
165  }
166 
167  void addLgrs()
168  { /* do nothing: PolyhedralGrid with LGRs not supported yet! */
169  }
170 
176  { return *cartesianIndexMapper_; }
177 
184  { return LevelCartesianIndexMapper(*cartesianIndexMapper_); }
185 
193  { return *cartesianIndexMapper_; }
194 
195  const std::vector<int>& globalCell()
196  {
197  return globalcell_;
198  }
199 
200  unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const {
201  return elemIndex;
202  }
203 
204  unsigned int gridIdxToEquilGridIdx(unsigned int elemIndex) const {
205  return elemIndex;
206  }
207 
214  {
215  }
216 
217  std::unordered_set<std::string> defunctWellNames() const
218  { return defunctWellNames_; }
219 
220  const TransmissibilityType& globalTransmissibility() const
221  {
222  return simulator_.problem().eclTransmissibilities();
223  }
224 
232  std::function<std::array<double,FlowBaseVanguard<TypeTag>::dimensionworld>(int)>
234  {
235  return this->cellCentroids_(this->cartesianIndexMapper(), false);
236  }
237 
238  std::vector<int> cellPartition() const
239  {
240  // not required for this type of grid yet (only from bdaBridge??)
241  return {};
242  }
243 
244 protected:
245  void createGrids_()
246  {
247  this->grid_ = std::make_unique<Grid>
248  (this->eclState().getInputGrid(),
249  this->eclState().fieldProps().porv(true),
250  this->edgeConformal());
251 
252  this->cartesianIndexMapper_ =
253  std::make_unique<CartesianIndexMapper>(*this->grid_);
254 
255  this->updateGridView_();
256  this->updateCartesianToCompressedMapping_();
257  this->updateCellDepths_();
258  }
259 
260  void filterConnections_()
261  {
262  // not handling the removal of completions for this type of grid yet.
263  }
264 
265  Simulator& simulator_;
266 
267  std::unique_ptr<Grid> grid_;
268  std::unique_ptr<CartesianIndexMapper> cartesianIndexMapper_;
269  //CartesianIndexMapperPointer cartesianIndexMapper_;
270 
271  std::unordered_set<std::string> defunctWellNames_;
272  std::vector<int> globalcell_;
273 };
274 
275 } // namespace Opm
276 
277 #endif // OPM_POLYHEDRAL_GRID_VANGUARD_HPP
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
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition: FlowGenericVanguard.hpp:168
Helper class for grid instantiation of ECL file-format using problems.
Definition: EclGenericWriter.hpp:50
void loadBalance()
Distribute the simulation grid over multiple processes.
Definition: PolyhedralGridVanguard.hpp:163
const GridView & gridView() const
Returns a reference to the grid view to be used.
Definition: basevanguard.hh:70
const Grid & grid() const
Return a reference to the simulation grid.
Definition: PolyhedralGridVanguard.hpp:133
Defines the common properties required by the porous medium multi-phase models.
void releaseGlobalTransmissibilities()
Free the memory occupied by the global transmissibility object.
Definition: PolyhedralGridVanguard.hpp:213
Definition: FlowBaseVanguard.hpp:70
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
const LevelCartesianIndexMapper levelCartesianIndexMapper() const
Returns the object which maps a global element index of the simulation grid to the corresponding elem...
Definition: PolyhedralGridVanguard.hpp:183
const CartesianIndexMapper & equilCartesianIndexMapper() const
Returns mapper from compressed to cartesian indices for the EQUIL grid.
Definition: PolyhedralGridVanguard.hpp:192
Helper class for grid instantiation of ECL file-format using problems.
Definition: PolyhedralGridVanguard.hpp:46
const EquilGrid & equilGrid() const
Returns a refefence to the grid which should be used by the EQUIL initialization code.
Definition: PolyhedralGridVanguard.hpp:145
The type of the DUNE grid.
Definition: basicproperties.hh:104
Property which provides a Vanguard (manages grids)
Definition: basicproperties.hh:100
Helper class for grid instantiation of ECL file-format using problems.
Definition: FlowBaseVanguard.hpp:56
void releaseEquilGrid()
Indicates that the initial condition has been computed and the memory used by the EQUIL grid can be r...
Definition: PolyhedralGridVanguard.hpp:155
const CartesianIndexMapper & cartesianIndexMapper() const
Returns the object which maps a global element index of the simulation grid to the corresponding elem...
Definition: PolyhedralGridVanguard.hpp:175
Definition: Transmissibility.hpp:54
Definition: CollectDataOnIORank.hpp:49
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:83
Definition: blackoilmodel.hh:80
Grid & grid()
Return a reference to the simulation grid.
Definition: PolyhedralGridVanguard.hpp:127
std::function< std::array< double, dimensionworld >int)> cellCentroids_(const CartMapper &cartMapper, const bool &isCpGrid) const
Get function to query cell centroids for a distributed grid.
Definition: FlowBaseVanguard.hpp:305
Definition: PolyhedralGridVanguard.hpp:52
std::function< std::array< double, FlowBaseVanguard< TypeTag >::dimensionworld >int)> cellCentroids() const
Get function to query cell centroids for a distributed grid.
Definition: PolyhedralGridVanguard.hpp:233