7#ifndef DUNE_FUFEM_BACKENDS_TRAVERSAL_HH
8#define DUNE_FUFEM_BACKENDS_TRAVERSAL_HH
21#include <dune/assembler/backends/singlerowcolmatrix.hh>
27namespace Dune::Fufem::Impl {
31 template<
class Vector,
class F>
32 static void forEachVectorEntry(Vector&& vector, F&& f)
39 template<
class Matrix,
class F>
40 static void forEachMatrixEntry(Matrix&& matrix, F&& f)
47 template<
class... MatrixRows,
class F>
53 f(matrix[i][j], i, j);
58 template<
class... MatrixRows,
class F>
64 f(matrix[i][j], i, j);
69 template<
class Matrix,
class F>
70 static void forEachMatrixEntry(
const Dune::Assembler::SingleRowMatrix<Matrix>& matrix, F&& f)
73 f(matrix_0j,
std::monostate(), j);
76 template<
class Matrix,
class F>
77 static void forEachMatrixEntry(Dune::Assembler::SingleRowMatrix<Matrix>& matrix, F&& f)
80 f(matrix_0j,
std::monostate(), j);
83 template<
class Matrix,
class F>
84 static void forEachMatrixEntry(
const Dune::Assembler::SingleColumnMatrix<Matrix>& matrix, F&& f)
88 f(matrix_i0, i,
std::monostate());
91 template<
class Matrix,
class F>
92 static void forEachMatrixEntry(Dune::Assembler::SingleColumnMatrix<Matrix>& matrix, F&& f)
96 f(matrix_i0, i,
std::monostate());
101 template<
class size_type, std::
size_t n,
class Tail>
107 return std::apply([&](
const auto&... headEntries) {
112 template<
class F,
class MultiIndex>
113 class RecursiveVectorVisitor
117 RecursiveVectorVisitor(F f, MultiIndex
index)
122 template<
class Entry,
class FlatIndex>
123 void operator()(Entry&& vector_i, FlatIndex i)
126 f_(vector_i, extendMultiIndex(index_, i));
128 Impl::forEachVectorEntry(vector_i, Dune::Fufem::Impl::RecursiveVectorVisitor(f_, extendMultiIndex(index_, i)));
133 const MultiIndex index_;
137 template<
class F,
class RowMultiIndex,
class ColMultiIndex>
138 class RecursiveMatrixVisitor
142 RecursiveMatrixVisitor(F f, RowMultiIndex
rowIndex, ColMultiIndex colIndex)
145 , colIndex_(colIndex)
148 template<
class Entry,
class FlatRowIndex,
class FlatColIndex>
149 void operator()(Entry&& matrix_ij, FlatRowIndex i, FlatColIndex j)
152 f_(matrix_ij, extendMultiIndex(rowIndex_, i), extendMultiIndex(colIndex_, j));
154 Impl::forEachMatrixEntry(matrix_ij, Dune::Fufem::Impl::RecursiveMatrixVisitor(f_, extendMultiIndex(rowIndex_, i), extendMultiIndex(colIndex_, j)));
159 const RowMultiIndex rowIndex_;
160 const RowMultiIndex colIndex_;
178 template<
class Vector,
class F>
179 static void forEachVectorEntry(Vector&& vector, F&& f)
181 Impl::forEachVectorEntry(vector, f);
192 template<
class Matrix,
class F>
193 static void forEachMatrixEntry(Matrix&& matrix, F&& f)
195 Impl::forEachMatrixEntry(matrix, f);
210 template<
class Vector,
class F>
211 static void recursiveForEachVectorEntry(Vector&& vector, F&& f)
214 auto recursive_f = Dune::Fufem::Impl::RecursiveVectorVisitor(
std::ref(f), EmptyIndex{});
215 Impl::forEachVectorEntry(vector, recursive_f);
230 template<
class Matrix,
class F>
231 static void recursiveForEachMatrixEntry(Matrix&& matrix, F&& f)
234 auto recursive_f = Dune::Fufem::Impl::RecursiveMatrixVisitor(
std::ref(f), EmptyIndex{}, EmptyIndex{});
235 Impl::forEachMatrixEntry(matrix, recursive_f);
Dune::BCRSMatrix< FieldMatrix< T, n, m >, TA > Matrix
OperatorHierarchy::ParallelMatrixHierarchy::ConstIterator matrix
static constexpr IntegralRange< std::decay_t< T > > range(T &&from, U &&to) noexcept
auto sparseRange(Range &&range)
constexpr auto size(const T &t)
constexpr void forEach(Range &&range, F &&f)
static constexpr size_type N()
size_type rowIndex() const
std::ptrdiff_t index() const
virtual void operator()()=0
constexpr std::integer_sequence< T, II... > tail(std::integer_sequence< T, I0, II... >)
constexpr std::integral_constant< T, I0 > head(std::integer_sequence< T, I0, II... >)
Definition dunefunctionsboundaryfunctionalassembler.hh:29