Default Galerkin with Explicit Time Integration for Known Types

#include "pressio/type_traits.hpp"
#include "pressio/ops.hpp"
#include "pressio/rom_galerkin.hpp"

struct TrivialFomOnlyVelocityEigen
{
  using scalar_type       = double;
  using state_type        = Eigen::VectorXd;
  using velocity_type     = state_type;
  int N_ = {};

  TrivialFomOnlyVelocityEigen(int N): N_(N){}

  velocity_type createVelocity() const{ return velocity_type(N_); }

  void velocity(const state_type & u, const scalar_type time, velocity_type & f) const
  {
    for (auto i=0; i<f.rows(); ++i){
       f(i) = u(i) + time;
    }
  }
};

struct Observer
{
  void operator()(int32_t step, double time, Eigen::VectorXd state)
  {
    std::cout << "Observer called: \n"
    << " step: " << step
    << "\n"
    << " state = ";
    for (int i=0; i<state.size(); ++i){
        std::cout << state(i) << ", ";
    }
    std::cout << "\n";
  }
};

int main(int argc, char *argv[])
{
  pressio::log::initialize(pressio::logto::terminal);

  using fom_t   = TrivialFomOnlyVelocityEigen;
  using scalar_t    = typename fom_t::scalar_type;
  using fom_state_t = typename fom_t::state_type;

  constexpr int N = 10;
  fom_t fomSystem(N);
  fom_state_t fomReferenceState(N);
  fomReferenceState.setZero();

  using phi_t = Eigen::MatrixXd;
  phi_t phi(N, 3);
  phi.col(0).setConstant(0.1);
  phi.col(1).setConstant(0.5);
  phi.col(2).setConstant(0.8);
  auto decoder = pressio::rom::create_time_invariant_linear_decoder<fom_state_t>(phi);

  Eigen::VectorXd romState(3);
  romState[0]=0.;
  romState[1]=1.;
  romState[2]=2.;

  constexpr auto odescheme = pressio::ode::StepScheme::ForwardEuler;
  auto problem = pressio::rom::galerkin::create_default_explicit_problem
    (odescheme, fomSystem, decoder, romState, fomReferenceState);

  const scalar_t dt = 1.;
  const int num_steps = 3;
  Observer obs;
  pressio::ode::advance_n_steps_and_observe(problem, romState, 0., dt, num_steps, obs);

  pressio::log::finalize();
}