WARPXM v1.10.0
Loading...
Searching...
No Matches
timestep_decision.h
Go to the documentation of this file.
1#pragma once
2
4
16{
17public:
19 {
20 _dt = std::numeric_limits<real>::infinity();
21 _explanation = std::make_shared<std::string>("nothing");
22 };
23
24 TimestepDecision(bool success, real dt, std::shared_ptr<std::string> explanation)
25 : _success(success), _dt(dt), _explanation(explanation)
26 {
27 _constraint = std::make_shared<TimestepConstraint>();
28 }
29
30 TimestepDecision(bool success,
31 real dt,
32 std::shared_ptr<std::string> explanation,
33 std::shared_ptr<TimestepConstraint> constraint)
34 : _success(success), _dt(dt), _explanation(explanation), _constraint(constraint)
35 {
36 }
37
41 void reset()
42 {
43 _success = true;
44 _dt = std::numeric_limits<real>::infinity();
45 _explanation = std::make_shared<std::string>("nothing");
46 }
47
48 bool isSuccess() const
49 {
50 return _success;
51 }
52
56 real getDt() const
57 {
58 return _dt;
59 }
60
64 std::shared_ptr<TimestepConstraint> getConstraint() const
65 {
66 return _constraint;
67 }
68
72 std::shared_ptr<std::string> getExplanation() const
73 {
74 return _explanation;
75 }
76
80 static const TimestepDecision& minDt(const TimestepDecision& a,
81 const TimestepDecision& b)
82 {
83 return a._dt < b._dt ? a : b;
84 }
85
86private:
87 bool _success;
88 real _dt;
89 std::shared_ptr<std::string> _explanation;
90 std::shared_ptr<TimestepConstraint> _constraint;
91};
Encapsulates information necessary to communicate and explain a decision about what timestep should b...
Definition: timestep_decision.h:16
void reset()
Resets everything to default values.
Definition: timestep_decision.h:41
real getDt() const
The timestep that was decided upon.
Definition: timestep_decision.h:56
std::shared_ptr< std::string > getExplanation() const
An explanation for why this timestep was chosen.
Definition: timestep_decision.h:72
TimestepDecision(bool success, real dt, std::shared_ptr< std::string > explanation, std::shared_ptr< TimestepConstraint > constraint)
Definition: timestep_decision.h:30
TimestepDecision()
Definition: timestep_decision.h:18
static const TimestepDecision & minDt(const TimestepDecision &a, const TimestepDecision &b)
Compare two TimestepDecisions and return the one with the smallest dt.
Definition: timestep_decision.h:80
TimestepDecision(bool success, real dt, std::shared_ptr< std::string > explanation)
Definition: timestep_decision.h:24
bool isSuccess() const
Definition: timestep_decision.h:48
std::shared_ptr< TimestepConstraint > getConstraint() const
The most restrictive TimestepConstraint that informed the decision.
Definition: timestep_decision.h:64
#define real
Definition: wmoclunstructuredreconstruction.h:11