Loading...
Searching...
No Matches
VectorVectorDataHandle.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=4:
/*
Copyright 2021 Equinor AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#include <dune/grid/common/datahandleif.hh>
#include <cstddef>
#include <utility>
namespace Opm
{
template<class GridView, class Vector>
class VectorVectorDataHandle
: public Dune::CommDataHandleIF<VectorVectorDataHandle<GridView,Vector>,
std::decay_t<decltype(std::declval<Vector>()[0][0])>> // NVCC needs declval
{
public:
using DataType = std::decay_t<decltype(std::declval<Vector>()[0][0])>; // NVCC needs declval
VectorVectorDataHandle(Vector& data, const GridView& gridView)
: data_(data), gridView_(gridView)
{}
bool contains(int /* dim */, int codim) const
{
return codim == 0;
}
bool fixedSize(int /* dim */, int /* codim */) const
{
return true;
}
template<class EntityType>
std::size_t size(const EntityType /* entity */) const
{
return data_.size();
}
template<class BufferType, class EntityType>
void gather(BufferType& buffer, const EntityType& e) const
{
for(const auto& vec: data_)
{
buffer.write(vec[gridView_.indexSet().index(e)]);
}
}
template<class BufferType, class EntityType>
void scatter(BufferType& buffer, const EntityType& e,
[[maybe_unused]] std::size_t n)
{
assert(n == data_.size());
for(auto& vec: data_)
{
buffer.read(vec[gridView_.indexSet().index(e)]);
}
}
private:
Vector& data_;
const GridView& gridView_;
};
} // 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