GlobalIdMapping.hpp
Go to the documentation of this file.
1/*
2Copyright 2014 Statoil ASA.
3Copyright 2014 Dr. Markus Blatt - HPC-Simulation-Software & Services
4
5This file is part of The Open Porous Media project (OPM).
6
7OPM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12OPM is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OPM. If not, see <http://www.gnu.org/licenses/>.
19*/
20#ifndef OPM_GLOBALIDMAPPING_HEADER
21#define OPM_GLOBALIDMAPPING_HEADER
22#include <vector>
23namespace Dune
24{
25namespace cpgrid
26{
31{
32public:
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 }
73protected:
75 std::vector<int> cellMapping_;
77 std::vector<int> faceMapping_;
79 std::vector<int> pointMapping_;
80};
81}
82}
83
84#endif
Class managing the mappings of local indices to global ids.
Definition: GlobalIdMapping.hpp:31
std::vector< int > pointMapping_
A vector containing the global id of point with index i at position i.
Definition: GlobalIdMapping.hpp:79
std::vector< int > & getMapping()
Get the vector with the mappings for a codimension.
Definition: GlobalIdMapping.hpp:49
std::vector< int > cellMapping_
A vector containing the global id of cell with index i at position i.
Definition: GlobalIdMapping.hpp:75
const std::vector< int > & getMapping() const
Get the vector with the mappings for a codimension.
Definition: GlobalIdMapping.hpp:63
std::vector< int > faceMapping_
A vector containing the global id of face with index i at position i.
Definition: GlobalIdMapping.hpp:77
void swap(std::vector< int > &cellMapping, std::vector< int > &faceMapping, std::vector< int > &pointMapping)
Swap data for initialization.
Definition: GlobalIdMapping.hpp:38
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10