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/GridHelpers.hpp>
31#include <opm/grid/polyhedralgrid.hh>
32#include <opm/grid/polyhedralgrid/levelcartesianindexmapper.hh>
33
35
38
39#include <array>
40#include <functional>
41#include <string>
42#include <tuple>
43#include <unordered_set>
44
45namespace Opm {
46template <class TypeTag>
48}
49
50namespace Opm::Properties {
51
52namespace TTag {
54 using InheritsFrom = std::tuple<FlowBaseVanguard>;
55};
56}
57
58// declare the properties
59template<class TypeTag>
60struct Vanguard<TypeTag, TTag::PolyhedralGridVanguard> {
62};
63template<class TypeTag>
64struct Grid<TypeTag, TTag::PolyhedralGridVanguard> {
65 using type = Dune::PolyhedralGrid<3, 3>;
66};
67template<class TypeTag>
68struct EquilGrid<TypeTag, TTag::PolyhedralGridVanguard> {
70};
71
72} // namespace Opm::Properties
73
74namespace Opm {
75
83template <class TypeTag>
85{
86 friend class FlowBaseVanguard<TypeTag>;
88
92
93public:
100 static constexpr int dimension = Grid::dimension;
101 static constexpr int dimensionworld = Grid::dimensionworld;
102
103private:
104 using GridPointer = Grid*;
105 using EquilGridPointer = EquilGrid*;
106
107public:
109 CartesianIndexMapper, Scalar>;
110
111 explicit PolyhedralGridVanguard(Simulator& simulator)
112 : FlowBaseVanguard<TypeTag>(simulator)
113 , simulator_(simulator)
114 {
116 // add a copy in standard vector format to fullfill new interface
117 const int* globalcellorg = this->grid().globalCell();
118 int num_cells = this->gridView().size(0);
119 globalcell_.resize(num_cells);
120 for(int i=0; i < num_cells; ++i){
121 globalcell_[i] = globalcellorg[i];
122 }
123 }
124
129 { return *grid_; }
130
134 const Grid& grid() const
135 { return *grid_; }
136
146 const EquilGrid& equilGrid() const
147 { return *grid_; }
148
157 { /* do nothing: The EQUIL grid is the simulation grid! */ }
158
165 { /* do nothing: PolyhedralGrid is not parallel! */
166 }
167
168 void addLgrs()
169 { /* do nothing: PolyhedralGrid with LGRs not supported yet! */
170 }
171
177 { return *cartesianIndexMapper_; }
178
186
194 { return *cartesianIndexMapper_; }
195
196 const std::vector<int>& globalCell()
197 {
198 return globalcell_;
199 }
200
201 unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const {
202 return elemIndex;
203 }
204
205 unsigned int gridIdxToEquilGridIdx(unsigned int elemIndex) const {
206 return elemIndex;
207 }
208
215 {
216 }
217
218 std::unordered_set<std::string> defunctWellNames() const
219 { return defunctWellNames_; }
220
222 {
223 return simulator_.problem().eclTransmissibilities();
224 }
225
233 std::function<std::array<double,FlowBaseVanguard<TypeTag>::dimensionworld>(int)>
235 {
236 return this->cellCentroids_(this->cartesianIndexMapper(), false);
237 }
238
239 std::vector<int> cellPartition() const
240 {
241 // not required for this type of grid yet (only from bdaBridge??)
242 return {};
243 }
244
245protected:
247 {
248 this->grid_ = std::make_unique<Grid>
249 (this->eclState().getInputGrid(),
250 this->eclState().fieldProps().porv(true),
251 this->edgeConformal(),
252 this->minpvMergeCells());
253
254 // The grid can have fewer cells than the deck has active cells, for instance if cells are
255 // removed because of MINPV. The properties of the cells are given for the active cells,
256 // so they must follow the cells of the grid, as they do for the CpGrid.
257 {
258 auto& eclState = this->eclState();
259 eclState.reset_actnum(UgGridHelpers::createACTNUM(*this->grid_));
260 const int* globalCell = this->grid_->globalCellPtr();
261 eclState.set_active_indices(std::vector<int>(globalCell, globalCell + this->grid_->size(0)));
262 }
263
265 std::make_unique<CartesianIndexMapper>(*this->grid_);
266
267 this->updateGridView_();
269 this->updateCellDepths_();
270 }
271
273 {
274 // not handling the removal of completions for this type of grid yet.
275 }
276
277 Simulator& simulator_;
278
279 std::unique_ptr<Grid> grid_;
280 std::unique_ptr<CartesianIndexMapper> cartesianIndexMapper_;
281 //CartesianIndexMapperPointer cartesianIndexMapper_;
282
283 std::unordered_set<std::string> defunctWellNames_;
284 std::vector<int> globalcell_;
285};
286
287} // namespace Opm
288
289#endif // OPM_POLYHEDRAL_GRID_VANGUARD_HPP
Definition: CollectDataOnIORank.hpp:50
Provides the base class for most (all?) simulator vanguards.
Definition: basevanguard.hh:50
void updateGridView_()
Definition: basevanguard.hh:132
const GridView & gridView() const
Returns a reference to the grid view to be used.
Definition: basevanguard.hh:70
Helper class for grid instantiation of ECL file-format using problems.
Definition: FlowBaseVanguard.hpp:84
void updateCartesianToCompressedMapping_()
Definition: FlowBaseVanguard.hpp:348
void updateCellDepths_()
Definition: FlowBaseVanguard.hpp:370
void callImplementationInit()
Definition: FlowBaseVanguard.hpp:337
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:317
bool minpvMergeCells() const
Definition: FlowGenericVanguard.hpp:264
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition: FlowGenericVanguard.hpp:170
bool edgeConformal() const
Definition: FlowGenericVanguard.hpp:259
Definition: EclGenericWriter.hpp:54
Helper class for grid instantiation of ECL file-format using problems.
Definition: PolyhedralGridVanguard.hpp:85
void releaseEquilGrid()
Indicates that the initial condition has been computed and the memory used by the EQUIL grid can be r...
Definition: PolyhedralGridVanguard.hpp:156
std::unique_ptr< Grid > grid_
Definition: PolyhedralGridVanguard.hpp:279
unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const
Definition: PolyhedralGridVanguard.hpp:201
const CartesianIndexMapper & equilCartesianIndexMapper() const
Returns mapper from compressed to cartesian indices for the EQUIL grid.
Definition: PolyhedralGridVanguard.hpp:193
void createGrids_()
Definition: PolyhedralGridVanguard.hpp:246
static constexpr int dimensionworld
Definition: PolyhedralGridVanguard.hpp:101
std::unordered_set< std::string > defunctWellNames_
Definition: PolyhedralGridVanguard.hpp:283
void releaseGlobalTransmissibilities()
Free the memory occupied by the global transmissibility object.
Definition: PolyhedralGridVanguard.hpp:214
const std::vector< int > & globalCell()
Definition: PolyhedralGridVanguard.hpp:196
void loadBalance()
Distribute the simulation grid over multiple processes.
Definition: PolyhedralGridVanguard.hpp:164
Simulator & simulator_
Definition: PolyhedralGridVanguard.hpp:277
Dune::CartesianIndexMapper< Grid > CartesianIndexMapper
Definition: PolyhedralGridVanguard.hpp:97
static constexpr int dimension
Definition: PolyhedralGridVanguard.hpp:100
const TransmissibilityType & globalTransmissibility() const
Definition: PolyhedralGridVanguard.hpp:221
std::vector< int > cellPartition() const
Definition: PolyhedralGridVanguard.hpp:239
const EquilGrid & equilGrid() const
Returns a refefence to the grid which should be used by the EQUIL initialization code.
Definition: PolyhedralGridVanguard.hpp:146
GetPropType< TypeTag, Properties::GridView > GridView
Definition: PolyhedralGridVanguard.hpp:96
GetPropType< TypeTag, Properties::EquilGrid > EquilGrid
Definition: PolyhedralGridVanguard.hpp:95
std::vector< int > globalcell_
Definition: PolyhedralGridVanguard.hpp:284
PolyhedralGridVanguard(Simulator &simulator)
Definition: PolyhedralGridVanguard.hpp:111
std::unordered_set< std::string > defunctWellNames() const
Definition: PolyhedralGridVanguard.hpp:218
void filterConnections_()
Definition: PolyhedralGridVanguard.hpp:272
Grid & grid()
Return a reference to the simulation grid.
Definition: PolyhedralGridVanguard.hpp:128
Opm::LevelCartesianIndexMapper< Grid > LevelCartesianIndexMapper
Definition: PolyhedralGridVanguard.hpp:98
GetPropType< TypeTag, Properties::Grid > Grid
Definition: PolyhedralGridVanguard.hpp:94
std::unique_ptr< CartesianIndexMapper > cartesianIndexMapper_
Definition: PolyhedralGridVanguard.hpp:280
const Grid & grid() const
Return a reference to the simulation grid.
Definition: PolyhedralGridVanguard.hpp:134
void addLgrs()
Definition: PolyhedralGridVanguard.hpp:168
unsigned int gridIdxToEquilGridIdx(unsigned int elemIndex) const
Definition: PolyhedralGridVanguard.hpp:205
const CartesianIndexMapper & cartesianIndexMapper() const
Returns the object which maps a global element index of the simulation grid to the corresponding elem...
Definition: PolyhedralGridVanguard.hpp:176
const LevelCartesianIndexMapper levelCartesianIndexMapper() const
Returns the object which maps a global element index of the simulation grid to the corresponding elem...
Definition: PolyhedralGridVanguard.hpp:184
std::function< std::array< double, FlowBaseVanguard< TypeTag >::dimensionworld >(int)> cellCentroids() const
Get function to query cell centroids for a distributed grid.
Definition: PolyhedralGridVanguard.hpp:234
Definition: Transmissibility.hpp:55
Defines the common properties required by the porous medium multi-phase models.
Definition: blackoilmodel.hh:74
Definition: blackoilbioeffectsmodules.hh:45
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
GetPropType< TypeTag, Properties::Grid > type
Definition: PolyhedralGridVanguard.hpp:69
Definition: FlowBaseVanguard.hpp:70
Dune::PolyhedralGrid< 3, 3 > type
Definition: PolyhedralGridVanguard.hpp:65
The type of the DUNE grid.
Definition: basicproperties.hh:104
Definition: PolyhedralGridVanguard.hpp:53
std::tuple< FlowBaseVanguard > InheritsFrom
Definition: PolyhedralGridVanguard.hpp:54
Property which provides a Vanguard (manages grids)
Definition: basicproperties.hh:100