SpECTRE  v2023.05.16
control_system::protocols::ControlSystem Struct Reference

Definition of a control system. More...

#include <ControlSystem.hpp>


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 static function component_name returning a std::optional<std::string>. This gives a name associated to each component of the FunctionOfTime that is being controlled. E.g. a FunctionOfTime controlling translation will have three components with names "X", "Y", and "Z". This is useful when writing data to disk.
  • 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 type alias control_error to a struct that conforms to the ControlError protocol
  • 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"; }
static std::optional<std::string> component_name(
const size_t i, const size_t num_components) {
ASSERT(num_components == 3,
"This control system expected 3 components but there are "
<< num_components << " instead.");
return i == 0 ? "X" : (i == 1 ? "Y" : "Z");
using measurement = ExampleMeasurement;
using simple_tags = tmpl::list<>;
static constexpr size_t deriv_order = 2;
using control_error = ExampleControlError;
// 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,
A Charm++ chare that caches constant data once per Charm++ node or non-constant data once per Charm++...
Definition: GlobalCache.hpp:374
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:182
#define ASSERT(a, m)
Assert that an expression should be true.
Definition: Assert.hpp:51
void simple_action(Proxy &&proxy)
Invoke a simple action on proxy
Definition: Invoke.hpp:86
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:835
std::string name()
Return the result of the name() member of a class. If a class doesn't have a name() member,...
Definition: PrettyType.hpp:733
Parallel::GlobalCache< Metavariables > & cache(MockRuntimeSystem< Metavariables > &runner, const ArrayIndex &array_index)
Returns the GlobalCache of Component with index array_index.
Definition: MockRuntimeSystemFreeFunctions.hpp:379
Add data to a LinkedMessageQueue.
Definition: UpdateMessageQueue.hpp:34
The singleton parallel component responsible for managing a single control system.
Definition: Component.hpp:31
An identifier for an element in a sequence.
Definition: LinkedMessageId.hpp:23
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: