Peano
Loading...
Searching...
No Matches
VolumeIndex.h
Go to the documentation of this file.
1// This file is part of the ExaHyPE2 project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5namespace exahype2 {
23 // Base case for recursion
24 template <int N, typename... Args>
25 struct VolumeIndex {
27
28 static VectorType generate(Args... args) {
29 VectorType result;
30 fillVector<0>(result, args...); // Start with index 0
31 return result;
32 }
33
34 private:
35 template <int I, class... RestArgs>
36 static void fillVector(VectorType& vector, int arg, RestArgs... args) {
37 vector(I) = arg;
38 fillVector<I + 1>(vector, args...);
39 }
40
41 // Termination condition when all arguments are processed
42 template <int I>
43 static void fillVector(VectorType&) {}
44 };
45
46 // Partial specialisation to handle the base case (N=0)
47 template <class... Args>
48 struct VolumeIndex<0, Args...> {
50 static VectorType generate(Args...) { return VectorType(); }
51 };
52
53 template <class... Args>
54 auto volumeIndex(Args... args) {
55 constexpr int N = sizeof...(args);
57 }
58} // namespace exahype2
For the generic kernels that I use here most of the time.
Definition CellAccess.h:13
auto volumeIndex(Args... args)
Definition VolumeIndex.h:54
static VectorType generate(Args...)
Definition VolumeIndex.h:50
A lot of the loop routines expect a voxel (or face) index which is a vector over integers.
Definition VolumeIndex.h:25
tarch::la::Vector< N, int > VectorType
Definition VolumeIndex.h:26
static VectorType generate(Args... args)
Definition VolumeIndex.h:28
static void fillVector(VectorType &vector, int arg, RestArgs... args)
Definition VolumeIndex.h:36
static void fillVector(VectorType &)
Definition VolumeIndex.h:43
Simple vector class.
Definition Vector.h:134