ABLATE Source Documentation  0.12.34
monitor.hpp
1 #ifndef ABLATELIBRARY_MONITOR_HPP
2 #define ABLATELIBRARY_MONITOR_HPP
3 #include <petsc.h>
4 #include <memory>
5 #include <utility>
6 #include "solver/solver.hpp"
7 
8 namespace ablate::monitors {
9 
10 typedef PetscErrorCode (*PetscMonitorFunction)(TS ts, PetscInt steps, PetscReal time, Vec u, void* mctx);
11 
12 class Monitor {
13  private:
14  std::shared_ptr<solver::Solver> solver;
15 
16  public:
17  virtual ~Monitor() = default;
22  virtual void Register(std::shared_ptr<solver::Solver> solverIn) { solver = std::move(solverIn); }
23 
28  virtual PetscMonitorFunction GetPetscFunction() { return nullptr; }
29 
33  virtual void* GetContext() { return this; }
34 
35  protected:
36  std::shared_ptr<solver::Solver> GetSolver() { return solver; }
37 };
38 
39 } // namespace ablate::monitors
40 
41 #endif // ABLATELIBRARY_MONITOR_HPP
Definition: monitor.hpp:12
virtual void Register(std::shared_ptr< solver::Solver > solverIn)
Definition: monitor.hpp:22
virtual void * GetContext()
Definition: monitor.hpp:33
virtual PetscMonitorFunction GetPetscFunction()
Definition: monitor.hpp:28
Definition: boundarySolverMonitor.hpp:16