dune-vtk 2.12
Loading...
Searching...
No Matches
rangetype.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3#pragma once
4
5#include <array>
6#include <type_traits>
7
8
9namespace Dune {
10
11// forward declarations
12template <class T, int N>
13class FieldVector;
14
15template <class T, int N, int M>
16class FieldMatrix;
17
18} // end namespace Dune
19
20namespace Dune::Vtk {
21
23template <class F, class D>
25
26namespace Impl {
27
28 template <class T, int N>
29 constexpr auto dimRangeImpl (Dune::FieldVector<T,N>)
30 -> std::integral_constant<int, N> { return {}; }
31
32 template <class T, int N, int M>
33 constexpr auto dimRangeImpl (Dune::FieldMatrix<T,N,M>)
34 -> std::integral_constant<int, N*M> { return {}; }
35
36 constexpr auto dimRangeImpl (...)
37 -> std::integral_constant<int, 1> { return {}; }
38
39} // end namespace Impl
40
42template <class T>
43static constexpr int dimRange ()
44{
45 return decltype(Impl::dimRangeImpl(std::declval<T>()))::value;
46}
47
48namespace Impl {
49
50 template <class T, int N, int M>
51 constexpr std::array<int,2> rangeShapeImpl (Dune::FieldMatrix<T,N,M> const*) { return {N,M}; }
52
53 constexpr std::array<int,2> rangeShapeImpl (...) { return {0,0}; }
54
55} // end namespace Impl
56
58template <class T>
60{
61 return Impl::rangeShapeImpl(static_cast<T const*>(nullptr));
62}
63
64} // end namespace Dune::Vtk
Definition datacollector.hh:19
constexpr std::array< int, 2 > rangeShape()
Static shape {rows,cols} of a matrix-valued range type, or {0,0} if unknown or not a matrix.
Definition rangetype.hh:59
static constexpr int dimRange()
Number of components the range contains.
Definition rangetype.hh:43
static constexpr size_type M()
static constexpr size_type N()
Implementation of DataCollector for cells, with continuous data.
Definition celltypedatacollector.hh:20