GridHelpers.hpp
Go to the documentation of this file.
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 <boost/range/iterator_range.hpp>
27 #include <opm/core/grid.h>
28 #include <opm/core/grid/GridHelpers.hpp>
29 
30 #include <opm/common/utility/platform_dependent/disable_warnings.h>
31 
32 #include <Eigen/Eigen>
33 #include <Eigen/Sparse>
34 
35 #ifdef HAVE_DUNE_CORNERPOINT
36 #include <dune/grid/CpGrid.hpp>
37 #include <dune/grid/cpgrid/GridHelpers.hpp>
38 #include <dune/grid/polyhedralgrid.hh>
39 #endif
40 
41 #include <opm/common/utility/platform_dependent/reenable_warnings.h>
42 
43 
44 namespace Opm
45 {
46 
47 namespace AutoDiffGrid
48 {
49 
53 template<class T>
55 {
56 };
57 
59 Eigen::Array<double, Eigen::Dynamic, 1>
60 cellCentroidsZToEigen(const UnstructuredGrid& grid);
61 
63 template<class T>
65  : public Opm::UgGridHelpers::Cell2FacesTraits<T>
66 {
67 };
68 
73 void extractInternalFaces(const UnstructuredGrid& grid,
74  Eigen::Array<int, Eigen::Dynamic, 1>& internal_faces,
75  Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor>& nbi);
76 
77 } // end namespace AutoDiffGrid
78 } // end namespace Opm
79 
80 #ifdef HAVE_DUNE_CORNERPOINT
81 namespace Opm
82 {
83 
84 namespace AutoDiffGrid
85 {
86 
89 Eigen::Array<double, Eigen::Dynamic, 1>
90 cellCentroidsZToEigen(const Dune::CpGrid& grid);
91 
92 template<>
93 struct ADCell2FacesTraits<Dune::CpGrid>
94 {
95  typedef Dune::cpgrid::Cell2FacesContainer Type;
96 };
97 
102 void extractInternalFaces(const Dune::CpGrid& grid,
103  Eigen::Array<int, Eigen::Dynamic, 1>& internal_faces,
104  Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor>& nbi);
105 
106 template<>
107 struct ADFaceCellTraits<Dune::CpGrid>
108  : public Opm::UgGridHelpers::FaceCellTraits<Dune::CpGrid>
109 {};
111 ADFaceCellTraits<Dune::CpGrid>::Type
112 faceCellsToEigen(const Dune::CpGrid& grid);
113 } // end namespace AutoDiffGrid
114 } //end namespace OPM
115 
116 #endif
117 namespace Opm
118 {
119 namespace AutoDiffGrid
120 {
121 
122 using Opm::UgGridHelpers::SparseTableView;
123 using Opm::UgGridHelpers::numCells;
124 using Opm::UgGridHelpers::faceCells;
125 using Opm::UgGridHelpers::numFaces;
126 using Opm::UgGridHelpers::dimensions;
127 using Opm::UgGridHelpers::cartDims;
128 using Opm::UgGridHelpers::globalCell;
129 using Opm::UgGridHelpers::cell2Faces;
130 using Opm::UgGridHelpers::increment;
131 using Opm::UgGridHelpers::getCoordinate;
132 using Opm::UgGridHelpers::numCellFaces;
133 using Opm::UgGridHelpers::beginFaceCentroids;
134 using Opm::UgGridHelpers::beginCellCentroids;
135 using Opm::UgGridHelpers::cellCentroid;
136 using Opm::UgGridHelpers::faceCentroid;
137 using Opm::UgGridHelpers::beginCellVolumes;
138 using Opm::UgGridHelpers::cellVolume;
139 
140 template<>
141 struct ADFaceCellTraits<UnstructuredGrid>
142 {
143  typedef Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor> Type;
144 };
145 
146 #ifdef HAVE_DUNE_CORNERPOINT
147 // specialization for PolyhedralGrid as a fallback to UnstructuredGrid
148 template< int dim, int dimworld >
149 struct ADFaceCellTraits< Dune::PolyhedralGrid< dim, dimworld > >
150  : public ADFaceCellTraits<UnstructuredGrid>
151 {
152 };
153 #endif
154 
155 
158 faceCellsToEigen(const UnstructuredGrid& grid);
159 
160 } // end namespace AutoDiffGrid
161 } //end namespace OPM
162 
163 #endif
Definition: AdditionalObjectDeleter.hpp:22
Eigen::Array< int, Eigen::Dynamic, 2, Eigen::RowMajor > Type
Definition: GridHelpers.hpp:143
Mapps a grid type to the corresponding face to cell mapping.
Definition: GridHelpers.hpp:54
ADFaceCellTraits< UnstructuredGrid >::Type faceCellsToEigen(const UnstructuredGrid &grid)
Get the face to cell mapping of a grid.
Mapping of the grid type to the type of the cell to faces mapping.
Definition: GridHelpers.hpp:64
Eigen::Array< double, Eigen::Dynamic, 1 > cellCentroidsZToEigen(const UnstructuredGrid &grid)
Get the z coordinates of the cell centroids of a grid.
void extractInternalFaces(const UnstructuredGrid &grid, Eigen::Array< int, Eigen::Dynamic, 1 > &internal_faces, Eigen::Array< int, Eigen::Dynamic, 2, Eigen::RowMajor > &nbi)
extracts the internal faces of a grid.