SpECTRE  v2021.12.06
control_system::protocols::ControlSystem Struct Reference

Definition of a control system. More...

#include <ControlSystem.hpp>

Classes

struct  test
 

Detailed Description

Definition of a control system.

Defines a control system for controlling a FunctionOfTime.

A conforming class must provide the following functionality:

  • a static function name returning a std::string. This corresponds to the name of the FunctionOfTime controlled by this system.
  • a type alias measurement to a struct implementing the Measurement protocol.
  • a type alias simple_tags to a tmpl::list of simple tags needed for the control system. These tags will be added to the DataBox of the ControlComponent. The list may be empty.
  • a static constexpr size_t deriv_order which is the order of the highest derivative of a FunctionOfTime that you wish to control. Typically, this is the order of the FunctionOfTime itself.
  • a member struct (or type alias) process_measurement, defining the following:

    • a templated type alias argument_tags, which must produce a tmpl::list of tags when instantiated for any submeasurement of the control system's measurement.
    • a static function apply that accepts as arguments:
      • any submeasurement of the control system's measurement. For measurements with multiple submeasurements, this can be accomplished either by a template parameter or by overloading the function.
      • the values corresponding to argument_tags instantiated with the type of the first argument.
      • the global cache Parallel::GlobalCache<Metavariables>&
      • a const LinkedMessageId<double>& identifying the measurement, with the id field being the measurement time.

    The apply function will be called once for each submeasurement of the control system's measurement using data from the DataBox passed to RunCallbacks. It should communicate any necessary data to the control system singleton.

Here's an example for a class conforming to this protocol:

struct ExampleControlSystem
: tt::ConformsTo<control_system::protocols::ControlSystem> {
static std::string name() { return "ExampleControlSystem"; }
using measurement = ExampleMeasurement;
using simple_tags = tmpl::list<>;
static constexpr size_t deriv_order = 2;
// This is not part of the required interface, but is used by this
// control system to store the measurement data. Most control
// systems will do something like this.
struct ExampleSubmeasurementQueueTag {
using type = double;
};
// As with the previous struct, this is not part of the required
// interface.
struct MeasurementQueue : db::SimpleTag {
using type =
LinkedMessageQueue<double, tmpl::list<ExampleSubmeasurementQueueTag>>;
};
struct process_measurement {
template <typename Submeasurement>
using argument_tags = tmpl::list<MeasurementResultTag>;
template <typename Metavariables>
static void apply(ExampleSubmeasurement /*meta*/,
const double measurement_result,
const LinkedMessageId<double>& measurement_id) {
// Process the submeasurement results and send whatever is
// necessary to the control system component. Usually calls
// some simple action.
auto& control_system_proxy = Parallel::get_parallel_component<
ExampleSubmeasurementQueueTag, MeasurementQueue,
SomeControlSystemUpdater>>(control_system_proxy, measurement_id,
measurement_result);
}
};
};
A Charm++ chare that caches constant data once per Charm++ node or non-constant data once per Charm++...
Definition: GlobalCache.hpp:272
auto apply(F &&f, const ObservationBox< ComputeTagsList, DataBoxType > &observation_box, Args &&... args)
Apply the function object f using its nested argument_tags list of tags.
Definition: ObservationBox.hpp:171
void simple_action(Proxy &&proxy)
Invoke a simple action on proxy
Definition: Invoke.hpp:62
auto get_parallel_component(GlobalCache< Metavariables > &cache) -> Parallel::proxy_from_parallel_component< GlobalCache_detail::get_component_if_mocked< typename Metavariables::component_list, ParallelComponentTag > > &
Access the Charm++ proxy associated with a ParallelComponent.
Definition: GlobalCache.hpp:524
Parallel::GlobalCache< Metavariables > & cache(MockRuntimeSystem< Metavariables > &runner, const ArrayIndex &array_index)
Returns the GlobalCache of Component with index array_index.
Definition: MockRuntimeSystemFreeFunctions.hpp:373
Add data to a LinkedMessageQueue.
Definition: UpdateMessageQueue.hpp:33
The singleton parallel component responsible for managing a single control system.
Definition: Component.hpp:30
An identifier for an element in a sequence.
Definition: LinkedMessageQueue.hpp:28
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
Indicate a class conforms to the Protocol.
Definition: ProtocolHelpers.hpp:22

The documentation for this struct was generated from the following file: