1#ifndef __DUNE_ACFEM_DOFMAPPERTUPLEDATAHANDLE_HH__
2#define __DUNE_ACFEM_DOFMAPPERTUPLEDATAHANDLE_HH__
4#include <dune/grid/common/datahandleif.hh>
6#include "containertuple.hh"
13 template<
class... Storages>
17 typedef typename StorageType::ConstValueType DataItemType;
18 typedef typename StorageType::ValueType DataItemScatterType;
40 template<
class Mapper,
class Operation,
class... Storages>
42 :
public CommDataHandleIF<DofMapperTupleDataHandle<Mapper, Operation, Storages...>,
43 typename DofMapperTupleDataHandleTraits<Storages...>::DataItemType>
46 typedef Mapper MapperType;
47 typedef Operation OperationType;
50 typedef typename TraitsType::DataItemType DataItemType;
51 typedef typename TraitsType::DataItemScatterType DataItemScatterType;
74 const Operation& operation,
75 Storages&... storages)
76 : mapper_(mapper), operation_(operation), storages_(storages...)
80 : mapper_(other.mapper_), operation_(other.operation_), storages_(other.storages_)
86 return mapper_.contains(codim);
100 template<
class Entity>
101 size_t size(
const Entity& entity)
const
103 return mapper_.numEntityDofs(entity);
107 template<
class MessageBuffer,
class Entity>
108 void gather(MessageBuffer& buff,
const Entity& entity)
const
110 size_t localBlocks = mapper_.numEntityDofs(entity);
111 std::vector<std::size_t> globalBlockDofs(localBlocks);
112 mapper_.mapEntityDofs(entity, globalBlockDofs);
113 assert(
size(entity) == globalBlockDofs.size());
114 for (
size_t localBlock = 0; localBlock < globalBlockDofs.size(); ++ localBlock) {
115 buff.write(storages_[globalBlockDofs[localBlock]]);
120 template<
class MessageBuffer,
class Entity>
121 void scatter(MessageBuffer& buff,
const Entity& entity,
size_t n)
123 size_t localBlocks = mapper_.numEntityDofs(entity);
124 std::vector<std::size_t> globalBlockDofs(localBlocks);
125 mapper_.mapEntityDofs(entity, globalBlockDofs);
126 assert(
size(entity) == n);
127 assert(
size(entity) == globalBlockDofs.size());
128 for (
size_t localBlock = 0; localBlock < globalBlockDofs.size(); ++ localBlock) {
138 auto dest = storages_[globalBlockDofs[localBlock]];
139 operation_(src, dest);
144 const MapperType& mapper_;
145 const Operation operation_;
146 StorageTupleType storages_;
163 template<
class Space,
class Operation,
class... Storages,
164 std::enable_if_t<
sizeof(
typename Space::BlockMapperType) >= 0,
int> = 0>
165 auto dofMapperTupleDataHandle(
const Space& space,
166 const Operation& operation,
167 Storages&... storages)
169 typedef DofMapperTupleDataHandle<
typename Space::BlockMapperType, Operation, Storages...> ResultType;
170 return ResultType(space.blockMapper(), operation, storages...);
Create a tuple of values from a tuple of containers.
Definition: containertuple.hh:35
Potential all - all communication for mapped data.
Definition: dofmappertupledatahandle.hh:44
bool fixedSize(int dim, int codim) const
We don't have a fixed-size.
Definition: dofmappertupledatahandle.hh:92
DofMapperTupleDataHandle(const MapperType &mapper, const Operation &operation, Storages &... storages)
Construct the data handle from the given mapper and storage container.
Definition: dofmappertupledatahandle.hh:73
void gather(MessageBuffer &buff, const Entity &entity) const
pack data from user to message buffer
Definition: dofmappertupledatahandle.hh:108
bool contains(int dim, int codim) const
returns true if data for this codim should be communicated
Definition: dofmappertupledatahandle.hh:84
void scatter(MessageBuffer &buff, const Entity &entity, size_t n)
unpack data from message to user buffer
Definition: dofmappertupledatahandle.hh:121
size_t size(const Entity &entity) const
how many objects of type DataItemType have to be sent for a given entity.
Definition: dofmappertupledatahandle.hh:101
Traits for just something indexable.
Definition: dofmappertupledatahandle.hh:15