WARPXM v1.10.0
Loading...
Searching...
No Matches
wxstepperstatus.h
Go to the documentation of this file.
1#ifndef wxstepperstatus_h
2#define wxstepperstatus_h
3
4#include "warpxm/warpxm_config.h"
6
7// std includes
8#include <limits>
9#include <algorithm>
10
19{
20
21public:
28 WxStepperStatus(bool timeStepStatus = true,
29 std::shared_ptr<TimestepConstraint> tc = std::make_shared<TimestepConstraint>())
30 : _timeStepSuccess(timeStepStatus), _tc(tc)
31 {
32 }
33
39 void reset()
40 {
41 _timeStepSuccess = true;
42 _fatalError = false;
43 real default_dt = std::numeric_limits<real>::infinity();
44 std::array<real, 3> default_x = {0, 0, 0};
45 std::shared_ptr<std::string> default_physics = std::make_shared<std::string>("nothing");
46 _tc = std::make_shared<TimestepConstraint>(default_dt, default_x, default_physics);
47 }
48
54 void setTimeStepStatus(bool timeStepStatus)
55 {
56 _timeStepSuccess = timeStepStatus;
57 }
58
64 bool getTimeStepStatus() const
65 {
66 return _timeStepSuccess;
67 }
68
69
75 const std::shared_ptr<TimestepConstraint> get_tc() const
76 {
77 return _tc;
78 }
79
85 void merge(const WxStepperStatus& other)
86 {
87 _timeStepSuccess = _timeStepSuccess && other._timeStepSuccess;
88 _fatalError = _fatalError || other._fatalError;
89 *_tc = TimestepConstraint::minDt(*_tc, *other._tc);
90 }
91
97 void add_tc(const std::shared_ptr<TimestepConstraint>& tc)
98 {
99 _tc = tc;
100 }
101
102private:
104 bool _timeStepSuccess;
105 bool _fatalError;
107 std::shared_ptr<TimestepConstraint> _tc;
108};
109
112#endif // wxstepperstatus_h
static const TimestepConstraint & minDt(const TimestepConstraint &a, const TimestepConstraint &b)
Definition: timestep_constraint.h:45
Represents important parameters for the efficacy of a completing simulation step.
Definition: wxstepperstatus.h:19
bool getTimeStepStatus() const
Get status of stepper's time step (i.e., CFL condition )
Definition: wxstepperstatus.h:64
void add_tc(const std::shared_ptr< TimestepConstraint > &tc)
Add timestep constraint information to wxstepperstatus.
Definition: wxstepperstatus.h:97
WxStepperStatus(bool timeStepStatus=true, std::shared_ptr< TimestepConstraint > tc=std::make_shared< TimestepConstraint >())
Create status object.
Definition: wxstepperstatus.h:28
void merge(const WxStepperStatus &other)
Merge resulting in worst case properties of this and other WxStepperStatus.
Definition: wxstepperstatus.h:85
const std::shared_ptr< TimestepConstraint > get_tc() const
Get writeout diagnostic.
Definition: wxstepperstatus.h:75
void setTimeStepStatus(bool timeStepStatus)
Set status of stepper's time step (i.e., CFL condition )
Definition: wxstepperstatus.h:54
void reset()
Returns object to its default construction state.
Definition: wxstepperstatus.h:39
#define real
Definition: wmoclunstructuredreconstruction.h:11