opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
VectorVectorDataHandle.hpp
Go to the documentation of this file.
1
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi: set et ts=4 sw=2 sts=4:
3
/*
4
Copyright 2021 Equinor AS.
5
6
This file is part of the Open Porous Media project (OPM).
7
8
OPM is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12
13
OPM is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with OPM. If not, see <http://www.gnu.org/licenses/>.
20
21
Consult the COPYING file in the top-level source directory of this
22
module for the precise wording of the license and the list of
23
copyright holders.
24
*/
30
31
#include <dune/grid/common/datahandleif.hh>
32
33
#include <cstddef>
34
#include <utility>
35
36
namespace
Opm
37
{
38
46
template
<
class
Gr
id
View,
class
Vector>
47
class
VectorVectorDataHandle
48
:
public
Dune::CommDataHandleIF<VectorVectorDataHandle<GridView,Vector>,
49
std::decay_t<decltype(std::declval<Vector>()[0][0])>>
// NVCC needs declval
50
{
51
public
:
52
54
using
DataType
= std::decay_t<decltype(std::declval<Vector>()[0][0])>;
// NVCC needs declval
55
59
VectorVectorDataHandle
(Vector& data,
const
GridView& gridView)
60
: data_(data), gridView_(gridView)
61
{}
62
63
bool
contains(
int
/* dim */
,
int
codim)
const
64
{
65
return
codim == 0;
66
}
67
68
bool
fixedSize(
int
/* dim */
,
int
/* codim */
)
const
69
{
70
return
true
;
71
}
72
73
template
<
class
EntityType>
74
std::size_t size(
const
EntityType
/* entity */
)
const
75
{
76
return
data_.size();
77
}
78
79
80
template
<
class
BufferType,
class
EntityType>
81
void
gather(BufferType& buffer,
const
EntityType& e)
const
82
{
83
for
(
const
auto
& vec: data_)
84
{
85
buffer.write(vec[gridView_.indexSet().index(e)]);
86
}
87
}
88
89
template
<
class
BufferType,
class
EntityType>
90
void
scatter(BufferType& buffer,
const
EntityType& e,
91
[[maybe_unused]] std::size_t n)
92
{
93
assert(n == data_.size());
94
for
(
auto
& vec: data_)
95
{
96
buffer.read(vec[gridView_.indexSet().index(e)]);
97
}
98
}
99
private
:
100
Vector& data_;
101
const
GridView& gridView_;
102
};
103
104
}
// end namespace Opm
Opm::VectorVectorDataHandle::VectorVectorDataHandle
VectorVectorDataHandle(Vector &data, const GridView &gridView)
Constructor.
Definition
VectorVectorDataHandle.hpp:59
Opm::VectorVectorDataHandle::DataType
std::decay_t< decltype(std::declval< Vector >()[0][0])> DataType
the data type we send
Definition
VectorVectorDataHandle.hpp:54
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition
blackoilbioeffectsmodules.hh:43
opm
simulators
utils
VectorVectorDataHandle.hpp
Generated by
1.17.0