Tags.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <string>
8 
10 #include "Domain/ElementIndex.hpp"
11 #include "IO/Observer/ArrayComponentId.hpp"
12 #include "Options/Options.hpp"
13 
14 /// Items related to loading data from files
15 namespace importers {
16 
17 /// The input file options associated with the data importer
18 namespace OptionTags {
19 
20 /*!
21  * \ingroup OptionGroupsGroup
22  * \brief Groups the data importer configurations in the input file
23  */
24 struct Group {
25  static std::string name() noexcept { return "Importers"; }
26  static constexpr OptionString help = "Options for loading data files";
27 };
28 
29 /*!
30  * \brief The file to read data from.
31  */
32 template <typename ImporterOptionsGroup>
33 struct FileName {
34  static_assert(
35  cpp17::is_same_v<typename ImporterOptionsGroup::group, Group>,
36  "The importer options should be placed in the 'Importers' option "
37  "group. Add a type alias `using group = importers::OptionTags::Group`.");
38  using type = std::string;
39  static constexpr OptionString help = "Path to the data file";
40  using group = ImporterOptionsGroup;
41 };
42 
43 /*!
44  * \brief The subgroup within the file to read data from.
45  *
46  * This subgroup should conform to the `h5::VolumeData` format.
47  */
48 template <typename ImporterOptionsGroup>
49 struct Subgroup {
50  static_assert(
51  cpp17::is_same_v<typename ImporterOptionsGroup::group, Group>,
52  "The importer options should be placed in the 'Importers' option "
53  "group. Add a type alias `using group = importers::OptionTags::Group`.");
54  using type = std::string;
55  static constexpr OptionString help =
56  "The subgroup within the file, excluding extensions";
57  using group = ImporterOptionsGroup;
58 };
59 
60 /*!
61  * \brief The observation value at which to read data from the file.
62  */
63 template <typename ImporterOptionsGroup>
65  static_assert(
66  cpp17::is_same_v<typename ImporterOptionsGroup::group, Group>,
67  "The importer options should be placed in the 'Importers' option "
68  "group. Add a type alias `using group = importers::OptionTags::Group`.");
69  using type = double;
70  static constexpr OptionString help =
71  "The observation value at which to read data";
72  using group = ImporterOptionsGroup;
73 };
74 
75 } // namespace OptionTags
76 
77 /// The \ref DataBoxGroup tags associated with the data importer
78 namespace Tags {
79 
80 /*!
81  * \brief The file to read data from.
82  */
83 template <typename ImporterOptionsGroup>
85  static std::string name() noexcept {
86  return "FileName(" + option_name<ImporterOptionsGroup>() + ")";
87  }
88  using type = std::string;
89  using option_tags = tmpl::list<OptionTags::FileName<ImporterOptionsGroup>>;
90 
91  template <typename Metavariables>
92  static type create_from_options(const type& file_name) noexcept {
93  return file_name;
94  }
95 };
96 
97 /*!
98  * \brief The subgroup within the file to read data from.
99  *
100  * This subgroup should conform to the `h5::VolumeData` format.
101  */
102 template <typename ImporterOptionsGroup>
104  static std::string name() noexcept {
105  return "Subgroup(" + option_name<ImporterOptionsGroup>() + ")";
106  }
107  using type = std::string;
108  using option_tags = tmpl::list<OptionTags::Subgroup<ImporterOptionsGroup>>;
109 
110  template <typename Metavariables>
111  static type create_from_options(const type& subgroup) noexcept {
112  return subgroup;
113  }
114 };
115 
116 /*!
117  * \brief The observation value at which to read data from the file.
118  */
119 template <typename ImporterOptionsGroup>
121  static std::string name() noexcept {
122  return "ObservationValue(" + option_name<ImporterOptionsGroup>() + ")";
123  }
124  using type = double;
125  using option_tags =
126  tmpl::list<OptionTags::ObservationValue<ImporterOptionsGroup>>;
127 
128  template <typename Metavariables>
129  static type create_from_options(const type& observation_value) noexcept {
130  return observation_value;
131  }
132 };
133 
134 /*!
135  * \brief The elements that will receive data from the importer.
136  *
137  * \details Identifiers for elements from multiple parallel components can be
138  * stored. Each element is identified by an `observers::ArrayComponentId` and
139  * also needs to provide the `std::string` that identifies it in the data file.
140  */
143 };
144 
145 } // namespace Tags
146 
147 } // namespace importers
The file to read data from.
Definition: Tags.hpp:84
The elements that will receive data from the importer.
Definition: Tags.hpp:141
The observation value at which to read data from the file.
Definition: Tags.hpp:120
The subgroup within the file to read data from.
Definition: Tags.hpp:103
Defines classes and functions for making classes creatable from input files.
Tags for the DataBox inherit from this type.
Definition: DataBoxTag.hpp:64
The observation value at which to read data from the file.
Definition: Tags.hpp:64
Groups the data importer configurations in the input file.
Definition: Tags.hpp:24
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:29
Definition: Strahlkorper.hpp:167
Definition: DataBoxTag.hpp:29
tuples::TaggedTuple< Tags... > create_from_options(const tuples::TaggedTuple< OptionTags... > &options, tmpl::list< Tags... >) noexcept
Given a list of tags and a tagged tuple containing items created from input options, return a tagged tuple of items constructed by calls to create_from_options for each tag in the list.
Definition: ParallelComponentHelpers.hpp:184
Items related to loading data from files.
Definition: ElementActions.hpp:18
Defines class ElementIndex.
The subgroup within the file to read data from.
Definition: Tags.hpp:49
The file to read data from.
Definition: Tags.hpp:33
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...