19#ifndef OPM_CUISTL_CUOWNEROVERLAPCOPY_HPP
20#define OPM_CUISTL_CUOWNEROVERLAPCOPY_HPP
21#include <dune/istl/owneroverlapcopy.hh>
24#include <opm/simulators/linalg/cuistl/CuVector.hpp>
41template <
class field_type,
int block_size,
class OwnerOverlapCopyCommunicationType>
60 std::call_once(m_initializedIndices, [&]() { initIndexSet(); });
62 const auto dotAtRank = x.dot(
y, *m_indicesOwner);
72 field_type
norm(
const X& x)
const
74 auto xDotX = field_type(0);
90 std::call_once(m_initializedIndices, [&]() { initIndexSet(); });
91 x.setZeroAtIndexSet(*m_indicesCopy);
118 mutable std::once_flag m_initializedIndices;
119 mutable std::unique_ptr<CuVector<int>> m_indicesCopy;
120 mutable std::unique_ptr<CuVector<int>> m_indicesOwner;
123 void initIndexSet()
const
127 const auto&
pis = m_cpuOwnerOverlapCopy.indexSet();
130 for (
const auto& index :
pis) {
131 if (index.local().attribute() == Dune::OwnerOverlapCopyAttributeSet::copy) {
137 if (index.local().attribute() == Dune::OwnerOverlapCopyAttributeSet::owner) {
138 for (
int component = 0; component < block_size; ++component) {
139 indicesOwnerCPU.push_back(index.local().local() * block_size + component);
144 m_indicesCopy = std::make_unique<CuVector<int>>(indicesCopyOnCPU);
145 m_indicesOwner = std::make_unique<CuVector<int>>(indicesOwnerCPU);
Definition AquiferInterface.hpp:35
CUDA compatiable variant of Dune::OwnerOverlapCopyCommunication.
Definition CuOwnerOverlapCopy.hpp:43
void project(X &x) const
project will project x to the owned subspace
Definition CuOwnerOverlapCopy.hpp:88
field_type norm(const X &x) const
norm computes the l^2-norm of x across processes.
Definition CuOwnerOverlapCopy.hpp:72
void copyOwnerToAll(const X &source, X &dest) const
copyOwnerToAll will copy source to the CPU, then call OwnerOverlapCopyCommunicationType::copyOwnerToA...
Definition CuOwnerOverlapCopy.hpp:100
void dot(const X &x, const X &y, field_type &output) const
dot will carry out the dot product between x and y on the owned indices, then sum up the result acros...
Definition CuOwnerOverlapCopy.hpp:58