version 3.10-dev
dunevectors.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_LINEAR_DUNE_VECTORS_HH
13#define DUMUX_LINEAR_DUNE_VECTORS_HH
14
15#include <type_traits>
16#include <dune/common/typetraits.hh>
17#include <dune/common/std/type_traits.hh>
18
19#include <dune/common/fvector.hh>
20#include <dune/istl/bvector.hh>
21#include <dune/istl/multitypeblockvector.hh>
22
23// implementation details specific to this header
25
26template<class T, std::enable_if_t<Dune::IsNumber<std::decay_t<T>>::value, int> = 0>
27constexpr std::size_t blockSize() { return 1; }
28
29template<class T, std::enable_if_t<!Dune::IsNumber<std::decay_t<T>>::value, int> = 0>
30constexpr std::size_t blockSize() { return std::decay_t<T>::size(); }
31
32template<class C> using StateDetector = decltype(std::declval<C>()[0].state());
33
34} // end namespace Dumux::Detail::DuneVectors
35
36// implementation details used elsewhere in Dumux
37namespace Dumux::Detail {
38
39template<class V, bool hasState>
41{ using type = V; };
42
43// only support single-nested block vectors for now
44template<class V>
46{
47 using Scalar = std::decay_t<decltype(std::declval<V>()[0][0])>;
48 static constexpr auto blockSize = Detail::DuneVectors::blockSize<decltype(std::declval<V>()[0])>();
49 using BlockType = Dune::FieldVector<Scalar, blockSize>;
50 using type = Dune::BlockVector<BlockType>;
51};
52
53// get native dune type from dumux vector (possibly with state)
54template<class V>
56{
58 V, Dune::Std::is_detected<Detail::DuneVectors::StateDetector, V>{}
59 >::type;
60};
61
62// specialization for multitype vector
63template<class... Args>
64struct NativeDuneVectorType<Dune::MultiTypeBlockVector<Args...>>
65{
68 >;
69};
70
71} // end namespace Dumux::Detail
72
73#endif
Definition: variablesbackend.hh:34
Definition: dunevectors.hh:24
constexpr std::size_t blockSize()
Definition: dunevectors.hh:27
decltype(std::declval< C >()[0].state()) StateDetector
Definition: dunevectors.hh:32
Distance implementation details.
Definition: cvfelocalresidual.hh:25
Definition: common/pdesolver.hh:24
Definition: dunevectors.hh:56
typename NativeDuneVectorTypeImpl< V, Dune::Std::is_detected< Detail::DuneVectors::StateDetector, V >{} >::type type
Definition: dunevectors.hh:59
Dune::BlockVector< BlockType > type
Definition: dunevectors.hh:50
std::decay_t< decltype(std::declval< V >()[0][0])> Scalar
Definition: dunevectors.hh:47
Dune::FieldVector< Scalar, blockSize > BlockType
Definition: dunevectors.hh:49
Definition: dunevectors.hh:41
V type
Definition: dunevectors.hh:41