GridHelpers.hpp
1 /*
2  Copyright 2014, 2015 Dr. Markus Blatt - HPC-Simulation-Software & Services.
3  Copyright 2014 Statoil AS
4  Copyright 2015 NTNU
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 3 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 */
21 #ifndef OPM_AUTODIFF_GRIDHELPERS_HEADER_INCLUDED
22 #define OPM_AUTODIFF_GRIDHELPERS_HEADER_INCLUDED
23 
24 #include <functional>
25 
26 #include <opm/core/grid.h>
27 #include <opm/core/grid/GridHelpers.hpp>
28 
29 #include <opm/common/utility/platform_dependent/disable_warnings.h>
30 
31 #include <Eigen/Eigen>
32 #include <Eigen/Sparse>
33 
34 #include <boost/range/iterator_range.hpp>
35 
36 #ifdef HAVE_OPM_GRID
37 #include <dune/grid/CpGrid.hpp>
38 #include <dune/grid/cpgrid/GridHelpers.hpp>
39 #include <dune/grid/polyhedralgrid.hh>
40 #endif
41 
42 #include <opm/common/utility/platform_dependent/reenable_warnings.h>
43 
44 
45 namespace Opm
46 {
47 
48 namespace AutoDiffGrid
49 {
50 
54 template<class T>
56 {
57 };
58 
60 Eigen::Array<double, Eigen::Dynamic, 1>
61 cellCentroidsZToEigen(const UnstructuredGrid& grid);
62 
64 template<class T>
66  : public Opm::UgGridHelpers::Cell2FacesTraits<T>
67 {
68 };
69 
74 void extractInternalFaces(const UnstructuredGrid& grid,
75  Eigen::Array<int, Eigen::Dynamic, 1>& internal_faces,
76  Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor>& nbi);
77 
78 } // end namespace AutoDiffGrid
79 } // end namespace Opm
80 
81 #ifdef HAVE_OPM_GRID
82 namespace Opm
83 {
84 
85 namespace AutoDiffGrid
86 {
87 
90 Eigen::Array<double, Eigen::Dynamic, 1>
91 cellCentroidsZToEigen(const Dune::CpGrid& grid);
92 
93 template<>
94 struct ADCell2FacesTraits<Dune::CpGrid>
95 {
96  typedef Dune::cpgrid::Cell2FacesContainer Type;
97 };
98 
103 void extractInternalFaces(const Dune::CpGrid& grid,
104  Eigen::Array<int, Eigen::Dynamic, 1>& internal_faces,
105  Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor>& nbi);
106 
107 template<>
108 struct ADFaceCellTraits<Dune::CpGrid>
109  : public Opm::UgGridHelpers::FaceCellTraits<Dune::CpGrid>
110 {};
112 ADFaceCellTraits<Dune::CpGrid>::Type
113 faceCellsToEigen(const Dune::CpGrid& grid);
114 } // end namespace AutoDiffGrid
115 } //end namespace OPM
116 
117 #endif
118 namespace Opm
119 {
120 namespace AutoDiffGrid
121 {
122 
123 using Opm::UgGridHelpers::SparseTableView;
124 using Opm::UgGridHelpers::numCells;
125 using Opm::UgGridHelpers::faceCells;
126 using Opm::UgGridHelpers::numFaces;
127 using Opm::UgGridHelpers::dimensions;
128 using Opm::UgGridHelpers::cartDims;
129 using Opm::UgGridHelpers::globalCell;
130 using Opm::UgGridHelpers::cell2Faces;
131 using Opm::UgGridHelpers::increment;
132 using Opm::UgGridHelpers::getCoordinate;
133 using Opm::UgGridHelpers::numCellFaces;
134 using Opm::UgGridHelpers::beginFaceCentroids;
135 using Opm::UgGridHelpers::beginCellCentroids;
136 using Opm::UgGridHelpers::cellCentroid;
137 using Opm::UgGridHelpers::faceCentroid;
138 using Opm::UgGridHelpers::beginCellVolumes;
139 using Opm::UgGridHelpers::cellVolume;
140 
141 template<>
142 struct ADFaceCellTraits<UnstructuredGrid>
143 {
144  typedef Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor> Type;
145 };
146 
147 #ifdef HAVE_OPM_GRID
148 // specialization for PolyhedralGrid as a fallback to UnstructuredGrid
149 template< int dim, int dimworld >
150 struct ADFaceCellTraits< Dune::PolyhedralGrid< dim, dimworld > >
151  : public ADFaceCellTraits<UnstructuredGrid>
152 {
153 };
154 #endif
155 
156 
158 ADFaceCellTraits<UnstructuredGrid>::Type
159 faceCellsToEigen(const UnstructuredGrid& grid);
160 
161 } // end namespace AutoDiffGrid
162 } //end namespace OPM
163 
164 #endif
Mapps a grid type to the corresponding face to cell mapping.
Definition: GridHelpers.hpp:55
Definition: ISTLSolver.hpp:44
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: AdditionalObjectDeleter.hpp:22
Mapping of the grid type to the type of the cell to faces mapping.
Definition: GridHelpers.hpp:65