version 3.11-dev
Loading...
Searching...
No Matches
multimapperview.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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
11#ifndef DUMUX_COMMON_MULTIMAPPERVIEW_HH
12#define DUMUX_COMMON_MULTIMAPPERVIEW_HH
13
14#include <array>
15
16namespace Dumux::Detail {
17
18template<class Mapper>
20{
21public:
22 explicit constexpr MultiMapperView(const Mapper& mapper)
23 : mapper_(mapper)
24 {}
25
26 template<class Entity>
27 decltype(auto) index(const Entity& entity) const
28 { return mapper_.index(entity); }
29
30 template<class Entity>
31 auto indices(const Entity& entity) const
32 {
33 if constexpr (requires { mapper_.indices(entity); })
34 return mapper_.indices(entity);
35 else
36 return std::array<decltype(mapper_.index(entity)), 1>{ mapper_.index(entity) };
37 }
38
39private:
40 const Mapper& mapper_;
41};
42
43} // end namespace Dumux::Detail
44
45namespace Dumux {
46
47template<class Mapper>
48constexpr auto asMultiMapper(const Mapper& mapper)
49{
51}
52
53} // end namespace Dumux
54
55#endif
Definition multimapperview.hh:20
constexpr MultiMapperView(const Mapper &mapper)
Definition multimapperview.hh:22
decltype(auto) index(const Entity &entity) const
Definition multimapperview.hh:27
auto indices(const Entity &entity) const
Definition multimapperview.hh:31
Definition cvfelocalresidual.hh:25
Definition adapt.hh:17
constexpr auto asMultiMapper(const Mapper &mapper)
Definition multimapperview.hh:48