3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
vectorcommdatahandle.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_VECTOR_COMM_DATA_HANDLE_HH
25#define DUMUX_VECTOR_COMM_DATA_HANDLE_HH
26
27#include <algorithm>
28
29#include <dune/grid/common/datahandleif.hh>
30
31namespace Dumux {
32
33namespace Detail {
34
35 struct SetEqual
36 {
37 template<class A, class B>
38 static void apply(A& a, const B& b)
39 { a = b; }
40 };
41
42 struct Sum
43 {
44 template<class A, class B>
45 static void apply(A& a, const B& b)
46 { a += b; }
47 };
48
49 struct Max
50 {
51 template<class A, class B>
52 static void apply(A& a, const B& b)
53 {
54 using std::max;
55 a = max(a,b);
56 }
57 };
58
59 struct Min
60 {
61 template<class A, class B>
62 static void apply(A& a, const B& b)
63 {
64 using std::min;
65 a = min(a,b);
66 }
67 };
68} // end namespace Detail
69
74template<class Mapper, class Vector, int entityCodim,
75 class ScatterOperator, class DataT = typename Vector::value_type>
77 : public Dune::CommDataHandleIF<VectorCommDataHandle<Mapper, Vector, entityCodim, ScatterOperator, DataT>, DataT>
78{
79public:
81 using DataType = DataT;
82
83 VectorCommDataHandle(const Mapper& mapper, Vector& vector)
84 : mapper_(mapper), vector_(vector)
85 {}
86
88 bool contains(int dim, int codim) const
89 { return (codim == entityCodim); }
90
92 bool fixedSize(int dim, int codim) const
93 { return true; }
94
99 template<class Entity>
100 std::size_t size(Entity& entity) const
101 { return 1; }
102
104 template<class MessageBuffer, class Entity>
105 void gather(MessageBuffer& buff, const Entity& entity) const
106 { buff.write(vector_[mapper_.index(entity)]); }
107
112 template<class MessageBuffer, class Entity>
113 void scatter(MessageBuffer& buff, const Entity& entity, std::size_t n)
114 {
115 DataType x;
116 buff.read(x);
117 ScatterOperator::apply(vector_[mapper_.index(entity)], x);
118 }
119
120protected:
121 const Mapper& mapper_;
122 Vector& vector_;
123};
124
125template<class Mapper, class Vector, int codim, class DataType = typename Vector::value_type>
127
128template<class Mapper, class Vector, int codim, class DataType = typename Vector::value_type>
130
131template<class Mapper, class Vector, int codim, class DataType = typename Vector::value_type>
133
134template<class Mapper, class Vector, int codim, class DataType = typename Vector::value_type>
136
137} // end namespace Dumux
138
139#endif
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Definition: vectorcommdatahandle.hh:36
static void apply(A &a, const B &b)
Definition: vectorcommdatahandle.hh:38
Definition: vectorcommdatahandle.hh:43
static void apply(A &a, const B &b)
Definition: vectorcommdatahandle.hh:45
Definition: vectorcommdatahandle.hh:50
static void apply(A &a, const B &b)
Definition: vectorcommdatahandle.hh:52
Definition: vectorcommdatahandle.hh:60
static void apply(A &a, const B &b)
Definition: vectorcommdatahandle.hh:62
A data handle class to exchange entries of a vector.
Definition: vectorcommdatahandle.hh:78
bool contains(int dim, int codim) const
returns true if data for this codim should be communicated
Definition: vectorcommdatahandle.hh:88
Vector & vector_
Definition: vectorcommdatahandle.hh:122
std::size_t size(Entity &entity) const
how many objects of type DataType have to be sent for a given entity
Definition: vectorcommdatahandle.hh:100
void gather(MessageBuffer &buff, const Entity &entity) const
pack data from user to message buffer
Definition: vectorcommdatahandle.hh:105
const Mapper & mapper_
Definition: vectorcommdatahandle.hh:121
bool fixedSize(int dim, int codim) const
returns true if size per entity of given dim and codim is a constant
Definition: vectorcommdatahandle.hh:92
DataT DataType
export type of data for message buffer
Definition: vectorcommdatahandle.hh:81
void scatter(MessageBuffer &buff, const Entity &entity, std::size_t n)
unpack data from message buffer to user
Definition: vectorcommdatahandle.hh:113
VectorCommDataHandle(const Mapper &mapper, Vector &vector)
Definition: vectorcommdatahandle.hh:83