My Project
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#include <dune/common/version.hh>
38
39namespace Dune
40{
41namespace cpgrid
42{
43template<int codim> class Entity;
44class CpGridData;
45
52template<class DataHandle, int codim>
54{
55public:
56 typedef typename DataHandle::DataType DataType;
57
58 Entity2IndexDataHandle(const CpGridData& grid, DataHandle& data)
59 : fromGrid_(grid), toGrid_(grid), data_(data)
60 {}
61 Entity2IndexDataHandle(const CpGridData& fromGrid, const CpGridData& toGrid, DataHandle& data)
62 : fromGrid_(fromGrid), toGrid_(toGrid), data_(data)
63 {}
64
65#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 8)
66 bool fixedSize()
67 {
68 return data_.fixedSize(3, codim);
69 }
70#else
71 bool fixedsize()
72 {
73#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 7)
74 return data_.fixedSize(3, codim);
75#else
76 return data_.fixedsize(3, codim);
77#endif
78 }
79#endif
80 std::size_t size(std::size_t i)
81 {
82 return data_.size(Entity<codim>(fromGrid_, i, true));
83 }
84 template<class B>
85 void gather(B& buffer, std::size_t i)
86 {
87 data_.gather(buffer, Entity<codim>(fromGrid_, i, true));
88 }
89 template<class B>
90 void scatter(B& buffer, std::size_t i, std::size_t s)
91 {
92 data_.scatter(buffer, Entity<codim>(toGrid_, i, true), s);
93 }
94private:
95 const CpGridData& fromGrid_;
96 const CpGridData& toGrid_;
97 DataHandle& data_;
98
99};
100} // end namespace cpgrid
101} // end namespace Dune
102#endif
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:123
Wrapper that turns a data handle suitable for dune-grid into one based on integers instead of entitie...
Definition: Entity2IndexDataHandle.hpp:54
Definition: Entity.hpp:64
Copyright 2019 Equinor AS.
Definition: CartesianIndexMapper.hpp:10