Go to the documentation of this file.
14 #include "Framework/MockRuntimeSystem.hpp"
18 #include "Utilities/TypeTraits.hpp"
22 template <
typename Metavariables>
24 const typename Metavariables::Phase& phase) noexcept {
25 runner->set_phase(phase);
31 template <
typename Component,
typename...
Options>
35 const typename Component::array_index& array_index,
37 runner->template emplace_component<Component>(array_index,
38 std::forward<Options>(opts)...);
45 template <
typename Component,
typename...
Options,
46 typename Metavars =
typename Component::metavariables,
51 const typename Component::array_index& array_index,
52 const typename detail::get_initialization<Component>::InitialValues&
55 runner->template emplace_component_and_initialize<Component>(
56 array_index, initial_values, std::forward<Options>(opts)...);
63 template <
typename Component,
typename TagsList,
typename Metavariables>
66 const typename Component::array_index& array_index) noexcept {
67 return runner.template mock_distributed_objects<Component>()
69 .template get_databox<TagsList>();
72 template <
typename Component,
typename TagsList,
typename Metavariables>
74 const typename Component::array_index& array_index) noexcept {
75 return runner->template mock_distributed_objects<Component>()
77 .template get_databox<TagsList>();
82 template <
typename Component,
typename Metavariables>
85 const typename Component::array_index& array_index) noexcept {
86 return runner.template get_next_action_index<Component>(array_index);
92 template <
typename Component,
typename Tag,
typename Metavariables>
95 const typename Component::array_index& array_index) noexcept {
96 return runner.template mock_distributed_objects<Component>()
98 .template get_databox_tag<Tag>();
104 template <
typename Component,
typename InboxTag,
typename Metavariables>
107 const typename Component::array_index& array_index) noexcept {
108 return tuples::get<InboxTag>(
109 runner.template inboxes<Component>().at(array_index));
112 template <
typename Component,
typename InboxTag,
typename Metavariables>
114 const gsl::not_null<MockRuntimeSystem<Metavariables>*> runner,
115 const typename Component::array_index& array_index) noexcept {
116 return tuples::get<InboxTag>(
117 runner->template inboxes<Component>().at(array_index));
124 template <
typename Component,
typename Tag,
typename Metavariables>
126 const typename Component::array_index& array_index) noexcept {
127 return runner.template mock_distributed_objects<Component>()
129 .template box_contains<Tag>();
134 template <
typename Component,
typename Tag,
typename Metavariables>
137 const typename Component::array_index& array_index) noexcept {
138 return runner.template mock_distributed_objects<Component>()
140 .template tag_is_retrievable<Tag>();
145 template <
typename Component,
typename Metavariables>
147 const typename Component::array_index& array_index) noexcept {
148 runner->template next_action<Component>(array_index);
154 template <
typename Component,
typename Metavariables>
156 const typename Component::array_index& array_index) noexcept {
157 return runner.template is_ready<Component>(array_index);
162 template <
typename Component,
typename Action,
typename Metavariables,
166 const typename Component::array_index& array_index,
167 Args&&... args) noexcept {
168 runner->template simple_action<Component, Action>(
169 array_index, std::forward<Args>(args)...);
174 template <
typename Component,
typename Action,
typename Metavariables,
178 const typename Component::array_index& array_index,
179 Args&&... args) noexcept {
180 runner->template threaded_action<Component, Action>(
181 array_index, std::forward<Args>(args)...);
186 template <
typename Component,
typename Metavariables>
189 const typename Component::array_index& array_index) noexcept {
190 runner->template invoke_queued_simple_action<Component>(array_index);
194 template <
typename Component,
typename Metavariables>
197 const typename Component::array_index& array_index) noexcept {
198 return runner.template is_simple_action_queue_empty<Component>(array_index);
203 template <
typename Component,
typename Metavariables>
206 const typename Component::array_index& array_index) noexcept {
207 runner->template invoke_queued_threaded_action<Component>(array_index);
211 template <
typename Component,
typename Metavariables>
214 const typename Component::array_index& array_index) noexcept {
215 return runner.template is_threaded_action_queue_empty<Component>(array_index);
220 template <
typename Component,
typename Metavariables>
223 const typename Component::array_index& array_index) noexcept {
224 return runner.template mock_distributed_objects<Component>()
231 template <
typename ComponentList,
typename MockRuntimeSystem,
235 const ArrayIndex& array_index) noexcept {
238 tmpl::for_each<ComponentList>([&](
auto tag) noexcept {
239 using Tag =
typename decltype(tag)::type;
240 if (not runner->template is_simple_action_queue_empty<Tag>(array_index)) {
251 template <
typename ComponentList,
typename MockRuntimeSystem,
252 typename ArrayIndex,
size_t... Is>
254 const size_t component_to_invoke,
255 const ArrayIndex& array_index,
257 const auto helper = [component_to_invoke, &runner,
258 &array_index](
auto I) noexcept {
259 if (I.value == component_to_invoke) {
261 tmpl::at_c<ComponentList, I.value>>(array_index);
272 template <
typename ComponentList,
typename MockRuntimeSystem,
273 typename Generator,
typename ArrayIndex>
277 const ArrayIndex& array_index) noexcept {
279 const size_t component_to_invoke = index_map.at(ran(*generator));
280 detail::invoke_queued_action<ComponentList>(
281 runner, component_to_invoke, array_index,
void emplace_component_and_initialize(const gsl::not_null< MockRuntimeSystem< typename Component::metavariables > * > runner, const typename Component::array_index &array_index, const typename detail::get_initialization< Component >::InitialValues &initial_values, Options &&... opts) noexcept
Emplaces a distributed object with index array_index into the parallel component Component....
Definition: MockRuntimeSystemFreeFunctions.hpp:48
void invoke_queued_simple_action(const gsl::not_null< MockRuntimeSystem< Metavariables > * > runner, const typename Component::array_index &array_index) noexcept
Runs the next queued simple action on the array_indexth element of the parallel component Component.
Definition: MockRuntimeSystemFreeFunctions.hpp:187
size_t get_next_action_index(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Get the index in the action list of the next action.
Definition: MockRuntimeSystemFreeFunctions.hpp:83
bool box_contains(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Returns true if the current DataBox of Component with index array_index contains the tag Tag....
Definition: MockRuntimeSystemFreeFunctions.hpp:125
void set_phase(const gsl::not_null< MockRuntimeSystem< Metavariables > * > runner, const typename Metavariables::Phase &phase) noexcept
Set the phase of all parallel components to phase
Definition: MockRuntimeSystemFreeFunctions.hpp:23
#define EXPAND_PACK_LEFT_TO_RIGHT(...)
Expand a parameter pack evaluating the terms from left to right.
Definition: TMPL.hpp:563
Definition: MockRuntimeSystem.hpp:91
std::vector< size_t > indices_of_components_with_queued_actions(const gsl::not_null< MockRuntimeSystem * > runner, const ArrayIndex &array_index) noexcept
Returns a vector of all the indices of the Components in the ComponentList that have queued actions.
Definition: MockRuntimeSystemFreeFunctions.hpp:233
Structures used for mocking the parallel components framework in order to test actions.
Definition: ActionTesting.hpp:308
void invoke_queued_threaded_action(const gsl::not_null< MockRuntimeSystem< Metavariables > * > runner, const typename Component::array_index &array_index) noexcept
Runs the next queued threaded action on the array_indexth element of the parallel component Component...
Definition: MockRuntimeSystemFreeFunctions.hpp:204
void threaded_action(const gsl::not_null< MockRuntimeSystem< Metavariables > * > runner, const typename Component::array_index &array_index, Args &&... args) noexcept
Runs the simple action Action on the array_indexth element of the parallel component Component.
Definition: MockRuntimeSystemFreeFunctions.hpp:176
Utilities for parsing input files.
Definition: MinmodType.hpp:8
bool is_ready(MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Runs the is_ready function and returns the result for the next action in the current phase on the arr...
Definition: MockRuntimeSystemFreeFunctions.hpp:155
bool get_terminate(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Returns whether or not the Component with index array_index has been terminated.
Definition: MockRuntimeSystemFreeFunctions.hpp:221
void emplace_component(const gsl::not_null< MockRuntimeSystem< typename Component::metavariables > * > runner, const typename Component::array_index &array_index, Options &&... opts) noexcept
Emplaces a distributed object with index array_index into the parallel component Component....
Definition: MockRuntimeSystemFreeFunctions.hpp:32
const auto & get_inbox_tag(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Returns the InboxTag from the parallel component Component with array index array_index.
Definition: MockRuntimeSystemFreeFunctions.hpp:105
bool is_threaded_action_queue_empty(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Returns true if there are no threaded actions in the queue.
Definition: MockRuntimeSystemFreeFunctions.hpp:212
const auto & get_databox_tag(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Returns the Tag from the DataBox of the parallel component Component with array index array_index....
Definition: MockRuntimeSystemFreeFunctions.hpp:93
const auto & get_databox(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Retrieves the DataBox with tags TagsList (omitting the GlobalCache and add_from_options tags) from th...
Definition: MockRuntimeSystemFreeFunctions.hpp:64
void simple_action(const gsl::not_null< MockRuntimeSystem< Metavariables > * > runner, const typename Component::array_index &array_index, Args &&... args) noexcept
Runs the simple action Action on the array_indexth element of the parallel component Component.
Definition: MockRuntimeSystemFreeFunctions.hpp:164
bool tag_is_retrievable(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Returns true if the tag Tag can be retrieved from the current DataBox of Component with index array_i...
Definition: MockRuntimeSystemFreeFunctions.hpp:135
bool is_simple_action_queue_empty(const MockRuntimeSystem< Metavariables > &runner, const typename Component::array_index &array_index) noexcept
Returns true if there are no simple actions in the queue.
Definition: MockRuntimeSystemFreeFunctions.hpp:195
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t
Definition: Requires.hpp:67
void invoke_random_queued_action(const gsl::not_null< MockRuntimeSystem * > runner, const gsl::not_null< Generator * > generator, const std::vector< size_t > &index_map, const ArrayIndex &array_index) noexcept
Invokes the next queued action on a random Component. index_map is the thing returned by indices_of_c...
Definition: MockRuntimeSystemFreeFunctions.hpp:274
void next_action(const gsl::not_null< MockRuntimeSystem< Metavariables > * > runner, const typename Component::array_index &array_index) noexcept
Runs the next action in the current phase on the array_indexth element of the parallel component Comp...
Definition: MockRuntimeSystemFreeFunctions.hpp:146
Require a pointer to not be a nullptr
Definition: ReadSpecThirdOrderPiecewisePolynomial.hpp:13