diff --git a/native/include/m_driver.h b/native/include/m_driver.h index 8ae042d0..11b4693d 100644 --- a/native/include/m_driver.h +++ b/native/include/m_driver.h @@ -2,6 +2,7 @@ #include #include "c_micro_sim.h" +class Integrator; // forward declaration // Base class for the drivers class Driver { public: @@ -13,15 +14,37 @@ class Driver { double * alpha; double gamma; double t; + MicroSim * sim; + Integrator * integrator; + + virtual void run_until(double t) {}; }; -class Integrator_RK4 { +// Abstract class +class Integrator { +public: + Integrator() {}; + virtual void _setup(int N) {}; + // Allow magnetisation to update (via LLG + effective field) + // TODO: figure out how to set the update function in Driver class + virtual void compute_RHS(void (* f) (double * m, double t)) {}; +} + +// Integrators should be independent of any driver/sim class +class Integrator_RK4: public Integrator { public: Integrator_RK4() {}; virtual ~Integrator_RK4() {std::cout << "Killing RK4 integrator\n";}; // Will get the parameters from a simulation class // void _setup(MicroSim * sim, Driver * driver); - std::vector rk_steps; // N * 4 array - void integration_step(double (*f)(double t, double y)); + std::vector rk1; // N array + std::vector rk2; // N array + std::vector rk3; // N array + std::vector rk4; // N array + void integration_step(double (*f)(double t, double m)); // compute_RHS ?? + void _setup(int N); + int N; + double t; + double dt; }; diff --git a/native/src/m_driver.c b/native/src/m_driver.c new file mode 100644 index 00000000..ef323bfa --- /dev/null +++ b/native/src/m_driver.c @@ -0,0 +1,5 @@ +#include "m_driver.h" + +void Integrator_RK4::_setup(int N) { + this->rk_steps(N * 4, 0.0); +}