GlobalIdMapping.hpp
1 /*
2 Copyright 2014 Statoil ASA.
3 Copyright 2014 Dr. Markus Blatt - HPC-Simulation-Software & Services
4 
5 This file is part of The Open Porous Media project (OPM).
6 
7 OPM is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 OPM is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with OPM. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifndef OPM_GLOBALIDMAPPING_HEADER
21 #define OPM_GLOBALIDMAPPING_HEADER
22 #include <vector>
23 namespace Dune
24 {
25 namespace cpgrid
26 {
31 {
32 public:
37 
38  void swap(std::vector<int>& cellMapping,
39  std::vector<int>& faceMapping,
40  std::vector<int>& pointMapping)
41  {
42  cellMapping_.swap(cellMapping);
43  faceMapping_.swap(faceMapping);
44  pointMapping_.swap(pointMapping);
45  }
48  template<int codim>
49  std::vector<int>& getMapping()
50  {
51  static_assert(codim == 0 || codim == 1 || codim==3,
52  "Mappings only available for codimension 0, 1, and 3");
53  if(codim==0)
54  return cellMapping_;
55  if(codim==1)
56  return faceMapping_;
57  return pointMapping_;
58  }
59 
62  template<int codim>
63  const std::vector<int>& getMapping() const
64  {
65  static_assert(codim == 0 || codim == 1 || codim==3,
66  "Mappings only available for codimension 0, 1, and 3");
67  if(codim==0)
68  return cellMapping_;
69  if(codim==1)
70  return faceMapping_;
71  return pointMapping_;
72  }
73 protected:
75  std::vector<int> cellMapping_;
77  std::vector<int> faceMapping_;
79  std::vector<int> pointMapping_;
80 };
81 }
82 }
83 
84 #endif
Holds the implementation of the CpGrid as a pimple.
Definition: OpmParserIncludes.hpp:42
std::vector< int > cellMapping_
A vector containing the global id of cell with index i at position i.
Definition: GlobalIdMapping.hpp:75
void swap(std::vector< int > &cellMapping, std::vector< int > &faceMapping, std::vector< int > &pointMapping)
Swap data for initialization.
Definition: GlobalIdMapping.hpp:38
std::vector< int > & getMapping()
Get the vector with the mappings for a codimension.
Definition: GlobalIdMapping.hpp:49
Class managing the mappings of local indices to global ids.
Definition: GlobalIdMapping.hpp:30
std::vector< int > faceMapping_
A vector containing the global id of face with index i at position i.
Definition: GlobalIdMapping.hpp:77
std::vector< int > pointMapping_
A vector containing the global id of point with index i at position i.
Definition: GlobalIdMapping.hpp:79
const std::vector< int > & getMapping() const
Get the vector with the mappings for a codimension.
Definition: GlobalIdMapping.hpp:63