ABLATE Source Documentation  0.12.34
dmViewFromOptions.hpp
1 #ifndef ABLATELIBRARY_DMVIEWFROMOPTIONS_HPP
2 #define ABLATELIBRARY_DMVIEWFROMOPTIONS_HPP
3 
4 #include <petsc.h>
5 #include <parameters/parameters.hpp>
6 #include <string>
7 #include "monitor.hpp"
8 
9 namespace ablate::monitors {
17  public:
18  enum class Scope { INITIAL, MONITOR };
19 
20  private:
21  PetscOptions petscOptions;
22  const std::string optionName;
23  const Scope scope;
24 
25  static PetscErrorCode CallDmViewFromOptions(TS ts, PetscInt steps, PetscReal time, Vec u, void* mctx);
26 
27  PetscErrorCode DMViewFromOptions(DM dm);
28 
29  public:
36  explicit DmViewFromOptions(Scope scope, std::string options = {}, const std::string& optionName = {});
37 
43  explicit DmViewFromOptions(std::string options = {}, std::string optionName = {});
44  ~DmViewFromOptions() override;
45 
46  void Register(std::shared_ptr<solver::Solver>) override;
47  PetscMonitorFunction GetPetscFunction() override { return CallDmViewFromOptions; }
48 
53  std::string ToString() const override { return "ablate::monitors::DmViewFromOptions"; }
54 
58  void Modify(DM&) override;
59 };
60 
67 std::ostream& operator<<(std::ostream& os, const DmViewFromOptions::Scope& v);
74 std::istream& operator>>(std::istream& is, DmViewFromOptions::Scope& v);
75 } // namespace ablate::monitors
76 #endif // ABLATELIBRARY_DMVIEWFROMOPTIONS_HPP
Definition: modifier.hpp:8
Definition: dmViewFromOptions.hpp:16
PetscMonitorFunction GetPetscFunction() override
Definition: dmViewFromOptions.hpp:47
DmViewFromOptions(Scope scope, std::string options={}, const std::string &optionName={})
Definition: dmViewFromOptions.cpp:7
void Register(std::shared_ptr< solver::Solver >) override
Definition: dmViewFromOptions.cpp:27
std::string ToString() const override
Definition: dmViewFromOptions.hpp:53
void Modify(DM &) override
Definition: dmViewFromOptions.cpp:74
Definition: monitor.hpp:12
Definition: boundarySolverMonitor.hpp:16
std::ostream & operator<<(std::ostream &os, const DmViewFromOptions::Scope &v)
Definition: dmViewFromOptions.cpp:76
std::istream & operator>>(std::istream &is, DmViewFromOptions::Scope &v)
Definition: dmViewFromOptions.cpp:87