Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include "Evolution/Imex/Protocols/ImplicitSector.hpp"
7 : #include "Utilities/ProtocolHelpers.hpp"
8 : #include "Utilities/TMPL.hpp"
9 :
10 1 : namespace imex::protocols {
11 : /// Protocol for an IMEX evolution system.
12 : ///
13 : /// In addition to the usual requirements for an evolution system, an
14 : /// IMEX system must specify an `implicit_sectors` typelist of structs
15 : /// conforming to protocols::ImplicitSector, each of which describes
16 : /// an implicit solve to be performed during time steps.
17 : ///
18 : /// For efficiency, the tags in the `tensors` type alias of each
19 : /// sector are required to be adjacent in the system's variables.
20 : ///
21 : /// \snippet DoImplicitStepSector.hpp ImexSystem
22 1 : struct ImexSystem {
23 : template <typename ConformingType>
24 0 : struct test {
25 0 : using implicit_sectors = typename ConformingType::implicit_sectors;
26 : static_assert(
27 : tmpl::all<implicit_sectors,
28 : tt::assert_conforms_to<tmpl::_1, ImplicitSector>>::value);
29 :
30 : template <typename Sector>
31 0 : struct sector_tensors {
32 0 : using type = typename Sector::tensors;
33 : };
34 :
35 0 : using variables_tag = typename ConformingType::variables_tag;
36 : static_assert(
37 : tmpl::all<
38 : implicit_sectors,
39 : std::is_same<
40 : tmpl::bind<tmpl::list_difference, sector_tensors<tmpl::_1>,
41 : tmpl::pin<typename variables_tag::type::tags_list>>,
42 : tmpl::pin<tmpl::list<>>>>::value,
43 : "Implicit sector variables must be part of the system.");
44 :
45 : // There is a bug in brigand::lazy::reverse_find that it does not
46 : // actually evaluate its arguments lazily, so we must
47 : // bind<brigand::reverse_find> instead.
48 : static_assert(
49 : tmpl::all<
50 : implicit_sectors,
51 : std::is_same<
52 : tmpl::bind<
53 : tmpl::reverse_find,
54 : tmpl::lazy::find<
55 : tmpl::pin<typename variables_tag::tags_list>,
56 : tmpl::defer<std::is_same<
57 : tmpl::_1,
58 : tmpl::bind<tmpl::front, sector_tensors<tmpl::parent<
59 : tmpl::_1>>>>>>,
60 : tmpl::defer<std::is_same<
61 : tmpl::_1,
62 : tmpl::bind<tmpl::back,
63 : sector_tensors<tmpl::parent<tmpl::_1>>>>>>,
64 : sector_tensors<tmpl::_1>>>::value,
65 : "Tensors in an implicit sector must be adjacent in the system's "
66 : "variables.");
67 : };
68 : };
69 : } // namespace imex::protocols
|