Skip to content

Commit

Permalink
Replace multi-variable connections with functions (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyllingstad authored Mar 27, 2020
1 parent d89cf43 commit 1ab44ea
Show file tree
Hide file tree
Showing 33 changed files with 1,932 additions and 794 deletions.
66 changes: 53 additions & 13 deletions include/cse/algorithm/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define CSECORE_ALGORITHM_ALGORITHM_HPP

#include <cse/algorithm/simulator.hpp>
#include <cse/connection.hpp>
#include <cse/execution.hpp>
#include <cse/function/function.hpp>
#include <cse/model.hpp>
#include <cse/observer/observer.hpp>

Expand Down Expand Up @@ -64,25 +64,65 @@ class algorithm
virtual void remove_simulator(simulator_index index) = 0;

/**
* Adds a connection to the co-simulation.
* Adds a function to the co-simulation.
*
* After this, the algorithm is responsible for acquiring the values of
* the connection's source variables, and distributing the connection's
* destination variable values at communication points.
* \param index
* A numerical index that will be used to identify the function
* in other function calls.
* \param fun
* A pointer to an object that is used to access the function.
* Note that the algorithm does not have resource ownership of
* the object it points to (i.e., should not try to delete it).
*/
virtual void add_function(function_index index, function* fun) = 0;

/**
* Connects a simulator output variable to a simulator input variable.
*
* After this, the algorithm is responsible for acquiring the value of
* the output variable and assigning it to the input variable at
* communication points.
*
* It is assumed that the variables contained by the connection are valid
* and that there are no existing connections to any of the connection's
* destination variables.
* \param output
* A reference to the output variable.
* \param input
* A reference to the input variable.
*/
virtual void add_connection(std::shared_ptr<connection> conn) = 0;
virtual void connect_variables(variable_id output, variable_id input) = 0;

/**
* Removes a connection from the co-simulation.
* Connects a simulator output variable to a function input variable.
*
* It is assumed that the connection has previously been added to the
* co-simulation with `add_connection()`.
* After this, the algorithm is responsible for acquiring the value of
* the output variable and assigning it to the input variable before
* the function is calculated.
*
* \param output
* A reference to the output variable.
* \param input
* A reference to the input variable.
*/
virtual void connect_variables(variable_id output, function_io_id input) = 0;

/**
* Connects a function output variable to a simulator input variable.
*
* After this, the algorithm is responsible for acquiring the value of
* the output variable and assigning it to the input variable after
* the function is calculated.
*
* \param output
* A reference to the output variable.
* \param input
* A reference to the input variable.
*/
virtual void remove_connection(std::shared_ptr<connection> conn) = 0;
virtual void connect_variables(function_io_id output, variable_id input) = 0;

/// Breaks any previously established connection to input variable `input`.
virtual void disconnect_variable(variable_id input) = 0;

/// Breaks any previously established connection to input variable `input`.
virtual void disconnect_variable(function_io_id input) = 0;

/**
* Performs initial setup.
Expand Down
8 changes: 6 additions & 2 deletions include/cse/algorithm/fixed_step_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ class fixed_step_algorithm : public algorithm
// `algorithm` methods
void add_simulator(simulator_index i, simulator* s, duration stepSizeHint) override;
void remove_simulator(simulator_index i) override;
void add_connection(std::shared_ptr<connection> c) override;
void remove_connection(std::shared_ptr<connection> c) override;
void add_function(function_index i, function* f) override;
void connect_variables(variable_id output, variable_id input) override;
void connect_variables(variable_id output, function_io_id input) override;
void connect_variables(function_io_id output, variable_id input) override;
void disconnect_variable(variable_id input) override;
void disconnect_variable(function_io_id input) override;
void setup(time_point startTime, std::optional<time_point> stopTime) override;
void initialize() override;
std::pair<duration, std::unordered_set<simulator_index>> do_step(time_point currentT) override;
Expand Down
14 changes: 0 additions & 14 deletions include/cse/connection.hpp

This file was deleted.

58 changes: 0 additions & 58 deletions include/cse/connection/connection.hpp

This file was deleted.

23 changes: 0 additions & 23 deletions include/cse/connection/linear_transformation_connection.hpp

This file was deleted.

32 changes: 0 additions & 32 deletions include/cse/connection/scalar_connection.hpp

This file was deleted.

34 changes: 0 additions & 34 deletions include/cse/connection/sum_connection.hpp

This file was deleted.

Loading

0 comments on commit 1ab44ea

Please sign in to comment.