All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Entity2IndexDataHandle.hpp
1 //===========================================================================
2 //
3 // File: Entity2IndexDataHandle.hpp
4 //
5 // Created: Mon Nov 4 2013
6 //
7 // Author(s): Markus Blatt <markus@dr-blatt.de>
8 //
9 // $Date$
10 //
11 // $Revision$
12 //
13 //===========================================================================
14 
15 /*
16  Copyright 2013 Statoil ASA.
17  Copyright 2013 Dr. Markus Blatt - HPC-Simulation-Software & Services
18 
19  This file is part of The Open Porous Media project (OPM).
20 
21  OPM is free software: you can redistribute it and/or modify
22  it under the terms of the GNU General Public License as published by
23  the Free Software Foundation, either version 3 of the License, or
24  (at your option) any later version.
25 
26  OPM is distributed in the hope that it will be useful,
27  but WITHOUT ANY WARRANTY; without even the implied warranty of
28  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  GNU General Public License for more details.
30 
31  You should have received a copy of the GNU General Public License
32  along with OPM. If not, see <http://www.gnu.org/licenses/>.
33 */
34 #ifndef OPM_ENTITY2INDEXDATAHANDLE_HEADER
35 #define OPM_ENTITY2INDEXDATAHANDLE_HEADER
36 
37 namespace Dune
38 {
39 namespace cpgrid
40 {
41 template<int codim> class Entity;
42 class CpGridData;
43 
50 template<class DataHandle, int codim>
52 {
53 public:
54  typedef typename DataHandle::DataType DataType;
55 
56  Entity2IndexDataHandle(const CpGridData& grid, DataHandle& data)
57  : grid_(grid), data_(data)
58  {}
59  bool fixedsize()
60  {
61  return data_.fixedsize(3, codim);
62  }
63  std::size_t size(std::size_t i)
64  {
65  return data_.size(Entity<codim>(grid_, i, true));
66  }
67  template<class B>
68  void gather(B& buffer, std::size_t i)
69  {
70  data_.gather(buffer, Entity<codim>(grid_, i, true));
71  }
72  template<class B>
73  void scatter(B& buffer, std::size_t i, std::size_t s)
74  {
75  data_.scatter(buffer, Entity<codim>(grid_, i, true), s);
76  }
77 private:
78  const CpGridData& grid_;
79  DataHandle& data_;
80 
81 };
82 } // end namespace cpgrid
83 } // end namespace Dune
84 #endif
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:105
Wrapper that turns a data handle suitable for dune-grid into one based on integers instead of entitie...
Definition: Entity2IndexDataHandle.hpp:51