Entity2IndexDataHandle.hpp
Go to the documentation of this file.
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
39#include <cstddef>
40
41namespace Dune
42{
43namespace cpgrid
44{
45template<int codim> class Entity;
46class CpGridData;
47
54template<class DataHandle, int codim>
56{
57public:
58 typedef typename DataHandle::DataType DataType;
59
60 Entity2IndexDataHandle(const CpGridData& grid, DataHandle& data)
61 : fromGrid_(grid), toGrid_(grid), data_(data)
62 {}
63 Entity2IndexDataHandle(const CpGridData& fromGrid, const CpGridData& toGrid, DataHandle& data)
64 : fromGrid_(fromGrid), toGrid_(toGrid), data_(data)
65 {}
66
67#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 8)
68 bool fixedSize()
69 {
70 return data_.fixedSize(3, codim);
71 }
72#else
73 bool fixedsize()
74 {
75 return data_.fixedSize(3, codim);
76 }
77#endif
78 std::size_t size(std::size_t i)
79 {
80 return data_.size(Entity<codim>(fromGrid_, i, true));
81 }
82 template<class B>
83 void gather(B& buffer, std::size_t i)
84 {
85 data_.gather(buffer, Entity<codim>(fromGrid_, i, true));
86 }
87 template<class B>
88 void scatter(B& buffer, std::size_t i, std::size_t s)
89 {
90 data_.scatter(buffer, Entity<codim>(toGrid_, i, true), s);
91 }
92private:
93 const CpGridData& fromGrid_;
94 const CpGridData& toGrid_;
95 DataHandle& data_;
96
97};
98} // end namespace cpgrid
99} // end namespace Dune
100#endif
DataHandle & data
Definition: CpGridData.hpp:1085
mover::MoveBuffer< typename DataHandle::DataType > & buffer
Definition: CpGridData.hpp:1103
std::size_t fixedSize
The number of data items per index if it is fixed, 0 otherwise.
Definition: VariableSizeCommunicator.hpp:267
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:131
Wrapper that turns a data handle suitable for dune-grid into one based on integers instead of entitie...
Definition: Entity2IndexDataHandle.hpp:56
void scatter(B &buffer, std::size_t i, std::size_t s)
Definition: Entity2IndexDataHandle.hpp:88
std::size_t size(std::size_t i)
Definition: Entity2IndexDataHandle.hpp:78
bool fixedsize()
Definition: Entity2IndexDataHandle.hpp:73
Entity2IndexDataHandle(const CpGridData &grid, DataHandle &data)
Definition: Entity2IndexDataHandle.hpp:60
Entity2IndexDataHandle(const CpGridData &fromGrid, const CpGridData &toGrid, DataHandle &data)
Definition: Entity2IndexDataHandle.hpp:63
void gather(B &buffer, std::size_t i)
Definition: Entity2IndexDataHandle.hpp:83
DataHandle::DataType DataType
Definition: Entity2IndexDataHandle.hpp:58
Definition: Entity.hpp:65
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10